Update app.py
Browse files
app.py
CHANGED
|
@@ -191,19 +191,16 @@ def update_and_resubmit_one_answer(task_id_to_redo: str, profile: gr.OAuthProfil
|
|
| 191 |
|
| 192 |
# 3. Run your Agent
|
| 193 |
results_log = []
|
|
|
|
|
|
|
| 194 |
with open("saved_answers.json", "r") as f:
|
| 195 |
saved_payload = json.load(f)
|
| 196 |
|
| 197 |
-
new_payload = []
|
| 198 |
-
for a in saved_payload:
|
| 199 |
-
if a["task_id"] != task_id_to_redo:
|
| 200 |
-
new_payload.append(a)
|
| 201 |
-
|
| 202 |
print(f"Running agent on 1 question...")
|
| 203 |
for item in questions_data:
|
| 204 |
task_id = item.get("task_id")
|
|
|
|
| 205 |
if task_id == task_id_to_redo:
|
| 206 |
-
question_text = item.get("question")
|
| 207 |
try:
|
| 208 |
messages = [HumanMessage(content=json.dumps(item))]
|
| 209 |
response = agent.invoke({"messages": messages})
|
|
@@ -213,6 +210,11 @@ def update_and_resubmit_one_answer(task_id_to_redo: str, profile: gr.OAuthProfil
|
|
| 213 |
except Exception as e:
|
| 214 |
print(f"Error running agent on task {task_id}: {e}")
|
| 215 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
|
| 218 |
# 4. Prepare Submission
|
|
|
|
| 191 |
|
| 192 |
# 3. Run your Agent
|
| 193 |
results_log = []
|
| 194 |
+
new_payload = []
|
| 195 |
+
|
| 196 |
with open("saved_answers.json", "r") as f:
|
| 197 |
saved_payload = json.load(f)
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
print(f"Running agent on 1 question...")
|
| 200 |
for item in questions_data:
|
| 201 |
task_id = item.get("task_id")
|
| 202 |
+
question_text = item.get("question")
|
| 203 |
if task_id == task_id_to_redo:
|
|
|
|
| 204 |
try:
|
| 205 |
messages = [HumanMessage(content=json.dumps(item))]
|
| 206 |
response = agent.invoke({"messages": messages})
|
|
|
|
| 210 |
except Exception as e:
|
| 211 |
print(f"Error running agent on task {task_id}: {e}")
|
| 212 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
|
| 213 |
+
else:
|
| 214 |
+
for a in saved_payload:
|
| 215 |
+
if a["task_id"] == task_id:
|
| 216 |
+
new_payload.append(a)
|
| 217 |
+
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": a["submitted_answer"]})
|
| 218 |
|
| 219 |
|
| 220 |
# 4. Prepare Submission
|