Spaces:
Sleeping
Sleeping
Pycrolis
feat(tool): add `sort_words_alphabetically` tool for sorting and joining word lists
83001c2
from typing import List | |
from langchain_core.tools import tool | |
from loguru import logger | |
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"]})) | |