Spaces:
Runtime error
Runtime error
Create websearch tool
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -18,6 +18,17 @@ 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.
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
+
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 22 |
+
@tool
|
| 23 |
+
def web_search(search_query:str, max_results:int)-> str:
|
| 24 |
+
"""A tool that does web search using a query and max number number of results
|
| 25 |
+
Args:
|
| 26 |
+
search_query: a string for a search query
|
| 27 |
+
max_results: the maximum number of results to gather for the prompt
|
| 28 |
+
"""
|
| 29 |
+
search_tool = DuckDuckGoSearchTool()
|
| 30 |
+
return search_tool(search_query, max_results=max_results)
|
| 31 |
+
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 34 |
"""A tool that fetches the current local time in a specified timezone.
|