Spaces:
Sleeping
Sleeping
Add DuckDuckGo web search
Browse files
app.py
CHANGED
|
@@ -18,6 +18,19 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 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.
|
|
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
+
@tool
|
| 22 |
+
def web_search_tool(search:str) -> str:
|
| 23 |
+
"""A tool that searches the web
|
| 24 |
+
Args:
|
| 25 |
+
search: A string representing the query to be searched on the web (e.g., 'What are the news for New York today?')
|
| 26 |
+
"""
|
| 27 |
+
try:
|
| 28 |
+
# Get results from DuckDuckgo
|
| 29 |
+
search_tool = DuckDuckGoSearchTool()
|
| 30 |
+
return search_tool(search)
|
| 31 |
+
except Exception as e:
|
| 32 |
+
return f"Error getting results from DuckDuckGo"
|
| 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.
|