Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,15 +8,29 @@ from tools.final_answer import FinalAnswerTool
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
|
|
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +69,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,
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
+
# Edit: now updated to conduct a web search
|
| 12 |
+
|
| 13 |
@tool
|
| 14 |
+
def web_search(query: str) -> str:
|
| 15 |
+
"""A tool that conducts a web search using DuckDuckGo
|
| 16 |
+
|
| 17 |
Args:
|
| 18 |
+
query: A string representing a valid query for a web search.
|
| 19 |
+
Returns:
|
| 20 |
+
A string containing the search results or an error message.
|
| 21 |
"""
|
| 22 |
+
try:
|
| 23 |
+
# Initialize the DuckDuckGo search tool
|
| 24 |
+
search_tool = DuckDuckGoSearchTool()
|
| 25 |
+
|
| 26 |
+
# Perform the search using the forward method
|
| 27 |
+
results = search_tool.forward(query)
|
| 28 |
+
|
| 29 |
+
# Return the formatted results
|
| 30 |
+
return f"results"
|
| 31 |
+
|
| 32 |
+
except Exception as e:
|
| 33 |
+
return f"Error performing web search: {str(e)}"
|
| 34 |
|
| 35 |
@tool
|
| 36 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 69 |
|
| 70 |
agent = CodeAgent(
|
| 71 |
model=model,
|
| 72 |
+
tools=[final_answer, web_search, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 73 |
max_steps=6,
|
| 74 |
verbosity_level=1,
|
| 75 |
grammar=None,
|