MM58-crypto commited on
Commit
ccbeb90
·
1 Parent(s): 96c59fb

wooo another commit

Browse files
Files changed (1) hide show
  1. main.py +9 -4
main.py CHANGED
@@ -116,7 +116,7 @@ def retrieve_docs(session_id: str):
116
 
117
 
118
 
119
- def run_query(message: str, intent: str, request: Request) -> str:
120
  """
121
  Routes the user message to the appropriate Haystack pipeline
122
  based on the intent selected in the UI.
@@ -128,7 +128,7 @@ def run_query(message: str, intent: str, request: Request) -> str:
128
  Returns:
129
  LLM reply as a string
130
  """
131
- session_id = request.state.session_id
132
  match intent:
133
  case "i3rab":
134
  # Strip any leading instruction words so the parser gets
@@ -170,7 +170,12 @@ def run_query(message: str, intent: str, request: Request) -> str:
170
 
171
 
172
  case "knowledge":
173
- msg_history = retrieve_docs(session_id)
 
 
 
 
 
174
  result = knowledge_pipeline.run({
175
  "text_embedder": {"text": message},
176
  "prompt_builder": {
@@ -219,7 +224,7 @@ async def chat_stream(req: ChatRequest, request: Request):
219
  # stays non-blocking for other concurrent requests
220
  loop = asyncio.get_event_loop()
221
  full_reply = await loop.run_in_executor(
222
- None, run_query, req.message, req.intent, request
223
  )
224
  # via mongodb api, insert the msgs and replies into the docs
225
  # then in haystack_pipeline.py retrieve the docs and inject them into the prompt
 
116
 
117
 
118
 
119
+ def run_query(message: str, intent: str, session_id: str) -> str:
120
  """
121
  Routes the user message to the appropriate Haystack pipeline
122
  based on the intent selected in the UI.
 
128
  Returns:
129
  LLM reply as a string
130
  """
131
+ #session_id = request.state.session_id
132
  match intent:
133
  case "i3rab":
134
  # Strip any leading instruction words so the parser gets
 
170
 
171
 
172
  case "knowledge":
173
+
174
+ chat_docs = list(collection.find({
175
+ "session_id": session_id
176
+ }))
177
+ msg_history = json.dumps(docs, indent=2, default=str)
178
+
179
  result = knowledge_pipeline.run({
180
  "text_embedder": {"text": message},
181
  "prompt_builder": {
 
224
  # stays non-blocking for other concurrent requests
225
  loop = asyncio.get_event_loop()
226
  full_reply = await loop.run_in_executor(
227
+ None, run_query, req.message, req.intent, request.state.session_id
228
  )
229
  # via mongodb api, insert the msgs and replies into the docs
230
  # then in haystack_pipeline.py retrieve the docs and inject them into the prompt