araeyn commited on
Commit
0247d81
1 Parent(s): 1b8329a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
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
- Use three sentences minimum and include a lot of information that the user might need.
84
- Make it readable with lots of newlines in between sentences.
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
- response = conversational_rag_chain.invoke(
129
  {"input": m},
130
  config={
131
  "configurable": {"session_id": token}
132
  },
133
- )["answer"]
 
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):