Spaces:
Sleeping
Sleeping
added a calculus function
Browse files
app.py
CHANGED
|
@@ -18,6 +18,26 @@ 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.
|
|
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
+
|
| 22 |
+
@tool
|
| 23 |
+
def calculus(arg1:char, arg2:double, arg3: double)-> double:
|
| 24 |
+
"""A tool that does basic math operations, like adition, substraction, multimplication and division between two real numbers.
|
| 25 |
+
Args:
|
| 26 |
+
arg1: the operator (should be one of the following: '+','-','*','/')
|
| 27 |
+
arg2: the first number
|
| 28 |
+
arg3: the second number
|
| 29 |
+
"""
|
| 30 |
+
if char=='+'
|
| 31 |
+
return arg2+arg3
|
| 32 |
+
else if char=='-'
|
| 33 |
+
return arg2-arg3
|
| 34 |
+
else if char=='*'
|
| 35 |
+
return arg2*arg3
|
| 36 |
+
else if char=='/'
|
| 37 |
+
return arg2/arg3
|
| 38 |
+
|
| 39 |
+
return "The character in arg1 wasn't a valid mathematical operation!"
|
| 40 |
+
|
| 41 |
@tool
|
| 42 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 43 |
"""A tool that fetches the current local time in a specified timezone.
|