Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -3,6 +3,7 @@ import hashlib
|
|
| 3 |
import json
|
| 4 |
import logging
|
| 5 |
import requests
|
|
|
|
| 6 |
from smolagents import CodeAgent, tool
|
| 7 |
from smolagents.models import Model
|
| 8 |
import openai
|
|
@@ -31,7 +32,7 @@ def save_cache():
|
|
| 31 |
with open(CACHE_FILE, "w") as f:
|
| 32 |
json.dump(answer_cache, f)
|
| 33 |
|
| 34 |
-
# ---------- Tools (all with proper docstrings) ----------
|
| 35 |
@tool
|
| 36 |
def calculator(expression: str) -> str:
|
| 37 |
"""
|
|
@@ -130,7 +131,7 @@ def wikipedia_search(query: str) -> str:
|
|
| 130 |
return f"Wikipedia error: {e}"
|
| 131 |
|
| 132 |
@tool
|
| 133 |
-
def final_answer(answer) -> str:
|
| 134 |
"""
|
| 135 |
Output the final answer. Use this tool when you have determined the answer.
|
| 136 |
The answer can be any type; it will be converted to a string.
|
|
|
|
| 3 |
import json
|
| 4 |
import logging
|
| 5 |
import requests
|
| 6 |
+
from typing import Any
|
| 7 |
from smolagents import CodeAgent, tool
|
| 8 |
from smolagents.models import Model
|
| 9 |
import openai
|
|
|
|
| 32 |
with open(CACHE_FILE, "w") as f:
|
| 33 |
json.dump(answer_cache, f)
|
| 34 |
|
| 35 |
+
# ---------- Tools (all with proper docstrings and type hints) ----------
|
| 36 |
@tool
|
| 37 |
def calculator(expression: str) -> str:
|
| 38 |
"""
|
|
|
|
| 131 |
return f"Wikipedia error: {e}"
|
| 132 |
|
| 133 |
@tool
|
| 134 |
+
def final_answer(answer: Any) -> str:
|
| 135 |
"""
|
| 136 |
Output the final answer. Use this tool when you have determined the answer.
|
| 137 |
The answer can be any type; it will be converted to a string.
|