Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -80,8 +80,8 @@ history_aware_retriever = create_history_aware_retriever(
|
|
80 |
qa_system_prompt = """You are an assistant for question-answering tasks.
|
81 |
Use the following pieces of retrieved context to answer the question.
|
82 |
If you don't know the answer, just say that you don't know.
|
83 |
-
|
84 |
-
Make it
|
85 |
|
86 |
{context}"""
|
87 |
qa_prompt = ChatPromptTemplate.from_messages(
|
@@ -125,17 +125,20 @@ async def echo(websocket):
|
|
125 |
m = data["message"] + "\nAssistant: "
|
126 |
token = data["token"]
|
127 |
docs = retriever.get_relevant_documents(m)
|
128 |
-
|
129 |
{"input": m},
|
130 |
config={
|
131 |
"configurable": {"session_id": token}
|
132 |
},
|
133 |
-
)
|
|
|
134 |
response = response.replace("Assistant: ", "").replace("AI: ", "")
|
135 |
response.strip()
|
|
|
136 |
while response.startswith("\n"):
|
137 |
response = response[1:]
|
138 |
await websocket.send(json.dumps({"response": response}))
|
|
|
139 |
|
140 |
async def main():
|
141 |
async with serve(echo, "0.0.0.0", 7860):
|
|
|
80 |
qa_system_prompt = """You are an assistant for question-answering tasks.
|
81 |
Use the following pieces of retrieved context to answer the question.
|
82 |
If you don't know the answer, just say that you don't know.
|
83 |
+
|
84 |
+
Make it and use markdown with spaces in between sentences.
|
85 |
|
86 |
{context}"""
|
87 |
qa_prompt = ChatPromptTemplate.from_messages(
|
|
|
125 |
m = data["message"] + "\nAssistant: "
|
126 |
token = data["token"]
|
127 |
docs = retriever.get_relevant_documents(m)
|
128 |
+
rawresponse = conversational_rag_chain.invoke(
|
129 |
{"input": m},
|
130 |
config={
|
131 |
"configurable": {"session_id": token}
|
132 |
},
|
133 |
+
)
|
134 |
+
response = rawresponse["answer"]
|
135 |
response = response.replace("Assistant: ", "").replace("AI: ", "")
|
136 |
response.strip()
|
137 |
+
response = response.split("Human:")[0]
|
138 |
while response.startswith("\n"):
|
139 |
response = response[1:]
|
140 |
await websocket.send(json.dumps({"response": response}))
|
141 |
+
print(json.dumps(rawresponse))
|
142 |
|
143 |
async def main():
|
144 |
async with serve(echo, "0.0.0.0", 7860):
|