Spaces:
Runtime error
A newer version of the Streamlit SDK is available:
1.51.0
title: QUADRANT RAG - Medical AI Assistant
emoji: π©Ί
colorFrom: indigo
colorTo: blue
sdk: streamlit
sdk_version: 1.28.0
app_file: app.py
pinned: false
π©Ί QUADRANT RAG - Medical AI Assistant
A sophisticated Retrieval-Augmented Generation (RAG) system optimized for medical education, specifically designed for MRCS, USMLE, and NEET-PG exam preparation.
π Features
- π Cloud-Native: Uses Qdrant Cloud for scalable vector storage
- π§ Advanced AI: Powered by OpenAI GPT-4o-mini for medical responses
- π Medical-Optimized: Specialized for Harrison's Principles and medical textbooks
- π Semantic Search: Advanced embedding-based document retrieval
- π Citation System: Proper source attribution with page references
- π Clinical Pearls: Highlights crucial practical medical insights
π οΈ Technology Stack
- Frontend: Streamlit (optimized for HuggingFace Spaces)
- Vector Database: Qdrant Cloud
- LLM: OpenAI GPT-4o-mini
- Embeddings: OpenAI text-embedding-3-small
- PDF Processing: pypdf with medical text optimization
π§ Setup
Environment Variables
Create a .env file with your credentials:
# OpenAI Configuration
OPENAI_API_KEY=your-openai-api-key-here
# Qdrant Cloud Configuration
QDRANT_URL=https://your-cluster-url.qdrant.tech
QDRANT_API_KEY=your-qdrant-api-key-here
QDRANT_COLLECTION_NAME=documents
# Application Configuration
USE_MEMORY_DB=false
STREAMLIT_SERVER_PORT=7860
STREAMLIT_SERVER_ADDRESS=0.0.0.0
Local Development
pip install -r requirements.txt
streamlit run app.py
HuggingFace Spaces Deployment
- Configure Space metadata (already in this repo)
- README.md includes the Spaces front matter that declares a Streamlit app:
app_file: app.py.
- Set Secrets in your Space (Settings β Variables and secrets)
OPENAI_API_KEYOPENAI_COMPLETIONS_MODEL=gpt-4o-miniQDRANT_URLQDRANT_API_KEYQDRANT_COLLECTION_NAME=documents- Optional reliability on Spaces:
QDRANT_TIMEOUT=120QDRANT_UPSERT_BATCH=16QDRANT_PREFER_GRPC=false
- Deploy via helper script (from your local repo)
export HF_USER=athulnambiar
export HF_SPACE=pyqsprag
export HF_TOKEN=hf_xxx # write token
./scripts/push_to_hf.sh
- Open your Space App tab and βRestart this Spaceβ if needed.
π Usage
- Upload Documents: Use the sidebar to upload medical PDF documents
- Select Active Document: Click on a document to make it active for querying
- Ask Medical Questions: Type natural language medical queries
- Review Responses: Get structured, exam-focused answers with citations
Sample Questions
- "What are the diagnostic criteria for fever of unknown origin?"
- "Explain the differential diagnosis of anion gap metabolic acidosis"
- "What is the workup for neutropenic fever?"
- "Describe the MUDPILES mnemonic for metabolic acidosis"
π₯ Medical Education Focus
The system is specifically optimized for:
- Structured Learning: Organized responses by clinical categories
- Exam Preparation: MRCS, USMLE, NEET-PG focused content
- Clinical Pearls: Highlighted practical insights
- Evidence-Based: Citations from authoritative medical texts
- Differential Diagnosis: Systematic approach to medical conditions
π Security & Privacy
- API keys are stored securely in environment variables
- No medical data is persistently stored
- All processing happens in secure cloud infrastructure
- Compliant with medical education standards
π System Architecture
PDF Upload β Text Extraction β Chunking β Embedding β Qdrant Cloud
β
User Query β Query Expansion β Vector Search β Context Retrieval
β
Context + Query β GPT-4o-mini β Medical Response β Citations
π€ Contributing
This system is designed for medical education and research purposes. Contributions focused on improving medical accuracy and educational value are welcome.
β οΈ Disclaimer
This tool is for educational purposes only and should not be used for actual clinical decision-making. Always consult authoritative medical sources and qualified healthcare professionals for patient care decisions.
π License
Educational and research use only. Please respect medical education licensing and copyright requirements.