SkillAgentSearch skills...

Agentic Rag For Dummies

A modular Agentic RAG built with LangGraph — learn Retrieval-Augmented Generation Agents in minutes.

Install / Use

npx skills add GiovanniPasq/agentic-rag-for-dummies

Installs into whichever agent you are using.

README

<p align="center"> <img alt="Agentic RAG for Dummies Logo" src="assets/logo.png" width="350px"> </p> <h1 align="center">Agentic RAG for Dummies</h1> <p align="center"> <strong>Build a modular Agentic RAG system with LangGraph, conversation memory, and human-in-the-loop query clarification</strong> </p> <p align="center"> <a href="#overview">Overview</a> • <a href="#how-it-works">How It Works</a> • <a href="#llm-provider-configuration">LLM Providers</a> • <a href="#implementation">Implementation</a> • <a href="#installation--usage">Installation & Usage</a> • <a href="#troubleshooting">Troubleshooting</a> </p> <p align="center"> <img src="https://img.shields.io/github/stars/GiovanniPasq/agentic-rag-for-dummies?style=social" alt="GitHub Stars"/> <img src="https://img.shields.io/github/forks/GiovanniPasq/agentic-rag-for-dummies?style=social" alt="GitHub Forks"/> <img src="https://img.shields.io/badge/license-MIT-green" alt="License"/> <a href="https://github.com/von-development/awesome-langgraph"> <img src="https://awesome.re/badge.svg" alt="Awesome LangGraph"/> </a> </p> <p align="center"> <img src="https://img.shields.io/badge/python-3.11%2B-blue?logo=python&logoColor=white" alt="Python"/> <img src="https://img.shields.io/badge/LangGraph-1.2%2B-orange?logo=langchain&logoColor=white" alt="LangGraph"/> <img src="https://img.shields.io/badge/Qdrant-vector%20db-DC244C" alt="Qdrant"/> <img src="https://img.shields.io/badge/LLM%20Providers-Ollama%20%7C%20OpenAI%20%7C%20Anthropic%20%7C%20Google-purple" alt="LLM Providers"/> </p> <p align="center"> <a href="https://colab.research.google.com/github/GiovanniPasq/agentic-rag-for-dummies/blob/main/notebooks/agentic_rag.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a> </p> <p align="center"> <img alt="Agentic RAG Demo" src="assets/demo.gif" width="650px"> </p> <p align="center"> <strong>If you like this project, a star ⭐️ would mean a lot :)</strong><br> </p>

Overview

This repository demonstrates how to build an Agentic RAG (Retrieval-Augmented Generation) system using LangGraph with minimal code. Most RAG tutorials show basic concepts but lack guidance on building modular, agent-driven systems — this project bridges that gap by providing both learning materials and an extensible architecture.

What's inside

| Feature | Description | |---|---| | 🗂️ Hierarchical Indexing | Search small chunks for precision, retrieve large Parent chunks for context | | 🧠 Conversation Memory | Maintains context across questions for natural dialogue | | ❓ Query Clarification | Rewrites ambiguous queries or pauses to ask the user for details | | 🤖 Agent Orchestration | LangGraph coordinates the full retrieval and reasoning workflow | | 🔀 Multi-Agent Map-Reduce | Decomposes complex queries into parallel sub-queries | | ✅ Self-Correction | Re-queries automatically if initial results are insufficient | | 🗜️ Context Compression | Keeps working memory lean across long retrieval loops | | 🔍 Observability | Track LLM calls, tool usage, and graph execution with Langfuse | | 📊 Evaluation | Evaluate retrieval and answer quality with RAGAS metrics |

🎯 Two Ways to Use This Repo

1️⃣ Learning Path: Interactive Notebook

Step-by-step tutorial perfect for understanding core concepts. Start here if you're new to Agentic RAG or want to experiment quickly.

2️⃣ Building Path: Modular Project

Flexible architecture where each component can be independently adapted — LLM provider, embedding model, PDF converter, and agent workflow. The runnable app is Ollama-first, and it can be adapted to any chat model provider supported by LangChain. Examples are included for Anthropic, OpenAI, and Google.

See Modular Architecture and Installation & Usage to get started.

How It Works

Document Preparation: Hierarchical Indexing

Before queries can be processed, documents are split twice for optimal retrieval:

  • Parent Chunks: Bounded large sections based on Markdown headers (H1, H2, H3)
  • Child Chunks: Small, fixed-size pieces derived from parents

Optional: 🐿️ Chunky is an open-source toolkit for reliable RAG pipelines: convert PDFs to Markdown, clean documents, inspect chunks, compare chunking strategies, and enrich metadata before building the vector store.

This combines the precision of small chunks for search with the contextual richness of large chunks for answer generation.


Query Processing: Four-Stage Intelligent Workflow

