Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,6 +75,7 @@ Follow these steps for each question:
|
|
| 75 |
Your answer should be direct, concise, and match the requested format precisely.
|
| 76 |
"""
|
| 77 |
|
|
|
|
| 78 |
# Initialize the agent
|
| 79 |
agent = CodeAgent(
|
| 80 |
model=model,
|
|
@@ -84,8 +85,7 @@ agent = CodeAgent(
|
|
| 84 |
calculator,
|
| 85 |
],
|
| 86 |
max_steps=8,
|
| 87 |
-
verbosity_level=1
|
| 88 |
-
custom_system_instructions=SYSTEM_PROMPT # Changed parameter name
|
| 89 |
)
|
| 90 |
|
| 91 |
|
|
@@ -116,13 +116,16 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 116 |
api_url = DEFAULT_API_URL
|
| 117 |
questions_url = f"{api_url}/questions"
|
| 118 |
submit_url = f"{api_url}/submit"
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
| 126 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
| 127 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 128 |
print(agent_code)
|
|
@@ -159,7 +162,10 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 159 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 160 |
continue
|
| 161 |
try:
|
| 162 |
-
submitted_answer = agent(question_text)
|
|
|
|
|
|
|
|
|
|
| 163 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 164 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 165 |
except Exception as e:
|
|
|
|
| 75 |
Your answer should be direct, concise, and match the requested format precisely.
|
| 76 |
"""
|
| 77 |
|
| 78 |
+
# Initialize the agent
|
| 79 |
# Initialize the agent
|
| 80 |
agent = CodeAgent(
|
| 81 |
model=model,
|
|
|
|
| 85 |
calculator,
|
| 86 |
],
|
| 87 |
max_steps=8,
|
| 88 |
+
verbosity_level=1
|
|
|
|
| 89 |
)
|
| 90 |
|
| 91 |
|
|
|
|
| 116 |
api_url = DEFAULT_API_URL
|
| 117 |
questions_url = f"{api_url}/questions"
|
| 118 |
submit_url = f"{api_url}/submit"
|
| 119 |
+
# 1. Instantiate Agent (modify this part to create your agent)
|
| 120 |
+
try:
|
| 121 |
+
# agent = BasicAgent() # Comment out or remove this line
|
| 122 |
+
|
| 123 |
+
# Use the agent already defined at the top
|
| 124 |
+
# No need to create a new one, just use the existing agent
|
| 125 |
+
print("Using CodeAgent with tools for evaluation")
|
| 126 |
+
except Exception as e:
|
| 127 |
+
print(f"Error instantiating agent: {e}")
|
| 128 |
+
return f"Error initializing agent: {e}", None
|
| 129 |
# In the case of an app running as a hugging Face space, this link points toward your codebase ( usefull for others so please keep it public)
|
| 130 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 131 |
print(agent_code)
|
|
|
|
| 162 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 163 |
continue
|
| 164 |
try:
|
| 165 |
+
submitted_answer = agent.run(question_text)
|
| 166 |
+
# Clean up the answer if needed
|
| 167 |
+
if "FINAL ANSWER:" in submitted_answer:
|
| 168 |
+
submitted_answer = submitted_answer.split("FINAL ANSWER:")[1].strip()
|
| 169 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 170 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 171 |
except Exception as e:
|