Aan de slagGa gratis aan de slag

Binding multiple tools

You've just built multiple tools! Now you'll be able to add them to your chatbot by first binding them to the LLM. The tools wikipedia_tool, palindrome_checker and historical_events have all been added to your environment along with llm. You'll also create a tool node to add to your chatbot that lists all of the tools available.

Deze oefening maakt deel uit van de cursus

Designing Agentic Systems with LangChain

Cursus bekijken

Oefeninstructies

  • From langgraph.prebuilt, import the necessary module for defining a tool node.
  • Complete the list of tools by adding the appropriate tool names present in your environment.
  • Pass the list of tools to the ToolNode() class and assign it to tool_node.
  • Bind the tools to the llm using .bind_tools().

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import modules required for defining tool nodes
from ____.____ import ____

# List of tools
tools = [____, ____, ____]

# Pass the tools to the ToolNode()
____ = ____(____)

# Bind tools to the LLM
model_with_tools = ____.____(____)
Code bewerken en uitvoeren