Spaces:
Runtime error
Runtime error
Commit ·
8140fce
1
Parent(s): 81917a3
Minimal working version
Browse filesFiles changed (3)
- .gitignoreAdded+1
- app.py+30-7
- requirements.txt+5-2
1.env12345678910111213141516171819202122231 unmodified line25262728293031import osimport gradio as grimport requestsimport inspectimport pandas as pd# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"# --- Basic Agent Definition ---# ----- 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):"""1 unmodified lineand displays the results."""# --- Determine HF Space Runtime URL and Repo URL ---space_id = os.getenv("SPACE_ID") # Get the SPACE_ID for sending link to the codeif profile:username= f"{profile.username}"123456789101112131415161718192021222324252627282930313233343536373839404142434445461 unmodified line48495051525354import osimport gradio as grimport requestsimport pandas as pdimport osimport dotenvdotenv.load_dotenv()from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, AzureOpenAIServerModelMODEL = AzureOpenAIServerModel(model_id=os.environ.get("AZURE_OPENAI_DEPLOYMENT"),azure_endpoint=os.environ.get("AZURE_OPENAI_ENDPOINT"),api_key=os.environ.get("AZURE_OPENAI_KEY"),api_version=os.environ.get("AZURE_OPENAI_VERSION"))# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"class BasicAgent:def __init__(self):print("BasicAgent initialized.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")# Initialize the search toolsearch_tool = DuckDuckGoSearchTool(max_results=20)web_tool = VisitWebpageTool()agent = CodeAgent(model=MODEL,tools=[search_tool, web_tool])response = agent.run(question)print(f"Agent returning fixed answer: {response}")return responsedef run_and_submit_all( profile: gr.OAuthProfile | None):"""1 unmodified lineand displays the results."""# --- Determine HF Space Runtime URL and Repo URL ---space_id = os.getenv("SPACE_ID", "maxim-saplin/HF_Agent_Course_Final_Assignment") # Get the SPACE_ID for sending link to the codeif profile:username= f"{profile.username}"
12gradiorequests12345gradio[oauth]requestssmolagents[openai]duckduckgo-searchmarkdownify
.gitignoreAdded+1
app.py+30-7
requirements.txt+5-2