Ubik80 commited on
Commit
179d569
·
verified ·
1 Parent(s): 4b51ad9

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +10 -20
agent.py CHANGED
@@ -1,15 +1,10 @@
 
1
  import os
2
  import requests
3
  from smolagents import CodeAgent, tool, OpenAIServerModel
4
 
5
- # ------------------------
6
- # Constants
7
- # ------------------------
8
  API_URL = "https://agents-course-unit4-scoring.hf.space"
9
 
10
- # ------------------------
11
- # Tool definitions
12
- # ------------------------
13
  @tool
14
  def fetch_questions() -> list:
15
  """
@@ -22,7 +17,6 @@ def fetch_questions() -> list:
22
  resp.raise_for_status()
23
  return resp.json()
24
 
25
-
26
  @tool
27
  def fetch_random_question() -> dict:
28
  """
@@ -35,19 +29,18 @@ def fetch_random_question() -> dict:
35
  resp.raise_for_status()
36
  return resp.json()
37
 
38
-
39
  @tool
40
  def submit_answers(username: str, agent_code: str, answers: list) -> dict:
41
  """
42
  Submit the agent's answers to GAIA and get the scoring.
43
 
44
  Args:
45
- username (str): The Hugging Face username identifying the submission.
46
- agent_code (str): URL to your Space code repository for verification.
47
- answers (list): A list of dicts, each with 'task_id' and 'submitted_answer'.
48
 
49
  Returns:
50
- dict: A dict containing 'score', 'correct_count', 'total_attempted', 'message', etc.
51
  """
52
  payload = {
53
  "username": username,
@@ -58,24 +51,21 @@ def submit_answers(username: str, agent_code: str, answers: list) -> dict:
58
  resp.raise_for_status()
59
  return resp.json()
60
 
61
-
62
  def create_agent() -> CodeAgent:
63
  """
64
  Build and return a configured CodeAgent using OpenAI GPT-3.5 Turbo.
65
  Requires OPENAI_API_KEY in the environment.
66
-
67
- Returns:
68
- CodeAgent: An instance of CodeAgent configured with the GAIA tools.
69
  """
70
- # Correctly pass the model_id parameter here:
71
  model = OpenAIServerModel(model_id="gpt-3.5-turbo")
72
  agent = CodeAgent(
73
  tools=[fetch_questions, fetch_random_question, submit_answers],
74
  model=model,
75
- prompt_template=(
 
 
76
  "Here is a GAIA question:\n"
77
- "{question}\n"
78
- "Provide ONLY the exact answer (exact-match), with no extra text."
79
  )
80
  )
81
  return agent
 
1
+ # agent.py
2
  import os
3
  import requests
4
  from smolagents import CodeAgent, tool, OpenAIServerModel
5
 
 
 
 
6
  API_URL = "https://agents-course-unit4-scoring.hf.space"
7
 
 
 
 
8
  @tool
9
  def fetch_questions() -> list:
10
  """
 
17
  resp.raise_for_status()
18
  return resp.json()
19
 
 
20
  @tool
21
  def fetch_random_question() -> dict:
22
  """
 
29
  resp.raise_for_status()
30
  return resp.json()
31
 
 
32
  @tool
33
  def submit_answers(username: str, agent_code: str, answers: list) -> dict:
34
  """
35
  Submit the agent's answers to GAIA and get the scoring.
36
 
37
  Args:
38
+ username (str): HF username for the submission.
39
+ agent_code (str): URL of your Space repo for verification.
40
+ answers (list): List of dicts, each with 'task_id' and 'submitted_answer'.
41
 
42
  Returns:
43
+ dict: Contains 'score', 'correct_count', 'total_attempted', 'message', etc.
44
  """
45
  payload = {
46
  "username": username,
 
51
  resp.raise_for_status()
52
  return resp.json()
53
 
 
54
  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