avfranco commited on
Commit
914c29e
Β·
1 Parent(s): 1c60b2b

final assignment gaia agent tools submission enabled system prompt litellm login models

Browse files
Files changed (5) hide show
  1. README.md +1 -1
  2. agents/gaia.py +21 -13
  3. app.py +9 -5
  4. requirements.txt +0 -1
  5. tools/gaiatool.py +0 -2
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Template Final Assignment
3
  emoji: πŸ•΅πŸ»β€β™‚οΈ
4
  colorFrom: indigo
5
  colorTo: indigo
 
1
  ---
2
+ title: HF Smolagents Course: Gaia Agent Evaluation
3
  emoji: πŸ•΅πŸ»β€β™‚οΈ
4
  colorFrom: indigo
5
  colorTo: indigo
agents/gaia.py CHANGED
@@ -1,8 +1,10 @@
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, TransformersModel
5
  import os
 
 
6
 
7
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
8
  # (Keep Constants as is)
@@ -17,20 +19,26 @@ class GaiaAgent:
17
 
18
  self.questions_url = f"{api_url}/questions"
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
- #model_id = "meta-llama/Llama-3.3-70B-Instruct"
30
- #self.model = InferenceClientModel(model_id=model_id)
31
 
32
- model_id = "meta-llama/Llama-4-Maverick-17B-128E-Instruct"
33
- self.model = TransformersModel(model_id=model_id)
 
 
 
 
34
 
35
  search= DuckDuckGoSearchTool()
36
  web_browser = VisitWebpageTool()
 
1
  # --- Gaia Agent Definition ---
2
  from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool
3
  from tools.gaiatool import fetch_questions
4
+ from smolagents import LiteLLMModel, InferenceClientModel
5
  import os
6
+ from smolagents import HfApiModel
7
+ #from smolagents import OpenAIServerModel #uncoment in case of using OpenAI API, or Hugging Face API
8
 
9
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
10
  # (Keep Constants as is)
 
19
 
20
  self.questions_url = f"{api_url}/questions"
21
 
22
+ if not os.getenv("SPACE_ID"):
23
+ # Initialize local model
24
+ model_id = "ollama/qwen2.5:14b"
25
+ self.model = LiteLLMModel(
26
+ model_id=model_id,
27
+ api_base="http://localhost:11434"
28
+ #api_key=os.getenv("GEMINI_API_KEY")
29
+ )
30
+ else: # Run with Hugging Face Inference API
31
+ #model_id = "meta-llama/Llama-3.3-70B-Instruct"
32
+ #self.model = InferenceClientModel(model_id=model_id)
33
 
34
+ self.model = HfApiModel(temperature=0.0)
 
35
 
36
+ """self.model = OpenAIServerModel(
37
+ model_id="gpt-4o-mini",
38
+ api_base="https://api.openai.com/v1",
39
+ api_key=os.environ["OPENAI_API_KEY"],
40
+ temperature=0.0
41
+ )"""
42
 
43
  search= DuckDuckGoSearchTool()
44
  web_browser = VisitWebpageTool()
app.py CHANGED
@@ -15,12 +15,16 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
15
  # --- Determine HF Space Runtime URL and Repo URL ---
16
  space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
17
 
18
- if profile:
19
- username= f"{profile.username}"
20
- print(f"User logged in: {username}")
 
 
 
 
21
  else:
22
- print("User not logged in.")
23
- return "Please Login to Hugging Face with the button.", None
24
 
25
  submit_url = f"{DEFAULT_API_URL}/submit"
26
 
 
15
  # --- Determine HF Space Runtime URL and Repo URL ---
16
  space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the code
17
 
18
+ if space_id:
19
+ if profile:
20
+ username= f"{profile.username}"
21
+ print(f"User logged in: {username}")
22
+ else:
23
+ print("User not logged in.")
24
+ return "Please Login to Hugging Face with the button.", None
25
  else:
26
+ username = "avfranco"
27
+ print(f"Running locally with user {username}.")
28
 
29
  submit_url = f"{DEFAULT_API_URL}/submit"
30
 
requirements.txt CHANGED
@@ -4,4 +4,3 @@ pandas==2.2.3
4
  requests==2.32.3
5
  smolagents
6
  smolagents[litellm]
7
- transformers
 
4
  requests==2.32.3
5
  smolagents
6
  smolagents[litellm]
 
tools/gaiatool.py CHANGED
@@ -1,7 +1,5 @@
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"
 
 
1
  import requests
2
 
 
3
  # (Keep Constants as is)
4
  # --- Constants ---
5
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"