User Query → Conversation Summary → Query Rewriting → Query Clarification →
Parallel Agent Reasoning → Aggregation → Final Response

Stage 1 — Conversation Understanding: Maintains a rolling summary and recent conversation history to preserve continuity without indefinitely increasing context size.

Stage 2 — Query Clarification: Resolves references ("How do I update it?" → "How do I update SQL?"), splits multi-part questions into focused sub-queries, detects unclear inputs, and rewrites queries for optimal retrieval. Pauses for human input when clarification is needed.

Stage 3 — Intelligent Retrieval (Multi-Agent Map-Reduce): Spawns parallel agent subgraphs — one per sub-query. Each agent searches child chunks, fetches parent chunks for context, self-corrects if results are insufficient, compresses context to avoid redundant fetches, and falls back gracefully if the search budget is exhausted.

Example: "What is JavaScript? What is Python?" → 2 parallel agents execute simultaneously.

Stage 4 — Response Generation: Aggregates all agent responses into a single coherent answer.


LLM Provider Configuration

This system is provider-agnostic: the runnable app uses Ollama by default, and the chat model initialization can be adapted to any LLM provider available in LangChain. The examples below cover the most common options, but the same pattern applies to any other supported provider.

Note: Model names change frequently. Always check the official documentation for the latest available models and their identifiers before deploying.

Ollama (Local)

# Install Ollama from https://ollama.com
ollama pull granite4.1:8b
from langchain_ollama import ChatOllama

llm = ChatOllama(model="granite4.1:8b", temperature=0, seed=42)

⚠️ For reliable tool calling and instruction following, prefer models 8B+. Smaller models may ignore retrieval instructions or hallucinate. See Troubleshooting.


Cloud Providers

<details> <summary>Click to expand</summary>

OpenAI GPT:

pip install -qU langchain-openai
from langchain_openai import ChatOpenAI
import os

os.environ["OPENAI_API_KEY"] = "your-api-key-here"
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)

Anthropic Claude:

pip install -qU langchain-anthropic
from langchain_anthropic import ChatAnthropic
import os

os.environ["ANTHROPIC_API_KEY"] = "your-api-key-here"
llm = ChatAnthropic(model="claude-sonnet-4-5-20250929", temperature=0)

Google Gemini

pip install -qU langchain-google-genai
import os
from langchain_google_genai import ChatGoogleGenerativeAI

os.environ["GOOGLE_API_KEY"] = "your-api-key-here"
llm = ChatGoogleGenerativeAI(model="gemini-2.5-flash", temperature=0)
</details>

Implementation

Additional details, extended explanations, and Langfuse observability are available in the notebook and full project. The companion evaluation notebook scores the final answers and the actual child/parent tool outputs used by the agent with direct RAGAS metric calls.

| Step | Description | |------|-------------| | 1 | Initial Setup and Configuration | | 2 | Configure Vector Database | | 3 | PDFs to Markdown | | 4 | Hierarchical Document Indexing | | 5 | Define Agent Tools | | 6 | Define System Prompts | | 7 | Define State and Data Models | | 8 | Agent Configuration | | 9 | Build Graph Node and Edge Functions | | 10 | Build the LangGraph Graphs | | 11 | Create Chat Interface |

Step 1: Initial Setup and Configuration

Define paths and initialize core components.

import os
from pathlib import Path
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_qdrant.fastembed_sparse import FastEmbedSparse
from qdrant_client import QdrantClient

DOCS_DIR = "docs"  # Directory containing your pdf files
MARKDOWN_DIR = "markdown_docs" # Directory containing the pdfs converted to markdown
PARENT_STORE_PATH = "parent_store"  # Directory for parent chunk JSON files
CHILD_COLLECTION = "document_child_chunks"
DEFAULT_RETRIEVAL_K = 7
CHILD_CHUNK_SEPARATOR = "\n\n<CHILD_CHUNK_BOUNDARY>\n\n"

os.makedirs(DOCS_DIR, exist_ok=True)
os.makedirs(MARKDOWN_DIR, exist_ok=True)
os.makedirs(PARENT_STORE_PATH, exist_ok=True)

from langchain_ollama import ChatOllama
llm = ChatOllama(model="granite4.1:8b", temperature=0, seed=42)

dense_embeddings = HuggingFaceEmbeddings(model_name="Qwen/Qwen3-Embedding-0.6B")
sparse_embeddings = FastEmbedSparse(model_name="Qdrant/bm25")

client = QdrantClient(path="qdrant_db")

Step 2: Configure Vector Database

Set up Qdrant to store child chunks with hybrid search capabilities.

fro

Related Skills

View on GitHub
GitHub Stars3.9k
CategoryCustomer
Updated5h ago
Forks494

Languages

Jupyter Notebook

Security Score

100/100

Audited on Aug 7, 2026

No findings