final assignment gaia agent tools submission enabled system prompt litellm login models
Browse files- README.md +1 -1
- agents/gaia.py +21 -13
- app.py +9 -5
- requirements.txt +0 -1
- tools/gaiatool.py +0 -2
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 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,
|
| 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 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
|
| 30 |
-
#self.model = InferenceClientModel(model_id=model_id)
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
else:
|
| 22 |
-
|
| 23 |
-
|
| 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"
|