An AI-powered Patient Query Assistant built using Retrieval-Augmented Generation (RAG). The system answers user queries strictly based on a provided hospital document.
- 📄 PDF Upload & Ingestion
- ✂️ Smart Text Chunking
- 🧠 Semantic Search using Embeddings
- 🗄️ Vector Database (Supabase pgvector)
- 🤖 LLM-powered Answers (Groq - Llama 3.1)
- 🔍 Source Attribution (Page Numbers)
- 💬 Chat History (Conversational AI)
- 🖥️ Streamlit UI for interaction
User (UI / API)
↓
FastAPI Backend
↓
PDF Upload → Text Extraction → Chunking
↓
Embeddings (SentenceTransformers)
↓
Supabase (pgvector)
↓
Query → Embedding → Similarity Search
↓
Top-K Chunks
↓
LLM (Groq - Llama 3.1)
↓
Final Answer + Sources
- FastAPI
- Streamlit
- SentenceTransformers (all-MiniLM-L6-v2)
- Supabase (PostgreSQL + pgvector)
- Groq API (Llama 3.1)
git clone https://github.com/your-username/hospital-rag-assistant.git
cd hospital-rag-assistant
pip install -r requirements.txt
Or manually:
pip install fastapi uvicorn streamlit sentence-transformers supabase groq python-dotenv python-multipart requests
Create .env file:
SUPABASE_URL=your_url
SUPABASE_KEY=your_secret_key
GROQ_API_KEY=your_groq_key
uvicorn app.main:app --reload
python -m streamlit run app/ui.py
POST /upload
POST /query
Request:
{
"question": "What is ICU cost?"
}Response:
{
"answer": "ICU cost is $600 per day.",
"sources": ["page 5"]
}- What are OPD timings?
- Who is the cardiologist?
- What is the cost of MRI?
- What is ICU cost per day?
- What is the emergency number?
The system answers ONLY from the document. If information is not found:
"I don't have that information in the provided document."
- Prevents hallucination using RAG
- Supports conversational queries (chat history)
- Handles real-world document QA scenarios
Anshuman Singh