Spaces:
Build error
Build error
| """This module contains tools for performing mathematical operations.""" | |
| from langchain_core.tools import tool | |
| def add(x: float, y: float) -> float: | |
| """ | |
| Adds two numbers. | |
| Args: | |
| x (float): the first number | |
| y (float): the second number | |
| """ | |
| return x + y | |
| def subtract(x: float, y: float) -> float: | |
| """ | |
| Subtracts two numbers. | |
| Args: | |
| x (float): the first number | |
| y (float): the second number | |
| """ | |
| return x - y | |
| def multiply(x: float, y: float) -> float: | |
| """ | |
| Multiplies two numbers. | |
| Args: | |
| x (float): the first number | |
| y (float): the second number | |
| """ | |
| return x * y | |
| def divide(x: float, y: float) -> float: | |
| """ | |
| Divides two numbers. | |
| Args: | |
| x (float): the first number | |
| y (float): the second number to divide by | |
| """ | |
| if y == 0: | |
| raise ValueError("Cannot divide by zero") | |
| return x / y | |
| def modulus(x: float, y: float) -> float: | |
| """ | |
| Returns the remainder when x is divided by y. | |
| Args: | |
| x (float): the dividend | |
| y (float): the divisor | |
| """ | |
| if y == 0: | |
| raise ValueError("Cannot compute modulus with zero divisor") | |
| return x % y | |
| def power(x: float, y: float) -> float: | |
| """ | |
| Raises x to the power of y. | |
| Args: | |
| x (float): the base number | |
| y (float): the exponent | |
| """ | |
| return x ** y | |
| def sqrt(x: float) -> float: | |
| """ | |
| Returns the square root of x. | |
| Args: | |
| x (float): the number to find the square root of | |
| """ | |
| if x < 0: | |
| raise ValueError("Cannot compute square root of negative number") | |
| return x ** 0.5 | |