A production-style Retrieval-Augmented Generation (RAG) chatbot that answers questions about clinic documents. Built with LlamaIndex, ChromaDB, OpenAI, and served via a FastAPI backend with a clean, framework-free HTML/CSS/JS frontend.
- 💬 ChatGPT-style dark web UI — no React, no Vue, pure HTML/CSS/JS
- 🔍 Semantic search over clinic documents using vector embeddings
- 🤖 Answers grounded in your documents via
gpt-4o-mini - 💾 Automatic per-session chat backup to
chatBackup/as JSON - ⚡ FastAPI backend with instant startup — index loaded once at boot
- 📱 Responsive layout — works on mobile and desktop
- 🗂️ Sidebar with document list and "New Chat" button
This project implements the standard RAG pipeline in two phases:
docs/ (your .txt / .pdf files)
│
▼
[ingest.py]
→ split into 512-token chunks
→ embed with OpenAI text-embedding-ada-002
→ store vectors in ./chroma_db
User question
│
▼
[Embed question] → vector
│
▼
[ChromaDB] → top 3 semantically similar chunks
│
▼
[gpt-4o-mini] ← chunks + question as context
│
▼
🤖 Grounded answer
RAG-ChatBot/
├── docs/ # Source documents (clinic knowledge base)
│ ├── blood_tests_reference.txt
│ ├── clinic_faq.txt
│ ├── colonoscopy_prep.txt
│ ├── emergency_escalation_rules.txt
│ ├── insurance_guide.txt
│ ├── patient_rights.txt
│ ├── prescription_refill_policy.txt
│ └── telehealth_guide.txt
├── static/
│ └── index.html # Full chat UI (single file, no frameworks)
├── chroma_db/ # Auto-generated vector DB (git-ignored)
├── chatBackup/ # Per-session chat logs as JSON (git-ignored)
├── ingest.py # Step 1: Chunk, embed, and index documents
├── query.py # Step 2: Terminal Q&A interface
├── api.py # Step 3: FastAPI backend
├── .env # API keys (git-ignored)
├── .gitignore
└── README.md
git clone https://github.com/eziyoo/RAG-ChatBot.git
cd RAG-ChatBotpython3 -m venv .venv
source .venv/bin/activate # macOS / Linux
.venv\Scripts\activate # Windowspip install -r requirements.txtCreate a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key_hereGet your key from platform.openai.com/api-keys. Make sure billing is enabled — costs are minimal (fractions of a cent per query).
Run once to build the vector database from your documents:
python ingest.pyThis reads all files from docs/, chunks them into 512-token pieces, embeds them with OpenAI, and stores everything in ./chroma_db.
Re-run this any time you add, remove, or update documents.
uvicorn api:app --reloadOpen your browser at http://localhost:8000.
For quick testing without the web UI:
python query.py🙋 Your question: Do I need someone to drive me home after a colonoscopy?
🤖 Answer: Yes, you must arrange for a responsible adult to drive you home...
Type exit or quit to stop.
| Layer | Technology |
|---|---|
| RAG Framework | LlamaIndex |
| Vector Database | ChromaDB — local, no cloud needed |
| Embedding Model | OpenAI text-embedding-ada-002 |
| LLM | OpenAI gpt-4o-mini |
| Backend | FastAPI + Uvicorn |
| Frontend | Vanilla HTML / CSS / JavaScript (no frameworks) |
| Environment | Python 3.10+ |
Install all at once:
pip install -r requirements.txtKey packages:
llama-index
llama-index-vector-stores-chroma
llama-index-llms-openai
chromadb
fastapi
uvicorn
python-multipart
openai
python-dotenv
Generate a fresh lockfile after adding packages:
pip freeze > requirements.txtEvery conversation is automatically saved to chatBackup/ as a JSON file. One file is created per session — it is overwritten on each message (not duplicated).
chatBackup/
├── chat_2026-06-24_18-42-00.json ← Session 1
├── chat_2026-06-24_20-15-00.json ← Session 2 (New Chat clicked)
└── ...
Each file contains the full message history:
{
"saved_at": "2026-06-24_18-43-15",
"session_id": "2026-06-24_18-42-00",
"messages": [
{ "role": "user", "content": "What are my rights as a patient?" },
{ "role": "assistant", "content": "As a patient, you have the right to..." }
]
}- Add
.txt,.pdf, or.docxfiles to thedocs/folder - Delete the existing
chroma_db/folder to avoid stale data:rm -rf chroma_db/
- Re-run the ingestion pipeline:
python ingest.py
| Variable | Description |
|---|---|
OPENAI_API_KEY |
Your OpenAI API key |
The .env file is listed in .gitignore and will never be committed to version control.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License.