Ritesh-hf commited on
Commit
699cf00
1 Parent(s): f7bf5fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -86,12 +86,12 @@ retriever = PineconeHybridSearchRetriever(
86
  llm = ChatPerplexity(temperature=0, pplx_api_key=GROQ_API_KEY, model="llama-3.1-sonar-large-128k-chat", max_tokens=512, max_retries=2)
87
 
88
  # Initialize Reranker
89
- model = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-base")
90
- compressor = CrossEncoderReranker(model=model, top_n=10)
91
 
92
- compression_retriever = ContextualCompressionRetriever(
93
- base_compressor=compressor, base_retriever=retriever
94
- )
95
 
96
  # Contextualization prompt and retriever
97
  contextualize_q_system_prompt = """Given a chat history and the latest user question \
@@ -106,7 +106,7 @@ contextualize_q_prompt = ChatPromptTemplate.from_messages(
106
  ("human", "{input}")
107
  ]
108
  )
109
- history_aware_retriever = create_history_aware_retriever(llm, compression_retriever, contextualize_q_prompt)
110
 
111
  # QA system prompt and chain
112
  qa_system_prompt = """ You are a highly skilled information retrieval assistant. Use the following context to answer questions effectively.
@@ -206,7 +206,7 @@ async def websocket_endpoint(websocket: WebSocket):
206
  await stream_response()
207
  except Exception as e:
208
  print(f"Error during message handling: {e}")
209
- await websocket.send_json({'response': "Something went wrong, Please try again.."})
210
  except WebSocketDisconnect:
211
  print(f"Client disconnected: {websocket.client}")
212
  if session_id:
 
86
  llm = ChatPerplexity(temperature=0, pplx_api_key=GROQ_API_KEY, model="llama-3.1-sonar-large-128k-chat", max_tokens=512, max_retries=2)
87
 
88
  # Initialize Reranker
89
+ # model = HuggingFaceCrossEncoder(model_name="BAAI/bge-reranker-base")
90
+ # compressor = CrossEncoderReranker(model=model, top_n=10)
91
 
92
+ # compression_retriever = ContextualCompressionRetriever(
93
+ # base_compressor=compressor, base_retriever=retriever
94
+ # )
95
 
96
  # Contextualization prompt and retriever
97
  contextualize_q_system_prompt = """Given a chat history and the latest user question \
 
106
  ("human", "{input}")
107
  ]
108
  )
109
+ history_aware_retriever = create_history_aware_retriever(llm, retriever, contextualize_q_prompt)
110
 
111
  # QA system prompt and chain
112
  qa_system_prompt = """ You are a highly skilled information retrieval assistant. Use the following context to answer questions effectively.
 
206
  await stream_response()
207
  except Exception as e:
208
  print(f"Error during message handling: {e}")
209
+ await websocket.send_json({'response': "Something went wrong, Please try again." + str(e)})
210
  except WebSocketDisconnect:
211
  print(f"Client disconnected: {websocket.client}")
212
  if session_id: