added together ai agent
Browse files- controller.py +18 -14
controller.py
CHANGED
@@ -620,18 +620,22 @@ async def csv_chart(request: dict, authorization: str = Header(None)):
|
|
620 |
# return {"orchestrator_response": jsonable_encoder(orchestrator_answer)}
|
621 |
|
622 |
# Next, try the groq-based method
|
623 |
-
groq_result = await loop.run_in_executor(
|
624 |
-
|
625 |
-
)
|
626 |
-
logger.info(f"Groq chart result: {groq_result}")
|
627 |
-
if isinstance(groq_result, str) and groq_result != "Chart not generated":
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
# return FileResponse(groq_result, media_type="image/png")
|
|
|
|
|
|
|
|
|
635 |
|
636 |
# Fallback: try langchain-based again
|
637 |
# logger.error("Groq chart generation failed, trying langchain....")
|
@@ -647,9 +651,9 @@ async def csv_chart(request: dict, authorization: str = Header(None)):
|
|
647 |
# os.remove(langchain_paths[0])
|
648 |
# return {"image_url": image_public_url}
|
649 |
# return FileResponse(langchain_paths[0], media_type="image/png")
|
650 |
-
else:
|
651 |
-
|
652 |
-
|
653 |
|
654 |
except Exception as e:
|
655 |
logger.error(f"Critical chart error: {str(e)}")
|
|
|
620 |
# return {"orchestrator_response": jsonable_encoder(orchestrator_answer)}
|
621 |
|
622 |
# Next, try the groq-based method
|
623 |
+
# groq_result = await loop.run_in_executor(
|
624 |
+
# process_executor, groq_chart, csv_url, query
|
625 |
+
# )
|
626 |
+
# logger.info(f"Groq chart result: {groq_result}")
|
627 |
+
# if isinstance(groq_result, str) and groq_result != "Chart not generated":
|
628 |
+
# unique_file_name =f'{str(uuid.uuid4())}.png'
|
629 |
+
# logger.info("Uploading the chart to supabase...")
|
630 |
+
# image_public_url = await upload_file_to_supabase(f"{groq_result}", unique_file_name, chat_id=chat_id)
|
631 |
+
# logger.info("Image uploaded to Supabase and Image URL is... ", {image_public_url})
|
632 |
+
# os.remove(groq_result)
|
633 |
+
# return {"image_url": image_public_url}
|
634 |
# return FileResponse(groq_result, media_type="image/png")
|
635 |
+
|
636 |
+
result = query_csv_agent(csv_url,query)
|
637 |
+
logger.info("together ai result ==>", result)
|
638 |
+
return {"orchestrator_response": jsonable_encoder(result)}
|
639 |
|
640 |
# Fallback: try langchain-based again
|
641 |
# logger.error("Groq chart generation failed, trying langchain....")
|
|
|
651 |
# os.remove(langchain_paths[0])
|
652 |
# return {"image_url": image_public_url}
|
653 |
# return FileResponse(langchain_paths[0], media_type="image/png")
|
654 |
+
# else:
|
655 |
+
# logger.error("All chart generation methods failed")
|
656 |
+
# return {"answer": "error"}
|
657 |
|
658 |
except Exception as e:
|
659 |
logger.error(f"Critical chart error: {str(e)}")
|