Update app.py
Browse files
app.py
CHANGED
|
@@ -45,8 +45,9 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 45 |
question_text = item.get("question")
|
| 46 |
if not task_id or question_text is None:
|
| 47 |
continue
|
|
|
|
| 48 |
try:
|
| 49 |
-
|
| 50 |
system_prompt = (
|
| 51 |
"You are a general AI assistant. I will ask you a question. "
|
| 52 |
"Report your thoughts, and finish your answer with the following template: "
|
|
@@ -61,26 +62,22 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 61 |
loop = asyncio.get_event_loop()
|
| 62 |
agent_response = await loop.run_in_executor(None, agent, full_prompt)
|
| 63 |
|
| 64 |
-
#
|
| 65 |
if "FINAL ANSWER:" in agent_response:
|
| 66 |
-
|
| 67 |
final_answer = final_answer.strip()
|
| 68 |
-
reasoning_trace = reasoning_trace.strip()
|
| 69 |
else:
|
| 70 |
final_answer = agent_response.strip()
|
| 71 |
-
|
| 72 |
-
|
| 73 |
answers_payload.append({
|
| 74 |
"task_id": task_id,
|
| 75 |
-
"model_answer": final_answer
|
| 76 |
-
"reasoning_trace": reasoning_trace
|
| 77 |
})
|
| 78 |
-
|
| 79 |
results_log.append({
|
| 80 |
"Task ID": task_id,
|
| 81 |
"Question": question_text,
|
| 82 |
-
"Submitted Answer": final_answer
|
| 83 |
-
"Reasoning Trace": reasoning_trace
|
| 84 |
})
|
| 85 |
|
| 86 |
except Exception as e:
|
|
@@ -88,10 +85,10 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 88 |
results_log.append({
|
| 89 |
"Task ID": task_id,
|
| 90 |
"Question": question_text,
|
| 91 |
-
"Submitted Answer": f"AGENT ERROR: {e}"
|
| 92 |
-
"Reasoning Trace": "N/A"
|
| 93 |
})
|
| 94 |
|
|
|
|
| 95 |
if not answers_payload:
|
| 96 |
return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
|
| 97 |
|
|
|
|
| 45 |
question_text = item.get("question")
|
| 46 |
if not task_id or question_text is None:
|
| 47 |
continue
|
| 48 |
+
|
| 49 |
try:
|
| 50 |
+
# Full prompt with required system instructions
|
| 51 |
system_prompt = (
|
| 52 |
"You are a general AI assistant. I will ask you a question. "
|
| 53 |
"Report your thoughts, and finish your answer with the following template: "
|
|
|
|
| 62 |
loop = asyncio.get_event_loop()
|
| 63 |
agent_response = await loop.run_in_executor(None, agent, full_prompt)
|
| 64 |
|
| 65 |
+
# Try to extract FINAL ANSWER
|
| 66 |
if "FINAL ANSWER:" in agent_response:
|
| 67 |
+
_, final_answer = agent_response.rsplit("FINAL ANSWER:", 1)
|
| 68 |
final_answer = final_answer.strip()
|
|
|
|
| 69 |
else:
|
| 70 |
final_answer = agent_response.strip()
|
| 71 |
+
|
|
|
|
| 72 |
answers_payload.append({
|
| 73 |
"task_id": task_id,
|
| 74 |
+
"model_answer": final_answer
|
|
|
|
| 75 |
})
|
| 76 |
+
|
| 77 |
results_log.append({
|
| 78 |
"Task ID": task_id,
|
| 79 |
"Question": question_text,
|
| 80 |
+
"Submitted Answer": final_answer
|
|
|
|
| 81 |
})
|
| 82 |
|
| 83 |
except Exception as e:
|
|
|
|
| 85 |
results_log.append({
|
| 86 |
"Task ID": task_id,
|
| 87 |
"Question": question_text,
|
| 88 |
+
"Submitted Answer": f"AGENT ERROR: {e}"
|
|
|
|
| 89 |
})
|
| 90 |
|
| 91 |
+
|
| 92 |
if not answers_payload:
|
| 93 |
return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
|
| 94 |
|