Spaces:
No application file
No application file
File size: 960 Bytes
12a2d68 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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) |