Spaces:
Sleeping
Sleeping
Update app.py
Browse filesAdded get_web_search_results function, Added tools [get_web_search_results, get_current_time_in_timezone] to CodeAgent
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.
|
@@ -55,7 +68,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,
|
|
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
20 |
|
21 |
+
@tool
|
22 |
+
def get_web_search_results(query:str)-> str: #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 searchs the web using a query
|
25 |
+
Args:
|
26 |
+
query: A string representing a valid web query (e.g. 'pictures of cats')
|
27 |
+
"""
|
28 |
+
try:
|
29 |
+
results = DuckDuckGoSearchTool.forward(query)
|
30 |
+
return results
|
31 |
+
except Exception as e:
|
32 |
+
return f"{query} is an invalid query"
|
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.
|
|
|
68 |
|
69 |
agent = CodeAgent(
|
70 |
model=model,
|
71 |
+
tools=[final_answer, get_web_search_results, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
72 |
max_steps=6,
|
73 |
verbosity_level=1,
|
74 |
grammar=None,
|