Skip to content

sathiya-22/self-correcting-rag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Self-Correcting RAG

A powerful, production-ready Retrieval-Augmented Generation (RAG) system built with LangGraph, Gemini, and Streamlit. This project features a self-correction loop that grades document relevance and fallbacks to web search when information is missing.


🚀 Key Features

  • Self-Correction Architecture: Uses LangGraph to grade retrieved documents and automatically trigger web search if context is insufficient.
  • Conversational Memory: Maintains the last 5 turns of conversation for seamless follow-up questions.
  • Multi-Query Retrieval: Automatically generates variations of your question to improve context coverage.
  • Quota Optimized: Implements Batch Grading and defaults to Gemini 3.1 Flash Lite to save 80%+ of API quota.
  • Modern Web UI: A beautiful Streamlit interface with live "reasoning" logs and file upload support.
  • Full Citations: Every answer includes metadata-backed citations from your documents.

🛠️ Tech Stack


📦 Getting Started

1. Clone the repository

git clone https://github.com/sathiya-22/self-correcting-rag.git
cd self-correcting-rag

2. Set up environment variables

Create a .env file in the root directory:

GOOGLE_API_KEY=your_gemini_key
TAVILY_API_KEY=your_tavily_key

# Optional: Override default models
# MODEL_GRADER=gemini-3.1-flash-lite-preview
# MODEL_GENERATOR=gemini-3.1-flash-lite-preview

3. Install dependencies

# Recommended: use a virtual environment
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

4. Run the application

streamlit run app.py

📂 Project Structure

  • app.py: Streamlit web interface.
  • graph/: Core LangGraph logic (nodes, edges, state).
  • ingest.py: Document processing and vector ingestion.
  • knowledge_base/: Drop your PDFs/DOCX files here.
  • chroma_db/: Local vector storage.

🛡️ License

MIT License. Free for personal and commercial use.

About

A LangGraph-powered Self-Correcting RAG system with Gemini, Tavily, and Streamlit. Features multi-query retrieval, batch grading, and conversational memory.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages