cowrycode commited on
Commit
3a5e8f2
·
verified ·
1 Parent(s): 5ad4c5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -23
app.py CHANGED
@@ -119,29 +119,30 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
119
  # return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
120
 
121
  #3A
122
- question_text = questions_data[0].get("question")
123
- task_id = questions_data[0].get("task_id")
124
- print(f"Processing my question 0 : : : : : : :")
125
- answer = agent.run(question_text)
126
- print(f"Answered Task {task_id}: {answer[:50]}...")
127
- answers_payload = []
128
- answers_payload.append({"task_id": task_id, "submitted_answer": answer})
129
- # async def run_all_questions(questions_data):
130
- # answers_payload = []
131
- # for item in questions_data:
132
- # task_id = item.get("task_id")
133
- # question_text = item.get("question")
134
- # if not task_id or question_text is None:
135
- # print(f"Skipping item with missing task_id or question: {item}")
136
- # continue
137
- # try:
138
- # answer = await agent.run(question_text) # await coroutine
139
- # answers_payload.append({"task_id": task_id, "submitted_answer": answer})
140
- # print(f"Answered Task {task_id}: {answer[:50]}...")
141
- # except Exception as e:
142
- # answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
143
- # print(f"Error on Task {task_id}: {e}")
144
- # return answers_payload
 
145
 
146
  answers_payload = asyncio.run(run_all_questions(questions_data))
147
 
 
119
  # return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
120
 
121
  #3A
122
+
123
+ async def run_all_questions(questions_data):
124
+ question_text = questions_data[0].get("question")
125
+ task_id = questions_data[0].get("task_id")
126
+ print(f"Processing my question 0 : : : : : : :")
127
+ answer = await agent.run(question_text)
128
+ print(f"Answered Task {task_id}: {answer[:50]}...")
129
+ answers_payload = []
130
+ # answers_payload.append({"task_id": task_id, "submitted_answer": answer})
131
+ # answers_payload = []
132
+ # for item in questions_data:
133
+ # task_id = item.get("task_id")
134
+ # question_text = item.get("question")
135
+ # if not task_id or question_text is None:
136
+ # print(f"Skipping item with missing task_id or question: {item}")
137
+ # continue
138
+ # try:
139
+ # answer = await agent.run(question_text) # await coroutine
140
+ # answers_payload.append({"task_id": task_id, "submitted_answer": answer})
141
+ # print(f"Answered Task {task_id}: {answer[:50]}...")
142
+ # except Exception as e:
143
+ # answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
144
+ # print(f"Error on Task {task_id}: {e}")
145
+ return answers_payload
146
 
147
  answers_payload = asyncio.run(run_all_questions(questions_data))
148