Spaces:
No application file
No application file
| from langchain_core.tools import tool | |
| import operator | |
| def add(a: float, b: float) -> float: | |
| """Adds two numbers. | |
| Args: | |
| a (float): The first number. | |
| b (float): The second number. | |
| Returns: | |
| float: The sum of a and b. | |
| """ | |
| return operator.add(a, b) | |
| def subtract(a: float, b: float) -> float: | |
| """Subtracts the second number from the first. | |
| Args: | |
| a (float): The first number (minuend). | |
| b (float): The second number (subtrahend). | |
| Returns: | |
| float: The result of subtracting b from a. | |
| """ | |
| return operator.sub(a, b) | |
| def multiply(a: float, b: float) -> float: | |
| """Multiplies two numbers. | |
| Args: | |
| a (float): The first number. | |
| b (float): The second number. | |
| Returns: | |
| float: The product of a and b. | |
| """ | |
| return operator.mul(a, b) | |
| def divide(a: float, b: float) -> float: | |
| """Divides the first number by the second. | |
| Args: | |
| a (float): The numerator. | |
| b (float): The denominator. | |
| Returns: | |
| float: The result of dividing a by b. | |
| Returns an error message string if division by zero occurs. | |
| """ | |
| if b == 0: | |
| return "Error: Cannot divide by zero." | |
| return operator.truediv(a, b) |