Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,46 +104,45 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 104 |
results_log = []
|
| 105 |
#answers_payload = []
|
| 106 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
|
| 125 |
#3A
|
| 126 |
|
| 127 |
-
def run_all_questions(questions_data):
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 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 |
|
|
|
|
| 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
|
| 148 |
|