{"id":229396,"date":"2025-05-07T20:13:38","date_gmt":"2025-05-07T20:13:38","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/langgraph-tutorial-for-beginners\/"},"modified":"2025-05-07T20:13:38","modified_gmt":"2025-05-07T20:13:38","slug":"langgraph-tutorial-for-beginners","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=229396","title":{"rendered":"LangGraph Tutorial for Beginners"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"article-start\">\n<p><span style=\"font-weight: 400;\">Building applications with <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2023\/03\/an-introduction-to-large-language-models-llms\/\" target=\"_blank\" rel=\"noreferrer noopener\">large language models<\/a> (LLMs) is exciting, as it lets us create smart, interactive systems. However, making these apps more complex brings along challenges, especially when several LLMs work together. So, how do we manage the flow of information between them? How do we make sure they work smoothly and understand the task? LangGraph is the answer to all such questions. This free tutorial is a great way for beginners to understand how LangGraph can solve these problems. With hands-on examples and complete code, this guide will teach you how to manage multiple LLMs effectively, making your applications more powerful and efficient.<\/span><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-understanding-langgraph\">Understanding LangGraph<\/h2>\n<p>LangGraph is a powerful library, which is a part of <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/06\/langchain-guide\/\" target=\"_blank\" rel=\"noreferrer noopener\">LangChain<\/a> tools. It helps streamline the integration of LLMs, ensuring they work together seamlessly to understand and execute tasks. It offers a neat way to build and handle LLM apps with many agents.<\/p>\n<p>LangGraph lets developers set up how multiple LLM agents talk to each other. It shows these workflows as graphs with cycles. This helps in keeping the communication smooth and performing complex tasks well. LangGraph is best when using <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2018\/04\/introduction-to-graph-theory-network-analysis-python-codes\/\" target=\"_blank\" rel=\"noreferrer noopener\">Directed Acyclic Graphs<\/a> (DAGs) for straight line tasks. But since it is cyclic and adds the ability to loop back, it allows for more complex and flexible systems. It\u2019s like how a smart agent might rethink things and use new information to update responses or change its choices.<\/p>\n<figure class=\"wp-block-image size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"702\" height=\"649\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp\" alt=\"LangGraph flowchart\" class=\"wp-image-233898\" style=\"width:339px;height:auto\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp 702w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6-300x277.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6-150x139.webp 150w\" sizes=\"(max-width: 702px) 100vw, 702px\"\/><\/figure>\n<p>Also Read: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/07\/langgraph-revolutionizing-ai-agent\/\" target=\"_blank\" rel=\"noopener\">What is LangGraph?<\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-key-concepts-of-langgraph\">Key Concepts of LangGraph<\/h2>\n<p>Here are some of the key concepts of LangGraph that you need to know:<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-1-graph-structures\">1. Graph Structures<\/h3>\n<p>LangGraph\u2019s core idea is using a graph for the application\u2019s workflow. This graph has two main parts \u2013 nodes and edges.<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Nodes:<\/strong> Nodes are the fundamental building blocks representing discrete units of work or computation within the workflow. Each node is a Python function that processes the current state and returns an updated state. Nodes can perform tasks such as calling an LLM and interacting with tools or APIs for manipulating data.<\/li>\n<li><strong>Edges:<\/strong> Edges connect nodes and define the flow of execution. They can be:\n<ul class=\"wp-block-list\">\n<li><strong>Simple edges:<\/strong> Direct, unconditional transitions from one node to another.<\/li>\n<li><b>Conditional edges: <\/b>Branching logic that directs flow based on node outputs, similar to if-else statements. This allows dynamic decision-making within the workflow.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-2-state-management\">2. State Management<\/h3>\n<p>Keeping track of what\u2019s happening is vital when you have many agents. All agents need to know the current status of the task. LangGraph handles this by managing the state automatically. The library keeps track of and updates a main state object. It does this as the agents do their jobs. The state object holds important information. It\u2019s available at different points in the workflow. This could include the chat history.<\/p>\n<p>In a chatbot, the state can save the conversation. This helps the bot respond using what was said before. It can also store context data, like user likes, past actions, etc. or external data. Agents can use this for making choices. Internal variables can also be kept here. Agents might use the state to track flags, counts, or other values. These help guide their actions and decisions.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-3-multi-agent-systems\">3. Multi-agent Systems<\/h3>\n<p>A multi-agent system consists of multiple independent agents that work together or compete to achieve a common goal. These agents use LLMs to make decisions and control the flow of an application. The complexity of a system can grow as more agents and tasks are added. This may lead to challenges like poor decision making, context management, and the need for specialization. A multi-agent system solves these problems by breaking the system into smaller agents, each focusing on a specific task, such as planning or research.<\/p>\n<p>The main benefits of using a multi-agent system is modularity, specialization, and control. Modularity is for easy development, testing and maintenance, while specialization ensures that expert agents improve overall performance. Control ensures that you can clearly tell how the agents should communicate.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-architectures-in-multi-agent-systems\">Architectures in Multi-agent Systems<\/h4>\n<p>Here are the various types of architectures followed in multi-agent systems.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"594\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/frtawnmwoclycbbvzss4.webp\" alt=\"\" class=\"wp-image-233900\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/frtawnmwoclycbbvzss4.webp 733w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/frtawnmwoclycbbvzss4-300x243.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/frtawnmwoclycbbvzss4-150x122.webp 150w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\"\/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/langchain-ai.github.io\/langgraph\/concepts\/img\/multi_agent\/architectures.png\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">LangChain<\/a><\/figcaption><\/figure>\n<p><strong>1. Network Architecture:<\/strong>\u00a0In this architecture, every agent communicates with every other agent, and each can then decide which agent they should call next. This is very helpful when there is no clear sequence of operations. Below is a simple example of how it works using StateGraph.<\/p>\n<pre class=\"wp-block-code\"><code>from langchain_openai import ChatOpenAI\nfrom langgraph.types import Command\nfrom langgraph.graph import StateGraph\n\nmodel = ChatOpenAI()\n\ndef agent_1(state) -&gt; Command:\n    response = model.invoke(...)\n    return Command(goto=response[\"next_agent\"], update={\"messages\": [response[\"content\"]]})\n\nbuilder = StateGraph()\nbuilder.add_node(agent_1)\nbuilder.compile()\n<\/code><\/pre>\n<p><strong>2. Supervisor Architecture:<\/strong> A supervisor agent controls the decision making process and routes tasks to the appropriate agents. Here\u2019s a sample of how it\u2019s done:<\/p>\n<pre class=\"wp-block-code\"><code>def supervisor(state) -&gt; Command:\n    response = model.invoke(...)\n    return Command(goto=response[\"next_agent\"])\n\nbuilder = StateGraph()\nbuilder.add_node(supervisor)\nbuilder.compile()<\/code><\/pre>\n<p><strong>3. Supervisor with Tool-calling:<\/strong> In this architecture, a supervisor agent uses a tool-calling agent to decide which tool (or agent) to use. The tool executes tasks and returns results that guide the next control flow decision.. A common pattern here is to have a tool-wrapped function:<\/p>\n<pre class=\"wp-block-code\"><code>def agent_1(state):\n    response = model.invoke(...)\n    return response.content<\/code><\/pre>\n<p><strong>4. Hierarchical Architecture:<\/strong> This approach addresses the complexity of multi-agent systems by organizing agents into teams, each with its own supervisor. The top-level supervisor directs which team to call. For instance:<\/p>\n<pre class=\"wp-block-code\"><code>def top_level_supervisor(state):\n    response = model.invoke(...)\n    return Command(goto=response[\"next_team\"])\n\nbuilder = StateGraph()\nbuilder.add_node(top_level_supervisor)\nbuilder.compile()<\/code><\/pre>\n<p><strong>5. Handoffs in Multi-agent Systems:<\/strong> Handoffs allow one agent to pass control to another, facilitating a flow from one agent to the next. Each agent returns a Command object that specifies the next agent to call and send any updates to the state.<\/p>\n<pre class=\"wp-block-code\"><code>def agent(state) -&gt; Command:\n    goto = get_next_agent(...)\n    return Command(goto=goto, update={\"my_state_key\": \"my_state_value\"})<\/code><\/pre>\n<p>In complex systems, agents may be nested within subgraphs, where a node in a subgraph can direct control to another agent outside its graph:<\/p>\n<pre class=\"wp-block-code\"><code>def some_node_inside_alice(state):\n    return Command(goto=\"bob\", graph=Command.PARENT)<\/code><\/pre>\n<p>Multi-agent systems enable modular and specialized designs where agents independently handle tasks and communicate for efficient problem-solving. Architectures like network, supervisor, and hierarchical systems each serve specific needs, while handoffs ensure smooth transitions between agents, maintaining flexibility and control.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-4-persistence\">4. Persistence<\/h3>\n<p>Persistence means saving the progress of a process so that you can come back to it later, even after some interruptions. Each step\u2019s state is saved, which helps with error recovery. It supports human feedback during runs. You can also replay steps to debug or try new paths.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1125\" height=\"351\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sim24timpx9ogme53yxl.webp\" alt=\"Persistence checkpoints in LangGraph\" class=\"wp-image-233905\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sim24timpx9ogme53yxl.webp 1125w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sim24timpx9ogme53yxl-300x94.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sim24timpx9ogme53yxl-768x240.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/sim24timpx9ogme53yxl-150x47.webp 150w\" sizes=\"auto, (max-width: 1125px) 100vw, 1125px\"\/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/langchain-ai.github.io\/langgraph\/concepts\/img\/persistence\/checkpoints.jpg\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">LangChain<\/a><\/figcaption><\/figure>\n<p>In LangGraph, persistence is done using checkpointers. Here, the graph\u2019s state is saved after every major step and each saved state is called a checkpoint. All the checkpoints are grouped inside a thread (the conversation history for a particular run).<\/p>\n<p>Checkpointing is done automatically and you don\u2019t always need to configure it manually. A checkpoint is like a snapshot of the graph\u2019s state that includes:<\/p>\n<ul class=\"wp-block-list\">\n<li>config: Configuration info used during that step<\/li>\n<li>metadata: Step details (e.g., which node is running)<\/li>\n<li>values: The actual state values at that point<\/li>\n<li>next: The next node(s) that will be run<\/li>\n<li>tasks: Info on what\u2019s coming or errors<\/li>\n<\/ul>\n<p>Each graph, while execution, needs a thread ID to group its checkpoints. You can provide this thread id using config: Below is a sample of how it can be done:<\/p>\n<pre class=\"wp-block-code\"><code>config = {\"configurable\": {\"thread_id\": \"1\"}}\n<\/code><\/pre>\n<p>To fetch the most recent state within a thread, use the below code:<\/p>\n<pre class=\"wp-block-code\"><code>graph.get_state({\"configurable\": {\"thread_id\": \"1\"}})\n<\/code><\/pre>\n<p>The below code shows how you can get a specific checkpoint:<\/p>\n<pre class=\"wp-block-code\"><code>graph.get_state({\n  \"configurable\": {\n    \"thread_id\": \"1\", \n    \"checkpoint_id\": \"your_checkpoint_id\"\n  }\n})\n<\/code><\/pre>\n<p>To get the state history or fetch all previous states, use this code:<\/p>\n<pre class=\"wp-block-code\"><code>history = graph.get_state_history({\"configurable\": {\"thread_id\": \"1\"}})<\/code><\/pre>\n<p>You can also update or edit the state manually at any point, using:<\/p>\n<pre class=\"wp-block-code\"><code>graph.update_state(\n    config={\"configurable\": {\"thread_id\": \"1\"}},\n    values={\"foo\": \"new_value\"}\n)\n<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-5-human-in-the-loop-integration\">5. Human-in-the-Loop Integration<\/h3>\n<p>Human-in-the-loop lets you add human feedback at key steps of an automated LangGraph workflow. This is crucial in certain tasks since LLMs may generate uncertain or risky outputs such as in tool calls, content generation, or decision-making. LangGraph\u2019s interrupt() function makes this possible by pausing the graph, surfacing data to a human, and resuming with their input using the Command(resume=value) method. This enables review, correction, or data entry.<\/p>\n<p>Human-in-the-loop supports patterns like Approve\/Reject, Edit State, Provide Input, or Multi-turn Conversations. To use it, define a checkpointer and add an interrupt() inside a node. You can resume the graph using Command after human input.<\/p>\n<figure class=\"wp-block-image size-full figure mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"769\" height=\"404\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/glro39hrthujo3xino0u.webp\" alt=\"Human-in-the-loop integration\" class=\"wp-image-233908\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/glro39hrthujo3xino0u.webp 769w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/glro39hrthujo3xino0u-300x158.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/glro39hrthujo3xino0u-150x79.webp 150w\" sizes=\"auto, (max-width: 769px) 100vw, 769px\"\/><figcaption class=\"wp-element-caption\">Source:\u00a0<b><a href=\"https:\/\/langchain-ai.github.io\/langgraph\/concepts\/img\/human_in_the_loop\/approve-or-reject.png\" target=\"_blank\" rel=\"nofollow noopener\">LangChain<\/a><\/b><\/figcaption><\/figure>\n<p>Below is a sample of how you can use Human-in-the-loop in LangGraph.<\/p>\n<pre class=\"wp-block-code\"><code>from langgraph.types import interrupt, Command\n\ndef human_node(state):\n    value = interrupt({\"text_to_revise\": state[\"some_text\"]})\n    return {\"some_text\": value}\n\ngraph = graph_builder.compile(checkpointer=checkpointer)\ngraph.invoke(some_input, config={\"configurable\": {\"thread_id\": \"some_id\"}})\ngraph.invoke(Command(resume=\"Edited text\"), config={\"configurable\": {\"thread_id\": \"some_id\"}})<\/code><\/pre>\n<p>This keeps workflows interactive, auditable, and accurate perfect for high-stakes or collaborative AI use cases.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-6-streaming\">6. Streaming<\/h3>\n<p>LangGraph streams outputs as they are created which lets users see results faster. This improves their experience with LLMs. Streaming helps you build responsive apps by showing you real-time progress. There are 3 main data types to stream: workflow progress, LLM tokens, and custom updates.<\/p>\n<p>Use .stream() (sync) or .astream() (async) to stream outputs. You can set stream_mode to control what you get:<\/p>\n<ul class=\"wp-block-list\">\n<li>\u201cvalues\u201d: full state after each graph step<\/li>\n<li>\u201cupdates\u201d: changes only after each node<\/li>\n<li>\u201ccustom\u201d: any custom data you log in a node<\/li>\n<li>\u201cmessages\u201d: LLM token stream with metadata<\/li>\n<li>\u201cdebug\u201d: all info throughout the run<\/li>\n<\/ul>\n<p>You can pass multiple modes like this:<\/p>\n<pre class=\"wp-block-code\"><code>for stream_type, data in graph.stream(inputs, stream_mode=[\"updates\", \"messages\"]):\n    if stream_type == \"messages\":\n        print(data[0].content)  # AIMessageChunk\n    elif stream_type == \"updates\":\n        print(data)  # State update\n<\/code><\/pre>\n<p>Use .astream_events() if you want a full event stream. This is perfect when migrating big apps.<\/p>\n<p><strong>Pro tip:<\/strong> For real-time UI feedback, use \u201cmessages\u201d for token-wise streaming and \u201cupdates\u201d for backend state.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-why-use-langgraph\">Why Use LangGraph?<\/h2>\n<p>LangGraph is ideal for developers building smart and flexible AI agents. Here\u2019s why:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Reliable and controllable:<\/strong> Add moderation checks and human approvals. It keeps context alive for long tasks.<\/li>\n<li><strong>Custom and extensible:<\/strong> Use low-level tools to build agents your way. Design systems with agents that each play a specific role.<\/li>\n<li><strong>Great streaming:<\/strong> See each token and step live, tracking agent thinking as it happens.<\/li>\n<\/ul>\n<p>You can also take the course from the <a href=\"https:\/\/academy.langchain.com\/courses\/intro-to-langgraph\" target=\"_blank\" rel=\"nofollow noopener\">Langchain academy<\/a>.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-building-the-simplest-graph\">Building the Simplest Graph<\/h2>\n<p>Now that we have seen the key components of LangGraph, let\u2019s try to build a basic graph with three nodes and one conditional edge. This simple example shows how to invoke a graph involving the key concepts of State, Nodes, and Edges.<\/p>\n<figure class=\"wp-block-image size-full figure mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"1058\" height=\"431\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/uxfs09bmvnibwie5lvie.webp\" alt=\"building the simplest graph in LangGraph\" class=\"wp-image-233911\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/uxfs09bmvnibwie5lvie.webp 1058w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/uxfs09bmvnibwie5lvie-300x122.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/uxfs09bmvnibwie5lvie-768x313.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/uxfs09bmvnibwie5lvie-150x61.webp 150w\" sizes=\"auto, (max-width: 1058px) 100vw, 1058px\"\/><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-step-1-define-the-graph-state\">Step 1: Define the Graph State<\/h3>\n<p>The State defines the data structure which is shared between nodes. It acts like a shared memory that flows through the graph.<\/p>\n<pre class=\"wp-block-code\"><code>from typing_extensions import TypedDict\nclass State(TypedDict):\n    graph_state: str<\/code><\/pre>\n<p>Here, we have used python\u2019s TypeDict to declare that our state will have a single key called the graph_state, which stores a string.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-2-create-the-nodes\">Step 2: Create the Nodes<\/h3>\n<p>Nodes are just simple Python functions. Each one takes in the current state, modifies it, and returns the updated state.<\/p>\n<pre class=\"wp-block-code\"><code>def node_1(state):\n    print(\"---Node 1---\")\n    return {\"graph_state\": state['graph_state'] + \" I am\"}<\/code><\/pre>\n<p>This function appends \u201cI am\u201d to whatever string is in graph_state.<\/p>\n<pre class=\"wp-block-code\"><code>def node_2(state):\n    print(\"---Node 2---\")\n    return {\"graph_state\": state['graph_state'] + \" extremely happy!\"}\n\ndef node_3(state):\n    print(\"---Node 3---\")\n    return {\"graph_state\": state['graph_state'] + \" extremely sad!\"}<\/code><\/pre>\n<p>Here, these two nodes add an emotional tone of \u201chappy!\u201d or \u201csad!\u201d to the sentence.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-3-add-conditional-logic\">Step 3: Add Conditional Logic<\/h3>\n<p>Sometimes you want dynamic behavior, where the next step depends on logic or randomness. That\u2019s what conditional edges enable.<\/p>\n<pre class=\"wp-block-code\"><code>import random\nfrom typing import Literal\n\ndef decide_mood(state) -&gt; Literal[\"node_2\", \"node_3\"]:\n    if random.random() <\/code><\/pre>\n<p>This function randomly picks between node_2 and node_3 with equal probability, simulating a simple mood selector.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-4-construct-the-graph\">Step 4: Construct the Graph<\/h3>\n<p>Let\u2019s bring it all together using LangGraph\u2019s StateGraph class. This is where we define the full graph structure.<\/p>\n<pre class=\"wp-block-code\"><code>from IPython.display import Image, display\nfrom langgraph.graph import StateGraph, START, END\n\n# Initialize the graph with the state schema\nbuilder = StateGraph(State)\n\n# Add nodes to the graph\nbuilder.add_node(\"node_1\", node_1)\nbuilder.add_node(\"node_2\", node_2)\nbuilder.add_node(\"node_3\", node_3)<\/code><\/pre>\n<p>We start with the START node and route to node_1. Then, we add a conditional edge from node_1 using decide_mood. After that, the graph continues to either node_2 or node_3 and ends at the END node.<\/p>\n<pre class=\"wp-block-code\"><code># Add edges to define flow\nbuilder.add_edge(START, \"node_1\")\nbuilder.add_conditional_edges(\"node_1\", decide_mood)\nbuilder.add_edge(\"node_2\", END)\nbuilder.add_edge(\"node_3\", END)\n\n# Compile and visualize the graph\ngraph = builder.compile()\ndisplay(Image(graph.get_graph().draw_mermaid_png()))\n<\/code><\/pre>\n<figure class=\"wp-block-image size-full figure mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"252\" height=\"364\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/bszsrfpirhhnsanym2zh.webp\" alt=\"Construct a graph using LangGraph\" class=\"wp-image-233912\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/bszsrfpirhhnsanym2zh.webp 252w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/bszsrfpirhhnsanym2zh-208x300.webp 208w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/bszsrfpirhhnsanym2zh-150x217.webp 150w\" sizes=\"auto, (max-width: 252px) 100vw, 252px\"\/><\/figure>\n<p>The compile() method performs basic validation, and draw_mermaid_png() lets you visualize the graph as a Mermaid diagram.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-5-invoke-the-graph\">Step 5: Invoke the Graph<\/h3>\n<p>Finally, we can run the graph using the invoke() method.<\/p>\n<pre class=\"wp-block-code\"><code>graph.invoke({\"graph_state\" : \"Hi, this is Janvi.\"})\n<\/code><\/pre>\n<p>This starts the graph at the START node and initializes graph_state with the sentence \u201cHi, this is Janvi.\u201d.<\/p>\n<ol class=\"wp-block-list\">\n<li>node_1 appends \u201d I am\u201d \u2192 \u201cHi, this is Janvi.\u201d<\/li>\n<li>decide_mood randomly chooses the path<\/li>\n<li>node_2 or node_3 appends either \u201d extremely happy!\u201d or \u201d extremely sad!\u201d<\/li>\n<\/ol>\n<p><strong>Output:<\/strong><\/p>\n<figure class=\"wp-block-image size-full figure mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"92\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/LangChain-output.webp\" alt=\"LangChain output\" class=\"wp-image-233915\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/LangChain-output.webp 800w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/LangChain-output-300x35.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/LangChain-output-768x88.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/LangChain-output-150x17.webp 150w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\"\/><\/figure>\n<p>This output shows how state flows and updates through each step of the graph.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-building-a-support-chatbot-with-langgraph-using-openai\">Building a Support Chatbot with LangGraph Using OpenAI<\/h2>\n<p>Now that we have built the simplest graph in the above section, in this section,\u00a0I will show you how to use LangGraph to build a support chatbot, starting with basic functionality and progressively adding features like web search, memory, and human-in-loop. Along the way, we will see the\u00a0core LangGraph concepts as well.<\/p>\n<p>Our goal here is to create a chatbot that can answer questions using web search, remember past conversations, ask a human for help when needed, use a custom state for behavior, and rewind conversation paths (enabled by checkpointing).<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-setup\">Setup<\/h3>\n<p>Before building the chatbot, let\u2019s install the necessary packages.<\/p>\n<pre class=\"wp-block-code\"><code>!pip install -U langgraph langchain openai<\/code><\/pre>\n<p>This command installs:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>LangGraph:<\/strong> For building the graph structure.<\/li>\n<li><strong>LangChain:<\/strong> For interacting with OpenAI\u2019s language models.<\/li>\n<li><strong>OpenAI:<\/strong> For using OpenAI\u2019s models (like GPT-4).<\/li>\n<\/ul>\n<p>We need to securely provide the OpenAI API key so the application can authenticate and use the GPT models. This function prompts for the key if it\u2019s not already set in the environment.<\/p>\n<pre class=\"wp-block-code\"><code>import getpass\nimport os\n\ndef _set_env(var: str):\n    if not os.environ.get(var):\n        os.environ[var] = getpass.getpass(f\"{var}: \")\n\n_set_env(\"OPENAI_API_KEY\")\n<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-part-1-build-a-basic-chatbot\">Part 1: Build a Basic Chatbot<\/h3>\n<p>We\u2019ll start by creating the simplest form of the chatbot.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-1-define-state\">1. Define State<\/h4>\n<p>The state defines the data structure that gets passed between nodes in the graph. Here, we define a state with a single key, messages, which will hold the list of conversation messages.<\/p>\n<pre class=\"wp-block-code\"><code>from typing import Annotated\nfrom typing_extensions import TypedDict\nfrom langgraph.graph import StateGraph, START, END\nfrom langgraph.graph.messae import add_messages\n\nclass State(TypedDict):\n    # 'messages' holds the list of chat messages.\n    # 'add_messages' ensures new messages are added, not replaced.\n    messages: Annotated[list, add_messages]\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-2-create-graph-builder\">2. Create Graph Builder<\/h4>\n<p>The StateGraph object is the entry point for defining the graph structure. It\u2019s initialized with the State definition we just created.<\/p>\n<pre class=\"wp-block-code\"><code>graph_builder = StateGraph(State)\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-3-add-chatbot-node\">3. Add Chatbot Node<\/h4>\n<p>We define a Python function chatbot that takes the current state, invokes OpenAI\u2019s GPT model with the messages from the state, and returns the LLM\u2019s response as an update to the messages key in the state.<\/p>\n<pre class=\"wp-block-code\"><code>import openai\n\n# Initialize OpenAI GPT model\nopenai.api_key = os.environ[\"OPENAI_API_KEY\"]\n\ndef chatbot(state: State):\n    response = openai.Completion.create(\n        model=\"gpt-4\",  # You can also use \"gpt-3.5-turbo\" or any other OpenAI model\n        prompt=state[\"messages\"],\n        max_tokens=150\n    )\n    return {\"messages\": [response.choices[0].text.strip()]}\n\ngraph_builder.add_node(\"chatbot\", chatbot)\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-4-set-entry-and-exit-points\">4. Set Entry and Exit Points<\/h4>\n<p>Define the entry point (START) and exit point (END) for the graph execution.<\/p>\n<pre class=\"wp-block-code\"><code>graph_builder.add_edge(START, \"chatbot\")\ngraph_builder.add_edge(\"chatbot\", END)\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-5-compile-the-graph\">5. Compile the Graph<\/h4>\n<p>Once all nodes and edges are defined, compile the graph structure.<\/p>\n<pre class=\"wp-block-code\"><code>graph = graph_builder.compile()\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-6-visualize-optional\">6. Visualize (Optional)<\/h4>\n<p>LangGraph allows visualizing the compiled graph structure. This helps understand the flow of execution. We can visualize the graph using tools like pygraphviz or mermaid.<\/p>\n<pre class=\"wp-block-code\"><code>from IPython.display import Image, display\n\ntry:\n    display(Image(graph.get_graph().draw_mermaid_png()))\nexcept Exception:\n    pass # Optional visualization\n<\/code><\/pre>\n<figure class=\"wp-block-image size-full figure mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"134\" height=\"244\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/tkzjcmb29agzao1rriop.webp\" alt=\"LangGraph chatbot flowchart\" class=\"wp-image-233916\"\/><\/figure>\n<h4 class=\"wp-block-heading\" id=\"h-7-run-the-chatbot\">7. Run the Chatbot<\/h4>\n<p>Set up a loop to interact with the chatbot. It takes user input, packages it into the expected State format ({\u201cmessages\u201d: [\u2026]}), and uses graph.stream to execute the graph. The stream method returns events as the graph progresses, and we print the assistant\u2019s final message.<\/p>\n<pre class=\"wp-block-code\"><code>def stream_graph_updates(user_input: str):\n    for event in graph.stream({\"messages\": [{\"role\": \"user\", \"content\": user_input}]}):\n        for value in event.values():\n            print(\"Assistant:\", value[\"messages\"][-1].content)\n\n# Loop to chat with the bot\nwhile True:\n    try:\n        user_input = input(\"User: \")\n        if user_input.lower() in [\"quit\", \"exit\", \"q\"]:\n            print(\"Goodbye!\")\n            break\n        stream_graph_updates(user_input)\n    except: # Fallback for environments without input()\n        user_input = \"What do you know about LangGraph?\"\n        print(\"User: \" + user_input)\n        stream_graph_updates(user_input)\n        break\n<\/code><\/pre>\n<figure class=\"wp-block-image size-full figure mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"1292\" height=\"98\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/wlfxrmjxdirufzfb8cuv-1.webp\" alt=\"Chatbot output\" class=\"wp-image-233917\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/wlfxrmjxdirufzfb8cuv-1.webp 1292w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/wlfxrmjxdirufzfb8cuv-1-300x23.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/wlfxrmjxdirufzfb8cuv-1-768x58.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/wlfxrmjxdirufzfb8cuv-1-150x11.webp 150w\" sizes=\"auto, (max-width: 1292px) 100vw, 1292px\"\/><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-part-2-enhancing-the-chatbot-with-tools\">Part 2: Enhancing the Chatbot with Tools<\/h3>\n<p>To make the chatbot more knowledgeable, especially about recent information, we\u2019ll integrate a web search tool (Tavily). This involves enabling the LLM to request tool usage and adding graph components to handle the execution of these tools.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-1-install-tool-requirements\">1. Install Tool Requirements<\/h4>\n<p>Install the necessary library for the Tavily search tool.<\/p>\n<pre class=\"wp-block-code\"><code>%pip install -U tavily-python langchain_community\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-2-set-tool-api-key\">2. Set Tool API Key<\/h4>\n<p>Configure the API key for the Tavily service.<\/p>\n<pre class=\"wp-block-code\"><code>_set_env(\"TAVILY_API_KEY\")  # Uses the function defined earlier\n<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-3-define-the-tool\">3. Define the Tool<\/h4>\n<p>Instantiate the TavilySearchResults tool, which will return 2 results. This tool will be used by both the LLM and the graph.<\/p>\n<pre class=\"wp-block-code\"><code>from langchain_community.tools.tavily_search import TavilySearchResults\n# Create a Tavily search tool instance, limiting to 2 results\ntool = TavilySearchResults(max_results=2)\ntools = [tool]  # List of tools the bot can use\n<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-part-3-add-memory-to-the-chatbot\">Part 3: Add Memory to the Chatbot<\/h3>\n<p>To enable multi-turn conversations where the bot remembers previous messages, we introduce LangGraph\u2019s checkpointing feature.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-add-checkpointer\">Add Checkpointer<\/h4>\n<p>Use the MemorySaver checkpointer to store the conversation state in memory. For production, you might use a persistent backend like SQLite or Postgres.<\/p>\n<pre class=\"wp-block-code\"><code>from langgraph.checkpoint.memory import MemorySaver\nmemory = MemorySaver()\n<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-part-4-human-in-the-loop\">Part 4: Human-in-the-loop<\/h3>\n<p>Sometimes, the AI agent might need human input before proceeding. We achieve this by creating a tool that pauses the graph\u2019s flow.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-define-human-assistance-tool\">Define Human Assistance Tool<\/h4>\n<pre class=\"wp-block-code\"><code>from langchain_core.tools import tool\nfrom langgraph.types import interrupt\n@tool\ndef human_assistance(query: str) -&gt; str:\n    print(f\"Pausing for human assistance regarding: {query}\")\n    # interrupt pauses graph execution and waits for input\n    human_response = interrupt({\"query\": query})\n    return human_response[\"data\"]\n<\/code><\/pre>\n<p>This tool pauses the graph and waits for human input before proceeding.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-deploying-your-langgraph-applications\">Deploying Your LangGraph Applications<\/h2>\n<p>Once you have built your LangGraph application, the next thing which you need to do is running the app either on your local machine or cloud platforms for further development and testing. LangGraph provides us with several deployment options which can have different workflows and infrastructure.<\/p>\n<p>For deployment, LangGraph supports several options. The <a href=\"https:\/\/langchain-ai.github.io\/langgraph\/concepts\/langgraph_cloud\/\" target=\"_blank\" rel=\"nofollow noopener\">Cloud SaaS model<\/a> handles everything for you. The <a href=\"https:\/\/langchain-ai.github.io\/langgraph\/concepts\/langgraph_self_hosted_data_plane\/\" target=\"_blank\" rel=\"nofollow noopener\">Self-Hosted Data Plane<\/a> lets you run apps in your own cloud while using LangChain\u2019s control plane. With the Self-Hosted Control Plane, you manage everything yourself. Or go with <a href=\"https:\/\/langchain-ai.github.io\/langgraph\/concepts\/langgraph_standalone_container\/\" target=\"_blank\" rel=\"nofollow noopener\">Standalone Containers<\/a> for full flexibility using Docker.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-use-cases-of-langgraph\">Use Cases of LangGraph<\/h2>\n<p>LangGraph is used to build interactive and intelligent AI Agents. Let\u2019s explore and see some of its use cases.<\/p>\n<p><strong>Improved Customer Service<\/strong>: LangGraph is capable of developing advanced chatbots for customer support. These chatbots are able to recall past purchases and customer preferences.With the recalled past they can respond to the queries about the order and can link to humans when necessary. With this the customer\u2019s problem can be solved faster.<\/p>\n<p><strong>Research Assistant for AI<\/strong>: A research assistant can also be created using LangGraph. It can look for scholarly articles and then highlight important information. The assistant can then extract the information and this information then can be used by researchers and students to gain more insights from various fields.<\/p>\n<p><strong>Personalized Learning:<\/strong> With LangGraph we can also build personalized or customized learning systems which will adjust the content based on the learner. This will help the learner understand the weaker area and then recommend resources based on that. This creates a personalized learning experience, improving engagement and outcomes.<\/p>\n<p><strong>Streamlining Business Tasks:<\/strong> LangGraph can also help us in automating business processes. With this document approval and project management can be automated and also the agent can also be used to analyze data. Automation helps in increasing productivity and reduces human error, allowing teams to focus on higher-level tasks.<\/p>\n<p>Learn More: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/10\/langgraph-react-function-calling\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dynamic AI Workflows Through LangGraph ReAct Function Calling<\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n<p>In this LangGraph tutorial for beginners, you learned how to build interactive AI systems. These systems go beyond simple Q&amp;A bots. Through LangGraph examples, we saw how LangGraph manages state, integrates multiple agents, and allows human input. The guide showed how to build a support chatbot that can handle web searches, remember past interactions, and even involve human intervention. The LangGraph tutorial for beginners is very good\u00a0 for developers. It helps create powerful, AI-driven applications. By using LangGraph, we can build flexible, adaptive systems that can handle complex tasks. Whether you\u2019re building a chatbot, research assistant, or personalized learning tool, LangGraph has the structure and tools you need for efficient development.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-frequently-asked-questions\">Frequently Asked Questions<\/h2>\n<div class=\"schema-faq wp-block-yoast-faq-block\">\n<div class=\"schema-faq-section\" id=\"faq-question-1746635598906\"><strong class=\"schema-faq-question\">Q1. What is LangGraph?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. LangGraph is a powerful library that allows developers to make complex and\u00a0advanced AI agents which can interact with large language models. It also helps in managing workflow using graph structure. With the help of this graph structure multiple agents can be built to handle complex tasks.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1746635609826\"><strong class=\"schema-faq-question\">Q2. How does LangGraph work?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. LangGraph works by defining workflows as graphs. The graph consists of nodes (tasks or computations) and edges (connections between tasks). It handles state management, making sure each agent has the information it needs to perform its task and interact with other agents.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1746635640652\"><strong class=\"schema-faq-question\">Q3. What are some key features of LangGraph?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. LangGraph offers:<br \/>\u2013 State management which keeps track of data as the agent performs tasks.<br \/>\u2013 Multi-agent support which allows multiple agents to work together within a graph.<br \/>\u2013 Persistence with checkpointers as it saves the state at each step which enable error recovery and debudding.<br \/>\u2013 Human-in-the-loop which helps in pausing the workflow for human review and approval.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1746636212294\"><strong class=\"schema-faq-question\">Q4. Can I integrate LangGraph with OpenAI\u2019s GPT models?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. Yes, LangGraph can be very easily integrated with OpenAI\u2019s GPT models. It allows us to build applications that use the power of LLMs, such as chatbots and AI assistants, while managing complex workflows and state across multiple agents.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1746636355395\"><strong class=\"schema-faq-question\">Q5. Is LangGraph beginner-friendly?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. Yes, this LangGraph tutorial for beginners is designed to help you get started. It walks through key concepts with LangGraph examples and explains how to build systems step by step. Additionally, the LangGraph tutorial for beginners free provides resources for learning the framework at no cost.<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"border-top py-3 author-info my-4\">\n<div class=\"author-card d-flex align-items-center\">\n<div class=\"flex-shrink-0 overflow-hidden\">\n                                    <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/author\/janvikumari01\/\" class=\"text-decoration-none active-avatar\"><br \/>\n                                                                       <img decoding=\"async\" src=\"https:\/\/av-eks-lekhak.s3.amazonaws.com\/media\/lekhak-profile-images\/converted_image_ToTu2tx.webp\" width=\"48\" height=\"48\" alt=\"Janvi Kumari\" loading=\"lazy\" class=\"rounded-circle\"\/><\/p>\n<p>                                <\/a>\n                                <\/div>\n<\/p><\/div>\n<p>Hi, I am Janvi, a passionate data science enthusiast currently working at Analytics Vidhya. My journey into the world of data began with a deep curiosity about how we can extract meaningful insights from complex datasets.<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<p><h4 class=\"fs-24 text-dark\">Login to continue reading and enjoy expert-curated content.<\/h4>\n<p>                        <button class=\"btn btn-primary mx-auto d-table\" data-bs-toggle=\"modal\" data-bs-target=\"#loginModal\" id=\"readMoreBtn\">Keep Reading for Free<\/button>\n                    <\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Building applications with large language models (LLMs) is exciting, as it lets us create smart, interactive systems. However, making these apps more complex brings along challenges, especially when several LLMs work together. So, how do we manage the flow of information between them? How do we make sure they work smoothly and understand the task? [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":229397,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[2737,31128,13955],"dealstore":[],"offerexpiration":[],"class_list":["post-229396","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-beginners","tag-langgraph","tag-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>LangGraph Tutorial for Beginners - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=229396\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LangGraph Tutorial for Beginners - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"Building applications with large language models (LLMs) is exciting, as it lets us create smart, interactive systems. However, making these apps more complex brings along challenges, especially when several LLMs work together. So, how do we manage the flow of information between them? How do we make sure they work smoothly and understand the task? [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=229396\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-07T20:13:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"702\" \/>\n\t<meta property=\"og:image:height\" content=\"649\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"20 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=229396#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=229396\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"LangGraph Tutorial for Beginners\",\"datePublished\":\"2025-05-07T20:13:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=229396\"},\"wordCount\":3202,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=229396#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp\",\"keywords\":[\"Beginners\",\"LangGraph\",\"Tutorial\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=229396#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=229396\",\"url\":\"https:\/\/fivemor.com\/?p=229396\",\"name\":\"LangGraph Tutorial for Beginners - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=229396#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=229396#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp\",\"datePublished\":\"2025-05-07T20:13:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=229396#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=229396\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=229396#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp\",\"width\":702,\"height\":649},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=229396#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"LangGraph Tutorial for Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"LangGraph Tutorial for Beginners - Som2ny Network","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fivemor.com\/?p=229396","og_locale":"en_US","og_type":"article","og_title":"LangGraph Tutorial for Beginners - Som2ny Network","og_description":"Building applications with large language models (LLMs) is exciting, as it lets us create smart, interactive systems. However, making these apps more complex brings along challenges, especially when several LLMs work together. So, how do we manage the flow of information between them? How do we make sure they work smoothly and understand the task? [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=229396","og_site_name":"Som2ny Network","article_published_time":"2025-05-07T20:13:38+00:00","og_image":[{"width":702,"height":649,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"20 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=229396#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=229396"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"LangGraph Tutorial for Beginners","datePublished":"2025-05-07T20:13:38+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=229396"},"wordCount":3202,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=229396#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp","keywords":["Beginners","LangGraph","Tutorial"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=229396#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=229396","url":"https:\/\/fivemor.com\/?p=229396","name":"LangGraph Tutorial for Beginners - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=229396#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=229396#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp","datePublished":"2025-05-07T20:13:38+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=229396#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=229396"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=229396#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/sjaf030qvifnk9ko17z6.webp.webp","width":702,"height":649},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=229396#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"LangGraph Tutorial for Beginners"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/229396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=229396"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/229396\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/229397"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=229396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=229396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=229396"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=229396"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=229396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}