ok
Browse files- controller.py +13 -14
controller.py
CHANGED
|
@@ -441,19 +441,6 @@ async def csv_chat(request: Dict, authorization: str = Header(None)):
|
|
| 441 |
if detailed_answer is True:
|
| 442 |
logger.info("Processing detailed answer with orchestrator...")
|
| 443 |
return await handle_detailed_answer(decoded_url, query, conversation_history, chat_id)
|
| 444 |
-
|
| 445 |
-
# # Process with standard CSV agent (Cerebras)
|
| 446 |
-
# logger.info("Processing with standard CSV agent (Cerebras)...")
|
| 447 |
-
# try:
|
| 448 |
-
# result = await query_csv_agent_cerebras(decoded_url, query, chat_id)
|
| 449 |
-
# logger.info(f"Standard CSV agent (Cerebras) result: {str(result)[:200]}...")
|
| 450 |
-
# if result is not None and result != "":
|
| 451 |
-
# return {"answer": result}
|
| 452 |
-
# else:
|
| 453 |
-
# logger.warning("Standard CSV agent (Cerebras) returned empty or None result")
|
| 454 |
-
# except Exception as e:
|
| 455 |
-
# logger.error(f"Standard CSV agent (Cerebras) failed: {str(e)}")
|
| 456 |
-
|
| 457 |
|
| 458 |
# Process with standard CSV agent (Groq)
|
| 459 |
logger.info("Processing with standard CSV agent (Groq)...")
|
|
@@ -467,6 +454,18 @@ async def csv_chat(request: Dict, authorization: str = Header(None)):
|
|
| 467 |
except Exception as e:
|
| 468 |
logger.error(f"Standard CSV agent (Groq) failed: {str(e)}")
|
| 469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
# Fallback to langchain
|
| 471 |
logger.info("Falling back to langchain CSV chat...")
|
| 472 |
try:
|
|
@@ -740,7 +739,7 @@ async def csv_chart(request: dict, authorization: str = Header(None)):
|
|
| 740 |
# return {"image_url": image_public_url}
|
| 741 |
# return FileResponse(groq_result, media_type="image/png")
|
| 742 |
|
| 743 |
-
logger.info("Trying cerebras ai...")
|
| 744 |
result = await query_csv_agent_cerebras(csv_url, query, chat_id)
|
| 745 |
logger.info("cerebras ai result ==>", result)
|
| 746 |
if result is not None and result != "":
|
|
|
|
| 441 |
if detailed_answer is True:
|
| 442 |
logger.info("Processing detailed answer with orchestrator...")
|
| 443 |
return await handle_detailed_answer(decoded_url, query, conversation_history, chat_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
|
| 445 |
# Process with standard CSV agent (Groq)
|
| 446 |
logger.info("Processing with standard CSV agent (Groq)...")
|
|
|
|
| 454 |
except Exception as e:
|
| 455 |
logger.error(f"Standard CSV agent (Groq) failed: {str(e)}")
|
| 456 |
|
| 457 |
+
# Process with standard CSV agent (Cerebras)
|
| 458 |
+
logger.info("Groq failed. Processing with standard CSV agent (Cerebras)...")
|
| 459 |
+
try:
|
| 460 |
+
result = await query_csv_agent_cerebras(decoded_url, query, chat_id)
|
| 461 |
+
logger.info(f"Standard CSV agent (Cerebras) result: {str(result)[:200]}...")
|
| 462 |
+
if result is not None and result != "":
|
| 463 |
+
return {"answer": result}
|
| 464 |
+
else:
|
| 465 |
+
logger.warning("Standard CSV agent (Cerebras) returned empty or None result")
|
| 466 |
+
except Exception as e:
|
| 467 |
+
logger.error(f"Standard CSV agent (Cerebras) failed: {str(e)}")
|
| 468 |
+
|
| 469 |
# Fallback to langchain
|
| 470 |
logger.info("Falling back to langchain CSV chat...")
|
| 471 |
try:
|
|
|
|
| 739 |
# return {"image_url": image_public_url}
|
| 740 |
# return FileResponse(groq_result, media_type="image/png")
|
| 741 |
|
| 742 |
+
logger.info("Trying cerebras ai llama...")
|
| 743 |
result = await query_csv_agent_cerebras(csv_url, query, chat_id)
|
| 744 |
logger.info("cerebras ai result ==>", result)
|
| 745 |
if result is not None and result != "":
|