कस्टम टूल बनाना
अब जबकि आपके पास customers DataFrame से कस्टमर डेटा निकालने वाला एक फ़ंक्शन है, इसे LangChain एजेंट्स के साथ कम्पैटिबल टूल में बदलने का समय है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
LangChain के साथ LLM एप्लिकेशन विकसित करना
अभ्यास निर्देश
- फ़ंक्शन डेफ़िनिशन से पहले
@toolडेकोरेटर जोड़ें ताकि इसे LangChain टूल में बदला जा सके. - टूल पर
.argsएट्रिब्यूट (जैसे,tool_name.args) का उपयोग करके टूल के आर्ग्यूमेंट्स प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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.____)