File size: 1,514 Bytes
726d2d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from smolagents import tool
import cmath

@tool
def add(a:int, b:int) -> int:
  """
  This tool returns the sum of two numbers.

  Args:
    a: first number
    b: second number
  """

  return a+b


@tool
def subtract(a:int, b:int) -> int:
  """
  This tool returns the difference between two numbers.

  Args:
    a: first number
    b: second number
  """

  return a-b


@tool
def multiply(a:int, b:int) -> int:
  """
  This tool multiplies two numbers.

  Args:
    a: first number
    b: second number
  """

  return a*b


@tool
def divide(a:int, b:int) -> float:
  """
  This tool divides two numbers.

  Args:
    a: first number
    b: second number
  """

  if b==0: raise ValueError('Cannot divide by zero')
  return a/b


@tool
def modulus(a:int, b:int) -> int:
  """
  This tool returns the modulus of two numbers.

  Args:
    a: first number
    b: second number
  """

  return a%b


@tool
def rounder(a:float, n:int) -> float:
  """
  This tool return a number rounded to a certain number of decimals.

  Args:
    a: number to be rounded
    n: number of decimals to use when rounding the number
  """

  return round(a,n)


@tool
def power(a: float, b: float) -> float:
  """
  Get the power of two numbers.
  Args:
    a: the first number
    b: the second number
  """

  return a**b


@tool
def square_root(a: float) -> float | complex:
  """
  Get the square root of a number.
  Args:
    a: the number to get the square root of
  """

  if a >= 0:
    return a**0.5
  return cmath.sqrt(a)