एजेंट्स के साथ कस्टम टूल्स इंटीग्रेट करना
अब जबकि आपके पास टूल्स तैयार हैं, तो अपना एजेंटिक वर्कफ़्लो सेट अप करने का समय है! आप फिर से एक ReAct एजेंट का उपयोग करेंगे, जो याद रखें, अपने उठाए जाने वाले स्टेप्स पर तर्क करता है और इसी कॉन्टेक्स्ट व टूल डिस्क्रिप्शंस के आधार पर टूल्स चुनता है. आपके लिए पहले से एक llm परिभाषित है जो OpenAI के gpt-4o-mini मॉडल का उपयोग करता है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
LangChain के साथ LLM एप्लिकेशन विकसित करना
अभ्यास निर्देश
llmऔर आपकेretrieve_customer_infoटूल को शामिल करने वाली लिस्ट के साथcreate_react_agent()का उपयोग करके एक ReAct एजेंट बनाएँ.- दिए गए इनपुट पर
agent.invoke()के साथ एजेंट को इनवोक करें. - अंतिम मैसेज से कंटेंट प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
@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()
# Create a ReAct agent
agent = create_react_agent(____, [____])
# Invoke the agent on the input
messages = agent.____({"messages": [("human", "Create a summary of our customer: Peak Performance Co.")]})
print(messages['messages'][-1].____)