Privacy-first, fully offline AI document assistant secured by tiered safety guardrails
Project description
GuardRAG
A privacy-first, fully offline AI document assistant — secured by a tiered safety guardrails system
Upload any document. Ask anything. Get answers — entirely on your machine.
No cloud. No API keys. No data leaves your device.
🚀 Overview
GuardRAG is a powerful, production-ready command-line tool that lets you chat with your documents offline. By combining LangChain, Ollama, and FAISS, it provides a private alternative to cloud-based RAG solutions. It includes a built-in safety engine that protects sensitive data using a tiered sensitivity system.
🛠 Why GuardRAG?
Most RAG chatbots rely on cloud APIs, which creates privacy risks for sensitive documents — contracts, medical records, internal reports. GuardRAG solves that by:
- Local Inference: Runs models locally via Ollama.
- Offline Embeddings: Uses HuggingFace transformers strictly on your device.
- Tiered Safety: 4 levels of guardrails (Public → Restricted).
- Pro Design: Clean, modern CLI and Web interfaces.
✨ Features
- 100% Offline — No network calls at runtime.
- Multi-format Support — PDF, TXT, DOCX.
- Persistent Memory — Disk-cached FAISS indexes for rapid re-queries.
- Privacy-First Guardrails — Integrated protection against jailbreaks and PII leaks.
- Built-in Web UI — Optional browser-based interface included in the package.
⚙️ Data Sensitivity Tiers
| Level | Badge | Protection Scope |
|---|---|---|
| Public | Jailbreak & prompt injection detection. | |
| Internal | + API keys, credentials, tokens. | |
| Confidential | + SSN, email, phone, DOB, credit cards. | |
| Restricted | + Medical, HIPAA/GDPR, financial data. |
📥 Installation
Install GuardRAG directly from PyPI:
pip install guard-rag
Prerequisites:
- Ollama installed and running.
- Pull a model (e.g.,
ollama pull gemma3:1b).
🏁 Quick Start
Once installed, simply run the guard-rag command:
1. Simple Interactive Chat
guard-rag --pdf my_doc.pdf
2. Custom Model & Sensitivity
guard-rag --pdf secret_report.pdf --model llama3.1 --sensitivity Confidential
3. Launch Web Interface
# Running without arguments launches the built-in Web UI
guard-rag
This will start an interactive chat session with your document.
CLI Options
guard-rag --pdf <file> Load and chat with a PDF document
--model <model> Ollama model to use (default: gemma3:1b)
--ollama-host <url> Ollama server URL (default: http://localhost:11434)
--chunk-size <int> Document chunk size (default: 1000)
--chunk-overlap <int> Chunk overlap (default: 200)
--sensitivity <level> Data sensitivity: Public | Internal | Confidential | Restricted
--no-guardrails Disable safety guardrails
--help Show this help message
Example Session
# Start with a PDF using Llama 3.1
guard-rag --pdf report.pdf --model llama3.1 --sensitivity Confidential
# You: What are the key findings?
# Chatbot: Based on the document, the key findings are...
Project Structure
GUADRAILS-RAG-CHAT-TOOL/
│
├── guardrag/ # Main installable package
│ ├── api/ # FastAPI local server
│ ├── cli/ # Command-line interface
│ ├── rag/ # RAG pipeline logic
│ └── utils/ # General utilities
│
├── docs/ # Documentation (INSTALL, QUICK_REFERENCE)
├── tests/ # Unit and integration tests
├── scripts/ # Development and maintenance scripts
├── extras/ # Experimental / legacy components
│
├── pyproject.toml # Modern build configuration
├── setup.py # Legacy support configuration
├── README.md # Project overview
├── CONTRIBUTING.md # Contribution guidelines
├── CODE_OF_CONDUCT.md # Community standards
└── LICENSE # MIT License open source
.guardrag_storage/is auto-generated on first document load (FAISS cache).
Configuration
Environment Variables
Copy .env.example to .env and adjust as needed:
cp .env.example .env
| Variable | Default | Description |
|---|---|---|
OLLAMA_HOST |
http://localhost:11434 |
Ollama API endpoint |
NO_PROXY |
huggingface.co,... |
Bypass proxy for local+HF calls |
PORT |
8000 |
Server port (auto-set by PaaS) |
Chunking Parameters
Adjustable per-session via the sidebar in the UI:
- Chunk Size (default 1000 chars)
- Chunk Overlap (default 200 chars)
Different chunk settings for the same file produce a separate FAISS index automatically.
Deployment
From PyPI (recommended)
pip install guard-rag
From Source
git clone https://github.com/sowmiyan-s/GUADRAILS-RAG-CHAT-TOOL.git
cd GUADRAILS-RAG-CHAT-TOOL
pip install .
In a virtual environment (best practice)
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS / Linux:
source .venv/bin/activate
pip install guard-rag
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
Bug reports and feature requests are welcome via GitHub Issues.
License
This project is licensed under the MIT License — see LICENSE for details.
Built with ❤️ by Sowmiyan S
FastAPI · LangChain · Ollama · HuggingFace · FAISS · Vanilla JS
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guard_rag-1.0.9.tar.gz.
File metadata
- Download URL: guard_rag-1.0.9.tar.gz
- Upload date:
- Size: 54.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
571f1013bb1faf4fea4ab62d7900a50eb500829f0e9fe800492056bce37972d3
|
|
| MD5 |
f0fc039b2863103b0579baa3849bf6bd
|
|
| BLAKE2b-256 |
38b40db7f4f5fdd36d19797a33df59814c85bc74abc20ebe6517bce86cb299ce
|
File details
Details for the file guard_rag-1.0.9-py3-none-any.whl.
File metadata
- Download URL: guard_rag-1.0.9-py3-none-any.whl
- Upload date:
- Size: 46.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cae637be7806267958edfce021fdab60a042288a9638301f32c7e0f3f9611364
|
|
| MD5 |
ea2b7b298f631759fb346b726eec9564
|
|
| BLAKE2b-256 |
4e8f8c4542bd94bb18d9a2767f1d9ffbd8b6361723ee9de2ed31265f1221cd69
|