Spaces:
Sleeping
Sleeping
Add calculus tools
Browse files- calculus_tools.py +60 -0
calculus_tools.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_core.tools import tool
|
| 2 |
+
|
| 3 |
+
@tool
|
| 4 |
+
def add(a: float, b: float) -> float:
|
| 5 |
+
"""
|
| 6 |
+
Add two float numbers.
|
| 7 |
+
|
| 8 |
+
Args:
|
| 9 |
+
a: float
|
| 10 |
+
b float
|
| 11 |
+
|
| 12 |
+
Returns:
|
| 13 |
+
a + b
|
| 14 |
+
"""
|
| 15 |
+
return a + b
|
| 16 |
+
|
| 17 |
+
@tool
|
| 18 |
+
def substract(a: float, b: float) -> float:
|
| 19 |
+
"""
|
| 20 |
+
Substract two float numbers.
|
| 21 |
+
|
| 22 |
+
Args:
|
| 23 |
+
a: float
|
| 24 |
+
b float
|
| 25 |
+
|
| 26 |
+
Returns:
|
| 27 |
+
a - b
|
| 28 |
+
"""
|
| 29 |
+
return a - b
|
| 30 |
+
|
| 31 |
+
@tool
|
| 32 |
+
def multiple(a: float, b: float) -> float:
|
| 33 |
+
"""
|
| 34 |
+
Multiple two float numbers.
|
| 35 |
+
|
| 36 |
+
Args:
|
| 37 |
+
a: float
|
| 38 |
+
b float
|
| 39 |
+
|
| 40 |
+
Returns:
|
| 41 |
+
a * b
|
| 42 |
+
"""
|
| 43 |
+
return a * b
|
| 44 |
+
|
| 45 |
+
@tool
|
| 46 |
+
def divide(a: float, b: float) -> float:
|
| 47 |
+
"""
|
| 48 |
+
Divide two float numbers.
|
| 49 |
+
|
| 50 |
+
Args:
|
| 51 |
+
a: float
|
| 52 |
+
b float
|
| 53 |
+
|
| 54 |
+
Returns:
|
| 55 |
+
a / b
|
| 56 |
+
"""
|
| 57 |
+
if b is not 0:
|
| 58 |
+
return a / b
|
| 59 |
+
else:
|
| 60 |
+
raise "Illegal operation. Unable to divide by zero."
|