Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
# agent.py
|
2 |
import os
|
3 |
import requests
|
4 |
from smolagents import CodeAgent, tool, OpenAIServerModel
|
@@ -42,11 +41,7 @@ def submit_answers(username: str, agent_code: str, answers: list) -> dict:
|
|
42 |
Returns:
|
43 |
dict: Contains 'score', 'correct_count', 'total_attempted', 'message', etc.
|
44 |
"""
|
45 |
-
payload = {
|
46 |
-
"username": username,
|
47 |
-
"agent_code": agent_code,
|
48 |
-
"answers": answers
|
49 |
-
}
|
50 |
resp = requests.post(f"{API_URL}/submit", json=payload, timeout=60)
|
51 |
resp.raise_for_status()
|
52 |
return resp.json()
|
@@ -55,17 +50,15 @@ def create_agent() -> CodeAgent:
|
|
55 |
"""
|
56 |
Build and return a configured CodeAgent using OpenAI GPT-3.5 Turbo.
|
57 |
Requires OPENAI_API_KEY in the environment.
|
|
|
|
|
|
|
58 |
"""
|
|
|
59 |
model = OpenAIServerModel(model_id="gpt-3.5-turbo")
|
|
|
60 |
agent = CodeAgent(
|
61 |
tools=[fetch_questions, fetch_random_question, submit_answers],
|
62 |
-
model=model
|
63 |
-
# Use `system_prompt`, not `prompt_template`
|
64 |
-
system_prompt=(
|
65 |
-
"You are a concise assistant.\n"
|
66 |
-
"Here is a GAIA question:\n"
|
67 |
-
"{task}\n"
|
68 |
-
"Respond with only the exact answer (exact-match), no extra text.\n"
|
69 |
-
)
|
70 |
)
|
71 |
return agent
|
|
|
|
|
1 |
import os
|
2 |
import requests
|
3 |
from smolagents import CodeAgent, tool, OpenAIServerModel
|
|
|
41 |
Returns:
|
42 |
dict: Contains 'score', 'correct_count', 'total_attempted', 'message', etc.
|
43 |
"""
|
44 |
+
payload = {"username": username, "agent_code": agent_code, "answers": answers}
|
|
|
|
|
|
|
|
|
45 |
resp = requests.post(f"{API_URL}/submit", json=payload, timeout=60)
|
46 |
resp.raise_for_status()
|
47 |
return resp.json()
|
|
|
50 |
"""
|
51 |
Build and return a configured CodeAgent using OpenAI GPT-3.5 Turbo.
|
52 |
Requires OPENAI_API_KEY in the environment.
|
53 |
+
|
54 |
+
Returns:
|
55 |
+
CodeAgent: Configured with GAIA tools.
|
56 |
"""
|
57 |
+
# Initialize the model for CodeAgent
|
58 |
model = OpenAIServerModel(model_id="gpt-3.5-turbo")
|
59 |
+
# Instantiate CodeAgent with default prompt and provided tools
|
60 |
agent = CodeAgent(
|
61 |
tools=[fetch_questions, fetch_random_question, submit_answers],
|
62 |
+
model=model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
)
|
64 |
return agent
|