cowrycode commited on
Commit
43b0388
·
verified ·
1 Parent(s): c93d289

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -37
app.py CHANGED
@@ -102,46 +102,46 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
102
 
103
  # 3. Run your Agent
104
  results_log = []
105
- answers_payload = []
106
- print(f"Running agent on {len(questions_data)} questions...")
107
- for item in questions_data:
108
- task_id = item.get("task_id")
109
- question_text = item.get("question")
110
- if not task_id or question_text is None:
111
- print(f"Skipping item with missing task_id or question: {item}")
112
- continue
113
- try:
114
- submitted_answer = agent(question_text)
115
- answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
116
- results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
117
- except Exception as e:
118
- print(f"Error running agent on task {task_id}: {e}")
119
- results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
120
-
121
- if not answers_payload:
122
- print("Agent did not produce any answers to submit.")
123
- return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
124
 
125
  #3A
126
 
127
- # 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 = 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
  #answers_payload = run_all_questions(questions_data)
146
 
147
  #3B
 
102
 
103
  # 3. Run your Agent
104
  results_log = []
105
+ # answers_payload = []
106
+ # print(f"Running agent on {len(questions_data)} questions...")
107
+ # for item in questions_data:
108
+ # task_id = item.get("task_id")
109
+ # question_text = item.get("question")
110
+ # if not task_id or question_text is None:
111
+ # print(f"Skipping item with missing task_id or question: {item}")
112
+ # continue
113
+ # try:
114
+ # submitted_answer = agent(question_text)
115
+ # answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
116
+ # results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
117
+ # except Exception as e:
118
+ # print(f"Error running agent on task {task_id}: {e}")
119
+ # results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
120
+
121
+ # if not answers_payload:
122
+ # print("Agent did not produce any answers to submit.")
123
+ # return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
124
 
125
  #3A
126
 
127
+ 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 = 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
  #answers_payload = run_all_questions(questions_data)
146
 
147
  #3B