wishmi1234 commited on
Commit
98ccefd
·
verified ·
1 Parent(s): 1c4623a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -17
app.py CHANGED
@@ -151,23 +151,26 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
151
  answers_payload = []
152
  print(f"Running agent on {len(questions_data)} questions...")
153
  for item in questions_data:
154
- task_id = item.get("task_id")
155
- submitted_answer = agent(question_text)
156
- question_text = item.get("question")
157
- image = item.get("image", None)
158
- if not task_id or question_text is None:
159
- print(f"Skipping item with missing task_id or question: {item}")
160
- continue
161
- try:
162
- question_input = {"question": question_text}
163
- if image:
164
- question_input["image"] = {"type": "image", "data": image}
165
- submitted_answer = agent(question_input)
166
-
167
-
168
- except Exception as e:
169
- print(f"Error running agent on task {task_id}: {e}")
170
- results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
 
 
 
171
 
172
  if not answers_payload:
173
  print("Agent did not produce any answers to submit.")
 
151
  answers_payload = []
152
  print(f"Running agent on {len(questions_data)} questions...")
153
  for item in questions_data:
154
+ task_id = item.get("task_id")
155
+ question_text = item.get("question")
156
+ image = item.get("image", None)
157
+
158
+ if not task_id or question_text is None:
159
+ print(f"Skipping item with missing task_id or question: {item}")
160
+ continue
161
+
162
+ try:
163
+ question_input = {"question": question_text}
164
+ if image:
165
+ question_input["image"] = {"type": "image", "data": image}
166
+ submitted_answer = agent(question_input)
167
+
168
+ answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
169
+ results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
170
+
171
+ except Exception as e:
172
+ print(f"Error running agent on task {task_id}: {e}")
173
+ results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
174
 
175
  if not answers_payload:
176
  print("Agent did not produce any answers to submit.")