cowrycode commited on
Commit
5a5e786
·
verified ·
1 Parent(s): 75c715a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -14
app.py CHANGED
@@ -125,21 +125,29 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
125
  #3A
126
 
127
  async def run_all_questions(questions_data):
 
128
  answers_payload = []
129
- for item in questions_data:
130
- task_id = item.get("task_id")
131
- question_text = item.get("question")
132
- if not task_id or question_text is None:
133
- print(f"Skipping item with missing task_id or question: {item}")
134
- continue
135
- try:
136
- answer = await agent.run(question_text) # await coroutine
137
- answers_payload.append({"task_id": task_id, "submitted_answer": answer})
138
- print(f"Answered Task {task_id}: {answer[:50]}...")
139
- except Exception as e:
140
- answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
141
- print(f"Error on Task {task_id}: {e}")
142
- return answers_payload
 
 
 
 
 
 
 
143
 
144
  answers_payload = asyncio.run(run_all_questions(questions_data))
145
 
 
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