dmfelder commited on
Commit
94e4a1b
·
verified ·
1 Parent(s): cd2d0ed

Update tools/maths.py

Browse files
Files changed (1) hide show
  1. tools/maths.py +8 -16
tools/maths.py CHANGED
@@ -1,5 +1,4 @@
1
  from typing import List
2
-
3
  from langchain_core.tools import tool
4
  from loguru import logger
5
 
@@ -7,24 +6,17 @@ from loguru import logger
7
  @tool("add_integers_tool", parse_docstring=True)
8
  def add_integers(numbers: List[int]) -> int:
9
  """
10
- Add a list of integers together and return their sum.
11
- This tool takes a list of integers and calculates their sum. It's useful for
12
- performing basic arithmetic operations on multiple numbers at once.
13
  Args:
14
- numbers (List[int]): A list of integers to be summed.
 
15
  Returns:
16
- int: The sum of all integers in the input list.
17
  """
18
- logger.info(f"use add_integers with param: {numbers}")
19
- if not numbers:
20
- raise ValueError("Input list cannot be empty")
21
-
22
- try:
23
- return sum(numbers)
24
- except TypeError as e:
25
- raise TypeError("All elements in the list must be integers") from e
26
 
27
 
28
  if __name__ == "__main__":
29
- result = add_integers.invoke({"numbers": [10577, 10037, 10107, 9888, 10089, 10061, 10089, 9917, 10031]})
30
- print(result)
 
1
  from typing import List
 
2
  from langchain_core.tools import tool
3
  from loguru import logger
4
 
 
6
  @tool("add_integers_tool", parse_docstring=True)
7
  def add_integers(numbers: List[int]) -> int:
8
  """
9
+ Adds a list of integers and returns the sum.
10
+
 
11
  Args:
12
+ numbers (List[int]): A list of integers to add together.
13
+
14
  Returns:
15
+ int: The total sum of all integers in the list.
16
  """
17
+ logger.info(f"add_integers called with: {numbers}")
18
+ return sum(numbers)
 
 
 
 
 
 
19
 
20
 
21
  if __name__ == "__main__":
22
+ print(add_integers.invoke({"numbers": [1, 2, 3]}))