update prompt
Browse files
app.py
CHANGED
@@ -127,8 +127,8 @@ When responding to queries, follow these guidelines:
|
|
127 |
|
128 |
3. Proper Source References:
|
129 |
- ALWAYS USE INLINE CITATIONS and References with embed source URLs where users can verify information or explore further.
|
130 |
-
- The inline citations should be in the format [
|
131 |
-
-
|
132 |
|
133 |
FOLLOW ALL THE GIVEN INSTRUCTIONS, FAILURE TO DO SO WILL RESULT IN TERMINATION OF THE CHAT.
|
134 |
|
@@ -195,22 +195,11 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
195 |
{"input": question, 'language': language},
|
196 |
config={"configurable": {"session_id": session_id}}
|
197 |
):
|
198 |
-
if "context" in chunk:
|
199 |
-
context = chunk['context']
|
200 |
# Send each chunk to the client
|
201 |
if "answer" in chunk:
|
202 |
complete_response += chunk['answer']
|
203 |
await websocket.send_json({'response': chunk['answer']})
|
204 |
|
205 |
-
if context:
|
206 |
-
citations = re.findall(r'\[(\d+)\]', complete_response)
|
207 |
-
citation_numbers = list(map(int, citations))
|
208 |
-
sources = dict()
|
209 |
-
for index, doc in enumerate(context):
|
210 |
-
if (index+1) in citation_numbers:
|
211 |
-
sources[f"[{index+1}]"] = doc.metadata["source"]
|
212 |
-
await websocket.send_json({'sources': sources})
|
213 |
-
|
214 |
await stream_response()
|
215 |
except Exception as e:
|
216 |
print(f"Error during message handling: {e}")
|
|
|
127 |
|
128 |
3. Proper Source References:
|
129 |
- ALWAYS USE INLINE CITATIONS and References with embed source URLs where users can verify information or explore further.
|
130 |
+
- The inline citations should be in the format '[Source]' where on clicking on 'Source' the user should be redirected to the source url in a new tab.
|
131 |
+
- Include References at the end if needed.
|
132 |
|
133 |
FOLLOW ALL THE GIVEN INSTRUCTIONS, FAILURE TO DO SO WILL RESULT IN TERMINATION OF THE CHAT.
|
134 |
|
|
|
195 |
{"input": question, 'language': language},
|
196 |
config={"configurable": {"session_id": session_id}}
|
197 |
):
|
|
|
|
|
198 |
# Send each chunk to the client
|
199 |
if "answer" in chunk:
|
200 |
complete_response += chunk['answer']
|
201 |
await websocket.send_json({'response': chunk['answer']})
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
await stream_response()
|
204 |
except Exception as e:
|
205 |
print(f"Error during message handling: {e}")
|