Skip to main content

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.

Python LangChain Docker Offline

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.

Universal-AI-ChatBot Offline Cover

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

  1. Install Python Requirements
pip install -r requirements.txt
  1. Install & Pull Ollama Model
ollama pull mistral:instruct
  1. Set HuggingFace Token (First Time Only)
export HUGGINGFACEHUB_API_TOKEN=your_token      # macOS/Linux
set HUGGINGFACEHUB_API_TOKEN=your_token         # Windows CMD
  1. Run the CLI Bot
python Bot.py

๐ŸŒ Run with Streamlit Frontend

streamlit run streamlit_app.py

๐Ÿ“ธ Streamlit Preview

โณ Loading Screen

Loading Screen

๐Ÿค– Chat in Action

Running the Model


๐Ÿณ Docker Support

Prerequisites

  • Docker installed & running
  • .env file containing HF_TOKEN (Hugging Face token)

๐Ÿ› ๏ธ Docker Build & Run

To build and run the chatbot using Docker, follow these steps:

  1. Build the Docker image:

    docker build -t ai-chatbot .
    
  2. 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 8501 to local 8501
    • Use your local .env for HF_TOKEN
    • Mount the data/ folder into the container for access to PDFs

Access the chatbot at http://localhost:8501

๐Ÿ“ธ Screenshot:

๐Ÿณ Building the Image

Docker Build and Run


๐Ÿ”„ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

universal_offline_ai_chatbot-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

universal_offline_ai_chatbot-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file universal_offline_ai_chatbot-0.1.0.tar.gz.

File metadata

File hashes

Hashes for universal_offline_ai_chatbot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4459a4fad57368ef0984c9d6cd3b66781be6ab2712d580ebcc1ebe5c24b87558
MD5 1f15102ba1c12fc1e97399583e5943a2
BLAKE2b-256 d8e378bdcf5b377eca412aa1ab01d06ab68322c3f92a4459dc975c3cbca0a366

See more details on using hashes here.

File details

Details for the file universal_offline_ai_chatbot-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for universal_offline_ai_chatbot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9188c00d4a4188315c2283f460366d615e6645a536479c3df0feb5d429292e5
MD5 6c8d62f37aa1c223212f408e2a8d9918
BLAKE2b-256 da3beb782b81be6805ec2875ab91fffc8cb1d188a9d7abceef27f50f099ce289

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page