Spaces:
Runtime error
Runtime error
add test agent to understand the task
Browse files- app.py +20 -6
- requirements.txt +3 -1
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -12,12 +12,26 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
-
print(f"
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
+
# 1) pick your model
|
| 16 |
+
hf_model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 17 |
+
# 2) pick your tools
|
| 18 |
+
tools = [DuckDuckGoSearchTool()]
|
| 19 |
+
# 3) build the agent
|
| 20 |
+
self.agent = CodeAgent(tools=tools, model=hf_model)
|
| 21 |
+
|
| 22 |
+
print("✅ BasicAgent initialized with web-search capability.")
|
| 23 |
+
|
| 24 |
def __call__(self, question: str) -> str:
|
| 25 |
+
print(f"🔍 Running agent on: {question[:60]}…")
|
| 26 |
+
try:
|
| 27 |
+
# run your CodeAgent (or LangGraph agent) synchronously
|
| 28 |
+
answer = self.agent.run(question)
|
| 29 |
+
except Exception as e:
|
| 30 |
+
print(f"⚠️ Agent error: {e}")
|
| 31 |
+
answer = f"AGENT ERROR: {e}"
|
| 32 |
+
print(f"💬 Agent answered: {answer[:100]}…")
|
| 33 |
+
return answer
|
| 34 |
+
|
| 35 |
|
| 36 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 37 |
"""
|
requirements.txt
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
gradio
|
| 2 |
-
requests
|
|
|
|
|
|
|
|
|
| 1 |
gradio
|
| 2 |
+
requests
|
| 3 |
+
smolagents
|
| 4 |
+
gradio[oauth]
|