File size: 2,006 Bytes
c65bd6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from langchain_core.tools import tool


@tool
def add(a: float, b: float) -> float:
    """Adds two numbers and returns the result rounded to 2 decimal places.

    Args:
        a (float): First number to be added
        b (float): Second number to be added

    Returns:
        float: The sum of a and b, rounded to 2 decimal places
    """
    return round((a + b), 2)


@tool
def sub(a: float, b: float) -> float:
    """Subtracts the second number from the first and returns the result rounded to 2 decimal places.

    Args:
        a (float): Number to subtract from
        b (float): Number to subtract

    Returns:
        float: The difference between a and b, rounded to 2 decimal places
    """
    return round((a - b), 2)


@tool
def mult(a: float, b: float) -> float:
    """Multiplies two numbers and returns the result rounded to 2 decimal places.

    Args:
        a (float): First number to multiply
        b (float): Second number to multiply

    Returns:
        float: The product of a and b, rounded to 2 decimal places
    """
    return round((a * b), 2)


@tool
def div(a: float, b: float) -> float:
    """Divides the first number by the second and returns the result rounded to 2 decimal places.

    Args:
        a (float): Number to be divided (dividend)
        b (float): Number to divide by (divisor)

    Raises:
        ValueError: If the divisor (b) is zero

    Returns:
        float: The quotient of a divided by b, rounded to 2 decimal places
    """
    if b == 0:
        raise ValueError("Cannot divide by zero!")

    return round((a / b), 2)


@tool
def mod(a: float, b: float) -> float:
    """Calculates the remainder of dividing the first number by the second and returns the result rounded to 2 decimal places.

    Args:
        a (float): Number to be divided (dividend)
        b (float): Number to divide by (divisor)

    Returns:
        float: The remainder of a divided by b, rounded to 2 decimal places
    """
    return round((a % b), 2)