Update app.py
Browse files3 unmodified lines4567891 unmodified line111213141516171819202122233 unmodified linesimport inspectimport pandas as pd# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"1 unmodified line# --- 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):"""3 unmodified lines4567891011121 unmodified line141516171819202122232425262728293031323334353637383940414243444546474849505152535455563 unmodified linesimport inspectimport pandas as pdfrom smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,toolfrom tools.final_answer import FinalAnswerTool# (Keep Constants as is)# --- Constants ---DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"1 unmodified line# --- Basic Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:agentdef __init__(self):final_answer = FinalAnswerTool()# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'model = HfApiModel(max_tokens=2096,temperature=0.5,model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud', #Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloadedcustom_role_conversions=None,)with open("prompts.yaml", 'r') as stream:prompt_templates = yaml.safe_load(stream)self.agent = CodeAgent(model=model,tools=[final_answer], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,planning_interval=None,name=None,description=None,prompt_templates=prompt_templates)print("BasicAgent initialized.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")answer = self.agent.run(question)print(f"Agent returning answer: {answer}")return answerdef run_and_submit_all( profile: gr.OAuthProfile | None):"""
app.py+36-3