Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,10 @@
|
|
| 1 |
-
from smolagents import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import datetime
|
| 3 |
import pytz
|
| 4 |
import yaml
|
|
@@ -50,15 +56,15 @@ model = HfApiModel(
|
|
| 50 |
)
|
| 51 |
|
| 52 |
# —————————————————————————————————————————————
|
| 53 |
-
# 4) Load
|
|
|
|
| 54 |
# —————————————————————————————————————————————
|
| 55 |
|
| 56 |
-
# DuckDuckGo search must be instantiated, not passed as a class
|
| 57 |
duck_search = DuckDuckGoSearchTool()
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
|
| 63 |
# —————————————————————————————————————————————
|
| 64 |
# 5) Load your custom prompt templates
|
|
@@ -74,11 +80,11 @@ with open("prompts.yaml", "r") as stream:
|
|
| 74 |
agent = CodeAgent(
|
| 75 |
model=model,
|
| 76 |
tools=[
|
| 77 |
-
final_answer,
|
| 78 |
-
my_custom_tool,
|
| 79 |
-
get_current_time_in_timezone,
|
| 80 |
-
duck_search,
|
| 81 |
-
image_generation_tool,
|
| 82 |
],
|
| 83 |
max_steps=6,
|
| 84 |
verbosity_level=1,
|
|
|
|
| 1 |
+
from smolagents import (
|
| 2 |
+
CodeAgent,
|
| 3 |
+
DuckDuckGoSearchTool,
|
| 4 |
+
HfApiModel,
|
| 5 |
+
load_tool,
|
| 6 |
+
tool
|
| 7 |
+
)
|
| 8 |
import datetime
|
| 9 |
import pytz
|
| 10 |
import yaml
|
|
|
|
| 56 |
)
|
| 57 |
|
| 58 |
# —————————————————————————————————————————————
|
| 59 |
+
# 4) Load external tools
|
| 60 |
+
# * **Do not** call the returned object!
|
| 61 |
# —————————————————————————————————————————————
|
| 62 |
|
|
|
|
| 63 |
duck_search = DuckDuckGoSearchTool()
|
| 64 |
+
image_generation_tool = load_tool(
|
| 65 |
+
"agents-course/text-to-image",
|
| 66 |
+
trust_remote_code=True
|
| 67 |
+
)
|
| 68 |
|
| 69 |
# —————————————————————————————————————————————
|
| 70 |
# 5) Load your custom prompt templates
|
|
|
|
| 80 |
agent = CodeAgent(
|
| 81 |
model=model,
|
| 82 |
tools=[
|
| 83 |
+
final_answer, # instance of FinalAnswerTool
|
| 84 |
+
my_custom_tool, # your @tool
|
| 85 |
+
get_current_time_in_timezone, # your @tool
|
| 86 |
+
duck_search, # instance of DuckDuckGoSearchTool
|
| 87 |
+
image_generation_tool, # the load_tool() instance
|
| 88 |
],
|
| 89 |
max_steps=6,
|
| 90 |
verbosity_level=1,
|