Update app.py
#69
by
ace3848w34u32y
- opened
app.py
CHANGED
|
@@ -18,6 +18,35 @@ 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 +84,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 basic_calculator(num1:float,num2:float,operation:str)->float:
|
| 23 |
+
|
| 24 |
+
operation=operation.lower()
|
| 25 |
+
|
| 26 |
+
if operation=="add":
|
| 27 |
+
return num1+num2
|
| 28 |
+
|
| 29 |
+
elif operation=="subtract":
|
| 30 |
+
return num1-num2
|
| 31 |
+
|
| 32 |
+
elif operation=="multiply":
|
| 33 |
+
return num1*num2
|
| 34 |
+
|
| 35 |
+
elif operation=="division":
|
| 36 |
+
if num2==0:
|
| 37 |
+
return"Divison by Zero not Possible!"
|
| 38 |
+
break
|
| 39 |
+
num1/num2
|
| 40 |
+
|
| 41 |
+
elif operation=="modulo":
|
| 42 |
+
return num1%num2
|
| 43 |
+
|
| 44 |
+
else:
|
| 45 |
+
return "Invalid Opeartion! Please Use add,subtract,division,modulo operations"
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
@tool
|
| 51 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 52 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 84 |
|
| 85 |
agent = CodeAgent(
|
| 86 |
model=model,
|
| 87 |
+
tools=[basic_calculator,image_generation_tool,get_current_time_in_timezone,final_answer], ## add your tools here (don't remove final answer)
|
| 88 |
max_steps=6,
|
| 89 |
verbosity_level=1,
|
| 90 |
grammar=None,
|