Spaces:
Runtime error
Runtime error
add test agent to understand the task
Browse filesFiles changed (2)
- app.py+20-6
- requirements.txt+3-1
2 unmodified lines34567892 unmodified lines1213141516171819202122232 unmodified linesimport requestsimport inspectimport pandas as pd# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"2 unmodified lines# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:def __init__(self):print("BasicAgent initialized.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")fixed_answer = "This is a default answer."print(f"Agent returning fixed answer: {fixed_answer}")return fixed_answerdef run_and_submit_all( profile: gr.OAuthProfile | None):"""2 unmodified lines34567892 unmodified lines12131415161718192021222324252627282930313233343536372 unmodified linesimport requestsimport inspectimport pandas as pdfrom smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"2 unmodified lines# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:def __init__(self):# 1) pick your modelhf_model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct")# 2) pick your toolstools = [DuckDuckGoSearchTool()]# 3) build the agentself.agent = CodeAgent(tools=tools, model=hf_model)print("✅ BasicAgent initialized with web-search capability.")def __call__(self, question: str) -> str:print(f"🔍 Running agent on: {question[:60]}…")try:# run your CodeAgent (or LangGraph agent) synchronouslyanswer = self.agent.run(question)except Exception as e:print(f"⚠️ Agent error: {e}")answer = f"AGENT ERROR: {e}"print(f"💬 Agent answered: {answer[:100]}…")return answerdef run_and_submit_all( profile: gr.OAuthProfile | None):"""
12gradiorequests1234gradiorequestssmolagentsgradio[oauth]
app.py+20-6
requirements.txt+3-1