#import smolagentsfrom smolagents import CodeAgent, HfApiModel, InferenceClientModel, WebSearchTool import numpy, math, xlrd, os #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, WebSearchTool class BasicAgent: """Adapts smolagents.CodeAgent to the HF course template API.""" def __init__(self): model_id = "meta-llama/Meta-Llama-3-70B-Instruct" # correct repo name hf_token = os.getenv("HUGGINGFACEHUB_API_TOKEN") # read real secret if not hf_token: raise 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) def __call__(self, question: str) -> str: """ONE question in → ONE pure-text answer out.""" # ↓ Replace .run with whatever method actually returns the answer string. return self.agent.run(question) #agent.run( # "At what temperature and for how long should I bake French baguettes made with type 65 flour?", #)