bstraehle commited on
Commit
30d2cfb
·
verified ·
1 Parent(s): 05f7d0b

Update tools/arithmetic_tools.py

Browse files
Files changed (1) hide show
  1. tools/arithmetic_tools.py +66 -1
tools/arithmetic_tools.py CHANGED
@@ -1 +1,66 @@
1
- x
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Automatic function calling
2
+ # https://ai.google.dev/gemini-api/docs/function-calling
3
+
4
+ from crewai.tools import tool
5
+
6
+ class ArithmeticTools():
7
+ @tool("Addition Tool")
8
+ def add(a: float, b: float) -> float:
9
+ """Add two numbers.
10
+
11
+ Args:
12
+ a: First number
13
+ b: Second number
14
+ Returns:
15
+ Result number
16
+ """
17
+ return a + b
18
+
19
+ @tool("Subtraction Tool")
20
+ def subtract(a: float, b: float) -> float:
21
+ """Subtract two numbers.
22
+
23
+ Args:
24
+ a: First number
25
+ b: Second number
26
+ Returns:
27
+ Result number
28
+ """
29
+ return a - b
30
+
31
+ @tool("Multiplication Tool")
32
+ def multiply(a: float, b: float) -> float:
33
+ """Multiply two numbers.
34
+ Args:
35
+ a: First number
36
+ b: Second number
37
+ Returns:
38
+ Result number
39
+ """
40
+ return a * b
41
+
42
+ @tool("Division Tool")
43
+ def divide(a: float, b: float) -> float:
44
+ """Divide two numbers.
45
+
46
+ Args:
47
+ a: First number
48
+ b: Second number
49
+ Returns:
50
+ Result number
51
+ """
52
+ if b == 0:
53
+ raise ValueError("Cannot divide by zero.")
54
+ return a / b
55
+
56
+ @tool("Modulus Tool")
57
+ def modulus(a: float, b: float) -> float:
58
+ """Get the modulus of two numbers.
59
+
60
+ Args:
61
+ a: First number
62
+ b: Second number
63
+ Returns:
64
+ Result number
65
+ """
66
+ return a % b