Vytváření vlastních nástrojů
Teď, když máš funkci pro extrakci zákaznických dat z DataFrame customers, je čas převést ji na nástroj kompatibilní s agenty LangChain.
Toto cvičení je součástí kurzu
Vývoj LLM aplikací s LangChain
Pokyny k cvičení
- Přidej dekorátor
@toolpřed definici funkce, aby se z ní stal nástroj LangChain. - Vypiš argumenty nástroje pomocí atributu
.argsna daném nástroji (např.tool_name.args).
Interaktivní cvičení na vyzkoušení si v praxi
Vyzkoušejte si toto cvičení dokončením tohoto ukázkového kódu.
# Convert the retrieve_customer_info function into a tool
____
def retrieve_customer_info(name: str) -> str:
"""Retrieve customer information based on their name."""
customer_info = customers[customers['name'] == name]
return customer_info.to_string()
# Print the tool's arguments
print(retrieve_customer_info.____)