How lehen20/agentic-rag works
Project type and purpose
• This is an Agentic Retrieval-Augmented Generation (RAG) system built in Python.
• It ingests PDFs, embeds them, stores embeddings in LanceDB, retrieves relevant chunks at query time, runs an LLM agent (via Ollama + LangGraph) with tool use and grading, and exposes a Gradio frontend.
File structure
• Top-level:
• config/ – application settings (settings.yml)
• db/ – connectors for LanceDB and Redis cache
• docs/ – input PDF knowledge base
• models/ – wrapper around Ollama LLaMA3.1 (“ollama_model.py”)
• pipeline/ – core agent graph and step definitions (agent.py, graph.py, steps.py, retriever_tools.py)
• prompts/ – prompt templates for retrieval, grading and final generation
• src/ – utility modules (pdf_loader.py, embeddings.py)
• main.py – orchestrates startup: loads config, spins up Gradio UI, initializes pipeline
• flow.psql – sample DB schema for relational storage if used
• requirements.txt and .gitignore round out dependencies and ignored files.
Key insights from the README
• Tech stack: LangGraph + LangChain for agent orchestration, LanceDB for vector store, Redis for LLM caching, Ollama for LLM, Gradio for UI.
• Flow: PDF ingestion → chunking → embedding → storage → retrieval → agent decision → grading → generation → UI.
Final advice
• Every major module: config, db clients, pipeline steps, prompt templates, model wrappers, and main startup.
• Don’t over-complicate—represent each Python module or directory as its own component if it has unique responsibilities.