Skip to content

๐Ÿค– Intelligent RAG chatbot with dual modes: COVID-19 medical assistant + custom document Q&A. Built with LangChain, ChromaDB & Streamlit. Upload PDFs -> Ask questions -> Get cited answers instantly

Notifications You must be signed in to change notification settings

fomativeh/RAG-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Dual Mode RAG Chatbot

Intelligent Document Q&A with Context-Aware Responses

๐Ÿ“น Live Demo (https://covid-rag.streamlit.app)

App Demo

Python Streamlit LangChain ChromaDB

๐ŸŽฏ Quick Demo: Upload a PDF โ†’ Ask questions โ†’ Get intelligent, source-cited answers in seconds

๐Ÿš€ The best part?

Two Intelligent Modes in One App:

  • ๐Ÿฉบ COVID-19 Assistant: Pre-loaded with NIH treatment guidelines
  • ๐Ÿง  Custom Document Bot: Upload your own PDFs/docs for instant Q&A

Key Features:

  • โšก Real-time RAG: Semantic search + GPT responses with conversation memory
  • ๐Ÿ“š Smart Citations: Every answer includes source page references
  • ๐Ÿง  Context Awareness: Remembers conversation history for follow-up questions
  • ๐Ÿ“ Multi-format Support: PDF, TXT, Markdown files
  • ๐ŸŽจ Clean UI: Intuitive Streamlit interface with mode switching
  • ๐Ÿ’พ Persistent Storage: ChromaDB vector database with session management

๐Ÿ› ๏ธ Technical Architecture

๐Ÿ“„ Documents โ†’ ๐Ÿ”„ Text Splitting โ†’ ๐Ÿงฎ Embeddings โ†’ ๐Ÿ—ƒ๏ธ ChromaDB
                                                        โ†“
๐Ÿค– LLM Response โ† ๐Ÿ“ Prompt Engineering โ† ๐Ÿ” Semantic Search

Tech Stack:

  • Backend: Python, LangChain, ChromaDB
  • Embeddings: HuggingFace (all-MiniLM-L6-v2)
  • LLM: OpenAI GPT-3.5-turbo via OpenRouter
  • Frontend: Streamlit
  • Vector Store: ChromaDB with cosine similarity

โšก Quick Start

1. Clone & Install

git clone https://github.com/fomativeh/RAG-Chatbot.git
cd RAG-Chatbot
pip install -r requirements.txt

2. Environment Setup

Create .env file:

OPENROUTER_API_KEY=your_openrouter_api_key_here
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
COVID_DOC_URL=https://www.ncbi.nlm.nih.gov/books/NBK570371/pdf/Bookshelf_NBK570371.pdf

3. Launch

streamlit run app.py

4. Usage Options

Option A - COVID Mode:

  • Add PDF files to data/covid_docs/ directory
  • Select "COVID-19 Assistant" mode
  • Start asking medical guideline questions

Option B - Custom Mode:

  • Select "Your Custom Bot" mode
  • Upload PDFs via the sidebar
  • Ask questions about your documents

๐ŸŽฏ Core Features Breakdown

๐Ÿ” Intelligent Retrieval

  • Semantic search using HuggingFace embeddings
  • Top-K document retrieval (configurable)
  • Metadata preservation for accurate citations

๐Ÿ’ฌ Conversation Memory

  • Maintains context across multiple exchanges
  • Configurable conversation history depth
  • Smart prompt engineering with context injection

๐Ÿ“Š Document Processing

  • Recursive text splitting for optimal chunks
  • Multi-format support (PDF, TXT, MD)
  • Automatic metadata extraction (source, page numbers)

๐Ÿ—„๏ธ Data Management

  • Persistent ChromaDB storage
  • Session-based collections for uploaded files
  • Automatic cleanup and error handling

๐Ÿ“‹ Requirements

streamlit>=1.28.0
langchain>=0.1.0
langchain-openai>=0.0.5
langchain-community>=0.0.13
chromadb>=0.4.15
sentence-transformers>=2.2.2
PyPDF2>=3.0.1
python-dotenv>=1.0.0
requests>=2.31.0

๐ŸŽจ UI/UX Highlights

  • Mode Switching: Toggle between COVID and custom document modes
  • File Upload: Drag-and-drop interface with progress indicators
  • Real-time Status: Loading spinners, success/error messages
  • Citation Display: Source references with page numbers
  • Conversation Management: Clear chat functionality
  • Responsive Design: Clean, professional Streamlit interface

๐Ÿ”ง Advanced Configuration

Custom Prompt Templates

Modify prompts in /prompts/ directory:

  • covid_assistant_prompt.txt - COVID mode system prompt
  • custom_bot_prompt.txt - Custom document mode prompt

About

๐Ÿค– Intelligent RAG chatbot with dual modes: COVID-19 medical assistant + custom document Q&A. Built with LangChain, ChromaDB & Streamlit. Upload PDFs -> Ask questions -> Get cited answers instantly

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages