Pycrolis commited on
Commit
83001c2
·
1 Parent(s): efcf2db

feat(tool): add `sort_words_alphabetically` tool for sorting and joining word lists

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
37
+ *.xlsx filter=lfs diff=lfs merge=lfs -text
ShrewdAgent.py CHANGED
@@ -14,6 +14,7 @@ from loguru import logger
14
  from pydantic import SecretStr
15
 
16
  from tools.produce_classifier import produce_classifier
 
17
  from tools.web_page_information_extractor import web_page_information_extractor
18
  from tools.wikipedia_search import wikipedia_search
19
  from tools.youtube_transcript import youtube_transcript
@@ -44,6 +45,7 @@ class ShrewdAgent:
44
  web_page_information_extractor,
45
  youtube_transcript,
46
  produce_classifier,
 
47
  ]
48
  self.llm = ChatOpenAI(
49
  model="gpt-4o-mini",
 
14
  from pydantic import SecretStr
15
 
16
  from tools.produce_classifier import produce_classifier
17
+ from tools.sort_words_alphabetically import sort_words_alphabetically
18
  from tools.web_page_information_extractor import web_page_information_extractor
19
  from tools.wikipedia_search import wikipedia_search
20
  from tools.youtube_transcript import youtube_transcript
 
45
  web_page_information_extractor,
46
  youtube_transcript,
47
  produce_classifier,
48
+ sort_words_alphabetically
49
  ]
50
  self.llm = ChatOpenAI(
51
  model="gpt-4o-mini",
tools/sort_words_alphabetically.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List
2
+
3
+ from langchain_core.tools import tool
4
+ from loguru import logger
5
+
6
+
7
+ @tool("sort_words_alphabetically_tool", parse_docstring=True)
8
+ def sort_words_alphabetically(words: List[str]) -> str:
9
+ """Sort a list of words alphabetically and join them with commas.
10
+
11
+ Args:
12
+ words (List[str]): List of strings to be sorted
13
+
14
+ Returns:
15
+ str: A string containing all sorted words joined with commas
16
+ """
17
+ logger.info(f"use sort_words_alphabetically with param: {words}")
18
+ sorted_words = sorted(words)
19
+
20
+ result = ", ".join(sorted_words)
21
+
22
+ return result
23
+
24
+
25
+ if __name__ == "__main__":
26
+ print(sort_words_alphabetically.invoke({"words": ["broccoli", "celery", "sweet potatoes", "lettuce"]}))