Spaces:
Runtime error
Runtime error
π₯ Healthcare Chatbot β Implementation Flow (Dynamic & CPU-Optimized)
High-Level Runtime Flow
- Message Intake: Socket.IO/API ->
chat_messages->chat_sessions - Context Resolution:
context_service.py(Patient context + session memory) - Medical Intent Detection:
intent_classifier.py(Symptom, Info, Safety, Casual, Non-medical) - Dynamic Risk Scoring:
risk_engine.py(Score 0.0-1.0) -> Updates patient context - Dataset Routing:
dataset_router.py(Weighted routing, e.g. SymCAT/MedQuAD) - Hybrid Retrieval:
retrieval_engine.py(BM25 + FAISS + Cached Embeddings) - Safety & Compliance:
safety_guard.py(No diagnosis, Prescriptions, Dosage; Add Disclaimers) - Response Composition:
response_composer.py(Template vs LLM) - Delivery: Socket.IO -> storage -> feedback loop
Component Mapping
| Existing Component | New Role |
|---|---|
ai_engine.py |
Medical Orchestrator Wrapper |
FAISS |
Primary Medical Retrieval |
BM25 |
Clinical Term Matching |
Unanswered Questions |
Human-in-the-loop |
Gemini |
Last-resort Synthesis |
Optimization
- CPU-Only: No heavy local LLMs (use APIs or efficient retrieval)
- Async: Non-blocking calls
- Caching: Embeddings and frequent responses
π Dataset & Knowledge Strategy
| Dataset | Purpose | Notes |
|---|---|---|
| MedQuAD | Medical Q&A pairs | Covers diseases like flu, diabetes, cardiovascular; used for evidence-based responses |
| SymCAT | Symptom-to-Disease mapping | Helps chatbot compute risk score, suggest next questions, and verify symptom consistency |
| HealthTap | Professional health advice | Used to improve natural phrasing and context-aware responses |
| WHO / CDC | Guidelines & Escalation | Provides authoritative references for high-risk symptoms and emergency protocols |
| ICD-10 Codes | Disease Taxonomy | Standardized identifiers for internal mapping & consistent terminology |
Next Steps
- Implement
medical_orchestrator.py(Core Brain) - Implement
risk_engine.pywith dynamic formulas - Add
patient_contextDB migration - Create healthcare-safe response templates
- Build symptom stepper UI