Update app.py
Browse files
app.py
CHANGED
|
@@ -11,24 +11,25 @@ from Gradio_UI import GradioUI
|
|
| 11 |
|
| 12 |
@tool
|
| 13 |
def calculator(number1: float, number2: float, operation: str)-> float:
|
| 14 |
-
"""A tool that does three kinds of maths operations
|
| 15 |
Args:
|
| 16 |
number1: The first float number, it can be int
|
| 17 |
number2: the second float number, it can be int
|
| 18 |
-
operation: the type of math operation to carry out.
|
| 19 |
"""
|
| 20 |
try:
|
| 21 |
if type(number1)== int:
|
| 22 |
number1= float(number1)
|
| 23 |
if type(number2)== int:
|
| 24 |
number2= float(number2)
|
|
|
|
| 25 |
if operation == "sum":
|
| 26 |
result= number1 + number2
|
| 27 |
-
elif operation == "
|
| 28 |
result= number1 - number2
|
| 29 |
-
elif operation == "
|
| 30 |
result= number1 /number2
|
| 31 |
-
elif operation == "
|
| 32 |
result= number1 * number2
|
| 33 |
|
| 34 |
return result
|
|
|
|
| 11 |
|
| 12 |
@tool
|
| 13 |
def calculator(number1: float, number2: float, operation: str)-> float:
|
| 14 |
+
"""A tool that does three kinds of maths operations: sum, subtract, divide, or multiply.
|
| 15 |
Args:
|
| 16 |
number1: The first float number, it can be int
|
| 17 |
number2: the second float number, it can be int
|
| 18 |
+
operation: the type of math operation to carry out, it can be sum, subtraction (subtract), division(divide), or multiplication (multiply).
|
| 19 |
"""
|
| 20 |
try:
|
| 21 |
if type(number1)== int:
|
| 22 |
number1= float(number1)
|
| 23 |
if type(number2)== int:
|
| 24 |
number2= float(number2)
|
| 25 |
+
|
| 26 |
if operation == "sum":
|
| 27 |
result= number1 + number2
|
| 28 |
+
elif operation == "subtract":
|
| 29 |
result= number1 - number2
|
| 30 |
+
elif operation == "divide":
|
| 31 |
result= number1 /number2
|
| 32 |
+
elif operation == "multiply":
|
| 33 |
result= number1 * number2
|
| 34 |
|
| 35 |
return result
|