Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,12 @@
|
|
1 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
2 |
import datetime
|
3 |
-
import requests
|
4 |
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
from Gradio_UI import GradioUI
|
8 |
|
9 |
-
#
|
10 |
-
|
11 |
-
"""A tool that does nothing yet.
|
12 |
-
Args:
|
13 |
-
arg1: The first argument.
|
14 |
-
arg2: The second argument.
|
15 |
-
"""
|
16 |
-
return "What magic will you build?"
|
17 |
-
|
18 |
-
# Tool to get current time in a specified timezone
|
19 |
def get_current_time_in_timezone(timezone: str) -> str:
|
20 |
"""Fetches the current local time in a specified timezone.
|
21 |
Args:
|
@@ -46,7 +37,7 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
|
|
46 |
with open("prompts.yaml", 'r') as stream:
|
47 |
prompt_templates = yaml.safe_load(stream)
|
48 |
|
49 |
-
# Create the Agent with
|
50 |
agent = CodeAgent(
|
51 |
model=model,
|
52 |
tools=[final_answer, DuckDuckGoSearchTool(), get_current_time_in_timezone, image_generation_tool],
|
@@ -61,3 +52,4 @@ agent = CodeAgent(
|
|
61 |
|
62 |
# Launch UI
|
63 |
GradioUI(agent).launch()
|
|
|
|
1 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
2 |
import datetime
|
|
|
3 |
import pytz
|
4 |
import yaml
|
5 |
from tools.final_answer import FinalAnswerTool
|
6 |
from Gradio_UI import GradioUI
|
7 |
|
8 |
+
# Define the tool correctly using @tool decorator
|
9 |
+
@tool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def get_current_time_in_timezone(timezone: str) -> str:
|
11 |
"""Fetches the current local time in a specified timezone.
|
12 |
Args:
|
|
|
37 |
with open("prompts.yaml", 'r') as stream:
|
38 |
prompt_templates = yaml.safe_load(stream)
|
39 |
|
40 |
+
# Create the Agent with properly defined tools
|
41 |
agent = CodeAgent(
|
42 |
model=model,
|
43 |
tools=[final_answer, DuckDuckGoSearchTool(), get_current_time_in_timezone, image_generation_tool],
|
|
|
52 |
|
53 |
# Launch UI
|
54 |
GradioUI(agent).launch()
|
55 |
+
|