Spaces:
Build error
Build error
Update BasicAgent.py
Browse files9 unmodified lines10111213141516171819202122232425263 unmodified lines303132333435363738394041424344454647484950519 unmodified linesGoogleSearchTool,)#model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"#model_id = 'meta-llama/Llama-3.3-70B-Instruct'#model = HfApiModel(model_id=model_id, token="HUGGINGFACEHUB_API_TOKEN")#agent = CodeAgent(tools=[], model=model, add_base_tools=True)#max_steps=5#import os#from smolagents import CodeAgent, HfApiModel, InferenceClientModel, WebSearchToolclass newAgent:"""Adapts smolagents.CodeAgent to the HF course template API."""def __init__(self):3 unmodified linesraise RuntimeError("HUGGINGFACEHUB_API_TOKEN not set in Space secrets")model = HfApiModel(model_id=model_id, token=hf_token)# add_base_tools=True already gives you search, python, etc.self.agent = CodeAgent(tools=[], model=model, add_base_tools=True)#*# include FinalAnswerTool in tools so agent knows when to stoptools = [FinalAnswerTool()]self.agent = CodeAgent(tools=tools,model=model,add_base_tools=True)#*def __call__(self, question: str) -> str:"""ONE question in → ONE pure-text answer out."""#↓ Replace .run with whatever method actually returns the answer string.result = self.agent.run(question)return answer#answer = self.run9 unmodified lines1011121314153 unmodified lines1920212223242526272829303132333435363738399 unmodified linesGoogleSearchTool,)class newAgent:"""Adapts smolagents.CodeAgent to the HF course template API."""def __init__(self):3 unmodified linesraise RuntimeError("HUGGINGFACEHUB_API_TOKEN not set in Space secrets")model = HfApiModel(model_id=model_id, token=hf_token)# include FinalAnswerTool in tools so agent knows when to stoptools = [FinalAnswerTool()]self.agent = CodeAgent(tools=tools,model=model,add_base_tools=Truemax_steps=5 # limit reasoning time)def __call__(self, question: str) -> str:"""ONE question in → ONE pure-text answer out."""#↓ Replace .run with whatever method actually returns the answer string.result = self.agent.run(question)return result#answer = self.run
BasicAgent.py+5-17