This repository contains a collection of Jupyter notebooks exploring various concepts and patterns in LangGraph, a library for building stateful, multi-actor applications with LLMs (Large Language Models).
LangGraph enables the creation of complex AI workflows with multiple agents, state management, and flexible graph-based architectures. This repository serves as a learning resource covering fundamental concepts to advanced patterns.
- Python 3.11+
- Virtual environment (recommended)
- API keys for LLM providers (Anthropic, OpenAI, etc.)
- Environment variables configured in
.envfile
- Create and activate a virtual environment:
python -m venv langgraph
source langgraph/bin/activate # On Windows: langgraph\Scripts\activate- Install dependencies:
pip install langgraph langchain langchain-openai langchain-anthropic langchain-community langchain-tavily langchain-text-splitters- Set up environment variables:
Create a
.envfile in the root directory with your API keys:
ANTHROPIC_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here
TAVILY_API_KEY=your_key_here
- Description: Basic introduction to LangGraph with a simple chatbot implementation
- Concepts:
- StateGraph creation
- Node and edge definition
- Basic message handling
- Streaming responses
- Key Learning: Understanding the fundamental structure of a LangGraph application
- Description: Extends the simple chatbot with persistent conversation memory
- Concepts:
- MemorySaver for checkpointing
- State persistence across conversations
- Production-ready memory solutions (SqliteSaver, PostgresSaver)
- Key Learning: How to maintain conversation context and state
- Description: Adds web search capabilities to the chatbot using Tavily
- Concepts:
- Tool binding to LLMs
- Tool invocation patterns
- Integrating external APIs
- Key Learning: Extending agent capabilities with tools
- Description: Exploration of prebuilt ReAct agents and their capabilities
- Concepts:
create_react_agentfromlanggraph.prebuilt- Structured outputs with agents
- Custom prompts for agents
- Model initialization patterns
- Key Learning: Using prebuilt agent components vs building from scratch
- Description: Multi-agent system with a supervisor agent coordinating specialized agents
- Concepts:
- Supervisor pattern
- Specialized agent creation (research agent)
- Multi-agent coordination
- Agent routing and delegation
- Key Learning: Building complex multi-agent systems
- Description: Asynchronous patterns in LangGraph
- Concepts:
- Async/await with LangGraph
ainvokefor async execution- Async node definitions
- Key Learning: Performance optimization through async operations
- Description: Retrieval-Augmented Generation implementation using agents
- Concepts:
- Document loading and splitting
- Vector store creation (InMemoryVectorStore)
- Embeddings and retrieval
- RAG patterns with LangGraph
- Key Learning: Combining retrieval systems with agent workflows
- Description: Advanced RAG pattern with retrieval grading and correction
- Concepts:
- Retrieval quality assessment
- Self-correction mechanisms
- Advanced RAG workflows
- Key Learning: Improving RAG accuracy through feedback loops
- Description: Advanced agent patterns including recursion limits
- Concepts:
- Recursion limits and error handling
GraphRecursionErrormanagement- Configuring agent iteration limits
- Tool integration patterns
- Key Learning: Controlling agent behavior and preventing infinite loops
LangGraph/
├── README.md # This file
├── .gitignore # Git ignore rules
├── documentation.txt # Reference links and package ecosystem
├── simple_chatbot.py # Simple chatbot script
├── simple_chatbot.ipynb # Simple chatbot notebook
├── chatbot_with_conversation_memory.ipynb
├── chatbot_with_search.ipynb
├── exploring_agents.ipynb
├── agent_supervisor.ipynb
├── async_langgraph.ipynb
├── agentic_rag.ipynb
├── corrective_rag.ipynb
├── langgraph_agents.ipynb
└── langgraph/ # Virtual environment directory
- TypedDict for state definition
- Annotated types with reducer functions (
add_messages) - State updates and persistence
StateGraphcreation- Node addition and configuration
- Edge definition (START, END, conditional edges)
- Graph compilation
- ReAct agent pattern
- Tool integration
- Structured outputs
- Custom prompts and configurations
- Multi-agent systems
- Supervisor patterns
- RAG implementations
- Async execution
- Error handling and recursion limits
As documented in documentation.txt, the LangGraph ecosystem includes:
- langgraph (base): Core LangGraph functionality
- langgraph-prebuilt: Prebuilt components for creating agents
- langgraph-supervisor: Tools for building supervisor agents
- langgraph-swarm: Tools for building swarm multi-agent systems
- langchain-mcp-adapters: Interfaces to MCP servers
- langmem: Agent memory management (short-term and long-term)
- agentevals: Utilities to evaluate agent performance
- LangGraph Documentation
- LangGraph Tutorials
- ReAct Agent Guide
- Agent Overview
- Tool Usage Documentation
- All notebooks use environment variables from
.envfile - The virtual environment directory (
langgraph/) is excluded from git - Some notebooks may require additional dependencies (check individual notebook cells)
- API keys should never be committed to version control
This is a personal learning repository. Feel free to explore and adapt the code for your own learning purposes.
This repository is for educational purposes.