Spaces:
No application file
No application file
| from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel | |
| import os # | |
| # ============================================ | |
| # GET TOKEN FROM SECRET | |
| # ============================================ | |
| MY_TOKEN = os.getenv("HF_TOKEN") # ← Changed! | |
| # ============================================ | |
| # CREATE MODEL | |
| # ============================================ | |
| model = HfApiModel( | |
| model_id="Qwen/Qwen2.5-Coder-32B-Instruct", | |
| token=MY_TOKEN | |
| ) | |
| # ============================================ | |
| # CREATE AGENT | |
| # ============================================ | |
| agent = CodeAgent( | |
| tools=[DuckDuckGoSearchTool()], | |
| model=model, | |
| additional_authorized_imports=["math", "requests"] | |
| ) | |
| # ============================================ | |
| # RUN THE AGENT | |
| # ============================================ | |
| print("Running agent...") | |
| result = agent.run("What is the current temperature in Lyon, France?") | |
| print("\n" + "="*60) | |
| print("RESULT:") | |
| print("="*60) | |
| print(result) |