Skip to content

About

A modular, framework-free RAG server & database management hub with an embeddable AI chat widget generator. Built with FastAPI, ChromaDB, Sentence-Transformers, and supports local (Ollama) or cloud (Groq) LLMs. Easily ingest PDFs, test queries live, and deploy custom context-grounded AI assistants to any website via a simple JS snippet.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

🚀 Professional RAG Ingestion Hub & Standalone Pipeline

A high-performance, developer-first Retrieval-Augmented Generation (RAG) server, database management dashboard, and embeddable AI widget generator. This repository provides a fully modular, framework-free RAG engine designed to ingest private document data, test it live, and deploy a context-grounded AI assistant to any external website via a simple JavaScript snippet.

Unlike monolithic setups, the RAG core is isolated as a self-contained, importable Python class (RAGPipeline) that you can drop directly into external projects, APIs, or personal websites.


🏗️ Architecture & Core Components

rag-project/
├── backend/
│   ├── main.py            # FastAPI ASGI backend: exposes management, chat & widget APIs
│   ├── config.py          # Configuration hub: manages mutable runtime settings
│   └── services/
│       ├── rag.py         # 📦 Reusable standalone RAG orchestrator class (RAGPipeline)
│       ├── pdf_loader.py  # Text extractor
│       ├── chunker.py     # Text segmenter (sliding window chunking)
│       ├── embeddings.py  # Local vector generation (Sentence-Transformers)
│       ├── vectordb.py    # Persistent storage (ChromaDB)
│       ├── retriever.py   # Vector semantic matcher
│       └── llm.py         # LIVE model router (Ollama / Groq API)
├── frontend/              # Administration Console & Interface
│   ├── index.html         # Data, Playground, Widget Customizer, and Settings panels
│   ├── style.css          # Premium slate-dark SaaS design sheets
│   └── script.js          # Live stats binder, widget builder script, and chat inspector
├── requirements.txt       # Dependency configurations
└── .env.example           # Runtime environment variables template


⚡ Quick Start

1. Installation & Environment Setup

Clone the repository and install the dependencies in a virtual environment:

git clone https://github.com/Sahil002620Q/RAG-pipeline.git
cd RAG-pipeline

# Initialize virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

2. Configure Environment

Create your .env file:

cp .env.example .env

Default parameters are configured for local operation.

3. Launch the Server

Start the FastAPI server:

uvicorn main:app --host 127.0.0.1 --port 8000 --reload --app-dir backend

Access the RAG Control Console at http://localhost:8000.


🛠️ Ingesting and Managing Private Data

The Data Management panel in the administration dashboard allows you to build and clean your knowledge base index:

  1. Upload Documents: Drag and drop any .pdf file. The ingestion engine extracts, chunks, generates embeddings, and indexes them in ChromaDB.
  2. Knowledge Base Manager: Review indexed files in the database table and selectively remove documents. Deleting a document instantly wipes all its vector chunks and deletes the file from disk.
  3. Purge Database: Flush the entire ChromaDB index and physical uploads to start clean.

💬 Embeddable Website Widget

Easily deploy your RAG-powered chatbot onto any external website (e.g., business site, portfolio, documentation page) to handle FAQs, inquiries, and data queries automatically.

How to Generate & Install the Widget:

  1. Open your RAG Control Console dashboard and navigate to the Widget Generator tab.
  2. Customize Appearance: Pick your preferred color style and theme configurations for the floating chat bubble sitting at the bottom right corner of your page.
  3. Get the Snippet: Once confirmed, the system generates a clean, plug-and-play JavaScript snippet.
  4. Embed: Copy and paste the script tag right before the closing </body> tag of your target website, following the on-screen instructions:
<!-- Paste this snippet into your target website HTML -->
<script 
  src="http://localhost:8000/widget.js" 
  data-color="#4f46e5" 
  data-position="bottom-right">
</script>
  • Live Testing: The exact behavior, context-grounding, and responses tested inside your RAG pipeline interface will immediately reflect on the external site where the script is embedded. This makes it effortless to integrate an AI assistant for Q&A, repetitive questions, inquiries, and data retrieval on any website.

🌐 Integrate the Bot via Python or REST API

Option A: Integrate via HTTP REST API

FastAPI exposes the pipeline as a JSON endpoint. You can query the bot from any external frontend or custom application:

async function askRagBot(question) {
    const response = await fetch('http://localhost:8000/chat', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ message: question })
    });
    
    const data = await response.json();
    console.log("Answer:", data.reply);
    console.log("Sources Used:", data.context);
}

Option B: Use as a Standalone Python Library

The entire engine is encapsulated inside the RAGPipeline class in backend/services/rag.py. To use it in a separate Python project:

  1. Copy the backend/services/ directory into your project.
  2. Initialize and call the pipeline directly:
from services.rag import RAGPipeline

# Initialize the pipeline
rag = RAGPipeline()

# Ingest document data
rag.ingest_document("/path/to/private_specs.pdf", "specs.pdf")

# Run semantic queries
response = rag.query("What is the hardware requirement?")
print("AI Response:", response["answer"])

# Inspect matched chunks
for chunk in response["context"]:
    print(f"Matched from: {chunk['source']} (Distance: {chunk['distance']})")
    print(f"Text snippet: {chunk['text']}\n")

🎛️ Live Model Switching & Selection

Through the Settings panel, you can hot-swap the LLM provider at runtime:

  • Local Mode (Ollama): Automatically detects live models on your local machine (e.g., gemma3:1b).
  • Cloud API Mode (Groq): Switch to Groq for fast cloud inference by saving your API key in the UI.

About

A modular, framework-free RAG server & database management hub with an embeddable AI chat widget generator. Built with FastAPI, ChromaDB, Sentence-Transformers, and supports local (Ollama) or cloud (Groq) LLMs. Easily ingest PDFs, test queries live, and deploy custom context-grounded AI assistants to any website via a simple JS snippet.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages