Skip to main content

LangGraph Ollama Local

Learn LangGraph by building agents that run entirely on your hardware.

Python 3.12+ License: MIT


What This Is

A hands-on tutorial series for building LangGraph agents with local LLMs via Ollama. Each notebook teaches a concept from scratch - no cloud APIs required.

You'll learn:

  • LangGraph fundamentals: StateGraph, nodes, edges, reducers
  • Tool calling and the ReAct pattern
  • Memory and conversation persistence
  • Human-in-the-loop workflows
  • Self-reflection and critique patterns
  • RAG patterns: Basic RAG, Self-RAG, CRAG, Adaptive RAG, Agentic RAG
  • Build a Perplexity-style research assistant

Quick Start

Prerequisites

  1. Python 3.12+
  2. Ollama running locally or on your LAN:
    # Install Ollama
    curl -fsSL https://ollama.ai/install.sh | sh
    
    # Pull a model
    ollama pull llama3.2:3b
    

Installation

git clone https://github.com/AbhinaavRamesh/langgraph-ollama-tutorial.git
cd langgraph-ollama-tutorial

# Install with RAG dependencies
pip install -e ".[all]"

# Verify connection
langgraph-local check

Configuration

cp .env.example .env
# Edit .env with your settings
Variable Default Description
OLLAMA_HOST 127.0.0.1 Ollama server address
OLLAMA_PORT 11434 Ollama server port
OLLAMA_MODEL llama3.2:3b Default model
TAVILY_API_KEY (optional) For web search in CRAG tutorials

Web Search Setup (Optional)

For CRAG and Perplexity-style tutorials, get a free Tavily API key:

  1. Sign up at https://tavily.com
  2. Get your API key from the dashboard
  3. Add to .env:
    TAVILY_API_KEY=tvly-your-key-here
    

LAN Server with Monitoring

To host Ollama on a GPU machine accessible across your network, use ollama-local-serve:

pip install ollama-local-serve[all]
make init && make up
# Dashboard at http://your-server:3000

Tutorials

Core Patterns (Phase 2)

# Notebook Documentation What You'll Learn
01 Chatbot Basics docs StateGraph, nodes, edges, message handling
02 Tool Calling docs Tools, ReAct loop from scratch
03 Memory & Persistence docs Checkpointers, threads, conversation history
04 Human-in-the-Loop docs Interrupts, approvals, resume
05 Reflection docs Generate, Critique, Revise loops
06 Plan & Execute docs Structured outputs, multi-step planning
07 Research Assistant docs Capstone: all patterns combined

RAG Patterns (Phase 3)

# Notebook Documentation What You'll Learn
08 Basic RAG docs Document loading, chunking, embeddings, ChromaDB
09 Self-RAG docs Document grading, hallucination detection, retry loops
10 CRAG docs Web search fallback, corrective retrieval
11 Adaptive RAG docs Query classification, strategy routing
12 Agentic RAG docs Agent-controlled retrieval, multi-step
13 Perplexity Clone docs Citations, source metadata, follow-ups

Run any notebook:

jupyter lab examples/

RAG Quick Start

Index your documents and start querying:

from langgraph_ollama_local.rag import DocumentIndexer, LocalRetriever

# Index documents
indexer = DocumentIndexer()
indexer.index_directory("sources/")

# Query
retriever = LocalRetriever()
docs = retriever.retrieve_documents("What is Self-RAG?", k=4)

Project Structure

langgraph-ollama-tutorial/
├── examples/
│   ├── core_patterns/          # Tutorials 01-07
│   │   ├── 01_chatbot_basics.ipynb
│   │   └── ...
│   └── rag_patterns/           # Tutorials 08-13
│       ├── 08_basic_rag.ipynb
│       └── ...
├── docs/
│   ├── core_patterns/          # Core pattern documentation
│   └── rag_patterns/           # RAG pattern documentation
├── sources/                    # PDF sources for RAG indexing
├── langgraph_ollama_local/
│   ├── config.py               # Configuration
│   ├── cli.py                  # CLI tools
│   └── rag/                    # RAG infrastructure
│       ├── embeddings.py       # Local embeddings
│       ├── indexer.py          # Document indexing
│       ├── retriever.py        # Document retrieval
│       └── graders.py          # Quality graders
├── tests/                      # Test suite
└── pyproject.toml

CLI

langgraph-local check    # Verify Ollama connection
langgraph-local config   # Show current configuration
langgraph-local list     # List available examples

Development

make test          # Run tests
make test-int      # Integration tests (requires Ollama)
make lint          # Linting
make format        # Format code

Adapted From

These tutorials are adapted from the official LangGraph documentation (MIT License), optimized for local Ollama deployment.

License

MIT License

Metadata

Release files for langgraph-ollama-local 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langgraph-ollama-local 0.1.0
File Size Uploaded
langgraph_ollama_local-0.1.0.tar.gz 120.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langgraph-ollama-local 0.1.0
File Interpreter ABI Platform
langgraph_ollama_local-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 216.1 kB

Release files / langgraph_ollama_local-0.1.0.tar.gz

Download URL langgraph_ollama_local-0.1.0.tar.gz
Size 120.8 kB
Tags Source
SHA-256 checksum
How to use checksums
170a7761aa1b07ddbf8f9e1b9815fb8424c4578b8c57d869339121beeadab8cd
BLAKE2b-256 checksum
How to use checksums
1a143bbfe55820a7ddd63929b1cc152b017b1f5ba0dbca3f7a7f2523aaf4b031
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / langgraph_ollama_local-0.1.0-py3-none-any.whl

Download URL langgraph_ollama_local-0.1.0-py3-none-any.whl
Size 95.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
923b5c8eed5b1daca34e92e0e5a5ba80a1d13c9509c72e08c6fd08257d529aa1
BLAKE2b-256 checksum
How to use checksums
dc17227a22f0d8d1e2da125847ff652ba4b047a5f4b84bcdec97c3afde1d4566
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page