Video summary

Sequential Workflows in LangGraph | Agentic AI using LangGraph | Video 5 | CampusX

Main summary

Key takeaways

Technology

High-level purpose

  • Transition from theory to hands-on coding in the “Agentic AI Using LangGraph” playlist.
  • Two teaching goals:
    1. Show basic LangGraph coding so beginners can run their first graph.
    2. Enable viewers to create arbitrary sequential (linear) workflows in LangGraph.

Setup & tooling

  • Environment:
    • Create and activate a virtualenv.
    • Install packages used in the demo:
      • langgraph
      • langchain
      • langchain-openai (LangChain’s OpenAI integration)
      • python-dotenv (or equivalent) to load environment variables / API keys
      • ipykernel for running Jupyter notebooks
  • Use Jupyter Notebook for coding and graph visualization (LangGraph visualizations render in notebooks).
  • Load OpenAI API key via a .env file.
  • Use ChatOpenAI from LangChain for LLM calls.

Core LangGraph concepts demonstrated (workflow pattern)

  • State
    • Represented by a Python TypedDict class (the persistent graph state).
    • Each workflow passes and returns the state object across nodes.
  • StateGraph
    • Construct a StateGraph with the TypedDict as the state type.
  • Nodes
    • Added with graph.add_node("node_name", function_reference).
    • Nodes are plain Python functions that receive state and return (possibly modified) state.
  • Start/End pseudo-nodes
    • Imported from LangGraph to mark graph entry and exit.
  • Edges
    • Use graph.add_edge(source, target) to create flow between nodes.
  • Compile and invoke
    • graph.compile() returns a runnable workflow object.
    • workflow.invoke(initial_state) executes nodes in order and returns final state.
  • Visualization
    • Use LangGraph sample code (from docs) to render the graph in Jupyter for design/debugging.

Tutorials / example workflows

1) Non-LLM sequential example — BMI calculator

  • State: BMIState TypedDict with weight (float), height (float), bmi (float).
  • Node: calculate_bmi(state) computes bmi = weight / height**2, rounds it, updates state, and returns state.
  • Graph edges: start → calculate_bmi → end.
  • Execution: workflow.invoke(initial_state) returns final state with bmi.
  • Extended example: add label_bmi node to categorize BMI (underweight, normal, overweight, obese) and update state with category.
    • Edges: start → calculate_bmi → label_bmi → end.

2) Simple LLM QA workflow (LangChain integration)

  • State: LLMState with question_body (string) and answer_body (string).
  • Node: llm_qa(state) builds a prompt from the question, calls ChatOpenAI (via LangChain), extracts response.content, stores it in state.answer_body, and returns state.
  • Graph: start → llm_qa → end.
  • Demonstrates invoking an LLM from inside a LangGraph node and combining LangChain models with LangGraph workflow structure.

3) Prompt-chaining workflow (multiple LLM calls in sequence)

  • Motivation: show chaining multiple LLM interactions inside a workflow (decomposition across nodes).
  • State: BlogState with title, outline, content (strings).
  • Nodes:
    • CreateOutline: reads title, asks the LLM for a detailed outline, stores outline in state.
    • CreateBlog: uses title + outline, asks the LLM to write the full blog, stores content in state.
  • Graph: start → CreateOutline → CreateBlog → end.
  • Benefit: Persistent state retains intermediate artifacts (outline, title, content) making inspection and downstream use easier than ad-hoc LangChain chains.

Practical tips & patterns shown

  • Use type hinting for states and node functions: functions accept and return the TypedDict type.
  • Partial state updates: nodes mutate and return state so it evolves across nodes.
  • Call graph.compile() to validate graph structure before running.
  • Visualize the graph in Jupyter for debugging and design.
  • LangGraph complements LangChain:
    • LangChain supplies LLM primitives (models, prompts, loaders).
    • LangGraph handles orchestration and workflow structure.

Analysis / commentary from the author

  • LangGraph can be overkill for trivial linear flows, but it scales well for complex workflows requiring orchestration, state tracking, and multiple LLM interactions.
  • The stateful model makes it easy to preserve and inspect intermediate results across multiple steps — a practical advantage for multi-step prompt chains.
  • LangChain and LangGraph are complementary: LangChain for models & prompt tooling, LangGraph for nodes & orchestration.

Homework / suggested exercise

  • Extend the prompt-chaining blog workflow by adding an Evaluate node that rates the generated blog (based on the outline) and produces an integer score. Update the state and graph accordingly.

Code artifacts & repo

  • The author created a desktop folder and Jupyter notebooks for each example (BMI workflow, simple LLM QA, prompt chaining).
  • A GitHub repo with the folder and notebooks is promised in the video description.
  • Visualization code snippets are taken from the LangGraph docs.

Main speakers / sources

  • Speaker: Nitesh (YouTuber, presenter of the CampusX playlist)
  • Primary referenced projects/documents:
    • LangGraph documentation and API
    • LangChain library (ChatOpenAI and other LangChain components)
    • OpenAI models (via API key / ChatOpenAI)

Rate this summary

Your feedback will help improve summaries.

Improve this summary

Reprocess with a stronger model when the summary feels incomplete or inaccurate.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video