Spaces:
Sleeping
Sleeping
chatgpt...
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -19,24 +21,34 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
|
|
|
|
| 22 |
@tool
|
| 23 |
-
def calculus(arg1:
|
| 24 |
-
"""
|
|
|
|
|
|
|
|
|
|
| 25 |
Args:
|
| 26 |
-
arg1:
|
| 27 |
-
arg2:
|
| 28 |
-
arg3:
|
|
|
|
|
|
|
|
|
|
| 29 |
"""
|
| 30 |
-
if arg1=='+':
|
| 31 |
-
return arg2+arg3
|
| 32 |
-
elif arg1=='-':
|
| 33 |
-
return arg2-arg3
|
| 34 |
-
elif arg1=='*':
|
| 35 |
-
return arg2*arg3
|
| 36 |
-
elif arg1=='/':
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
@tool
|
| 42 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from typing import Union
|
| 8 |
+
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
|
|
|
| 21 |
return "What magic will you build ?"
|
| 22 |
|
| 23 |
|
| 24 |
+
|
| 25 |
@tool
|
| 26 |
+
def calculus(arg1: str, arg2: float, arg3: float) -> Union[float, str]:
|
| 27 |
+
"""
|
| 28 |
+
A tool that does basic math operations: addition, subtraction,
|
| 29 |
+
multiplication, and division between two real numbers.
|
| 30 |
+
|
| 31 |
Args:
|
| 32 |
+
arg1: The operator (should be one of the following: '+', '-', '*', '/')
|
| 33 |
+
arg2: The first number
|
| 34 |
+
arg3: The second number
|
| 35 |
+
|
| 36 |
+
Returns:
|
| 37 |
+
The result of the math operation, or an error message if invalid input.
|
| 38 |
"""
|
| 39 |
+
if arg1 == '+':
|
| 40 |
+
return arg2 + arg3
|
| 41 |
+
elif arg1 == '-':
|
| 42 |
+
return arg2 - arg3
|
| 43 |
+
elif arg1 == '*':
|
| 44 |
+
return arg2 * arg3
|
| 45 |
+
elif arg1 == '/':
|
| 46 |
+
if arg3 == 0:
|
| 47 |
+
return "Error: Division by zero!"
|
| 48 |
+
return arg2 / arg3
|
| 49 |
+
|
| 50 |
+
return "Error: Invalid operator. Use one of '+', '-', '*', '/'"
|
| 51 |
+
|
| 52 |
|
| 53 |
@tool
|
| 54 |
def get_current_time_in_timezone(timezone: str) -> str:
|