Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -68,7 +68,7 @@ def initialize_pinecone(index_name: str):
|
|
68 |
|
69 |
# Initialize Pinecone index and BM25 encoder
|
70 |
pinecone_index = initialize_pinecone("updated-mbzuai-policies")
|
71 |
-
bm25 = BM25Encoder().load("./
|
72 |
|
73 |
##################################################
|
74 |
##################################################
|
@@ -112,7 +112,7 @@ history_aware_retriever = create_history_aware_retriever(llm, compression_retrie
|
|
112 |
|
113 |
# QA system prompt and chain
|
114 |
qa_system_prompt = """ You are a highly skilled information retrieval assistant. Use the following context to answer questions effectively.
|
115 |
-
If you don't know the answer, state that you don't know.
|
116 |
Your answer should be in {language} language.
|
117 |
|
118 |
When responding to queries, follow these guidelines:
|
@@ -132,7 +132,7 @@ When responding to queries, follow these guidelines:
|
|
132 |
- The inline citations should be in the format [[1]], [[2]], etc., in the response with links to reference sources.
|
133 |
- AT THE END OF THE RESPONSE, LIST OUT THE CITATIONS WITH THEIR SOURCES.
|
134 |
|
135 |
-
FOLLOW ALL THE GIVEN INSTRUCTIONS, FAILURE TO DO SO WILL RESULT IN
|
136 |
{context}
|
137 |
"""
|
138 |
qa_prompt = ChatPromptTemplate.from_messages(
|
@@ -212,7 +212,7 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
212 |
await stream_response()
|
213 |
except Exception as e:
|
214 |
print(f"Error during message handling: {e}")
|
215 |
-
await websocket.send_json({'response': "Something went wrong, Please try again
|
216 |
except WebSocketDisconnect:
|
217 |
print(f"Client disconnected: {websocket.client}")
|
218 |
if session_id:
|
|
|
68 |
|
69 |
# Initialize Pinecone index and BM25 encoder
|
70 |
pinecone_index = initialize_pinecone("updated-mbzuai-policies")
|
71 |
+
bm25 = BM25Encoder().load("./mbzuai-policies.json")
|
72 |
|
73 |
##################################################
|
74 |
##################################################
|
|
|
112 |
|
113 |
# QA system prompt and chain
|
114 |
qa_system_prompt = """ You are a highly skilled information retrieval assistant. Use the following context to answer questions effectively.
|
115 |
+
If you don't know the answer, simply state that you don't know.
|
116 |
Your answer should be in {language} language.
|
117 |
|
118 |
When responding to queries, follow these guidelines:
|
|
|
132 |
- The inline citations should be in the format [[1]], [[2]], etc., in the response with links to reference sources.
|
133 |
- AT THE END OF THE RESPONSE, LIST OUT THE CITATIONS WITH THEIR SOURCES.
|
134 |
|
135 |
+
FOLLOW ALL THE GIVEN INSTRUCTIONS, FAILURE TO DO SO WILL RESULT IN TERMINATION OF THE CHAT.
|
136 |
{context}
|
137 |
"""
|
138 |
qa_prompt = ChatPromptTemplate.from_messages(
|
|
|
212 |
await stream_response()
|
213 |
except Exception as e:
|
214 |
print(f"Error during message handling: {e}")
|
215 |
+
await websocket.send_json({'response': "Something went wrong, Please try again." + "<br>" + str(e)})
|
216 |
except WebSocketDisconnect:
|
217 |
print(f"Client disconnected: {websocket.client}")
|
218 |
if session_id:
|