JetzeJ commited on
Commit
0741c56
·
1 Parent(s): 6d69133

Upgrade to gpt-4o, add VisitWebpageTool, sharper prompt, more steps

Browse files
Files changed (2) hide show
  1. app.py +15 -8
  2. requirements.txt +2 -0
app.py CHANGED
@@ -9,7 +9,7 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
9
  # --- Agent Definition ---
10
  def build_agent():
11
  """Build and return the smolagents CodeAgent with Groq backend."""
12
- from smolagents import CodeAgent, LiteLLMModel, DuckDuckGoSearchTool, WikipediaSearchTool, tool
13
 
14
  @tool
15
  def download_task_file(task_id: str) -> str:
@@ -57,7 +57,7 @@ def build_agent():
57
  raise ValueError("OPENAI_API_KEY environment variable not set. Add it as a Secret in your HF Space settings.")
58
 
59
  model = LiteLLMModel(
60
- model_id="openai/gpt-4o-mini",
61
  api_key=openai_api_key,
62
  temperature=0.0,
63
  )
@@ -66,6 +66,7 @@ def build_agent():
66
  tools=[
67
  DuckDuckGoSearchTool(),
68
  WikipediaSearchTool(),
 
69
  download_task_file,
70
  ],
71
  model=model,
@@ -73,9 +74,9 @@ def build_agent():
73
  "requests", "json", "re", "math", "datetime",
74
  "csv", "io", "os", "pathlib",
75
  "PIL", "PIL.Image",
76
- "pandas",
77
  ],
78
- max_steps=10,
79
  )
80
 
81
  return agent
@@ -90,10 +91,16 @@ class BasicAgent:
90
  def __call__(self, question: str) -> str:
91
  print(f"Question: {question[:100]}...")
92
  system_note = (
93
- "You are a precise research assistant. "
94
- "Answer the question with ONLY the final answer — no explanation, no 'FINAL ANSWER:' prefix, "
95
- "no extra text. If the answer is a number, give only the number. "
96
- "If it is a name, give only the name. Be exact."
 
 
 
 
 
 
97
  )
98
  full_prompt = f"{system_note}\n\nQuestion: {question}"
99
  try:
 
9
  # --- Agent Definition ---
10
  def build_agent():
11
  """Build and return the smolagents CodeAgent with Groq backend."""
12
+ from smolagents import CodeAgent, LiteLLMModel, DuckDuckGoSearchTool, WikipediaSearchTool, VisitWebpageTool, tool
13
 
14
  @tool
15
  def download_task_file(task_id: str) -> str:
 
57
  raise ValueError("OPENAI_API_KEY environment variable not set. Add it as a Secret in your HF Space settings.")
58
 
59
  model = LiteLLMModel(
60
+ model_id="openai/gpt-4o",
61
  api_key=openai_api_key,
62
  temperature=0.0,
63
  )
 
66
  tools=[
67
  DuckDuckGoSearchTool(),
68
  WikipediaSearchTool(),
69
+ VisitWebpageTool(),
70
  download_task_file,
71
  ],
72
  model=model,
 
74
  "requests", "json", "re", "math", "datetime",
75
  "csv", "io", "os", "pathlib",
76
  "PIL", "PIL.Image",
77
+ "pandas", "openpyxl",
78
  ],
79
+ max_steps=15,
80
  )
81
 
82
  return agent
 
91
  def __call__(self, question: str) -> str:
92
  print(f"Question: {question[:100]}...")
93
  system_note = (
94
+ "You are a precise research assistant solving GAIA benchmark questions. "
95
+ "Your answers are graded by EXACT STRING MATCH, so formatting is critical.\n\n"
96
+ "Rules:\n"
97
+ "- Reply with ONLY the answer, nothing else. No explanation, no 'FINAL ANSWER:' prefix.\n"
98
+ "- Numbers: use digits (e.g. 42, 3.14). No units unless the question asks for them.\n"
99
+ "- Lists: comma-separated on one line unless the question specifies otherwise.\n"
100
+ "- Names/strings: exact spelling, match the question's expected format.\n"
101
+ "- If a file is attached to the question, use the download_task_file tool first.\n"
102
+ "- Search the web and visit pages to verify facts before answering.\n"
103
+ "- Think step by step, but output ONLY the final answer."
104
  )
105
  full_prompt = f"{system_note}\n\nQuestion: {question}"
106
  try:
requirements.txt CHANGED
@@ -5,3 +5,5 @@ smolagents[litellm]
5
  ddgs
6
  wikipedia-api
7
  Pillow
 
 
 
5
  ddgs
6
  wikipedia-api
7
  Pillow
8
+ openpyxl
9
+ markdownify