Spaces:
Sleeping
Sleeping
RagBot: Multi-Agent RAG System for Medical Biomarker Analysis
A production-ready biomarker analysis system combining 6 specialized AI agents with medical knowledge retrieval to provide evidence-based insights on blood test results in 15-25 seconds.
β¨ Key Features
- 6 Specialist Agents - Biomarker validation, disease prediction, RAG-powered analysis, confidence assessment
- Medical Knowledge Base - 750+ pages of clinical guidelines (FAISS vector store, local embeddings)
- Multiple Interfaces - Interactive CLI chat, REST API, ready for web/mobile integration
- Evidence-Based - All recommendations backed by retrieved medical literature
- Free & Offline - Uses free Groq API + local embeddings (no embedding API costs)
- Production-Ready - Full error handling, safety alerts, confidence scoring
π Quick Start
Installation (5 minutes):
# Clone & setup
git clone https://github.com/yourusername/ragbot.git
cd ragbot
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -r requirements.txt
# Get free API key
# 1. Sign up: https://console.groq.com/keys
# 2. Copy API key to .env
# Run setup
python scripts/setup_embeddings.py
# Start chatting
python scripts/chat.py
See QUICKSTART.md for detailed setup instructions.
π Documentation
| Document | Purpose |
|---|---|
| QUICKSTART.md | 5-minute setup guide |
| CONTRIBUTING.md | How to contribute |
| docs/ARCHITECTURE.md | System design & components |
| docs/API.md | REST API reference |
| docs/DEVELOPMENT.md | Development & extension guide |
| scripts/README.md | Utility scripts reference |
| examples/README.md | Web/mobile integration examples |
π» Usage
Interactive CLI
python scripts/chat.py
You: My glucose is 140 and HbA1c is 10
π΄ Primary Finding: Diabetes (85% confidence)
β οΈ Critical Alerts: Hyperglycemia, elevated HbA1c
β
Recommendations: Seek medical attention, lifestyle changes
π± Actions: Physical activity, reduce carbs, weight loss
REST API
# Start server
python -m uvicorn api.app.main:app
# POST /api/v1/analyze
curl -X POST http://localhost:8000/api/v1/analyze \
-H "Content-Type: application/json" \
-d '{
"biomarkers": {"Glucose": 140, "HbA1c": 10.0}
}'
See docs/API.md for full API reference.
ποΈ Project Structure
RagBot/
βββ src/ # Core application
β βββ workflow.py # Multi-agent orchestration (LangGraph)
β βββ biomarker_validator.py # Validation logic
β βββ pdf_processor.py # Vector store management
β βββ agents/ # 6 specialist agents
β
βββ api/ # REST API (optional)
β βββ app/main.py # FastAPI server
β βββ app/routes/ # API endpoints
β
βββ scripts/ # Utilities
β βββ chat.py # Interactive CLI
β βββ setup_embeddings.py # Vector store builder
β
βββ config/ # Configuration
β βββ biomarker_references.json # Reference ranges
β
βββ data/ # Data storage
β βββ medical_pdfs/ # Source documents
β βββ vector_stores/ # FAISS database
β
βββ tests/ # Test suite
βββ examples/ # Integration examples
βββ docs/ # Documentation
β βββ ARCHITECTURE.md # System design
β βββ API.md # API reference
β βββ DEVELOPMENT.md # Development guide
β βββ archive/ # Old docs
β βββ plans/ # Planning docs
β
βββ QUICKSTART.md # Setup guide
βββ CONTRIBUTING.md # Contribution guidelines
βββ requirements.txt # Python dependencies
βββ .env.template # Configuration template
βββ LICENSE
π§ Technology Stack
| Component | Technology | Purpose |
|---|---|---|
| Orchestration | LangGraph | Multi-agent workflow control |
| LLM | Groq (LLaMA 3.3-70B) | Fast, free inference |
| Embeddings | HuggingFace (sentence-transformers) | Local, offline embeddings |
| Vector DB | FAISS | Efficient similarity search |
| API | FastAPI | REST endpoints |
| Data | Pydantic V2 | Type validation |
π How It Works
User Input ("My glucose is 140...")
β
[Biomarker Extraction] β Parse & normalize
β
[Prediction Agent] β Disease hypothesis
β
[RAG Retrieval] β Get medical docs from vector store
β
[6 Parallel Agents] β Analyze from different angles
ββ Biomarker Analyzer (validation)
ββ Disease Explainer (RAG)
ββ Biomarker-Disease Linker (RAG)
ββ Clinical Guidelines (RAG)
ββ Confidence Assessor (scoring)
ββ Response Synthesizer (summary)
β
[Output] β Comprehensive report with safety alerts
π Supported Biomarkers
24+ biomarkers including:
- Glucose Control: Glucose, HbA1c, Fasting Glucose
- Lipids: Total Cholesterol, LDL, HDL, Triglycerides
- Cardiac: Troponin, BNP, CK-MB
- Blood Cells: WBC, RBC, Hemoglobin, Hematocrit, Platelets
- Liver: ALT, AST, Albumin, Bilirubin
- Kidney: Creatinine, BUN, eGFR
- And more...
See config/biomarker_references.json for complete list.
π― Disease Coverage
- Diabetes
- Anemia
- Heart Disease
- Thrombocytopenia
- Thalassemia
- (Extensible - add custom domains)
π Privacy & Security
- All processing runs locally after setup
- No personal health data sent to APIs (except LLM inference)
- Embeddings computed locally or cached
- Fully HIPAA-compliant architecture ready
- Vector store derived from public medical literature
- Can operate completely offline after initial setup
π Performance
- Response Time: 15-25 seconds (8 agents + RAG retrieval)
- Knowledge Base: 750 pages β 2,609 document chunks
- Embedding Dimensions: 384
- Cost: Free (Groq API + local embeddings)
- Hardware: CPU-only (no GPU needed)
π Deployment Options
- CLI - Interactive chatbot (development/testing)
- REST API - FastAPI server (production)
- Docker - Containerized deployment
- Embedded - Direct Python library import
- Web - JavaScript/React integration
- Mobile - React Native / Flutter
See examples/README.md for integration patterns.
π§ͺ Testing
# Run all tests
pytest tests/ -v
# Test specific module
pytest tests/test_diabetes_patient.py -v
# Coverage report
pytest --cov=src tests/
π€ Contributing
Contributions welcome! See CONTRIBUTING.md for:
- Code style guidelines
- Pull request process
- Testing requirements
- Development setup
π Development
Want to extend RagBot?
- Add custom biomarkers: docs/DEVELOPMENT.md
- Add medical domains: docs/DEVELOPMENT.md
- Create custom agents: docs/DEVELOPMENT.md
- Switch LLM providers: docs/DEVELOPMENT.md
π License
MIT License - See LICENSE
π Support
- Issues: GitHub Issues for bugs and feature requests
- Discussion: GitHub Discussions for questions
- Docs: Full documentation in
/docsfolder
π Resources
Ready to get started? β QUICKSTART.md
Want to understand the architecture? β docs/ARCHITECTURE.md
Looking to integrate with your app? β examples/README.md