curemind / README.md
Alishba Siddique
feat: implement RAG LLM chain with dynamic model routing and update README documentation
b83ceaa
|
Raw History Blame Contribute Delete
5.16 kB
metadata
title: CureMind
emoji: 🩺
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false

CureMind β€” AI Medical Information Assistant

An end-to-end Retrieval-Augmented Generation (RAG) medical chatbot built as part of a German MSc AI portfolio. It combines curated open biomedical datasets with user-uploaded documents to answer clinical questions with source citations.


Architecture

User Question
     β”‚
     β–Ό
Streamlit UI  ──►  FastAPI Backend
                        β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό                    β–Ό
    Google GenAI             Pinecone Vector DB
    Embeddings (768d)   ◄──  (medicalindex)
              β”‚
              β–Ό
     Top-5 Relevant Chunks
              β”‚
              β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚  LLM Router        β”‚
     β”‚  β”œβ”€ Qwen-3.8-27B   β”‚  (fast queries)
     β”‚  β”œβ”€ GPT-OSS-120B   β”‚  (reasoning / "why/how")
     β”‚  └─ Groq-Compound  β”‚  (fallback)
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚  (via Groq API)
              β–Ό
     Answer + Source Citations

Tech Stack

Layer Technology
Frontend Streamlit
Backend FastAPI + Uvicorn
Vector Store Pinecone (768-dim, dotproduct)
Embeddings Google Generative AI (embedding-001)
LLM Inference Groq API (Qwen-3.8-27B Β· GPT-OSS-120B Β· Groq-Compound)
RAG Framework LangChain LCEL
Datasets HuggingFace Hub
Config Pydantic Settings
Deployment HuggingFace Spaces (Docker)

Knowledge Base β€” Open Datasets

Dataset Source Size License
PubMedQA qiaojin/PubMedQA 1 k (labeled) MIT
Mental Health Counseling Amod/mental_health_counseling_conversations 3.5 k RAIL-D
Medical Meadow MediQA medalpaca/medical_meadow_mediqa 2.2 k Academic
MedQA-USMLE GBaker/MedQA-USMLE-4-options-hf 12.7 k CC-BY-SA-4.0

Users can also upload their own PDF documents via the sidebar to extend the knowledge base.


API Endpoints

Method Path Description
GET /health Service health check
POST /ask/ Submit a question, returns answer + sources
POST /upload_pdfs/ Upload PDF documents for indexing
GET /hf_datasets/ List available HuggingFace datasets
POST /hf_datasets/load/ Load a dataset into the vector store

Interactive docs available at /docs when running.


Local Development

1. Clone and install

git clone https://github.com/YOUR_USERNAME/curemind.git
cd curemind

2. Configure environment

cp server/.env.example server/.env
# Fill in your API keys in server/.env

Required keys:

3. Run backend

cd server
pip install -r requirements.txt
uvicorn main:app --reload

4. Run frontend

cd client
pip install -r requirements.txt
streamlit run app.py

HuggingFace Spaces Deployment

Environment Variables (set in Space Settings β†’ Variables and Secrets)

Key Type
GOOGLE_API_KEY Secret
GROQ_API_KEY Secret
PINECONE_API_KEY Secret
HUGGINGFACE_HUB_TOKEN Secret
PINECONE_INDEX_NAME Variable β€” medicalindex
PINECONE_REGION Variable β€” us-east-1

The Docker container starts both FastAPI (port 8000, internal) and Streamlit (port 7860, public) automatically.


Project Structure

curemind/
β”œβ”€β”€ Dockerfile                  # HF Spaces Docker build
β”œβ”€β”€ docker-entrypoint.sh        # Starts both services
β”œβ”€β”€ render.yaml                 # Render.com alternative deployment
β”‚
β”œβ”€β”€ server/                     # FastAPI backend
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ settings.py         # Pydantic BaseSettings
β”‚   β”‚   └── schemas.py          # Request / response models
β”‚   β”œβ”€β”€ modules/
β”‚   β”‚   β”œβ”€β”€ llm.py              # LangChain LCEL chain + model router
β”‚   β”‚   β”œβ”€β”€ load_vectorstore.py # PDF ingestion pipeline
β”‚   β”‚   └── hf_dataset_loader.py# HuggingFace dataset ingestion
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ ask_question.py     # POST /ask/
β”‚   β”‚   β”œβ”€β”€ upload_pdfs.py      # POST /upload_pdfs/
β”‚   β”‚   └── load_hf_datasets.py # GET|POST /hf_datasets/
β”‚   └── main.py
β”‚
└── client/                     # Streamlit frontend
    β”œβ”€β”€ app.py                  # Entry point
    β”œβ”€β”€ components/
    β”‚   β”œβ”€β”€ chatUI.py
    β”‚   β”œβ”€β”€ upload.py
    β”‚   β”œβ”€β”€ hf_loader.py
    β”‚   └── history_download.py
    └── utils/
        └── api.py