avfranco commited on
Commit
7813102
·
1 Parent(s): 8f3b987

final assignment gaia agent tools submission enabled system prompt litellm llama

Browse files
Files changed (2) hide show
  1. agents/gaia.py +13 -7
  2. app.py +1 -4
agents/gaia.py CHANGED
@@ -1,7 +1,7 @@
1
  # --- Gaia Agent Definition ---
2
  from smolagents import CodeAgent, DuckDuckGoSearchTool
3
  from tools.gaiatool import fetch_questions
4
- from smolagents import LiteLLMModel, OpenAIServerModel, HfApiModel
5
  import os
6
 
7
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
@@ -19,12 +19,16 @@ class GaiaAgent:
19
 
20
  # Initialize the model
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
- )
 
 
 
 
28
 
29
  # Initialize the DuckDuckGo search tool
30
  self.search_tool = DuckDuckGoSearchTool()
@@ -32,6 +36,8 @@ class GaiaAgent:
32
  self.agent = CodeAgent(
33
  model=self.model,
34
  tools=[self.search_tool],
 
 
35
  )
36
 
37
  self.agent.prompt_templates["system_prompt"] += "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated 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 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 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 to be put in the list is a number or a string."
 
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
6
 
7
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
19
 
20
  # Initialize the model
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
+ #)
28
+
29
+
30
+ model_id = "meta-llama/Llama-3.3-70B-Instruct"
31
+ self.model = InferenceClientModel(model_id=model_id)
32
 
33
  # Initialize the DuckDuckGo search tool
34
  self.search_tool = DuckDuckGoSearchTool()
 
36
  self.agent = CodeAgent(
37
  model=self.model,
38
  tools=[self.search_tool],
39
+ add_base_tools=True,
40
+ additional_authorized_imports=["pandas"]
41
  )
42
 
43
  self.agent.prompt_templates["system_prompt"] += "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated 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 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 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 to be put in the list is a number or a string."
app.py CHANGED
@@ -115,10 +115,7 @@ with gr.Blocks() as demo:
115
  gr.Markdown(
116
  """
117
  **Instructions:**
118
-
119
- 1. (DUPLICATED) Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
120
- 2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
121
- 3. (NOT SUBMITTING FOR NOW: Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
122
 
123
  ---
124
  **Disclaimers:**
 
115
  gr.Markdown(
116
  """
117
  **Instructions:**
118
+ 1. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
 
 
 
119
 
120
  ---
121
  **Disclaimers:**