Spaces:
No application file
No application file
Create agent001
Browse files
agent001
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
| 2 |
+
import os #
|
| 3 |
+
# ============================================
|
| 4 |
+
# GET TOKEN FROM SECRET
|
| 5 |
+
# ============================================
|
| 6 |
+
MY_TOKEN = os.getenv("HF_TOKEN") # ← Changed!
|
| 7 |
+
# ============================================
|
| 8 |
+
# CREATE MODEL
|
| 9 |
+
# ============================================
|
| 10 |
+
model = HfApiModel(
|
| 11 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 12 |
+
token=MY_TOKEN
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
# ============================================
|
| 16 |
+
# CREATE AGENT
|
| 17 |
+
# ============================================
|
| 18 |
+
agent = CodeAgent(
|
| 19 |
+
tools=[DuckDuckGoSearchTool()],
|
| 20 |
+
model=model,
|
| 21 |
+
additional_authorized_imports=["math", "requests"]
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# ============================================
|
| 25 |
+
# RUN THE AGENT
|
| 26 |
+
# ============================================
|
| 27 |
+
print("Running agent...")
|
| 28 |
+
result = agent.run("What is the current temperature in Lyon, France?")
|
| 29 |
+
|
| 30 |
+
print("\n" + "="*60)
|
| 31 |
+
print("RESULT:")
|
| 32 |
+
print("="*60)
|
| 33 |
+
print(result)
|