put middle orchestrator
Browse files- controller.py +14 -14
controller.py
CHANGED
@@ -317,21 +317,21 @@ async def csv_chat(request: Dict, authorization: str = Header(None)):
|
|
317 |
return {"answer": jsonable_encoder(orchestrator_answer)}
|
318 |
|
319 |
# Process with groq_chat first
|
320 |
-
|
321 |
-
|
322 |
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
|
336 |
except Exception as e:
|
337 |
logger.error(f"Error processing request: {str(e)}")
|
|
|
317 |
return {"answer": jsonable_encoder(orchestrator_answer)}
|
318 |
|
319 |
# Process with groq_chat first
|
320 |
+
groq_answer = await asyncio.to_thread(groq_chat, decoded_url, query)
|
321 |
+
logger.info("groq_answer:", groq_answer)
|
322 |
|
323 |
+
if process_answer(groq_answer) == "Empty response received.":
|
324 |
+
return {"answer": "Sorry, I couldn't find relevant data..."}
|
325 |
+
|
326 |
+
if process_answer(groq_answer):
|
327 |
+
lang_answer = await asyncio.to_thread(
|
328 |
+
langchain_csv_chat, decoded_url, query, False
|
329 |
+
)
|
330 |
+
if process_answer(lang_answer):
|
331 |
+
return {"answer": "error"}
|
332 |
+
return {"answer": jsonable_encoder(lang_answer)}
|
333 |
+
|
334 |
+
return {"answer": jsonable_encoder(groq_answer)}
|
335 |
|
336 |
except Exception as e:
|
337 |
logger.error(f"Error processing request: {str(e)}")
|