cowrycode commited on
Commit
bb28ac7
·
verified ·
1 Parent(s): e0da436

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -73,17 +73,19 @@ async def smart_agent(questions_data: List[Dict[str, Any]]) -> List[Dict[str, An
73
 
74
  try:
75
  # Retry up to 3 times if connection closes
76
- for attempt in range(3):
77
- try:
78
- response = await llamaindex_agent.run(question_text)
79
- print(f"Answered Task {task_id}: {response[:50]}...")
80
- return {"task_id": task_id, "submitted_answer": response}
81
- except Exception as e:
82
- if "client has been closed" in str(e) and attempt < 2:
83
- print(f"Retrying task {task_id} (attempt {attempt + 2})...")
84
- await asyncio.sleep(1)
85
- continue
86
- raise e
 
 
87
  except Exception as e:
88
  print(f"Error on Task {task_id}: {e}")
89
  return {"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"}
 
73
 
74
  try:
75
  # Retry up to 3 times if connection closes
76
+ response = await llamaindex_agent.run(question_text)
77
+ print(f"Answered Task {task_id}: {response[:50]}...")
78
+ return {"task_id": task_id, "submitted_answer": response}
79
+ # for attempt in range(3):
80
+ # try:
81
+ # response = await llamaindex_agent.run(question_text)
82
+ # print(f"Answered Task {task_id}: {response[:50]}...")
83
+ # return {"task_id": task_id, "submitted_answer": response}
84
+ # except Exception as e:
85
+ # if "client has been closed" in str(e) and attempt < 2:
86
+ # print(f"Retrying task {task_id} (attempt {attempt + 2})...")
87
+ # continue
88
+ # raise e
89
  except Exception as e:
90
  print(f"Error on Task {task_id}: {e}")
91
  return {"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"}