Soumik555 commited on
Commit
6733cba
·
1 Parent(s): ec565aa

test orchestrator

Browse files
Files changed (1) hide show
  1. controller.py +13 -10
controller.py CHANGED
@@ -300,6 +300,7 @@ async def csv_chat(request: Dict, authorization: str = Header(None)):
300
  query = request.get("query")
301
  csv_url = request.get("csv_url")
302
  decoded_url = unquote(csv_url)
 
303
 
304
  if if_initial_chat_question(query):
305
  answer = await asyncio.to_thread(
@@ -309,12 +310,12 @@ async def csv_chat(request: Dict, authorization: str = Header(None)):
309
  return {"answer": jsonable_encoder(answer)}
310
 
311
  # Orchestrate the execution
312
- orchestrator_answer = await asyncio.to_thread(
 
313
  csv_orchestrator_chat, decoded_url, query
314
- )
315
-
316
- if orchestrator_answer is not None:
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)
@@ -796,6 +797,7 @@ async def csv_chart(request: dict, authorization: str = Header(None)):
796
  try:
797
  query = request.get("query", "")
798
  csv_url = unquote(request.get("csv_url", ""))
 
799
 
800
  loop = asyncio.get_running_loop()
801
  # First, try the langchain-based method if the question qualifies
@@ -813,12 +815,13 @@ async def csv_chart(request: dict, authorization: str = Header(None)):
813
  # return FileResponse(langchain_result[0], media_type="image/png")
814
 
815
  # Use orchestrator to handle the user's chart query first
816
- orchestrator_answer = await asyncio.to_thread(
817
- csv_orchestrator_chat, csv_url, query
818
- )
 
819
 
820
- if orchestrator_answer is not None:
821
- return {"orchestrator_response": jsonable_encoder(orchestrator_answer)}
822
 
823
  # Next, try the groq-based method
824
  groq_result = await loop.run_in_executor(
 
300
  query = request.get("query")
301
  csv_url = request.get("csv_url")
302
  decoded_url = unquote(csv_url)
303
+ detailed_answer = request.get("detailed_answer")
304
 
305
  if if_initial_chat_question(query):
306
  answer = await asyncio.to_thread(
 
310
  return {"answer": jsonable_encoder(answer)}
311
 
312
  # Orchestrate the execution
313
+ if detailed_answer is True:
314
+ orchestrator_answer = await asyncio.to_thread(
315
  csv_orchestrator_chat, decoded_url, query
316
+ )
317
+ if orchestrator_answer is not None:
318
+ return {"answer": jsonable_encoder(orchestrator_answer)}
 
319
 
320
  # Process with groq_chat first
321
  groq_answer = await asyncio.to_thread(groq_chat, decoded_url, query)
 
797
  try:
798
  query = request.get("query", "")
799
  csv_url = unquote(request.get("csv_url", ""))
800
+ detailed_answer = request.get("detailed_answer", False)
801
 
802
  loop = asyncio.get_running_loop()
803
  # First, try the langchain-based method if the question qualifies
 
815
  # return FileResponse(langchain_result[0], media_type="image/png")
816
 
817
  # Use orchestrator to handle the user's chart query first
818
+ if detailed_answer is True:
819
+ orchestrator_answer = await asyncio.to_thread(
820
+ csv_orchestrator_chat, csv_url, query
821
+ )
822
 
823
+ if orchestrator_answer is not None:
824
+ return {"orchestrator_response": jsonable_encoder(orchestrator_answer)}
825
 
826
  # Next, try the groq-based method
827
  groq_result = await loop.run_in_executor(