Spaces:
Sleeping
Sleeping
File size: 734 Bytes
83001c2 |
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 |
from typing import List
from langchain_core.tools import tool
from loguru import logger
@tool("sort_words_alphabetically_tool", parse_docstring=True)
def sort_words_alphabetically(words: List[str]) -> str:
"""Sort a list of words alphabetically and join them with commas.
Args:
words (List[str]): List of strings to be sorted
Returns:
str: A string containing all sorted words joined with commas
"""
logger.info(f"use sort_words_alphabetically with param: {words}")
sorted_words = sorted(words)
result = ", ".join(sorted_words)
return result
if __name__ == "__main__":
print(sort_words_alphabetically.invoke({"words": ["broccoli", "celery", "sweet potatoes", "lettuce"]}))
|