Spaces:
Sleeping
Sleeping
Update app.py
Browse filesadded duckduckgo search tool
app.py
CHANGED
|
@@ -18,6 +18,28 @@ 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 SearchWebTool(query:str)-> list: #it's import to specify the return type
|
| 23 |
+
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 24 |
+
"""A tool that searches the web for top 5 results with the titles
|
| 25 |
+
Args:
|
| 26 |
+
query: A string representing the search topic (e.g., Where is San Fransisco?)
|
| 27 |
+
|
| 28 |
+
Returns:
|
| 29 |
+
list: A list of dictionaries with 'title', 'url', and 'snippet' keys.
|
| 30 |
+
"""
|
| 31 |
+
results = DuckDuckGoSearchTool.run(query)
|
| 32 |
+
|
| 33 |
+
#ensure consistent output format
|
| 34 |
+
formatted_results = []
|
| 35 |
+
for r in results:
|
| 36 |
+
formatted_Results.append){
|
| 37 |
+
"title": r.get("title", ""),
|
| 38 |
+
"url": r.get("link, ""),
|
| 39 |
+
"snippet":r.get("snippet", "")
|
| 40 |
+
})
|
| 41 |
+
return formatted_results
|
| 42 |
+
|
| 43 |
@tool
|
| 44 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 45 |
"""A tool that fetches the current local time in a specified timezone.
|