Ubik80 commited on
Commit
434f948
·
verified ·
1 Parent(s): b6af241

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +16 -15
agent.py CHANGED
@@ -15,7 +15,7 @@ def fetch_questions() -> list:
15
  """
16
  Fetch the full list of GAIA evaluation questions.
17
 
18
- :return: A list of question dicts, each with 'task_id' and 'question'.
19
  """
20
  resp = requests.get(f"{API_URL}/questions", timeout=15)
21
  resp.raise_for_status()
@@ -26,7 +26,7 @@ def fetch_random_question() -> dict:
26
  """
27
  Fetch a single random GAIA question.
28
 
29
- :return: A dict containing 'task_id' and 'question'.
30
  """
31
  resp = requests.get(f"{API_URL}/random-question", timeout=15)
32
  resp.raise_for_status()
@@ -37,8 +37,8 @@ def fetch_file(task_id: str) -> bytes:
37
  """
38
  Download a file associated with a given GAIA task.
39
 
40
- :param task_id: The ID of the GAIA task whose file to download.
41
- :return: Raw bytes of the file.
42
  """
43
  resp = requests.get(f"{API_URL}/files/{task_id}", timeout=15)
44
  resp.raise_for_status()
@@ -51,12 +51,12 @@ def submit_answers(
51
  answers: list
52
  ) -> dict:
53
  """
54
- Submit the agent's answers to GAIA and return the scoring.
55
 
56
- :param username: Your HF username for the submission.
57
- :param agent_code: URL to your Space code (for verification).
58
- :param answers: List of dicts each with 'task_id' and 'submitted_answer'.
59
- :return: Dict with keys 'score', 'correct_count', 'total_attempted', 'message', etc.
60
  """
61
  payload = {
62
  "username": username,
@@ -67,20 +67,21 @@ def submit_answers(
67
  resp.raise_for_status()
68
  return resp.json()
69
 
70
-
71
  def create_agent() -> CodeAgent:
72
  """
73
- Build and return a configured CodeAgent using OpenAI GPT-3.5 Turbo.
74
- Expects OPENAI_API_KEY in the environment.
 
 
75
  """
76
- openai_model = OpenAIServerModel(model_name="gpt-3.5-turbo")
77
  agent = CodeAgent(
78
  tools=[fetch_questions, fetch_random_question, fetch_file, submit_answers],
79
- model=openai_model,
80
  prompt_template=(
81
  "Here is a GAIA question:\n"
82
  "{question}\n"
83
- "Respond with only the exact answer (exact-match), no extra text."
84
  )
85
  )
86
  return agent
 
15
  """
16
  Fetch the full list of GAIA evaluation questions.
17
 
18
+ :return: List of question dicts, each containing 'task_id' and 'question'.
19
  """
20
  resp = requests.get(f"{API_URL}/questions", timeout=15)
21
  resp.raise_for_status()
 
26
  """
27
  Fetch a single random GAIA question.
28
 
29
+ :return: A dict with keys 'task_id' and 'question'.
30
  """
31
  resp = requests.get(f"{API_URL}/random-question", timeout=15)
32
  resp.raise_for_status()
 
37
  """
38
  Download a file associated with a given GAIA task.
39
 
40
+ :param task_id: The GAIA task ID whose file should be downloaded.
41
+ :return: Raw bytes of the file content.
42
  """
43
  resp = requests.get(f"{API_URL}/files/{task_id}", timeout=15)
44
  resp.raise_for_status()
 
51
  answers: list
52
  ) -> dict:
53
  """
54
+ Submit the agent's answers to the GAIA API and retrieve scoring results.
55
 
56
+ :param username: Hugging Face username for submission identification.
57
+ :param agent_code: URL linking to the code repository of this Space.
58
+ :param answers: List of dicts, each with 'task_id' and 'submitted_answer'.
59
+ :return: Dict with keys 'username', 'score', 'correct_count', 'total_attempted', 'message', etc.
60
  """
61
  payload = {
62
  "username": username,
 
67
  resp.raise_for_status()
68
  return resp.json()
69
 
 
70
  def create_agent() -> CodeAgent:
71
  """
72
+ Factory that initializes and returns a configured CodeAgent using OpenAI GPT-3.5-turbo.
73
+ Expects OPENAI_API_KEY set in the environment.
74
+
75
+ :return: Configured CodeAgent instance.
76
  """
77
+ model = OpenAIServerModel(model_name="gpt-3.5-turbo")
78
  agent = CodeAgent(
79
  tools=[fetch_questions, fetch_random_question, fetch_file, submit_answers],
80
+ model=model,
81
  prompt_template=(
82
  "Here is a GAIA question:\n"
83
  "{question}\n"
84
+ "Provide only the exact answer (exact-match), with no additional explanation."
85
  )
86
  )
87
  return agent