Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,45 @@ 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 +94,12 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[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 online_search(arg1:str)-> str:
|
| 23 |
+
|
| 24 |
+
'''A tool that fetchs the top serach result website content
|
| 25 |
+
Args:
|
| 26 |
+
arg1: the thing we want to search on web
|
| 27 |
+
'''
|
| 28 |
+
|
| 29 |
+
search=DuckDuckGoSearchTool()
|
| 30 |
+
result=search(arg1)
|
| 31 |
+
return result
|
| 32 |
+
|
| 33 |
+
@tool
|
| 34 |
+
def math_evaluator(expression : str) -> str:
|
| 35 |
+
|
| 36 |
+
'''Evaluates math expressions
|
| 37 |
+
Args:
|
| 38 |
+
expression: Mathematical expression
|
| 39 |
+
'''
|
| 40 |
+
|
| 41 |
+
try:
|
| 42 |
+
res=str(eval(expression))
|
| 43 |
+
return res
|
| 44 |
+
|
| 45 |
+
except Exception as e:
|
| 46 |
+
return str(e)
|
| 47 |
+
|
| 48 |
+
@tool
|
| 49 |
+
def weather_reporter(city:str) -> str:
|
| 50 |
+
'''fetches weather for a city
|
| 51 |
+
Args:
|
| 52 |
+
city: name of the city
|
| 53 |
+
'''
|
| 54 |
+
|
| 55 |
+
url=f"https://wttr.in/{city}?format=3"
|
| 56 |
+
response=requests.get(url)
|
| 57 |
+
|
| 58 |
+
return response.text
|
| 59 |
+
|
| 60 |
@tool
|
| 61 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 62 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 94 |
|
| 95 |
agent = CodeAgent(
|
| 96 |
model=model,
|
| 97 |
+
tools=[final_answer,
|
| 98 |
+
get_current_time_in_timezone,
|
| 99 |
+
weather_reporter,
|
| 100 |
+
math_evaluator,
|
| 101 |
+
online_search,
|
| 102 |
+
my_custom_tool], ## add your tools here (don't remove final answer)
|
| 103 |
max_steps=6,
|
| 104 |
verbosity_level=1,
|
| 105 |
grammar=None,
|