Welcome to LangGraph 101, a hands-on tutorial series designed to help you learn and master LangGraph, a powerful library for building stateful, multi-actor applications with Large Language Models (LLMs).
This repository offers a structured learning path from basic concepts to advanced applications, featuring code examples, detailed tutorials, and full applications. Whether you're new to LangGraph or looking to deepen your expertise, this resource will guide you through effective LangGraph implementation.
- Python 3.9+
- Ollama (for running local models)
- Basic understanding of LLMs and Python
- OpenAI API key (optional, for OpenAI models)
-
Clone this repository:
git clone https://github.com/yourusername/LangGraph_101.git cd LangGraph_101
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up your environment variables (if needed):
cp .env.example .env # Edit .env with your API keys and configuration
The repository is organized into several key sections to facilitate a clear learning progression:
Get started with the fundamentals of LangGraph:
- 01-LangGraph_Basics.ipynb: Interactive Jupyter notebook introduction to core concepts.
- 01.1-graph_basics.py: A basic three-step linear graph example.
- 02-langgraph_connecting_llms.py: Demonstrates connecting various LLM providers.
Explore core LangGraph concepts and graph-based workflows:
- 03-Graph_Basics: Fundamental graph structures and state management.
- 04-Multiple_Inputs: Working with various input types within graphs.
- 05-Conditional_Routing: Implementing decision logic within graphs.
- 06-Looping_Logic: Creating loops and recursive patterns.
- 07-Basic_Chat_Graph: Building a complete chat application.
Dive into advanced agent implementations and patterns:
- 01-Running_Agents: Basic agent setup and execution.
- 02-Agent-State: Managing complex agent state.
- 02-Streaming: Implementing streaming responses.
- 03-Models: Working with different LLM providers.
- 04-Tools-v2: Advanced tool usage and integration.
- 05-MCP: Multi-agent coordination patterns.
- 06-Context: Context management strategies.
- 07-Memory: Implementing agent memory.
- 08-Human_in_the_Loop: Human intervention patterns.
- 09-Advanced-Agent-Examples-v2: Complex agent implementations.
- 09-Multi_Agent: Multi-agent systems.
- 10-RAG_Agent: Retrieval-Augmented Generation agents.
Explore complete real-world application examples:
- 01-LangGraph_Stock_Agent: Financial data analysis.
- 01-Travel_Planning_Agent: Trip planning assistant.
- 02-Finance_Investment_Agent: Investment advisory system.
- 03-Customer_Support_Agent: Customer service automation.
- 04-Medical_Appointment_Scheduler_Agent: Healthcare scheduling.
- 05-Smart_Home_Automation_Agent: IoT control system.
- 06-Developer_Assistant_Agent: Code assistance and review.
- 07-Legal_Document_Analyzer_Agent: Legal document processing.
- 08-Content_Creation_Pipeline_Agent: Content generation workflow.
- 09-Research_Summarization_Agent: Academic research assistant.
- 10-Personalized_Health_Fitness_Planner_Agent: Health and fitness planning.
- 11-E-commerce_Recommendation_Agent: Product recommendation system.
- 12-Interactive_Storyteller_Agent: Creative storytelling assistant.
This example demonstrates the fundamental structure of a LangGraph StateGraph
.
from langgraph.graph import StateGraph
from typing import TypedDict, List
# Define your state
class WorkflowState(TypedDict):
user_input: str
steps: List[str]
# Create a node function
def start_node(state: WorkflowState) -> dict:
return {"steps": ["started"]}
# Build the graph
builder = StateGraph(WorkflowState)
builder.add_node("start", start_node)
builder.set_entry_point("start")
builder.set_finish_point("start")
app = builder.compile()
This snippet illustrates how to initialize an LLM for use in a LangGraph application. See the complete example in 01-Graphs/07-Basic_Chat_Graph/
for full details.
from langgraph.graph import StateGraph
from langchain_litellm import ChatLiteLLM
# Initialize LLM
llm = ChatLiteLLM(
model="ollama/qwen3:0.6b",
api_base="http://localhost:11434",
temperature=0.7,
)
# ... (see complete example in 01-Graphs/07-Basic_Chat_Graph/)
This repository demonstrates integration with various LLM providers, offering flexibility for your projects:
- Ollama (local models): Examples include
llama3.2
,qwen3
,deepseek-r1
. - OpenAI: Supports models like
gpt-4o-mini
,gpt-4
. - OpenRouter: Integrates with various models, including
google/gemma-3-27b-it
. - LiteLLM: Provides a unified interface for multiple providers.
Key dependencies for this project include:
langgraph~=0.4.7
: The core graph framework.langchain-core~=0.3.59
: Foundation for LangChain integration.langchain-openai~=0.3.11
: For seamless OpenAI integration.litellm~=1.67.4
: A versatile multi-provider LLM interface.rich~=14.0.0
: For enhanced terminal output.yfinance~=0.2.61
: Used for financial data in stock agent examples.
For a complete list, please refer to the requirements.txt
file.
We recommend the following learning progression:
- Start with Basics: Begin with
01-LangGraph_Intro
to grasp core concepts. - Explore Graphs: Work through the examples in
01-Graphs
to master graph structures. - Build Agents: Progress to
02-Agents
for advanced agent patterns and implementations. - Create Applications: Apply your knowledge with the real-world examples in
03-Apps
.
For development and testing, follow these steps:
# Install in development mode
pip install -e .
# Run with a specific Python version (e.g., Python 3.11)
python3.11 -m pip install -r requirements.txt
# Use with Jupyter notebooks
jupyter notebook 01-LangGraph_Intro/01-LangGraph_Basics.ipynb
Many examples within this repository include graph visualization, typically generated as .png
and .mermaid
files in their respective directories. This helps in understanding the flow and structure of the LangGraph applications.
Contributions are highly encouraged and welcome! Please feel free to submit pull requests or open issues for:
- New example applications.
- Bug fixes and general improvements.
- Documentation enhancements.
- Additional LLM provider integrations.
This project is licensed under the MIT License - see the LICENSE file for details.