एक से अधिक टूल परिभाषित करना

LangChain के साथ Agentic Systems डिज़ाइन करना

Dilini K. Sumanapala, PhD

Founder & AI Engineer, Genverv, Ltd.

कई टूल इंटीग्रेट करना

कई टूल वाला बॉट

   

  • कई कस्टम टूल जोड़ें

  • हर क्वेरी के लिए टूल चयन ऑटोमेट करें

LangChain के साथ Agentic Systems डिज़ाइन करना

एजुकेशन चैटबॉट को बेहतर बनाना

लोग बड़ी किताबों पर बैठे पढ़ रहे हैं.

 

  • ऐतिहासिक घटनाएँ खोजें

  • पैलिंड्रोम जाँचें:

     
    • level = level

    • top spot = tops pot

LangChain के साथ Agentic Systems डिज़ाइन करना

टूल बनाने के कई तरीके

 

  • LLM इनवोक करें

    नेचुरल लैंग्वेज इनपुट से तारीखें खोजें, जैसे "5th of November"
      Agent: The 5th of November is famous for the Gunpowder treason and 
      plot...
    
  • Python कोड

    स्ट्रिंग्स की सीधी तुलना से पैलिंड्रोम ढूँढें, जैसे string == string[::-1]
      Agent: Yes, "madam" is a palindrome...
    
LangChain के साथ Agentic Systems डिज़ाइन करना

ऐतिहासिक घटनाएँ टूल

# Use a decorator to label the tool and set the input format to string
@tool

def date_checker(date: str) -> str:
"""Provide a list of important historical events for a given date in any format."""
try: # Invoke the LLM to interpret the date and generate historical events answer = llm.invoke(f"List important historical events that occurred on {date}.")
# Return the response return answer.content
# Set an exception block for errors in retrieval except Exception as e: return f"Error retrieving events: {str(e)}"
LangChain के साथ Agentic Systems डिज़ाइन करना

पैलिंड्रोम टूल

@tool

# Set input format to string def check_palindrome(text: str):
"""Check if a word or phrase is a palindrome."""
# Remove non-alphanumeric characters and convert to lowercase cleaned = ''.join(char.lower() for char in text if char.isalnum())
# Check if the reversed text is the same as original text if cleaned == cleaned[::-1]: return f"The phrase or word '{text}' is a palindrome." else: return f"The phrase or word '{text}' is not a palindrome."
LangChain के साथ Agentic Systems डिज़ाइन करना

कई टूल बाइंड करना

# Import modules required for defining tool nodes
from langgraph.prebuilt import ToolNode


# List of tools tools = [wikipedia_tool, date_checker, check_palindrome]
# Pass the tools to the ToolNode() tool_node = ToolNode(tools)
# Bind tools to the LLM model_with_tools = llm.bind_tools(tools)
LangChain के साथ Agentic Systems डिज़ाइन करना

अभ्यास करते हैं!

LangChain के साथ Agentic Systems डिज़ाइन करना

Preparing Video For Download...