avfranco commited on
Commit
0b1e28b
·
1 Parent(s): ef18d8b

final assignment gaia agent tools submission enabled system prompt litellm login

Browse files
Files changed (2) hide show
  1. agents/gaia.py +9 -12
  2. tools/gaiatool.py +2 -1
agents/gaia.py CHANGED
@@ -1,5 +1,5 @@
1
  # --- Gaia Agent Definition ---
2
- from smolagents import CodeAgent, DuckDuckGoSearchTool
3
  from tools.gaiatool import fetch_questions
4
  from smolagents import LiteLLMModel, OpenAIServerModel, HfApiModel, InferenceClientModel
5
  import os
@@ -21,7 +21,7 @@ class GaiaAgent:
21
  #self.model = LiteLLMModel(model_id="gemini/gemini-1.5-flash-latest", api_key=os.getenv("GEMINI_API_KEY"))
22
  self.model = OpenAIServerModel(
23
  model_id="gpt-4o-mini",
24
- api_base="https://api.openai.com/v1",
25
  api_key=os.environ["OPENAI_API_KEY"],
26
  temperature=0.0
27
  )
@@ -29,25 +29,22 @@ class GaiaAgent:
29
  #model_id = "meta-llama/Llama-3.3-70B-Instruct"
30
  #self.model = InferenceClientModel(model_id=model_id)
31
 
32
- # Initialize the DuckDuckGo search tool
33
- self.search_tool = DuckDuckGoSearchTool()
34
 
35
  self.agent = CodeAgent(
36
  model=self.model,
37
- tools=[self.search_tool],
38
  add_base_tools=True,
39
- additional_authorized_imports=["pandas"]
40
  )
41
 
42
  system_prompt = """You are a general AI assistant. I will ask you a question. Report your thoughts, and
43
  finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
44
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated
45
- list of numbers and/or strings.
46
- If you are asked for a number, don’t use comma to write your number neither use units such as $ or
47
- percent sign unless specified otherwise.
48
- If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write the
49
- digits in plain text unless specified otherwise.
50
- If you are asked for a comma separated list, apply the above rules depending of whether the element
51
  to be put in the list is a number or a string."""
52
 
53
  self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + system_prompt
 
1
  # --- Gaia Agent Definition ---
2
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool
3
  from tools.gaiatool import fetch_questions
4
  from smolagents import LiteLLMModel, OpenAIServerModel, HfApiModel, InferenceClientModel
5
  import os
 
21
  #self.model = LiteLLMModel(model_id="gemini/gemini-1.5-flash-latest", api_key=os.getenv("GEMINI_API_KEY"))
22
  self.model = OpenAIServerModel(
23
  model_id="gpt-4o-mini",
24
+ api_base="https://api.openai.com/v1",
25
  api_key=os.environ["OPENAI_API_KEY"],
26
  temperature=0.0
27
  )
 
29
  #model_id = "meta-llama/Llama-3.3-70B-Instruct"
30
  #self.model = InferenceClientModel(model_id=model_id)
31
 
32
+ search= DuckDuckGoSearchTool()
33
+ web_browser = VisitWebpageTool()
34
 
35
  self.agent = CodeAgent(
36
  model=self.model,
37
+ tools=[search, web_browser],
38
  add_base_tools=True,
39
+ additional_authorized_imports=["pandas", "re"]
40
  )
41
 
42
  system_prompt = """You are a general AI assistant. I will ask you a question. Report your thoughts, and
43
  finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
44
  YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated
45
+ list of numbers and/or strings. If you are asked for a number, don’t use comma to write your number neither use units such as $ or
46
+ percent sign unless specified otherwise. If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write the
47
+ digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element
 
 
 
48
  to be put in the list is a number or a string."""
49
 
50
  self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + system_prompt
tools/gaiatool.py CHANGED
@@ -1,6 +1,7 @@
1
  from smolagents import tool
2
  import requests
3
 
 
4
  # (Keep Constants as is)
5
  # --- Constants ---
6
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -30,4 +31,4 @@ def fetch_questions(questions_url: str) -> list:
30
  print(f"An unexpected error occurred fetching questions: {e}")
31
  return f"An unexpected error occurred fetching questions: {e}", None
32
 
33
- return questions_data
 
1
  from smolagents import tool
2
  import requests
3
 
4
+
5
  # (Keep Constants as is)
6
  # --- Constants ---
7
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
31
  print(f"An unexpected error occurred fetching questions: {e}")
32
  return f"An unexpected error occurred fetching questions: {e}", None
33
 
34
+ return questions_data