1. Learn
  2. /
  3. Courses
  4. /
  5. Designing Agentic Systems with LangChain

Connected

Exercise

Create the graph workflow for multiple tools

Your building blocks for creating your chatbot graph are now ready! You'll put all of your nodes together into a single workflow using edges to manage the connections between them. To get started, your graph workflow has already been set up for you with MessagesState and the StateGraph() to track the chatbot's message updates. The display() function to render your graph as a LangGraph diagram has also been set up and the MemorySaver has been imported for you.

from langgraph.graph import StateGraph
from langgraph.checkpoint.memory import MemorySaver

workflow = StateGraph(MessagesState)

Instructions

100 XP
  • Add call_model as a node using the label "chatbot" and add tool_node with the label "tools".
  • Define an edge connecting the START node to the "chatbot" node.
  • Add conditional edges from the "chatbot" node to the "tools" and END nodes using should_continue, before connecting the "tools" node back to the "chatbot" node.
  • Create a MemorySaver() instance and compile the workflow into an application with the memory checkpointer.