{"slug": "practical-agentic-rag-patterns-implemented-with-langgraph", "title": "Practical Agentic RAG patterns implemented with LangGraph", "summary": "Developer Chandula7 released a free demo Jupyter notebook, 1_Agentic_RAG.ipynb, the first of four self-contained notebooks implementing distinct agentic Retrieval-Augmented Generation (RAG) patterns with LangGraph. The series covers Agentic RAG, Corrective RAG (CRAG), Adaptive RAG, and Human-in-the-Loop RAG, with the full set available via Gumroad and the notebooks requiring Python 3.11+, uv, a Groq API key, and a Tavily API key for the Corrective and Adaptive patterns.", "body_md": "Four self-contained Jupyter notebooks, each implementing a different way of making a Retrieval-Augmented Generation (RAG) pipeline \"agentic\" — able to decide, check itself, correct its own mistakes, or defer to a person, instead of blindly retrieving once and answering.\n\n| Notebook | Pattern | What makes it agentic | \n|---|---|---|\n| [`1_Agentic_RAG.ipynb`](https://chandula7.gumroad.com/l/AgenticRAGFundamentals)**(free demo)** | Agentic RAG | An LLM agent decides *whether* to retrieve at all, and*which* of two knowledge bases to search, using tool calling. | \n| [`2_Corrective_RAG.ipynb`](https://chandula7.gumroad.com/l/Advanced_RAG_LangGraph_Patterns) | Corrective RAG (CRAG) | Always retrieves first, then grades what it got — and automatically falls back to a live web search if the local documents aren't good enough. | \n| [`3_Adaptive_RAG.ipynb`](https://chandula7.gumroad.com/l/Advanced_RAG_LangGraph_Patterns) | Adaptive RAG | Routes each question to a vectorstore or the web *before* retrieving, then grades both the documents*and* the final answer (hallucination + relevance checks) before returning it. | \n| [`4_Human_in_the_Loop_RAG.ipynb`](https://chandula7.gumroad.com/l/Advanced_RAG_LangGraph_Patterns) | Human-in-the-Loop RAG | Takes the same retrieve/grade/generate machinery and replaces the automatic loop-decisions with a person: the graph pauses after retrieval and after generation, shows the LLM's grades as advisory suggestions only, and waits for a human to approve, request a revision, or send it back. | \n\nEach notebook is fully commented with markdown cells explaining what every step does and why — you don't need to already know LangGraph to follow along.\n\n**This is the free demo notebook** (`1_Agentic_RAG.ipynb`). The full series — including\nCorrective RAG, Adaptive RAG, and Human-in-the-Loop RAG — is available here:\n[Agentic RAG — Four Working Patterns with LangGraph](https://chandula7.gumroad.com/l/Advanced_RAG_LangGraph_Patterns)\n\nThey sit on a spectrum of how much a RAG pipeline second-guesses itself — and who gets the final say:\n\n- **Agentic RAG** — the retrieval decision itself is delegated to the LLM.\n- **Corrective RAG** — retrieval always happens, but the*result* is checked and\ncorrected with a web-search fallback.\n- **Adaptive RAG** — adds routing at the front (vectorstore vs. web)*and* a second\nself-check at the very end, on the generated answer itself.\n- **Human-in-the-Loop RAG** — keeps the same grading/self-check machinery as Adaptive\nRAG, but the LLM's verdicts stop being routing decisions and become suggestions: a\nreal person approves, revises, or rejects at two checkpoints using LangGraph's`interrupt` /`Command(resume=...)` pattern with a`MemorySaver` checkpointer.\n\nUnderstanding all four, and where each one is worth the extra complexity, is more useful than knowing just one.\n\n- [VS Code](https://code.visualstudio.com/) with the Python and Jupyter extensions\n- Python 3.11+\n- [uv](https://docs.astral.sh/uv/) — a fast, single-binary Python package/environment\nmanager. It replaces`pip` +`venv` with one tool and one lockfile.\n- A [Groq](https://console.groq.com/keys) API key (free tier available) — used by all\nfour notebooks as the LLM.\n- A [Tavily](https://app.tavily.com) API key (free tier available) — used by the\nCorrective RAG and Adaptive RAG notebooks for live web search. Not needed for\nAgentic RAG or Human-in-the-Loop RAG.\n\nPick whichever matches your setup — you only need one of these.\n\n**macOS / Linux:**\n\n```\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n```\n\n**Windows (PowerShell):**\n\n```\npowershell -c \"irm https://astral.sh/uv/install.ps1 | iex\"\n```\n\n**Already have Python + pip and prefer not to run an install script:**\n\n```\npip install uv\n```\n\n**Other options** (Homebrew, `pipx`, `winget`, `cargo`, standalone downloads) are listed\nin the [official install docs](https://docs.astral.sh/uv/getting-started/installation/).\n\nCheck it worked:\n\n```\nuv --version\n```\n\nFrom the project folder:\n\n```\n# Creates a .venv and installs every dependency from pyproject.toml,\n# pinned exactly via uv.lock, in one step.\nuv sync\n\n# Register the environment as a Jupyter kernel.\nuv run python -m ipykernel install --user --name agentic-rag\n```\n\nCopy the env template and add your API keys:\n\n**macOS / Linux:**\n\n```\ncp .env.example .env\n```\n\n**Windows (Command Prompt):**\n\n```\ncopy .env.example .env\n```\n\n**Windows (PowerShell):**\n\n```\nCopy-Item .env.example .env\n```\n\nOpen `.env` and fill in `GROQ_API_KEY` and `TAVILY_API_KEY`.\n\n1. Install the [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) and[Jupyter](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter) extensions in VS Code, if you don't already have them.\n2. Open the project folder in VS Code (`File > Open Folder...` ).\n3. Open any of the four `.ipynb` files.\n4. In the top-right of the notebook, click **Select Kernel** and choose the**agentic-rag** kernel you registered above (it may show as`.venv (Python 3.11)` —\npick the one whose path points at this project's`.venv` ).\n5. Run the cells top to bottom with the ▶ buttons, or **Run All** .\n\nThat's the whole setup — no manually creating a virtualenv, no separate `pip install -r requirements.txt` step, and `uv.lock` means everyone who runs `uv sync` gets the exact\nsame dependency versions you tested with.\n\n**Kernel is selected per notebook, not per project.** VS Code remembers a separate\nkernel choice for each `.ipynb` file, so it's easy to open a second notebook and have\nit silently fall back to your global Python install instead of this project's\n`.venv` — especially if the `.venv` kernel hasn't been used in that notebook before.\nIf one notebook runs fine but another throws import errors for packages this project\nclearly installs (e.g. `chromadb`, `langchain_chroma`), that's the first thing to\ncheck: open the kernel picker for the failing notebook and confirm the path points\ninto this project's `.venv`, not `AppData\\Local\\Programs\\Python\\...` or any other\nsystem/global install.\n\n**`1_Agentic_RAG.ipynb`** scrapes the LangGraph and LangChain documentation into two\nseparate Chroma vector stores, wraps each as a retriever tool, and gives both tools to a\ntool-calling agent. The agent decides per question whether to call a tool, which one,\nand whether the retrieved documents are good enough to answer from or need a rewritten\nquery.\n\n**`2_Corrective_RAG.ipynb`** indexes a small set of blog posts on AI agents into one\nvector store. Every question always retrieves from it; a grading step then checks each\nretrieved chunk for relevance. If nothing relevant comes back, the question is rewritten\nfor web search and Tavily fills the gap before the answer is generated.\n\n**`3_Adaptive_RAG.ipynb`** builds on the same idea but adds a router at the very start\n(should this question go to the vectorstore or straight to the web?) and two more graders\nat the very end, checking that the generated answer is actually grounded in the\nretrieved documents and actually answers the question — looping back to retry if either\ncheck fails.\n\n**`4_Human_in_the_Loop_RAG.ipynb`** takes the retrieve/grade/generate/self-check\nmachinery from the Adaptive RAG notebook and puts a person in charge of the two\ndecisions that used to be automatic:\n\n- After retrieval, each document is graded for relevance as before, but the grade is shown to a human as a suggestion only — the human decides whether to proceed to generation or reject and have the question rewritten and re-retrieved.\n- After generation, the two self-checks (grounded-in-documents, addresses-the-question) are shown for reference, but the human has the final call: approve, ask for a revision with their own feedback, or send it back to retrieval.\n\nMechanically, this runs on LangGraph's current recommended HITL pattern: `interrupt(payload)`\ncalled inside a node pauses the graph and surfaces `payload` to whoever is running it;\nresuming happens with `graph.stream(Command(resume=...), config)`, and a `MemorySaver`\ncheckpointer persists the graph's state while it's paused. All branching still goes\nthrough plain `add_conditional_edges` rather than `Command(goto=...)`, so every routing\ndecision lives in one place. This notebook only needs `GROQ_API_KEY` — it doesn't call\nTavily.\n\n- Embeddings run locally via `sentence-transformers` (`BAAI/bge-m3` ) — no embedding API\nkey needed.\n- Vector data is written to a local Chroma store at runtime and is not committed to the\nrepo (`chroma/` is gitignored).\n- These notebooks scrape live documentation pages and blog posts at run time, so results will vary slightly as those pages change.\n\n`1_Agentic_RAG.ipynb` is a free demo — use it, share it, redistribute it. The other\nthree notebooks are a paid, personal-use resource — see `LICENSE.md`. In short: use\nthem, learn from them, build on them, but don't resell or redistribute the notebooks\nthemselves.\n\nGet the full bundle here:\n[Agentic RAG — Four Working Patterns with LangGraph](https://chandula7.gumroad.com/l/Advanced_RAG_LangGraph_Patterns)", "url": "https://wpnews.pro/news/practical-agentic-rag-patterns-implemented-with-langgraph", "canonical_source": "https://github.com/ChandulaSenevirathna/Agentic_RAG", "published_at": "2026-09-10 07:19:46+00:00", "updated_at": "2026-09-10 07:53:31.084037+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "large-language-models", "developer-tools", "ai-products"], "entities": ["Chandula7", "LangGraph", "Agentic RAG", "Corrective RAG", "Adaptive RAG", "Human-in-the-Loop RAG", "Groq", "Tavily"], "alternates": {"html": "https://wpnews.pro/news/practical-agentic-rag-patterns-implemented-with-langgraph", "markdown": "https://wpnews.pro/news/practical-agentic-rag-patterns-implemented-with-langgraph.md", "text": "https://wpnews.pro/news/practical-agentic-rag-patterns-implemented-with-langgraph.txt", "jsonld": "https://wpnews.pro/news/practical-agentic-rag-patterns-implemented-with-langgraph.jsonld"}}