Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,24 @@ 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:
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def DuckDuckSearchTool(query: str, num_results: int = 3) -> str:
|
| 13 |
+
"""A tool that searches the web using DuckDuckGo and returns the top results.
|
| 14 |
+
|
| 15 |
Args:
|
| 16 |
+
query: The search query string.
|
| 17 |
+
num_results: Number of search results to retrieve (default is 3).
|
| 18 |
+
|
| 19 |
+
Returns:
|
| 20 |
+
A formatted string with search results.
|
| 21 |
"""
|
| 22 |
+
search_tool = DuckDuckGoSearchTool()
|
| 23 |
+
results = search_tool(query=query, num_results=num_results)
|
| 24 |
+
|
| 25 |
+
if results:
|
| 26 |
+
return "\n".join([f"{i+1}. {res['title']} - {res['href']}" for i, res in enumerate(results)])
|
| 27 |
+
else:
|
| 28 |
+
return "No results found."
|
| 29 |
+
|
| 30 |
|
| 31 |
@tool
|
| 32 |
def get_current_time_in_timezone(timezone: str) -> str:
|