cowrycode commited on
Commit
8c97e3a
·
verified ·
1 Parent(s): c71e8e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -24
app.py CHANGED
@@ -125,31 +125,25 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
125
  #3A
126
 
127
  async def run_all_questions(questions_data):
128
- print(f"START MY RUN")
129
- answers_payload = []
130
- task_id = questions_data[1].get("task_id")
131
- question_text = questions_data[1].get("question")
132
- answer = await agent.run(question_text) # await coroutine
133
- answers_payload.append({"task_id": task_id, "submitted_answer": answer})
134
- print(f"END MY RUN")
135
  #--------------------------------------------------
136
- # answers_payload = []
137
- # for item in questions_data:
138
- # task_id = item.get("task_id")
139
- # question_text = item.get("question")
140
- # if not task_id or question_text is None:
141
- # print(f"Skipping item with missing task_id or question: {item}")
142
- # continue
143
- # try:
144
- # answer = await agent.run(question_text) # await coroutine
145
- # answers_payload.append({"task_id": task_id, "submitted_answer": answer})
146
- # print(f"Answered Task {task_id}: {answer[:50]}...")
147
- # except Exception as e:
148
- # answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
149
- # print(f"Error on Task {task_id}: {e}")
150
- # return answers_payload
151
-
152
- answers_payload = asyncio.run(run_all_questions(questions_data))
 
153
 
154
  #3B
155
 
 
125
  #3A
126
 
127
  async def run_all_questions(questions_data):
 
 
 
 
 
 
 
128
  #--------------------------------------------------
129
+ answers_payload = []
130
+ for item in questions_data:
131
+ task_id = item.get("task_id")
132
+ question_text = item.get("question")
133
+ if not task_id or question_text is None:
134
+ print(f"Skipping item with missing task_id or question: {item}")
135
+ continue
136
+ try:
137
+ answer = await agent.run(question_text) # await coroutine
138
+ answers_payload.append({"task_id": task_id, "submitted_answer": answer})
139
+ print(f"Answered Task {task_id}: {answer[:50]}...")
140
+ except Exception as e:
141
+ answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
142
+ print(f"Error on Task {task_id}: {e}")
143
+ return answers_payload
144
+
145
+ #answers_payload = asyncio.run(run_all_questions(questions_data))
146
+ answers_payload = run_all_questions(questions_data)
147
 
148
  #3B
149