Universal Offline AI Chatbot powered by local Mistral + FAISS + LangChain
Project description
๐ Universal Offline AI Chatbot
Build your own domain-specific chatbot โ offline, modular, and blazing fast.
The Universal Offline AI Chatbot is a privacy-respecting, offline-ready assistant that can chat over any set of PDFs. Itโs ideal for legal, cybersecurity, academic, enterprise, or technical domains.
It uses a locally hosted LLM (mistral:instruct via Ollama) and semantic search powered by HuggingFace embeddings and FAISS. You get fast, accurate responses, without sending anything to the cloud.
GitHub Link: https://github.com/AdityaBhatt3010/Universal-Offline-AI-Chatbot
DockerHub Link: https://hub.docker.com/r/adityabhatt3010/ai-chatbot
โจ Highlights
- ๐ Fully offline-capable with local LLM (via Ollama)
- ๐ Works out-of-the-box with your PDFs
- ๐ง Semantic vector search using
all-MiniLM-L6-v2 - โก๏ธ Fast and responsive using FAISS backend
- ๐งฉ Modular, extendable architecture (Streamlit frontend + CLI)
- ๐ณ Docker-ready for deployment
- ๐ธ UI Preview with screenshots
- โ Built-in CI/CD check via GitHub Actions
- ๐ฏ Fully reproducible setup via PowerShell script or Docker
๐งฑ Tech Stack
| Layer | Stack |
|---|---|
| LLM | mistral:instruct via Ollama |
| Embeddings | all-MiniLM-L6-v2 via SentenceTransformers |
| Vector Store | FAISS (in-memory + disk) |
| Framework | LangChain (v0.2+) |
| Language | Python 3.11+ |
| UI | Streamlit |
| Container | Docker |
| CI/CD | GitHub Actions (.github/workflows/python.yml) |
โ ๏ธ HuggingFace Token is required to fetch the embedding model once. It's cached locally afterward.
Example .env:
HF_TOKEN=your_huggingface_token_here
๐ก Use Cases
| Chatbot Type | Add These PDFs |
|---|---|
| ๐จโโ๏ธ LawyerBot | Legal, Constitution, HR documents |
| ๐งฌ ResearchBot | Whitepapers, scientific papers |
| ๐ก๏ธ CyberSecBot | SOC2, GDPR, ISO27001, NIST docs |
| ๐ EdTechBot | Notes, textbooks, question banks |
| ๐งโ๐ผ HR/CompanyBot | SOPs, onboarding docs, HR policies |
๐ Project Structure
Universal-Offline-AI-Chatbot/
โ
โโโ data/ # Place your PDF documents here
โ โโโ Try.pdf
โ
โโโ Screenshots/ # UI snapshots
โ โโโ Loading_Screen.png
โ โโโ Running_the_Model.png
โ
โโโ src/ # Modular source code
โ โโโ chunker.py
โ โโโ config.py
โ โโโ embedding.py
โ โโโ loader.py
โ โโโ model_loader.py
โ โโโ prompts.py
โ โโโ qa_chain.py
โ โโโ utils.py
โ โโโ vectorstore.py
โ
โโโ vectorstore/ # Local FAISS vector index
โ โโโ db_faiss/
โ
โโโ Bot.py # CLI script
โโโ Bot.ipynb # Jupyter notebook version
โโโ main.py # Entry-point (optional)
โโโ streamlit_app.py # Frontend UI (Streamlit)
โโโ requirements.txt # Python dependencies
โโโ setup.ps1 # PowerShell setup script
โโโ Dockerfile # Docker image definition
โโโ .dockerignore
โโโ .env # Contains HF_TOKEN
โโโ README.md
โโโ LICENSE
๐งฐ Setup Instructions
๐ฅ๏ธ One-Click Setup (Windows Only)
.\setup.ps1
This will:
- Create virtual env
- Install dependencies
- Pull Mistral via Ollama
- Ask for Hugging Face token
- Build Docker image
๐ Manual Setup
- Install Python Requirements
pip install -r requirements.txt
- Install & Pull Ollama Model
ollama pull mistral:instruct
- Set HuggingFace Token (First Time Only)
export HUGGINGFACEHUB_API_TOKEN=your_token # macOS/Linux
set HUGGINGFACEHUB_API_TOKEN=your_token # Windows CMD
- Run the CLI Bot
python Bot.py
๐ Run with Streamlit Frontend
streamlit run streamlit_app.py
๐ธ Streamlit Preview
โณ Loading Screen
๐ค Chat in Action
๐ณ Docker Support
Prerequisites
- Docker installed & running
.envfile containingHF_TOKEN(Hugging Face token)
๐ ๏ธ Docker Build & Run
To build and run the chatbot using Docker, follow these steps:
-
Build the Docker image:
docker build -t ai-chatbot .
-
Run the container (with volume mount and token):
docker run -p 8501:8501 --env-file .env -v ${PWD}/data:/app/data ai-chatbot
This will:
- Map the container's port
8501to local8501 - Use your local
.envforHF_TOKEN - Mount the
data/folder into the container for access to PDFs
- Map the container's port
Access the chatbot at http://localhost:8501
๐ธ Screenshot:
๐ณ Building the Image
๐ Using Your Own PDFs
# Replace default file(s)
mv your_files/*.pdf ./data/
# Re-run the bot or restart Streamlit
python Bot.py
Automatically re-indexes your new documents using FAISS.
๐งช Sample Interaction
๐ง You: What does Article 21 state?
๐ค Bot: Article 21 of the Indian Constitution guarantees the protection of life and personal liberty...
๐งโ๐ป Author
Aditya Bhatt
Cybersecurity Specialist | VAPT Expert | OSS Contributor
GitHub | Medium
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 universal_offline_ai_chatbot-0.1.0.tar.gz.
File metadata
- Download URL: universal_offline_ai_chatbot-0.1.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4459a4fad57368ef0984c9d6cd3b66781be6ab2712d580ebcc1ebe5c24b87558
|
|
| MD5 |
1f15102ba1c12fc1e97399583e5943a2
|
|
| BLAKE2b-256 |
d8e378bdcf5b377eca412aa1ab01d06ab68322c3f92a4459dc975c3cbca0a366
|
File details
Details for the file universal_offline_ai_chatbot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: universal_offline_ai_chatbot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9188c00d4a4188315c2283f460366d615e6645a536479c3df0feb5d429292e5
|
|
| MD5 |
6c8d62f37aa1c223212f408e2a8d9918
|
|
| BLAKE2b-256 |
da3beb782b81be6805ec2875ab91fffc8cb1d188a9d7abceef27f50f099ce289
|