Update app.py
Browse files
app.py
CHANGED
|
@@ -86,6 +86,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 86 |
# 3. Run your Agent
|
| 87 |
results_log = []
|
| 88 |
answers_payload = []
|
|
|
|
| 89 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 90 |
for item in questions_data:
|
| 91 |
task_id = item.get("task_id")
|
|
@@ -96,7 +97,12 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 96 |
try:
|
| 97 |
input_state = {"messages": [HumanMessage(content=question_text)]}
|
| 98 |
answer = agent.invoke(input_state)
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 101 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 102 |
except Exception as e:
|
|
|
|
| 86 |
# 3. Run your Agent
|
| 87 |
results_log = []
|
| 88 |
answers_payload = []
|
| 89 |
+
submitted_answer = ""
|
| 90 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 91 |
for item in questions_data:
|
| 92 |
task_id = item.get("task_id")
|
|
|
|
| 97 |
try:
|
| 98 |
input_state = {"messages": [HumanMessage(content=question_text)]}
|
| 99 |
answer = agent.invoke(input_state)
|
| 100 |
+
final_answer = answer['messages'][-1].content
|
| 101 |
+
if "Final Answer:" in final_answer:
|
| 102 |
+
submitted_answer = final_answer.split("Final Answer:")[1].strip()
|
| 103 |
+
print(final_answer)
|
| 104 |
+
else:
|
| 105 |
+
print("No Final Answer found in the response.")
|
| 106 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 107 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 108 |
except Exception as e:
|