Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,16 +7,36 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 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 my_custom_tool(
|
| 13 |
-
|
| 14 |
-
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 7 |
|
| 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 my_custom_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
|
| 13 |
+
# # Keep this format for the tool description / args description but feel free to modify the tool
|
| 14 |
+
# """A tool that does nothing yet
|
| 15 |
+
# Args:
|
| 16 |
+
# arg1: the first argument
|
| 17 |
+
# arg2: the second argument
|
| 18 |
+
# """
|
| 19 |
+
# return "What magic will you build ?"
|
| 20 |
+
|
| 21 |
@tool
|
| 22 |
+
def my_custom_tool(query: str, max_results: int = 5) -> str:
|
| 23 |
+
"""
|
| 24 |
+
Function that performs a DuckDuckGo search using the DuckDuckGoSearchTool class.
|
| 25 |
Args:
|
| 26 |
+
query: The search query to perform.
|
| 27 |
+
max_results: Number of results to fetch (default is 5).
|
| 28 |
+
Returns:
|
| 29 |
+
A string containing the search results formatted as Markdown.
|
| 30 |
"""
|
| 31 |
+
# Initialize the DuckDuckGoSearchTool with the desired number of results
|
| 32 |
+
search_tool = DuckDuckGoSearchTool(max_results=max_results)
|
| 33 |
+
|
| 34 |
+
try:
|
| 35 |
+
# Perform the search and return formatted results
|
| 36 |
+
return search_tool.forward(query)
|
| 37 |
+
except Exception as e:
|
| 38 |
+
return f"An error occurred during the search: {e}"
|
| 39 |
+
|
| 40 |
|
| 41 |
@tool
|
| 42 |
def get_current_time_in_timezone(timezone: str) -> str:
|