changes for smolagents
Browse files
app.py
CHANGED
|
@@ -12,9 +12,9 @@ from dotenv import load_dotenv
|
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 13 |
|
| 14 |
# --- Agent Setup ---
|
| 15 |
-
|
| 16 |
-
if not
|
| 17 |
-
raise RuntimeError("Set
|
| 18 |
|
| 19 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
| 20 |
"""
|
|
@@ -22,7 +22,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 22 |
and displays the results.
|
| 23 |
"""
|
| 24 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 25 |
-
space_id = os.getenv("SPACE_ID")
|
| 26 |
|
| 27 |
if profile:
|
| 28 |
username = f"{profile.username}"
|
|
@@ -42,7 +42,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 42 |
print(f"Error instantiating agent: {e}")
|
| 43 |
return f"Error initializing agent: {e}", None
|
| 44 |
|
| 45 |
-
#
|
| 46 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main" if space_id else "Local"
|
| 47 |
print(f"Agent code location: {agent_code}")
|
| 48 |
|
|
@@ -163,7 +163,7 @@ with gr.Blocks() as demo:
|
|
| 163 |
gr.Markdown(
|
| 164 |
"""
|
| 165 |
**Instructions:**
|
| 166 |
-
1. This app
|
| 167 |
2. Log in to your Hugging Face account using the button below.
|
| 168 |
3. Click 'Run Evaluation & Submit All Answers' to fetch GAIA questions, run your agent, and submit answers.
|
| 169 |
|
|
@@ -171,8 +171,7 @@ with gr.Blocks() as demo:
|
|
| 171 |
- Mathematical operations (add, subtract, multiply, divide, modulus)
|
| 172 |
- Wikipedia search
|
| 173 |
- Web search (DuckDuckGo)
|
| 174 |
-
-
|
| 175 |
-
- Web Scraping Tool using BeautifulSoup
|
| 176 |
|
| 177 |
**Note:** Processing all questions may take several minutes depending on the number of questions and API response times.
|
| 178 |
"""
|
|
@@ -194,7 +193,7 @@ if __name__ == "__main__":
|
|
| 194 |
# Check for required environment variables
|
| 195 |
space_host_startup = os.getenv("SPACE_HOST")
|
| 196 |
space_id_startup = os.getenv("SPACE_ID")
|
| 197 |
-
|
| 198 |
|
| 199 |
if space_host_startup:
|
| 200 |
print(f"✅ SPACE_HOST found: {space_host_startup}")
|
|
@@ -209,10 +208,10 @@ if __name__ == "__main__":
|
|
| 209 |
else:
|
| 210 |
print("ℹ️ SPACE_ID environment variable not found (running locally?).")
|
| 211 |
|
| 212 |
-
if
|
| 213 |
-
print("✅
|
| 214 |
else:
|
| 215 |
-
print("⚠️
|
| 216 |
|
| 217 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 218 |
print("Launching Gradio Interface for GAIA Agent Evaluation...")
|
|
|
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 13 |
|
| 14 |
# --- Agent Setup ---
|
| 15 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 16 |
+
if not hf_token:
|
| 17 |
+
raise RuntimeError("Set HF_TOKEN in your Space secrets")
|
| 18 |
|
| 19 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
| 20 |
"""
|
|
|
|
| 22 |
and displays the results.
|
| 23 |
"""
|
| 24 |
# --- Determine HF Space Runtime URL and Repo URL ---
|
| 25 |
+
space_id = os.getenv("SPACE_ID")
|
| 26 |
|
| 27 |
if profile:
|
| 28 |
username = f"{profile.username}"
|
|
|
|
| 42 |
print(f"Error instantiating agent: {e}")
|
| 43 |
return f"Error initializing agent: {e}", None
|
| 44 |
|
| 45 |
+
# Agent code location
|
| 46 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main" if space_id else "Local"
|
| 47 |
print(f"Agent code location: {agent_code}")
|
| 48 |
|
|
|
|
| 163 |
gr.Markdown(
|
| 164 |
"""
|
| 165 |
**Instructions:**
|
| 166 |
+
1. This app uses a smolagents CodeAgent with multiple tools (calculator, Wikipedia, web search).
|
| 167 |
2. Log in to your Hugging Face account using the button below.
|
| 168 |
3. Click 'Run Evaluation & Submit All Answers' to fetch GAIA questions, run your agent, and submit answers.
|
| 169 |
|
|
|
|
| 171 |
- Mathematical operations (add, subtract, multiply, divide, modulus)
|
| 172 |
- Wikipedia search
|
| 173 |
- Web search (DuckDuckGo)
|
| 174 |
+
- Web content fetcher
|
|
|
|
| 175 |
|
| 176 |
**Note:** Processing all questions may take several minutes depending on the number of questions and API response times.
|
| 177 |
"""
|
|
|
|
| 193 |
# Check for required environment variables
|
| 194 |
space_host_startup = os.getenv("SPACE_HOST")
|
| 195 |
space_id_startup = os.getenv("SPACE_ID")
|
| 196 |
+
hf_token_startup = os.getenv("HF_TOKEN")
|
| 197 |
|
| 198 |
if space_host_startup:
|
| 199 |
print(f"✅ SPACE_HOST found: {space_host_startup}")
|
|
|
|
| 208 |
else:
|
| 209 |
print("ℹ️ SPACE_ID environment variable not found (running locally?).")
|
| 210 |
|
| 211 |
+
if hf_token_startup:
|
| 212 |
+
print("✅ HF_TOKEN found")
|
| 213 |
else:
|
| 214 |
+
print("⚠️ HF_TOKEN not found - agent will not work without it!")
|
| 215 |
|
| 216 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 217 |
print("Launching Gradio Interface for GAIA Agent Evaluation...")
|