alisamak commited on
Commit
3620c8f
·
verified ·
1 Parent(s): 20e486a

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +17 -0
tools.py CHANGED
@@ -38,6 +38,23 @@ WIKIPEDIA_PAGES = {
38
 
39
  @tool
40
  def extract_number_from_snippets(snippets: list[str]) -> Optional[int]:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  for s in snippets:
42
  match = re.search(r"\b\d{1,4}\b", s)
43
  if match:
 
38
 
39
  @tool
40
  def extract_number_from_snippets(snippets: list[str]) -> Optional[int]:
41
+ """
42
+ Extracts the first integer number found in a list of text snippets.
43
+
44
+ This function scans each snippet in order and looks for the first standalone
45
+ integer (1 to 4 digits). It returns the first match as an integer. If no
46
+ match is found across all snippets, the function returns None.
47
+
48
+ Args:
49
+ snippets (list[str]): A list of strings, typically search result snippets.
50
+
51
+ Returns:
52
+ Optional[int]: The first integer found in the snippets, or None if none found.
53
+
54
+ Example:
55
+ >>> extract_number_from_snippets(["The Eiffel Tower was built in 1889.", "Height is 324m"])
56
+ 1889
57
+ """
58
  for s in snippets:
59
  match = re.search(r"\b\d{1,4}\b", s)
60
  if match: