Spaces:
Sleeping
Sleeping
Add web_search and image_generation_tool to tools list.
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import requests
|
|
4 |
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
@@ -17,7 +18,19 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
17 |
arg2: the second argument
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
23 |
"""A tool that fetches the current local time in a specified timezone.
|
@@ -55,7 +68,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
4 |
import pytz
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
+
from tools.search_web import DuckDuckGoSearchTool
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
|
|
18 |
arg2: the second argument
|
19 |
"""
|
20 |
return "What magic will you build ?"
|
21 |
+
|
22 |
+
@tool
|
23 |
+
def search_web(query:str)-> str:
|
24 |
+
"""Performs a duckduckgo web search based on your query (think a Google search) then returns the top search results.
|
25 |
+
Args:
|
26 |
+
query: The search query to perform
|
27 |
+
"""
|
28 |
+
try:
|
29 |
+
search_results = DuckDuckGoSearchTool(query)
|
30 |
+
return search_results
|
31 |
+
except Exception as e:
|
32 |
+
return f"Error fetching search results for the query: '{query}'"
|
33 |
+
|
34 |
@tool
|
35 |
def get_current_time_in_timezone(timezone: str) -> str:
|
36 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
68 |
|
69 |
agent = CodeAgent(
|
70 |
model=model,
|
71 |
+
tools=[image_generation_tool, search_web, final_answer], ## add your tools here (don't remove final answer)
|
72 |
max_steps=6,
|
73 |
verbosity_level=1,
|
74 |
grammar=None,
|