Alishba Siddique
feat: implement RAG LLM chain with dynamic model routing and update README documentation
b83ceaa |
Download README.md from alishba38/curemind: direct link, hf CLI and curl.
- Browser
- Download file 5.16 kB
-
https://huggingface.co/spaces/alishba38/curemind/resolve/main/README.md
- Command line
-
hf download hf://spaces/alishba38/curemind/README.md
-
curl -L -o README.md https://huggingface.co/spaces/alishba38/curemind/resolve/main/README.md
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:
GOOGLE_API_KEYβ console.cloud.google.comGROQ_API_KEYβ console.groq.comPINECONE_API_KEYβ app.pinecone.ioHUGGINGFACE_HUB_TOKENβ huggingface.co/settings/tokens
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