Spaces:
Runtime error
Runtime error
Add: get_current_timezone and search_for_information tool
Browse files
app.py
CHANGED
|
@@ -10,7 +10,6 @@ from Gradio_UI import GradioUI
|
|
| 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 import to specify the return type
|
| 13 |
-
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
arg1: the first argument
|
|
@@ -18,6 +17,21 @@ 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.
|
|
@@ -55,7 +69,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 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 import to specify the return type
|
|
|
|
| 13 |
"""A tool that does nothing yet
|
| 14 |
Args:
|
| 15 |
arg1: the first argument
|
|
|
|
| 17 |
"""
|
| 18 |
return "What magic will you build ?"
|
| 19 |
|
| 20 |
+
@tool
|
| 21 |
+
def search_for_information(query: str) -> str:
|
| 22 |
+
"""A tool that searches for any given query.
|
| 23 |
+
Args:
|
| 24 |
+
query: A string representing the query (e.g., 'What is the Capital of Nepal?').
|
| 25 |
+
"""
|
| 26 |
+
try:
|
| 27 |
+
engine = DuckDuckGoSearchTool(max_results=15)
|
| 28 |
+
results = engine.forward(query)
|
| 29 |
+
return results
|
| 30 |
+
except Exception as e:
|
| 31 |
+
return f"Error fetching results for query `{query}`: {str(e)}"
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
@tool
|
| 36 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 37 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 69 |
|
| 70 |
agent = CodeAgent(
|
| 71 |
model=model,
|
| 72 |
+
tools=[final_answer, get_current_time_in_timezone, search_for_information], ## add your tools here (don't remove final answer)
|
| 73 |
max_steps=6,
|
| 74 |
verbosity_level=1,
|
| 75 |
grammar=None,
|