Spaces:
Build error
Build error
Download BasicAgent.py from optionEdge/testAgent: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/optionEdge/testAgent/resolve/6c17cbc275de46bbfebcf3a2e8a8d100dc2f815c/BasicAgent.py
- Command line
-
hf download hf://spaces/optionEdge/testAgent@6c17cbc275de46bbfebcf3a2e8a8d100dc2f815c/BasicAgent.py
-
curl -L -o BasicAgent.py https://huggingface.co/spaces/optionEdge/testAgent/resolve/6c17cbc275de46bbfebcf3a2e8a8d100dc2f815c/BasicAgent.py
1.4 kB
| #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 newAgent: | |
| """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?", | |
| #) |