Skip to content

RAG Assistant is an AI-powered tool that lets you upload documents, process them into a ChromaDB vector store, and ask natural language questions. It retrieves precise answers with cited sources for reliability.

License

Notifications You must be signed in to change notification settings

ak-rahul/RAG-Assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RAG Assistant

Python Streamlit LangChain ChromaDB License: MIT

A Retrieval-Augmented Generation (RAG) assistant for interactive document-based Question Answering.
Upload PDFs, DOCX, TXT, Markdown, or JSON files, and interact with them via Streamlit UI, CLI, or FastAPI API.


πŸš€ Features

  • πŸ“‚ Multi-format ingestion: PDF, DOCX, TXT, MD, JSON
  • βœ‚οΈ Smart text splitting with overlapping chunks
  • 🧠 Vector embeddings using SentenceTransformers
  • πŸ—‚ ChromaDB persistence for long-term storage
  • πŸ€– LLM providers: Groq & OpenAI
  • πŸ–₯ Multiple interfaces: Streamlit UI, CLI, FastAPI
  • πŸ“ Config-driven via config.yaml
  • πŸ”Ž Source citation for transparency

⚑ Quick Start (5 Minutes)

  1. Clone and Install
git clone https://github.com/ak-rahul/RAG-Assistant.git
cd RAG-Assistant
pip install -r requirements.txt
  1. Set API Key
echo "GROQ_API_KEY=your_key_here" > .env

πŸ’‘ Get free key at: https://console.groq.com/

  1. Run the App
python cli.py web
  1. Try the Sample
  • We included data/sample.txt to get started
  • Ask: "What is RAG?" or "List the benefits"
  • Upload your own documents and explore!

πŸ“š More examples in examples/


πŸ“Έ Screenshots

Upload Documents Upload and process documents

Ask Questions Get answers with cited sources


πŸ“‚ Project Structure

rag-assistant/
β”‚
β”œβ”€β”€ app.py                 # Streamlit UI
β”œβ”€β”€ cli.py                 # CLI entrypoint
β”œβ”€β”€ config.yaml            # Config file
β”œβ”€β”€ requirements.txt       # Dependencies
β”œβ”€β”€ scripts/               # Helper scripts
β”‚   β”œβ”€β”€ rag.sh 
β”‚   └── rag.bat
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config.py
β”‚   β”œβ”€β”€ logger.py
β”‚   β”œβ”€β”€ server.py          # FastAPI app
β”‚   β”œβ”€β”€ pipeline/
β”‚   β”‚   └── rag_pipeline.py
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   └── chroma_handler.py
β”‚   β”œβ”€β”€ ingestion/
β”‚   β”‚   └── ingest.py
β”‚   └── utils/
β”‚       β”œβ”€β”€ file_loader.py
β”‚       └── text_splitter.py
β”‚
β”œβ”€β”€ data/                  # Uploaded docs
β”œβ”€β”€ logs/                  # Logs
└── README.md

βš™οΈ Configuration

config.yaml controls everything:

data:
  source_dir: "./data"
  allowed_ext: [".pdf", ".docx", ".txt", ".md", ".json"]

vector_store:
  persist_directory: "./.chroma"
  embedding_model: "sentence-transformers/all-MiniLM-L6-v2"
  top_k: 4

ingestion:
  chunk_size: 1200
  chunk_overlap: 150

llm:
  provider: groq
  model: llama-3.1-8b-instant 
  temperature: 0.2
  max_tokens: 512

πŸ”‘ Environment overrides via .env:

GROQ_API_KEY=...
OPENAI_API_KEY=...

πŸ“‹ Prerequisites

  • Python 3.9 or higher [attached_file:1][attached_file:2]
  • Groq API key (free tier available at console.groq.com)
  • 2GB disk space for vector embeddings
  • (Optional) OpenAI API key for alternative LLM

βš™οΈ Setup

1. Clone the Repository

git clone https://github.com/ak-rahul/rag-assistant.git
cd rag-assistant

2. Create Virtual Environment

python -m venv .venv
source .venv/bin/activate   # (Linux/Mac)
.venv\Scripts\activate      # (Windows)

3. Install Dependencies

pip install -r requirements.txt

4. Configure Environment

Create a .env file in the project root:

GROQ_API_KEY=your_groq_api_key
OPENAI_API_KEY=your_openai_api_key   # optional

πŸ–₯ Usage

Web UI

Launch the Streamlit UI:

python cli.py web
  • Upload documents in the sidebar

  • Ask questions in the chat interface

  • Inspect DB stats or clear DB

CLI

Ingest Documents

python cli.py ingest

Query

python cli.py query "What is Kali Linux?"

Run API Server

python cli.py serve

Show DB Stats

python cli.py stats

Clear DB

python cli.py clear

🧩 Architecture

flowchart TD
    A[User Uploads Files] --> B[File Loader]
    B --> C[Text Splitter]
    C --> D[ChromaDB Vector Store]
    D --> E[Retriever]
    E --> F[LLM via Groq/OpenAI]
    F --> G[Answer + Sources]
Loading

🧾 Example Workflow

  • Upload a PDF in the Streamlit sidebar
  • The file is chunked and ingested into ChromaDB
  • Ask a question like:
    • "What is covered in Chapter 2 of the Kali Linux PDF?"
  • The system retrieves relevant chunks β†’ sends them to the LLM β†’ returns an answer with sources

πŸ“Š Vector Store Management

  • All documents are persisted in ChromaDB inside ./.chroma
  • You can check stats (total docs, embeddings, metadata)
  • Use Clear DB to reset your database

❓ Troubleshooting

GROQ_API_KEY not set : Create .env file with your API key

echo "GROQ_API_KEY=gsk_your_key" > .env

ChromaDB errors

python cli.py clear # Clear database
python cli.py ingest # Re-ingest documents

No documents found

  • Ensure files are in ./data folder
  • Run python cli.py ingest

Slow responses

  • Reduce top_k in config.yaml (4 β†’ 2)

Need help? Open an issue


πŸ›  Tech Stack


πŸ“ License

This project is licensed under the MIT License.

About

RAG Assistant is an AI-powered tool that lets you upload documents, process them into a ChromaDB vector store, and ask natural language questions. It retrieves precise answers with cited sources for reliability.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published