Spaces:
Sleeping
Sleeping
feat: Update Help tab and README with comprehensive documentation
Browse files- Updated Help tab with detailed information about all features
- Added documentation for Model Settings, Patient Profiles, and Edit Prompts
- Documented all 8 Spiritual Testing Profiles (GREEN, YELLOW, RED)
- Updated README.md with Simplified Medical Assistant information
- Added testing instructions and profile usage guide
- Updated project status and technology stack
- All 130 tests passing
- Ready for production use
- .hypothesis/constants/04f49bc462f957f1 +4 -0
- .hypothesis/constants/0f17f7a03d42626e +4 -0
- .hypothesis/constants/6845c48c4c9aae99 +4 -0
- .hypothesis/constants/d992e29f81671095 +4 -0
- .hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz +0 -0
- MODEL_SELECTION_GUIDE.md +180 -0
- README.md +177 -259
- TRIAGE_ANALYSIS.md +122 -0
- src/config/ai_providers_config.py +14 -16
- src/config/prompts.py +208 -136
- src/interface/simplified_gradio_app.py +558 -24
.hypothesis/constants/04f49bc462f957f1
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# file: /Users/serhiizabolotnii/Medical Brain/Lifestyle/src/core/spiritual_monitor.py
|
| 2 |
+
# hypothesis_version: 6.148.7
|
| 3 |
+
|
| 4 |
+
[0.5, 0.6, 0.7, 1.0, 'LLM classification', '\\{[^{}]*\\}', 'afterlife', 'anxious', 'better off dead', "can't cope", "can't go on", 'classification_error', 'confidence', 'death', 'depressed', 'died', 'end it all', 'end my life', 'faith', 'give up', 'god', 'green', 'grief', 'guilt', 'hopeless', 'indicators', 'kill myself', 'lonely', 'loss', 'meaning', 'miss them', 'mourning', 'no hope', 'no reason to live', 'nothing matters', 'overwhelmed', 'parse_error', 'pray', 'purpose', 'reasoning', 'red', 'sad', 'scared', 'sin', 'soul', 'spiritual', 'state', 'stressed', 'struggling', 'suicidal', 'suicide', 'want to die', 'want to disappear', 'why me', 'wish i was dead', 'worried', 'yellow', 'безнадія', 'бог', 'важко', 'все безглуздо', 'втрата', 'віра', 'горе', 'гріх', 'депресія', 'духовний', 'душа', 'краще б мене не було', 'краще б я помер', 'мета', 'молитва', 'не справляюсь', 'не хочу жити', 'немає надії', 'немає сенсу жити', 'нічого не має сенсу', 'перевантажений', 'покінчити з життям', 'помер', 'провина', 'самогубство', 'самотньо', 'сенс', 'скучаю', 'смерть', 'страшно', 'стрес', 'сумно', 'сумую', 'тривога', 'хвилююсь', 'хочу зникнути', 'хочу померти', 'чому я']
|
.hypothesis/constants/0f17f7a03d42626e
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# file: /Users/serhiizabolotnii/Medical Brain/Lifestyle/src/core/soft_triage_manager.py
|
| 2 |
+
# hypothesis_version: 6.148.7
|
| 3 |
+
|
| 4 |
+
['\nPatient responses:', '\nPrevious exchanges:', 'English', 'LLM evaluation', 'Ukrainian', '\\{[^{}]*\\}', '^["\\\']|["\\\']$', 'better', 'continue', 'coping', 'escalate_red', 'family', 'fine', 'friends', 'okay', 'outcome', 'reasoning', 'resolved_green', 'support', 'добре', 'друзі', 'краще', 'підтримка', 'справляюсь', "сім'я"]
|
.hypothesis/constants/6845c48c4c9aae99
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# file: /Users/serhiizabolotnii/Medical Brain/Lifestyle/src/config/ai_providers_config.py
|
| 2 |
+
# hypothesis_version: 6.148.7
|
| 3 |
+
|
| 4 |
+
[0.1, 0.2, 0.3, 20000, ' ⚠️ Warnings:', '=', 'ANTHROPIC_API_KEY', 'EntryClassifier', 'GEMINI_API_KEY', 'MedicalAssistant', 'SoftMedicalTriage', 'TriageExitClassifier', '__main__', 'agent_status', 'anthropic', 'api_key_env', 'available', 'available_models', 'available_providers', 'default_model', 'default_temperature', 'errors', 'fallback_model', 'fallback_needed', 'fallback_provider', 'gemini', 'gemini-2.0-flash', 'gemini-2.5-flash', 'gemini-flash-latest', 'max_tokens', 'model', 'provider', 'reasoning', 'temperature', 'valid', 'warnings', '✅', '✅ Configured', '❌']
|
.hypothesis/constants/d992e29f81671095
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# file: /Users/serhiizabolotnii/Medical Brain/Lifestyle/src/core/ai_client.py
|
| 2 |
+
# hypothesis_version: 6.148.7
|
| 3 |
+
|
| 4 |
+
[0.0, 0.3, 0.7, 20000, ' AI Client Test', '%Y-%m-%d %H:%M:%S', '=', 'ANTHROPIC_API_KEY', 'DefaultAgent', 'EntryClassifier', 'GEMINI_API_KEY', 'LOG_PROMPTS', 'MedicalAssistant', 'TEST', '__main__', 'active_model', 'active_provider', 'agent_name', 'ai_interactions.log', 'call_count', 'client_info', 'configured_model', 'configured_provider', 'content', 'default_model', 'false', 'get_client_info', 'last_error', 'model', 'performance_metrics', 'provider', 'reasoning', 'role', 'spiritual_analysis', 'successful_calls', 'system_instruction', 'temperature', 'text', 'thinking_config', 'total_calls', 'total_response_time', 'true', 'type', 'user', 'using_fallback', 'utf-8']
|
.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz
CHANGED
|
Binary files a/.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz and b/.hypothesis/unicode_data/16.0.0/codec-utf-8.json.gz differ
|
|
|
MODEL_SELECTION_GUIDE.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🤖 AI Model Selection Guide
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
|
| 5 |
+
The Medical Assistant now includes a dedicated **Model Settings** tab that allows you to dynamically select which AI models to use for different tasks during your session.
|
| 6 |
+
|
| 7 |
+
## Features
|
| 8 |
+
|
| 9 |
+
### ⚙️ Model Selection Tab
|
| 10 |
+
|
| 11 |
+
Access the model configuration through the **⚙️ Model Settings** tab in the interface.
|
| 12 |
+
|
| 13 |
+
### Available Models
|
| 14 |
+
|
| 15 |
+
#### Claude Models (Anthropic)
|
| 16 |
+
- `claude-sonnet-4-5-20250929` - Latest, most capable
|
| 17 |
+
- `claude-sonnet-4-20250514` - Stable, reliable
|
| 18 |
+
- `claude-3-7-sonnet-20250219` - Previous version
|
| 19 |
+
- `claude-haiku-4-5-20251001` - Lightweight, fast
|
| 20 |
+
|
| 21 |
+
#### Gemini Models (Google)
|
| 22 |
+
- `gemini-2.5-flash` - Latest, optimized
|
| 23 |
+
- `gemini-2.0-flash` - Stable, fast
|
| 24 |
+
- `gemini-flash-latest` - Always latest version
|
| 25 |
+
|
| 26 |
+
### Task-Specific Configuration
|
| 27 |
+
|
| 28 |
+
#### 🔍 Spiritual Distress Analyzer
|
| 29 |
+
Analyzes patient messages for emotional and spiritual distress indicators.
|
| 30 |
+
|
| 31 |
+
**Recommended:** `claude-sonnet-4-5-20250929`
|
| 32 |
+
- Requires empathy and nuanced understanding
|
| 33 |
+
- Handles sensitive content safely
|
| 34 |
+
|
| 35 |
+
**Alternative:** `claude-sonnet-4-20250514`
|
| 36 |
+
|
| 37 |
+
#### 🩺 Soft Medical Triage
|
| 38 |
+
Conducts gentle health check-ins during conversations.
|
| 39 |
+
|
| 40 |
+
**Recommended:** `claude-sonnet-4-5-20250929`
|
| 41 |
+
- Needs contextual awareness
|
| 42 |
+
- Requires warm, supportive tone
|
| 43 |
+
|
| 44 |
+
**Alternative:** `claude-sonnet-4-20250514`
|
| 45 |
+
|
| 46 |
+
#### 🏥 Medical Assistant
|
| 47 |
+
Provides medical guidance and health education.
|
| 48 |
+
|
| 49 |
+
**Recommended:** `claude-sonnet-4-5-20250929`
|
| 50 |
+
- Requires reliability and consistency
|
| 51 |
+
- Must maintain clinical accuracy
|
| 52 |
+
|
| 53 |
+
**Alternative:** `claude-sonnet-4-20250514`
|
| 54 |
+
|
| 55 |
+
#### 📋 Entry Classifier
|
| 56 |
+
Quickly classifies incoming messages by type.
|
| 57 |
+
|
| 58 |
+
**Recommended:** `gemini-2.0-flash`
|
| 59 |
+
- Fast classification task
|
| 60 |
+
- Optimized for speed
|
| 61 |
+
|
| 62 |
+
**Alternative:** `gemini-2.5-flash`
|
| 63 |
+
|
| 64 |
+
## How to Use
|
| 65 |
+
|
| 66 |
+
### Step 1: Open Model Settings
|
| 67 |
+
Click on the **⚙️ Model Settings** tab in the interface.
|
| 68 |
+
|
| 69 |
+
### Step 2: Select Models
|
| 70 |
+
For each task, choose your preferred model from the dropdown:
|
| 71 |
+
|
| 72 |
+
```
|
| 73 |
+
🤖 Spiritual Analysis
|
| 74 |
+
└─ Spiritual Distress Analyzer: [Select Model ▼]
|
| 75 |
+
|
| 76 |
+
🩺 Medical Triage
|
| 77 |
+
└─ Soft Medical Triage: [Select Model ▼]
|
| 78 |
+
|
| 79 |
+
🏥 Medical Assistance
|
| 80 |
+
└─ Medical Assistant: [Select Model ▼]
|
| 81 |
+
|
| 82 |
+
📋 Classification
|
| 83 |
+
└─ Entry Classifier: [Select Model ▼]
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
### Step 3: Apply Settings
|
| 87 |
+
Click **✅ Apply Model Settings** to activate your choices.
|
| 88 |
+
|
| 89 |
+
### Step 4: Verify
|
| 90 |
+
You'll see a confirmation message showing which models are now active.
|
| 91 |
+
|
| 92 |
+
## Important Notes
|
| 93 |
+
|
| 94 |
+
### Session-Scoped Changes
|
| 95 |
+
- Model selections apply **only to your current session**
|
| 96 |
+
- When you start a new session, defaults are restored
|
| 97 |
+
- Changes don't affect other users
|
| 98 |
+
|
| 99 |
+
### Default Configuration
|
| 100 |
+
If you want to revert to defaults, click **🔄 Reset to Defaults**.
|
| 101 |
+
|
| 102 |
+
Default models:
|
| 103 |
+
- Spiritual Analysis: `claude-sonnet-4-5-20250929`
|
| 104 |
+
- Medical Triage: `claude-sonnet-4-5-20250929`
|
| 105 |
+
- Medical Assistant: `claude-sonnet-4-5-20250929`
|
| 106 |
+
- Classifier: `gemini-2.0-flash`
|
| 107 |
+
|
| 108 |
+
## Performance Considerations
|
| 109 |
+
|
| 110 |
+
### Speed vs. Quality Trade-off
|
| 111 |
+
|
| 112 |
+
**Faster (but less capable):**
|
| 113 |
+
- `gemini-2.0-flash` - Fastest
|
| 114 |
+
- `claude-haiku-4-5-20251001` - Lightweight
|
| 115 |
+
|
| 116 |
+
**Balanced:**
|
| 117 |
+
- `gemini-2.5-flash` - Good speed + quality
|
| 118 |
+
- `claude-sonnet-4-20250514` - Reliable
|
| 119 |
+
|
| 120 |
+
**Most Capable (slower):**
|
| 121 |
+
- `claude-sonnet-4-5-20250929` - Best quality
|
| 122 |
+
- `gemini-2.5-pro` - Advanced reasoning
|
| 123 |
+
|
| 124 |
+
## Troubleshooting
|
| 125 |
+
|
| 126 |
+
### Model Not Available
|
| 127 |
+
If a model appears unavailable:
|
| 128 |
+
1. Check your API keys in `.env`
|
| 129 |
+
2. Verify the model name is correct
|
| 130 |
+
3. Try a different model
|
| 131 |
+
|
| 132 |
+
### Slow Responses
|
| 133 |
+
If responses are slow:
|
| 134 |
+
1. Try a faster model (e.g., `gemini-2.0-flash`)
|
| 135 |
+
2. Check your internet connection
|
| 136 |
+
3. Verify API rate limits
|
| 137 |
+
|
| 138 |
+
### Unexpected Behavior
|
| 139 |
+
If a model behaves unexpectedly:
|
| 140 |
+
1. Reset to defaults
|
| 141 |
+
2. Try a different model
|
| 142 |
+
3. Check the logs for errors
|
| 143 |
+
|
| 144 |
+
## Advanced: Custom Configuration
|
| 145 |
+
|
| 146 |
+
To permanently change default models, edit `src/config/ai_providers_config.py`:
|
| 147 |
+
|
| 148 |
+
```python
|
| 149 |
+
AGENT_CONFIGURATIONS = {
|
| 150 |
+
"SpiritualDistressAnalyzer": {
|
| 151 |
+
"provider": AIProvider.ANTHROPIC,
|
| 152 |
+
"model": AIModel.CLAUDE_SONNET_4_5, # Change here
|
| 153 |
+
"temperature": 0.2,
|
| 154 |
+
"reasoning": "..."
|
| 155 |
+
},
|
| 156 |
+
# ... other agents
|
| 157 |
+
}
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
Then restart the application.
|
| 161 |
+
|
| 162 |
+
## API Key Requirements
|
| 163 |
+
|
| 164 |
+
To use different models, ensure you have API keys configured:
|
| 165 |
+
|
| 166 |
+
```bash
|
| 167 |
+
# .env file
|
| 168 |
+
GEMINI_API_KEY=your_gemini_key
|
| 169 |
+
ANTHROPIC_API_KEY=your_anthropic_key
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
Both keys are required for full functionality.
|
| 173 |
+
|
| 174 |
+
## Support
|
| 175 |
+
|
| 176 |
+
For issues or questions about model selection:
|
| 177 |
+
1. Check the logs in `ai_interactions.log`
|
| 178 |
+
2. Review the model documentation
|
| 179 |
+
3. Try resetting to defaults
|
| 180 |
+
4. Contact support if problems persist
|
README.md
CHANGED
|
@@ -5,19 +5,19 @@ colorFrom: pink
|
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.0.2
|
| 8 |
-
app_file: src/interface/
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
-
# Medical Brain -
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
## ⚡ Швидкий Старт
|
| 17 |
|
| 18 |
### Локальний Запуск
|
| 19 |
|
| 20 |
-
**🏥
|
| 21 |
|
| 22 |
```bash
|
| 23 |
# 1. Налаштувати API ключі (перший раз)
|
|
@@ -27,172 +27,86 @@ ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
| 27 |
EOF
|
| 28 |
|
| 29 |
# 2. Запустити додаток
|
| 30 |
-
./
|
| 31 |
|
| 32 |
# 3. Відкрити в браузері
|
| 33 |
# http://localhost:7860
|
| 34 |
```
|
| 35 |
|
| 36 |
**Що включає інтерфейс:**
|
| 37 |
-
- 💬 **
|
| 38 |
-
-
|
| 39 |
-
-
|
| 40 |
-
-
|
|
|
|
| 41 |
|
| 42 |
Детальніше: [QUICK_START.md](QUICK_START.md)
|
| 43 |
|
| 44 |
---
|
| 45 |
|
| 46 |
-
## 🎯
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
Базовий медичний режим для обробки медичних питань та тріажу.
|
| 52 |
-
|
| 53 |
-
### 💚 Lifestyle Focus
|
| 54 |
-
Персоналізовані рекомендації щодо способу життя, харчування та фізичної активності.
|
| 55 |
-
|
| 56 |
-
### 🕊️ Spiritual Focus
|
| 57 |
-
Оцінка духовного дистресу з автоматичним виявленням red/yellow flags та генерацією referrals.
|
| 58 |
-
|
| 59 |
-
### 🌟 Combined (Lifestyle + Spiritual)
|
| 60 |
-
Комплексна підтримка з координацією обох асистентів та інтелектуальною пріоритизацією.
|
| 61 |
-
|
| 62 |
-
**Переключення режимів:**
|
| 63 |
-
- Автоматичне визначення через Entry Classifier (K/L/S/T)
|
| 64 |
-
- Ручний вибір через UI selector
|
| 65 |
-
- Збереження історії при переключенні
|
| 66 |
-
- Коректне завершення сесій
|
| 67 |
-
|
| 68 |
-
### 🔍 K/L/S/T Classification Logic
|
| 69 |
-
|
| 70 |
-
Система використовує інтелектуальний Entry Classifier для автоматичного визначення найкращого режиму підтримки на основі аналізу повідомлення пацієнта:
|
| 71 |
-
|
| 72 |
-
```mermaid
|
| 73 |
-
flowchart TD
|
| 74 |
-
%% Стилізація
|
| 75 |
-
classDef input fill:#e8f5e9,stroke:#4caf50,stroke-width:3px
|
| 76 |
-
classDef classifier fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
|
| 77 |
-
classDef medical fill:#e3f2fd,stroke:#2196f3,stroke-width:2px
|
| 78 |
-
classDef lifestyle fill:#fff3e0,stroke:#ff9800,stroke-width:2px
|
| 79 |
-
classDef spiritual fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px
|
| 80 |
-
classDef combined fill:#fce4ec,stroke:#e91e63,stroke-width:3px
|
| 81 |
-
classDef urgent fill:#ffebee,stroke:#f44336,stroke-width:3px
|
| 82 |
-
classDef decision fill:#eceff1,stroke:#607d8b,stroke-width:2px
|
| 83 |
-
|
| 84 |
-
%% Input
|
| 85 |
-
Start([📨 User Message]):::input
|
| 86 |
-
Start --> EntryClassifier
|
| 87 |
-
|
| 88 |
-
%% Entry Classifier
|
| 89 |
-
EntryClassifier["🔍 ENTRY CLASSIFIER<br/>(LLM-based Analysis)"]:::classifier
|
| 90 |
-
|
| 91 |
-
EntryClassifier --> KAnalysis["<b>K - Medical Indicators</b><br/>• Symptoms<br/>• Medications<br/>• Vital signs<br/>• Pain levels"]:::medical
|
| 92 |
-
EntryClassifier --> LAnalysis["<b>L - Lifestyle Indicators</b><br/>• Exercise mentions<br/>• Diet/nutrition<br/>• Sleep patterns<br/>• Wellness goals"]:::lifestyle
|
| 93 |
-
EntryClassifier --> SAnalysis["<b>S - Spiritual Indicators</b><br/>• Meaning/purpose<br/>• Faith concerns<br/>• Hopelessness<br/>• Existential questions"]:::spiritual
|
| 94 |
-
EntryClassifier --> TAnalysis["<b>T - Urgency Level</b><br/>• Emergency signs<br/>• Time sensitivity<br/>• Risk assessment"]:::urgent
|
| 95 |
-
|
| 96 |
-
KAnalysis --> KResult{"K Result"}:::decision
|
| 97 |
-
LAnalysis --> LResult{"L Result"}:::decision
|
| 98 |
-
SAnalysis --> SResult{"S Result"}:::decision
|
| 99 |
-
TAnalysis --> TResult{"T Result"}:::decision
|
| 100 |
-
|
| 101 |
-
KResult -->|"none"| KNone["K = none"]
|
| 102 |
-
KResult -->|"minor"| KMinor["K = minor"]
|
| 103 |
-
KResult -->|"urgent"| KUrgent["K = urgent"]:::urgent
|
| 104 |
-
|
| 105 |
-
LResult -->|"off"| LOff["L = off"]
|
| 106 |
-
LResult -->|"on"| LOn["L = on"]:::lifestyle
|
| 107 |
-
|
| 108 |
-
SResult -->|"off"| SOff["S = off"]
|
| 109 |
-
SResult -->|"on"| SOn["S = on"]:::spiritual
|
| 110 |
-
|
| 111 |
-
TResult -->|"routine"| TRoutine["T = routine"]
|
| 112 |
-
TResult -->|"urgent"| TUrgent["T = urgent"]:::urgent
|
| 113 |
-
TResult -->|"emergency"| TEmergency["T = emergency"]:::urgent
|
| 114 |
-
|
| 115 |
-
%% Routing Logic
|
| 116 |
-
KUrgent --> MedicalPriority["🏥 MEDICAL MODE<br/>(Priority Override)"]:::medical
|
| 117 |
-
TEmergency --> MedicalPriority
|
| 118 |
-
TUrgent --> MedicalPriority
|
| 119 |
-
|
| 120 |
-
KNone --> RoutingCheck
|
| 121 |
-
KMinor --> RoutingCheck
|
| 122 |
-
TRoutine --> RoutingCheck
|
| 123 |
-
|
| 124 |
-
RoutingCheck{"Routing<br/>Decision"}:::classifier
|
| 125 |
-
|
| 126 |
-
%% Routing based on L and S
|
| 127 |
-
LOff --> RoutingCheck
|
| 128 |
-
LOn --> RoutingCheck
|
| 129 |
-
SOff --> RoutingCheck
|
| 130 |
-
SOn --> RoutingCheck
|
| 131 |
-
|
| 132 |
-
RoutingCheck -->|"L=on, S=off"| LifestyleMode["💚 LIFESTYLE MODE"]:::lifestyle
|
| 133 |
-
RoutingCheck -->|"L=off, S=on"| SpiritualMode["🕊️ SPIRITUAL MODE"]:::spiritual
|
| 134 |
-
RoutingCheck -->|"L=on, S=on"| CombinedMode["🌟 COMBINED MODE"]:::combined
|
| 135 |
-
RoutingCheck -->|"L=off, S=off"| MedicalDefault["🏥 MEDICAL MODE<br/>(Default)"]:::medical
|
| 136 |
-
|
| 137 |
-
%% Output
|
| 138 |
-
MedicalPriority --> Output
|
| 139 |
-
LifestyleMode --> Output
|
| 140 |
-
SpiritualMode --> Output
|
| 141 |
-
CombinedMode --> Output
|
| 142 |
-
MedicalDefault --> Output
|
| 143 |
-
|
| 144 |
-
Output([📤 Route to Assistant]):::input
|
| 145 |
-
|
| 146 |
-
%% Legend
|
| 147 |
-
subgraph Legend["📋 K/L/S/T FORMAT"]
|
| 148 |
-
direction LR
|
| 149 |
-
LegK["<b>K</b> - Medical (none/minor/urgent)"]
|
| 150 |
-
LegL["<b>L</b> - Lifestyle (off/on)"]
|
| 151 |
-
LegS["<b>S</b> - Spiritual (off/on)"]
|
| 152 |
-
LegT["<b>T</b> - Urgency (routine/urgent/emergency)"]
|
| 153 |
-
end
|
| 154 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
---
|
| 167 |
|
| 168 |
-
## 📦
|
| 169 |
|
| 170 |
-
### 1.
|
| 171 |
-
|
| 172 |
|
| 173 |
-
|
| 174 |
-
```bash
|
| 175 |
-
source venv/bin/activate
|
| 176 |
-
python lifestyle_app.py
|
| 177 |
-
```
|
| 178 |
|
| 179 |
-
### 2.
|
| 180 |
-
|
| 181 |
|
| 182 |
-
|
| 183 |
-
```bash
|
| 184 |
-
./start.sh
|
| 185 |
-
```
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
```
|
| 192 |
|
| 193 |
-
|
|
|
|
| 194 |
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
|
| 197 |
### Перше Використання
|
| 198 |
|
|
@@ -203,151 +117,153 @@ source venv/bin/activate
|
|
| 203 |
pip install -r requirements.txt
|
| 204 |
```
|
| 205 |
|
| 206 |
-
2. **Налаштуйте API
|
| 207 |
```bash
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
| 209 |
```
|
| 210 |
|
| 211 |
-
3. **Запустіть
|
| 212 |
```bash
|
| 213 |
-
./
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
```
|
| 215 |
|
| 216 |
## 📚 Документація
|
| 217 |
|
| 218 |
-
###
|
| 219 |
-
- 📖 [QUICK_START.md](QUICK_START.md) - Швидкий старт
|
| 220 |
- 📁 [STRUCTURE.md](STRUCTURE.md) - Структура проекту
|
| 221 |
-
- 📑 [FILE_INDEX.md](FILE_INDEX.md) - Індекс
|
| 222 |
-
-
|
| 223 |
-
|
| 224 |
-
### Spiritual Health Assessment
|
| 225 |
-
- **Швидкий старт:** [docs/spiritual/ЗАПУСК_ДОДАТКУ.md](docs/spiritual/ЗАПУСК_ДОДАТКУ.md)
|
| 226 |
-
- **Повна документація:** [docs/spiritual/SPIRITUAL_HEALTH_ASSESSMENT_UA.md](docs/spiritual/SPIRITUAL_HEALTH_ASSESSMENT_UA.md)
|
| 227 |
-
- **Індекс документації:** [docs/spiritual/README.md](docs/spiritual/README.md)
|
| 228 |
|
| 229 |
-
###
|
| 230 |
-
-
|
| 231 |
-
- **
|
| 232 |
-
- **
|
|
|
|
| 233 |
|
| 234 |
## 🧪 Тестування
|
| 235 |
|
| 236 |
-
###
|
| 237 |
```bash
|
| 238 |
-
|
| 239 |
-
pytest tests/spiritual/ -v
|
| 240 |
```
|
| 241 |
|
| 242 |
-
**Результат:**
|
| 243 |
|
| 244 |
-
###
|
| 245 |
```bash
|
| 246 |
-
|
| 247 |
-
pytest tests/ -v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
```
|
| 249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
## 📁 Структура Проекту
|
| 251 |
|
| 252 |
```
|
| 253 |
.
|
| 254 |
-
├── src/
|
| 255 |
-
│ ├── core/
|
| 256 |
-
│ │ ├──
|
| 257 |
-
│ │ ├──
|
| 258 |
-
│ │
|
| 259 |
-
│ ├──
|
| 260 |
-
│ │ └──
|
| 261 |
-
│ ├──
|
| 262 |
-
│
|
| 263 |
-
│
|
| 264 |
-
|
| 265 |
-
│
|
| 266 |
-
│
|
| 267 |
-
├── docs/ # Документація
|
| 268 |
-
│ └── spiritual/ # Документація духовного модуля
|
| 269 |
│
|
| 270 |
-
├──
|
| 271 |
-
│
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
│
|
| 273 |
-
├──
|
| 274 |
-
├──
|
| 275 |
-
├──
|
| 276 |
-
└──
|
| 277 |
```
|
| 278 |
|
| 279 |
## 🎯 Основні Функції
|
| 280 |
|
| 281 |
-
###
|
| 282 |
-
|
| 283 |
-
####
|
| 284 |
-
-
|
| 285 |
-
-
|
| 286 |
-
-
|
| 287 |
-
-
|
| 288 |
-
|
| 289 |
-
####
|
| 290 |
-
-
|
| 291 |
-
-
|
| 292 |
-
-
|
| 293 |
-
-
|
| 294 |
-
|
| 295 |
-
####
|
| 296 |
-
-
|
| 297 |
-
-
|
| 298 |
-
-
|
| 299 |
-
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
-
|
| 305 |
-
-
|
| 306 |
-
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
-
|
| 312 |
-
-
|
| 313 |
-
-
|
| 314 |
-
|
| 315 |
-
#### Система Зворотного Зв'язку
|
| 316 |
-
- ✅ Валідація медичними працівниками
|
| 317 |
-
- 📊 Аналітика та метрики
|
| 318 |
-
- 📈 Експорт даних у CSV
|
| 319 |
-
- 🎯 Відстеження точності
|
| 320 |
|
| 321 |
## 🛠️ Технології
|
| 322 |
|
| 323 |
-
- **Backend:** Python 3.
|
| 324 |
-
- **LLM:** Google Gemini
|
| 325 |
-
- **UI:** Gradio
|
| 326 |
-
- **Testing:** Pytest
|
| 327 |
- **Storage:** JSON
|
| 328 |
|
| 329 |
## 📊 Статус Проекту
|
| 330 |
|
| 331 |
-
###
|
| 332 |
-
- ✅
|
| 333 |
-
- ✅
|
| 334 |
-
- ✅
|
| 335 |
-
- ✅
|
| 336 |
-
- ✅
|
| 337 |
-
- ✅
|
| 338 |
-
- ✅
|
| 339 |
-
|
| 340 |
-
### Spiritual Health Assessment
|
| 341 |
-
- ✅ Всі 15 задач виконано
|
| 342 |
-
- ✅ 145 тестів пройдено (100%)
|
| 343 |
-
- ✅ Повна документація створена
|
| 344 |
-
- ✅ Інтегровано в multi-mode систему
|
| 345 |
-
|
| 346 |
-
### Lifestyle Journey
|
| 347 |
-
- ✅ Основний функціонал працює
|
| 348 |
-
- ✅ Інтеграція з Spiritual Health
|
| 349 |
-
- ✅ Combined mode підтримка
|
| 350 |
-
- ✅ Тести пройдено
|
| 351 |
|
| 352 |
## 🔒 Безпека
|
| 353 |
|
|
@@ -362,23 +278,25 @@ pytest tests/ -v
|
|
| 362 |
|
| 363 |
1. **Перевірте логи:**
|
| 364 |
```bash
|
| 365 |
-
tail -f
|
| 366 |
```
|
| 367 |
|
| 368 |
2. **Запустіть тести:**
|
| 369 |
```bash
|
| 370 |
-
pytest tests/
|
| 371 |
```
|
| 372 |
|
| 373 |
3. **Перегляньте документацію:**
|
| 374 |
-
-
|
|
|
|
|
|
|
| 375 |
|
| 376 |
## 🎉 Готово!
|
| 377 |
|
| 378 |
-
|
| 379 |
|
| 380 |
---
|
| 381 |
|
| 382 |
**Версія:** 1.0
|
| 383 |
-
**Дата:**
|
| 384 |
**Статус:** ✅ Готово до використання
|
|
|
|
| 5 |
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.0.2
|
| 8 |
+
app_file: src/interface/simplified_gradio_app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Medical Brain - Simplified Medical Assistant with Spiritual Monitoring
|
| 13 |
|
| 14 |
+
Спрощена система для медичної підтримки пацієнтів з **автоматичним фоновим моніторингом духовного дистресу**.
|
| 15 |
|
| 16 |
## ⚡ Швидкий Старт
|
| 17 |
|
| 18 |
### Локальний Запуск
|
| 19 |
|
| 20 |
+
**🏥 Simplified Medical Assistant + 🕊️ Background Spiritual Monitoring**
|
| 21 |
|
| 22 |
```bash
|
| 23 |
# 1. Налаштувати API ключі (перший раз)
|
|
|
|
| 27 |
EOF
|
| 28 |
|
| 29 |
# 2. Запустити додаток
|
| 30 |
+
PYTHONPATH=. ./venv/bin/python run_simplified_app.py
|
| 31 |
|
| 32 |
# 3. Відкрити в браузері
|
| 33 |
# http://localhost:7860
|
| 34 |
```
|
| 35 |
|
| 36 |
**Що включає інтерфейс:**
|
| 37 |
+
- 💬 **Chat** - Медичні питання та консультації
|
| 38 |
+
- ⚙️ **Model Settings** - Вибір AI моделей для різних завдань
|
| 39 |
+
- � ***Patient Profiles** - 15 профілів для тестування (включаючи Spiritual scenarios)
|
| 40 |
+
- � ***Edit Prompts** - Редагування системних промптів
|
| 41 |
+
- 📖 **Help** - Повна документація та приклади
|
| 42 |
|
| 43 |
Детальніше: [QUICK_START.md](QUICK_START.md)
|
| 44 |
|
| 45 |
---
|
| 46 |
|
| 47 |
+
## 🎯 Архітектура
|
| 48 |
+
|
| 49 |
+
### Фоновий Духовний Моніторинг
|
| 50 |
+
Система працює в **Medical режимі**, але постійно моніторить духовний дистрес:
|
| 51 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
```
|
| 53 |
+
Пацієнт: "Я почуваюся стресованим"
|
| 54 |
+
↓
|
| 55 |
+
[Spiritual Monitor] → YELLOW (Потенційний дистрес)
|
| 56 |
+
↓
|
| 57 |
+
[Soft Spiritual Triage] → Задає 2-3 уточнювальні питання
|
| 58 |
+
↓
|
| 59 |
+
[Triage Response Evaluator] → Оцінює відповіді
|
| 60 |
+
↓
|
| 61 |
+
Результат: GREEN (Справляється) або RED (Потребує направлення)
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
### Три Стани Духовного Здоров'я
|
| 65 |
|
| 66 |
+
**🟢 GREEN - Без Дистресу**
|
| 67 |
+
- Медичні симптоми тільки
|
| 68 |
+
- Рутинні питання
|
| 69 |
+
- Стандартні теми здоров'я
|
| 70 |
|
| 71 |
+
**🟡 YELLOW - Потенційний Дистрес**
|
| 72 |
+
- Стрес, тривога, проблеми зі сном
|
| 73 |
+
- Горе та втрата
|
| 74 |
+
- Екзистенціальні питання
|
| 75 |
+
- Духовна відчуженість
|
| 76 |
+
- Почуття самотності
|
| 77 |
+
|
| 78 |
+
**🔴 RED - Важкий Дистрес (Негайна Направлення)**
|
| 79 |
+
- Суїцидальні думки
|
| 80 |
+
- Важка безнадійність
|
| 81 |
+
- Духовна криза
|
| 82 |
+
- Гнів на Бога
|
| 83 |
+
- Моральна травма
|
| 84 |
|
| 85 |
---
|
| 86 |
|
| 87 |
+
## 📦 Компоненти
|
| 88 |
|
| 89 |
+
### 1. � Simeplified Medical App
|
| 90 |
+
Основна логіка медичного асистента з фоновим духовним моніторингом.
|
| 91 |
|
| 92 |
+
**Файл:** `src/core/simplified_medical_app.py`
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
### 2. 🔍 Spiritual Monitor
|
| 95 |
+
Класифікує повідомлення пацієнта на GREEN/YELLOW/RED.
|
| 96 |
|
| 97 |
+
**Файл:** `src/core/spiritual_monitor.py`
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
+
### 3. 🟡 Soft Triage Manager
|
| 100 |
+
Проводить м'яке духовне питання для тріажу при YELLOW стані.
|
| 101 |
+
|
| 102 |
+
**Файл:** `src/core/soft_triage_manager.py`
|
|
|
|
| 103 |
|
| 104 |
+
### 4. 🎨 Gradio Interface
|
| 105 |
+
Веб-інтерфейс з 5 закладками.
|
| 106 |
|
| 107 |
+
**Файл:** `src/interface/simplified_gradio_app.py`
|
| 108 |
+
|
| 109 |
+
## 🚀 Запуск
|
| 110 |
|
| 111 |
### Перше Використання
|
| 112 |
|
|
|
|
| 117 |
pip install -r requirements.txt
|
| 118 |
```
|
| 119 |
|
| 120 |
+
2. **Налаштуйте API ключі:**
|
| 121 |
```bash
|
| 122 |
+
cat > .env << EOF
|
| 123 |
+
GEMINI_API_KEY=your_gemini_key_here
|
| 124 |
+
ANTHROPIC_API_KEY=your_anthropic_key_here
|
| 125 |
+
EOF
|
| 126 |
```
|
| 127 |
|
| 128 |
+
3. **Запустіть Simplified Medical Assistant:**
|
| 129 |
```bash
|
| 130 |
+
PYTHONPATH=. ./venv/bin/python run_simplified_app.py
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
4. **Відкрийте в браузері:**
|
| 134 |
+
```
|
| 135 |
+
http://localhost:7860
|
| 136 |
```
|
| 137 |
|
| 138 |
## 📚 Документація
|
| 139 |
|
| 140 |
+
### Основна Документація
|
| 141 |
+
- 📖 [QUICK_START.md](QUICK_START.md) - Швидкий старт
|
| 142 |
- 📁 [STRUCTURE.md](STRUCTURE.md) - Структура проекту
|
| 143 |
+
- 📑 [FILE_INDEX.md](FILE_INDEX.md) - Індекс файлів
|
| 144 |
+
- 🤖 [MODEL_SELECTION_GUIDE.md](MODEL_SELECTION_GUIDE.md) - Вибір моделей
|
| 145 |
+
- 📊 [TRIAGE_ANALYSIS.md](TRIAGE_ANALYSIS.md) - Аналіз тріажу
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
+
### Інтерфейс
|
| 148 |
+
- **Help Tab** - Вбудована документація в додатку
|
| 149 |
+
- **Model Settings** - Налаштування AI моделей
|
| 150 |
+
- **Patient Profiles** - 15 профілів для тестування
|
| 151 |
+
- **Edit Prompts** - Редагування системних промптів
|
| 152 |
|
| 153 |
## 🧪 Тестування
|
| 154 |
|
| 155 |
+
### Запуск Всіх Тестів
|
| 156 |
```bash
|
| 157 |
+
PYTHONPATH=. ./venv/bin/python -m pytest tests/ -v
|
|
|
|
| 158 |
```
|
| 159 |
|
| 160 |
+
**Результат:** 130/130 тестів пройдено ✅
|
| 161 |
|
| 162 |
+
### Тестування Spiritual Функціоналу
|
| 163 |
```bash
|
| 164 |
+
# Тести Spiritual Monitor
|
| 165 |
+
PYTHONPATH=. ./venv/bin/python -m pytest tests/test_spiritual_monitor_properties.py -v
|
| 166 |
+
|
| 167 |
+
# Тести Soft Triage
|
| 168 |
+
PYTHONPATH=. ./venv/bin/python -m pytest tests/test_soft_triage_properties.py -v
|
| 169 |
+
|
| 170 |
+
# Тести Referral Language
|
| 171 |
+
PYTHONPATH=. ./venv/bin/python -m pytest tests/test_referral_language_properties.py -v
|
| 172 |
```
|
| 173 |
|
| 174 |
+
### Тестування з Профілями
|
| 175 |
+
1. Відкрийте додаток
|
| 176 |
+
2. Перейдіть на закладку "👥 Patient Profiles"
|
| 177 |
+
3. Виберіть один з 8 Spiritual Testing Profiles
|
| 178 |
+
4. Завантажте профіль
|
| 179 |
+
5. Перейдіть на "💬 Chat" та тестуйте
|
| 180 |
+
|
| 181 |
## 📁 Структура Проекту
|
| 182 |
|
| 183 |
```
|
| 184 |
.
|
| 185 |
+
├── src/
|
| 186 |
+
│ ├── core/
|
| 187 |
+
│ │ ├── simplified_medical_app.py # Основна логіка
|
| 188 |
+
│ │ ├── spiritual_monitor.py # Класифікатор дистресу
|
| 189 |
+
│ │ ├── soft_triage_manager.py # М'яке питання для тріажу
|
| 190 |
+
│ │ ├── spiritual_state.py # State machine
|
| 191 |
+
│ │ └── ai_client.py # AI клієнт
|
| 192 |
+
│ ├── config/
|
| 193 |
+
│ │ ├── prompts.py # Системні промпти
|
| 194 |
+
│ │ └── ai_providers_config.py # Конфігурація моделей
|
| 195 |
+
│ └── interface/
|
| 196 |
+
│ └── simplified_gradio_app.py # Веб-інтерфейс
|
|
|
|
|
|
|
|
|
|
| 197 |
│
|
| 198 |
+
├── tests/
|
| 199 |
+
│ ├── test_spiritual_state_properties.py
|
| 200 |
+
│ ├── test_spiritual_monitor_properties.py
|
| 201 |
+
│ ├── test_soft_triage_properties.py
|
| 202 |
+
│ ├── test_simplified_app_properties.py
|
| 203 |
+
│ └── test_referral_language_properties.py
|
| 204 |
│
|
| 205 |
+
├── run_simplified_app.py # Запуск додатку
|
| 206 |
+
├── requirements.txt # Залежності
|
| 207 |
+
├── .env # API ключі
|
| 208 |
+
└── README.md # Цей файл
|
| 209 |
```
|
| 210 |
|
| 211 |
## 🎯 Основні Функції
|
| 212 |
|
| 213 |
+
### � Simpilified Medical Assistant
|
| 214 |
+
|
| 215 |
+
#### Фоновий Духовний Моніторинг
|
| 216 |
+
- 🔍 Автоматичне виявлення духовного дистресу
|
| 217 |
+
- 🚦 Триступенева класифікація (🟢 🟡 🔴)
|
| 218 |
+
- 📝 Генерація направлень при RED
|
| 219 |
+
- ❓ М'яке питання для тріажу при YELLOW
|
| 220 |
+
|
| 221 |
+
#### Вибір AI Моделей
|
| 222 |
+
- 🤖 Вибір між Claude та Gemini
|
| 223 |
+
- ⚙️ Налаштування для кожного завдання
|
| 224 |
+
- 🔄 Динамічна зміна моделей
|
| 225 |
+
- 💾 Збереження налаштувань в сесії
|
| 226 |
+
|
| 227 |
+
#### Профілі Пацієнтів
|
| 228 |
+
- �️ 15 предефінованих профілів
|
| 229 |
+
- 🟢 GREEN - Здоровий пацієнт
|
| 230 |
+
- 🟡 YELLOW - 4 типи легкого дистресу
|
| 231 |
+
- � RED - 3 тnипи важкого дистресу
|
| 232 |
+
- 📝 Редагування та збереження налаштувань
|
| 233 |
+
|
| 234 |
+
#### Редагування Промптів
|
| 235 |
+
- 🔧 Редагування 5 системних промптів
|
| 236 |
+
- � HTML зформатування для читаності
|
| 237 |
+
- � Скидтання до стандартних
|
| 238 |
+
- � Збережцення в сесії
|
| 239 |
+
|
| 240 |
+
### 🧪 Тестування
|
| 241 |
+
|
| 242 |
+
#### 130 Property-Based Tests
|
| 243 |
+
- ✅ Всі тести проходять
|
| 244 |
+
- � ІПеревірка 14 correctness properties
|
| 245 |
+
- � Пбокриття всіх сценаріїв
|
| 246 |
+
- 🎯 Валідація GREEN/YELLOW/RED логіки
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
## 🛠️ Технології
|
| 249 |
|
| 250 |
+
- **Backend:** Python 3.14
|
| 251 |
+
- **LLM:** Google Gemini + Anthropic Claude
|
| 252 |
+
- **UI:** Gradio 6.0.2
|
| 253 |
+
- **Testing:** Pytest + Hypothesis
|
| 254 |
- **Storage:** JSON
|
| 255 |
|
| 256 |
## 📊 Статус Проекту
|
| 257 |
|
| 258 |
+
### ✅ Simplified Medical Assistant (v1.0)
|
| 259 |
+
- ✅ Фоновий духовний моніторинг
|
| 260 |
+
- ✅ 3 стани (GREEN/YELLOW/RED)
|
| 261 |
+
- ✅ М'яке питання для тріажу
|
| 262 |
+
- ✅ Вибір AI моделей
|
| 263 |
+
- ✅ 15 профілів пацієнтів
|
| 264 |
+
- ✅ Редагування промптів
|
| 265 |
+
- ✅ 130/130 тестів пройдено
|
| 266 |
+
- ✅ Готово до використання
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
## 🔒 Безпека
|
| 269 |
|
|
|
|
| 278 |
|
| 279 |
1. **Перевірте логи:**
|
| 280 |
```bash
|
| 281 |
+
tail -f ai_interactions.log
|
| 282 |
```
|
| 283 |
|
| 284 |
2. **Запустіть тести:**
|
| 285 |
```bash
|
| 286 |
+
PYTHONPATH=. ./venv/bin/python -m pytest tests/ -v
|
| 287 |
```
|
| 288 |
|
| 289 |
3. **Перегляньте документацію:**
|
| 290 |
+
- Help Tab в додатку
|
| 291 |
+
- [MODEL_SELECTION_GUIDE.md](MODEL_SELECTION_GUIDE.md)
|
| 292 |
+
- [TRIAGE_ANALYSIS.md](TRIAGE_ANALYSIS.md)
|
| 293 |
|
| 294 |
## 🎉 Готово!
|
| 295 |
|
| 296 |
+
Simplified Medical Assistant повністю функціональний та готовий до використання.
|
| 297 |
|
| 298 |
---
|
| 299 |
|
| 300 |
**Версія:** 1.0
|
| 301 |
+
**Дата:** 8 грудня 2025
|
| 302 |
**Статус:** ✅ Готово до використання
|
TRIAGE_ANALYSIS.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Аналіз: Triage Question Generator vs Soft Medical Triage
|
| 2 |
+
|
| 3 |
+
## Поточна Структура
|
| 4 |
+
|
| 5 |
+
### 1. **Triage Question Generator** (`SYSTEM_PROMPT_TRIAGE_QUESTION`)
|
| 6 |
+
**Мета:** Генерувати одне емпатичне уточнювальне питання
|
| 7 |
+
|
| 8 |
+
**Характеристики:**
|
| 9 |
+
- Генерує **одне питання** за раз
|
| 10 |
+
- Фокус на **емоційному/духовному** розумінні
|
| 11 |
+
- Відповідь: **текст питання** (не JSON)
|
| 12 |
+
- Контекст: Пацієнт вже класифікований як YELLOW
|
| 13 |
+
- Мова: Відповідає мові пацієнта
|
| 14 |
+
- Приклади питань про почуття, підтримку, копінг-стратегії
|
| 15 |
+
|
| 16 |
+
**Використання:**
|
| 17 |
+
```
|
| 18 |
+
SoftTriageManager.generate_question()
|
| 19 |
+
→ Повертає одне питання
|
| 20 |
+
→ Показується пацієнту
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
### 2. **Soft Medical Triage** (`SYSTEM_PROMPT_SOFT_MEDICAL_TRIAGE`)
|
| 26 |
+
**Мета:** Проводити теплу, контекстно-свідому оцінку здоров'я
|
| 27 |
+
|
| 28 |
+
**Характеристики:**
|
| 29 |
+
- Генерує **повну відповідь** (не просто питання)
|
| 30 |
+
- Фокус на **медичному** контексті та історії
|
| 31 |
+
- Відповідь: **текст відповіді** (природна розмова)
|
| 32 |
+
- Контекст: Загальна медична розмова
|
| 33 |
+
- Мова: Відповідає мові пацієнта
|
| 34 |
+
- Сценарії: перша взаємодія, продовження, медичні оновлення
|
| 35 |
+
|
| 36 |
+
**Використання:**
|
| 37 |
+
```
|
| 38 |
+
SimplifiedMedicalApp.process_message()
|
| 39 |
+
→ Генерує теплу медичну відповідь
|
| 40 |
+
→ Показується пацієнту як асистент
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## Ключові Різниці
|
| 46 |
+
|
| 47 |
+
| Аспект | Triage Question | Soft Medical Triage |
|
| 48 |
+
|--------|-----------------|-------------------|
|
| 49 |
+
| **Мета** | Уточнити емоційний стан | Надати медичну підтримку |
|
| 50 |
+
| **Вихід** | Одне питання | Повна відповідь |
|
| 51 |
+
| **Контекст** | YELLOW стан (тріаж) | Загальна медична розмова |
|
| 52 |
+
| **Фокус** | Емоції, почуття, копінг | Здоров'я, симптоми, медичні питання |
|
| 53 |
+
| **Кількість питань** | 1 питання за раз | 1-2 питання в контексті відповіді |
|
| 54 |
+
| **Формат** | Чистий текст | Природна розмова |
|
| 55 |
+
| **Мета тріажу** | Визначити RED vs GREEN | Надати теплу підтримку |
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
## Чи Можна Їх Об'єднати?
|
| 60 |
+
|
| 61 |
+
### ❌ НІ, їх не варто об'єднувати
|
| 62 |
+
|
| 63 |
+
**Причини:**
|
| 64 |
+
|
| 65 |
+
1. **Різні Цілі**
|
| 66 |
+
- Triage Question: Діагностична (визначити серйозність)
|
| 67 |
+
- Soft Medical Triage: Терапевтична (надати підтримку)
|
| 68 |
+
|
| 69 |
+
2. **Різні Контексти**
|
| 70 |
+
- Triage Question: Активний тріаж (YELLOW стан)
|
| 71 |
+
- Soft Medical Triage: Загальна медична розмова
|
| 72 |
+
|
| 73 |
+
3. **Різні Вихідні Формати**
|
| 74 |
+
- Triage Question: Питання (для оцінки відповіді)
|
| 75 |
+
- Soft Medical Triage: Відповідь (для пацієнта)
|
| 76 |
+
|
| 77 |
+
4. **Різні Обробники**
|
| 78 |
+
- Triage Question: `SoftTriageManager.generate_question()`
|
| 79 |
+
- Soft Medical Triage: `SimplifiedMedicalApp.process_message()`
|
| 80 |
+
|
| 81 |
+
5. **Різні Оцінки**
|
| 82 |
+
- Triage Question: Оцінюється `SYSTEM_PROMPT_TRIAGE_EVALUATE`
|
| 83 |
+
- Soft Medical Triage: Просто показується пацієнту
|
| 84 |
+
|
| 85 |
+
---
|
| 86 |
+
|
| 87 |
+
## Поточний Потік
|
| 88 |
+
|
| 89 |
+
```
|
| 90 |
+
Пацієнт: "Я почуваюся стресованим"
|
| 91 |
+
↓
|
| 92 |
+
[Spiritual Monitor] → YELLOW
|
| 93 |
+
↓
|
| 94 |
+
[Soft Triage Manager]
|
| 95 |
+
├─ Triage Question Generator
|
| 96 |
+
│ └─ "Як ви справляєтесь з цим стресом?"
|
| 97 |
+
├─ Пацієнт відповідає
|
| 98 |
+
├─ Triage Response Evaluator
|
| 99 |
+
│ └─ "continue" / "resolved_green" / "escalate_red"
|
| 100 |
+
└─ Якщо "continue" → ще одне питання
|
| 101 |
+
|
| 102 |
+
Паралельно:
|
| 103 |
+
[Soft Medical Triage]
|
| 104 |
+
└─ Генерує теплу медичну відповідь
|
| 105 |
+
└─ Показується як асистент
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
---
|
| 109 |
+
|
| 110 |
+
## Рекомендація
|
| 111 |
+
|
| 112 |
+
**Зберегти обидва промпти окремо**, оскільки вони:
|
| 113 |
+
- Служать різним цілям
|
| 114 |
+
- Використовуються в різних контекстах
|
| 115 |
+
- Мають різні вихідні формати
|
| 116 |
+
- Обробляються різними компонентами
|
| 117 |
+
|
| 118 |
+
Це дозволяє:
|
| 119 |
+
- ✅ Чіткий розподіл відповідальності
|
| 120 |
+
- ✅ Легше тестувати кож��н компонент
|
| 121 |
+
- ✅ Легше модифікувати один без впливу на інший
|
| 122 |
+
- ✅ Кращий контроль якості для кожної функції
|
src/config/ai_providers_config.py
CHANGED
|
@@ -18,30 +18,29 @@ class AIProvider(Enum):
|
|
| 18 |
class AIModel(Enum):
|
| 19 |
"""Supported AI models"""
|
| 20 |
# Gemini models
|
|
|
|
| 21 |
GEMINI_2_5_FLASH = "gemini-2.5-flash"
|
| 22 |
GEMINI_2_0_FLASH = "gemini-2.0-flash"
|
| 23 |
-
|
| 24 |
-
GEMINI_1_5_PRO = "gemini-1.5-pro"
|
| 25 |
|
| 26 |
# Anthropic models
|
| 27 |
CLAUDE_SONNET_4_5 = "claude-sonnet-4-5-20250929"
|
|
|
|
| 28 |
CLAUDE_SONNET_4 = "claude-sonnet-4-20250514"
|
| 29 |
CLAUDE_SONNET_3_7 = "claude-3-7-sonnet-20250219"
|
| 30 |
-
|
| 31 |
-
CLAUDE_HAIKU_3_5 = "claude-3-5-haiku-20241022"
|
| 32 |
|
| 33 |
# Provider-specific configurations
|
| 34 |
PROVIDER_CONFIGS = {
|
| 35 |
AIProvider.GEMINI: {
|
| 36 |
"api_key_env": "GEMINI_API_KEY",
|
| 37 |
"default_model": AIModel.GEMINI_2_0_FLASH,
|
| 38 |
-
"default_temperature": 0
|
| 39 |
"max_tokens": None, # Gemini handles this automatically
|
| 40 |
"available_models": [
|
|
|
|
| 41 |
AIModel.GEMINI_2_5_FLASH,
|
| 42 |
AIModel.GEMINI_2_0_FLASH,
|
| 43 |
-
AIModel.GEMINI_2_5_PRO,
|
| 44 |
-
AIModel.GEMINI_1_5_PRO
|
| 45 |
]
|
| 46 |
},
|
| 47 |
AIProvider.ANTHROPIC: {
|
|
@@ -51,10 +50,9 @@ PROVIDER_CONFIGS = {
|
|
| 51 |
"max_tokens": 20000,
|
| 52 |
"available_models": [
|
| 53 |
AIModel.CLAUDE_SONNET_4_5,
|
|
|
|
| 54 |
AIModel.CLAUDE_SONNET_4,
|
| 55 |
-
AIModel.CLAUDE_SONNET_3_7
|
| 56 |
-
AIModel.CLAUDE_SONNET_3_5,
|
| 57 |
-
AIModel.CLAUDE_HAIKU_3_5
|
| 58 |
]
|
| 59 |
}
|
| 60 |
}
|
|
@@ -78,10 +76,10 @@ AGENT_CONFIGURATIONS = {
|
|
| 78 |
},
|
| 79 |
|
| 80 |
"TriageExitClassifier": {
|
| 81 |
-
"provider": AIProvider.
|
| 82 |
-
"model": AIModel.
|
| 83 |
"temperature": 0.2,
|
| 84 |
-
"reasoning": "Medical triage decisions require
|
| 85 |
},
|
| 86 |
|
| 87 |
# Medical Assistant uses Anthropic for safety and reliability
|
|
@@ -93,10 +91,10 @@ AGENT_CONFIGURATIONS = {
|
|
| 93 |
},
|
| 94 |
|
| 95 |
"SoftMedicalTriage": {
|
| 96 |
-
"provider": AIProvider.
|
| 97 |
-
"model": AIModel.
|
| 98 |
"temperature": 0.3,
|
| 99 |
-
"reasoning": "Gentle triage
|
| 100 |
},
|
| 101 |
|
| 102 |
# Spiritual Distress Analyzer uses Anthropic for empathy and safety
|
|
|
|
| 18 |
class AIModel(Enum):
|
| 19 |
"""Supported AI models"""
|
| 20 |
# Gemini models
|
| 21 |
+
GEMINI_FLASH_LATEST="gemini-flash-latest"
|
| 22 |
GEMINI_2_5_FLASH = "gemini-2.5-flash"
|
| 23 |
GEMINI_2_0_FLASH = "gemini-2.0-flash"
|
| 24 |
+
|
|
|
|
| 25 |
|
| 26 |
# Anthropic models
|
| 27 |
CLAUDE_SONNET_4_5 = "claude-sonnet-4-5-20250929"
|
| 28 |
+
CLAUDE_HAIKU_4_5 = "claude-haiku-4-5-20251001"
|
| 29 |
CLAUDE_SONNET_4 = "claude-sonnet-4-20250514"
|
| 30 |
CLAUDE_SONNET_3_7 = "claude-3-7-sonnet-20250219"
|
| 31 |
+
|
|
|
|
| 32 |
|
| 33 |
# Provider-specific configurations
|
| 34 |
PROVIDER_CONFIGS = {
|
| 35 |
AIProvider.GEMINI: {
|
| 36 |
"api_key_env": "GEMINI_API_KEY",
|
| 37 |
"default_model": AIModel.GEMINI_2_0_FLASH,
|
| 38 |
+
"default_temperature": 0,
|
| 39 |
"max_tokens": None, # Gemini handles this automatically
|
| 40 |
"available_models": [
|
| 41 |
+
AIModel.GEMINI_FLASH_LATEST,
|
| 42 |
AIModel.GEMINI_2_5_FLASH,
|
| 43 |
AIModel.GEMINI_2_0_FLASH,
|
|
|
|
|
|
|
| 44 |
]
|
| 45 |
},
|
| 46 |
AIProvider.ANTHROPIC: {
|
|
|
|
| 50 |
"max_tokens": 20000,
|
| 51 |
"available_models": [
|
| 52 |
AIModel.CLAUDE_SONNET_4_5,
|
| 53 |
+
AIModel.CLAUDE_HAIKU_4_5,
|
| 54 |
AIModel.CLAUDE_SONNET_4,
|
| 55 |
+
AIModel.CLAUDE_SONNET_3_7
|
|
|
|
|
|
|
| 56 |
]
|
| 57 |
}
|
| 58 |
}
|
|
|
|
| 76 |
},
|
| 77 |
|
| 78 |
"TriageExitClassifier": {
|
| 79 |
+
"provider": AIProvider.ANTHROPIC,
|
| 80 |
+
"model": AIModel.CLAUDE_SONNET_4_5,
|
| 81 |
"temperature": 0.2,
|
| 82 |
+
"reasoning": "Medical triage decisions require nuanced understanding and safety"
|
| 83 |
},
|
| 84 |
|
| 85 |
# Medical Assistant uses Anthropic for safety and reliability
|
|
|
|
| 91 |
},
|
| 92 |
|
| 93 |
"SoftMedicalTriage": {
|
| 94 |
+
"provider": AIProvider.ANTHROPIC,
|
| 95 |
+
"model": AIModel.CLAUDE_SONNET_4_5,
|
| 96 |
"temperature": 0.3,
|
| 97 |
+
"reasoning": "Gentle triage requires empathy and nuanced understanding"
|
| 98 |
},
|
| 99 |
|
| 100 |
# Spiritual Distress Analyzer uses Anthropic for empathy and safety
|
src/config/prompts.py
CHANGED
|
@@ -2,112 +2,124 @@
|
|
| 2 |
|
| 3 |
# ===== CLASSIFIERS =====
|
| 4 |
|
| 5 |
-
SYSTEM_PROMPT_ENTRY_CLASSIFIER = """
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
Classify the current patient message to determine the appropriate system mode(s). Analyze the message for medical concerns (K), lifestyle needs (L), and spiritual distress indicators (S).
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
- Moral distress, ethical dilemmas
|
| 49 |
-
- Loss of hope, future orientation
|
| 50 |
-
- Disconnection from spiritual community
|
| 51 |
-
- Inability to find peace or comfort
|
| 52 |
-
|
| 53 |
-
DECISION LOGIC:
|
| 54 |
1. Scan for medical symptoms → Set K level
|
| 55 |
2. Scan for lifestyle keywords → Set L (on/off)
|
| 56 |
3. Scan for emotional/spiritual markers → Set S (on/off)
|
| 57 |
4. Assess overall urgency → Set T level
|
|
|
|
| 58 |
|
| 59 |
-
|
| 60 |
✅ "I want to start exercising" → K:none, L:on, S:off, T:routine
|
| 61 |
✅ "I have a headache" → K:minor, L:off, S:off, T:routine
|
| 62 |
✅ "Why is this happening to me? I feel so hopeless" → K:none, L:off, S:on, T:urgent
|
| 63 |
✅ "I want to exercise but feel so depressed" → K:none, L:on, S:on, T:routine
|
| 64 |
✅ "Severe chest pain" → K:urgent, L:off, S:off, T:emergency
|
| 65 |
✅ "I can't find meaning in life anymore" → K:none, L:off, S:on, T:urgent
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
- Focus ONLY on current message content
|
| 69 |
- Be sensitive to subtle emotional/spiritual cues
|
| 70 |
- Medical safety is paramount (K and T take priority)
|
| 71 |
- Multiple dimensions can be active simultaneously
|
|
|
|
| 72 |
|
| 73 |
-
|
|
|
|
| 74 |
{
|
| 75 |
"K": "none|minor|urgent",
|
| 76 |
"L": "off|on",
|
| 77 |
"S": "off|on",
|
| 78 |
"T": "routine|urgent|emergency",
|
| 79 |
"reasoning": "Brief explanation of classification"
|
| 80 |
-
}
|
|
|
|
| 81 |
|
| 82 |
-
SYSTEM_PROMPT_TRIAGE_EXIT_CLASSIFIER = """
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
|
| 85 |
Determine if the patient is medically stable and ready to transition from medical triage to lifestyle coaching.
|
|
|
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
|
|
|
| 89 |
- Medical concerns addressed or stabilized
|
| 90 |
- Patient expresses interest in lifestyle activities
|
| 91 |
- No urgent symptoms requiring immediate attention
|
| 92 |
- Patient feels comfortable proceeding with lifestyle goals
|
|
|
|
| 93 |
|
| 94 |
-
|
|
|
|
| 95 |
- Active, unresolved medical symptoms
|
| 96 |
- Patient requests continued medical focus
|
| 97 |
- Urgent medical issues requiring attention
|
| 98 |
- Patient expresses discomfort with lifestyle transition
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
-
|
| 102 |
-
-
|
| 103 |
-
-
|
|
|
|
| 104 |
|
| 105 |
-
|
|
|
|
| 106 |
{
|
| 107 |
"ready_for_lifestyle": true/false,
|
| 108 |
"reasoning": "clear explanation in patient's language",
|
| 109 |
"medical_status": "stable|needs_attention|resolved"
|
| 110 |
-
}
|
|
|
|
| 111 |
|
| 112 |
# ===== DEPRECATED PROMPTS REMOVED =====
|
| 113 |
# LifestyleExitClassifier functionality moved to MainLifestyleAssistant
|
|
@@ -141,9 +153,11 @@ Assess patient's readiness for lifestyle coaching mode based on medical stabilit
|
|
| 141 |
|
| 142 |
# ===== LIFESTYLE PROFILE UPDATE =====
|
| 143 |
|
| 144 |
-
SYSTEM_PROMPT_LIFESTYLE_PROFILE_UPDATER = """
|
|
|
|
|
|
|
| 145 |
|
| 146 |
-
|
| 147 |
Analyze a completed lifestyle coaching session and intelligently update the patient's lifestyle profile based on:
|
| 148 |
- Patient responses and feedback during the session
|
| 149 |
- Expressed preferences, concerns, or limitations
|
|
@@ -151,26 +165,33 @@ Analyze a completed lifestyle coaching session and intelligently update the pati
|
|
| 151 |
- New goals or modifications to existing goals
|
| 152 |
- Changes in exercise preferences or dietary habits
|
| 153 |
- Planning for next lifestyle coaching session
|
|
|
|
| 154 |
|
| 155 |
-
|
| 156 |
1. Extract meaningful insights from patient interactions
|
| 157 |
2. Identify concrete progress or challenges
|
| 158 |
3. Update relevant profile sections with specific, actionable information
|
| 159 |
4. Maintain medical accuracy and safety considerations
|
| 160 |
5. Preserve existing information unless contradicted by new evidence
|
| 161 |
-
6.
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
Based on the session content, patient engagement, and progress stage, determine when the next lifestyle coaching session should occur:
|
| 165 |
-
-
|
| 166 |
-
-
|
| 167 |
-
-
|
| 168 |
-
-
|
| 169 |
-
-
|
|
|
|
| 170 |
|
| 171 |
-
|
|
|
|
|
|
|
| 172 |
|
| 173 |
-
|
|
|
|
|
|
|
| 174 |
|
| 175 |
def PROMPT_LIFESTYLE_PROFILE_UPDATE(current_profile, session_messages, session_context):
|
| 176 |
"""Generate prompt for LLM-based lifestyle profile update"""
|
|
@@ -235,80 +256,116 @@ RESPOND IN JSON FORMAT:
|
|
| 235 |
|
| 236 |
# ===== ASSISTANTS =====
|
| 237 |
|
| 238 |
-
SYSTEM_PROMPT_MEDICAL_ASSISTANT = """
|
|
|
|
|
|
|
| 239 |
|
| 240 |
-
|
| 241 |
Provide safe, evidence-based medical guidance while maintaining appropriate clinical boundaries.
|
|
|
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
|
|
|
| 245 |
- Provide general health education
|
| 246 |
- Explain chronic disease management principles
|
| 247 |
- Offer symptom monitoring guidance
|
| 248 |
- Support medication adherence (not prescribe)
|
| 249 |
- Recommend when to contact healthcare providers
|
|
|
|
| 250 |
|
| 251 |
-
|
|
|
|
| 252 |
- Diagnose medical conditions
|
| 253 |
- Prescribe or adjust medications
|
| 254 |
- Replace professional medical evaluation
|
| 255 |
- Provide emergency medical treatment
|
|
|
|
|
|
|
| 256 |
|
| 257 |
-
|
| 258 |
-
|
|
|
|
| 259 |
- Chest pain, severe shortness of breath
|
| 260 |
- Signs of stroke, severe allergic reactions
|
| 261 |
- Uncontrolled bleeding, severe trauma
|
| 262 |
- Loss of consciousness, severe confusion
|
|
|
|
| 263 |
|
| 264 |
-
|
|
|
|
| 265 |
- New or worsening symptoms
|
| 266 |
- Medication side effects or concerns
|
| 267 |
- Significant changes in chronic conditions
|
| 268 |
- Patient anxiety about health changes
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
-
|
| 274 |
-
-
|
| 275 |
-
-
|
| 276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
Always prioritize patient safety over providing comprehensive answers.
|
|
|
|
| 278 |
|
| 279 |
-
|
|
|
|
|
|
|
| 280 |
|
| 281 |
-
SYSTEM_PROMPT_SOFT_MEDICAL_TRIAGE = """
|
|
|
|
|
|
|
| 282 |
|
| 283 |
-
|
| 284 |
Provide a warm, contextually-aware health assessment during patient interactions.
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
Always respond in the same language the patient uses in their message.
|
|
|
|
| 310 |
|
| 311 |
-
|
|
|
|
|
|
|
| 312 |
|
| 313 |
def PROMPT_MEDICAL_ASSISTANT(clinical_background, active_problems, medications, recent_vitals, history_text, user_message):
|
| 314 |
return f"""PATIENT MEDICAL PROFILE ({clinical_background.patient_name}):
|
|
@@ -343,53 +400,68 @@ Conduct gentle medical triage - acknowledge the patient warmly and delicately ch
|
|
| 343 |
|
| 344 |
# ===== MAIN LIFESTYLE ASSISTANT (NEW) =====
|
| 345 |
|
| 346 |
-
SYSTEM_PROMPT_MAIN_LIFESTYLE = """
|
|
|
|
|
|
|
| 347 |
|
| 348 |
-
|
| 349 |
Provide personalized lifestyle coaching while determining the optimal action for each patient interaction.
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
-
|
| 354 |
-
-
|
| 355 |
-
-
|
| 356 |
-
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
|
|
|
|
|
|
| 361 |
- Patient asks general questions needing clarification
|
| 362 |
- Missing key information about preferences/limitations
|
| 363 |
- Need to understand patient's specific situation better
|
| 364 |
- Patient provides vague or incomplete requests
|
|
|
|
| 365 |
|
| 366 |
-
|
|
|
|
| 367 |
- Patient has clear, specific lifestyle questions
|
| 368 |
- Providing concrete advice on exercise/nutrition
|
| 369 |
- Motivating and supporting patient progress
|
| 370 |
- Discussing specific lifestyle strategies
|
|
|
|
| 371 |
|
| 372 |
-
|
|
|
|
| 373 |
- Patient mentions new medical symptoms or complaints
|
| 374 |
- Patient explicitly requests to end the session
|
| 375 |
- Session has become very long (8+ exchanges)
|
| 376 |
- Natural conversation endpoint reached
|
| 377 |
- Medical concerns emerge that need attention
|
|
|
|
|
|
|
| 378 |
|
| 379 |
-
|
| 380 |
- Keep responses practical and actionable
|
| 381 |
- Reference patient's medical conditions when relevant for safety
|
| 382 |
- Maintain warm, encouraging tone
|
| 383 |
- Provide specific, measurable recommendations when possible
|
|
|
|
| 384 |
|
| 385 |
-
|
|
|
|
| 386 |
{
|
| 387 |
"message": "your response in patient's language",
|
| 388 |
"action": "gather_info|lifestyle_dialog|close",
|
| 389 |
"reasoning": "brief explanation of chosen action"
|
| 390 |
}
|
|
|
|
| 391 |
|
| 392 |
-
|
|
|
|
|
|
|
| 393 |
|
| 394 |
# ===== DEPRECATED: Old lifestyle assistant (replaced with MAIN_LIFESTYLE) =====
|
| 395 |
|
|
|
|
| 2 |
|
| 3 |
# ===== CLASSIFIERS =====
|
| 4 |
|
| 5 |
+
SYSTEM_PROMPT_ENTRY_CLASSIFIER = """<system_role>
|
| 6 |
+
You are a message classification specialist for a medical chat system with lifestyle coaching and spiritual health assessment capabilities.
|
| 7 |
+
</system_role>
|
| 8 |
|
| 9 |
+
<task>
|
| 10 |
Classify the current patient message to determine the appropriate system mode(s). Analyze the message for medical concerns (K), lifestyle needs (L), and spiritual distress indicators (S).
|
| 11 |
+
</task>
|
| 12 |
+
|
| 13 |
+
<classification_dimensions>
|
| 14 |
+
<dimension name="K" label="Koncern - Medical">
|
| 15 |
+
<value>none: No medical concerns</value>
|
| 16 |
+
<value>minor: Minor medical questions or stable conditions</value>
|
| 17 |
+
<value>urgent: Active symptoms, pain, or medical issues requiring attention</value>
|
| 18 |
+
</dimension>
|
| 19 |
+
|
| 20 |
+
<dimension name="L" label="Lifestyle">
|
| 21 |
+
<value>off: No lifestyle/exercise/nutrition requests</value>
|
| 22 |
+
<value>on: Lifestyle, exercise, nutrition, rehabilitation requests</value>
|
| 23 |
+
</dimension>
|
| 24 |
+
|
| 25 |
+
<dimension name="S" label="Spiritual">
|
| 26 |
+
<value>off: No spiritual distress indicators</value>
|
| 27 |
+
<value>on: Spiritual/emotional distress, existential concerns, meaning/purpose questions</value>
|
| 28 |
+
</dimension>
|
| 29 |
+
|
| 30 |
+
<dimension name="T" label="Triage - Urgency">
|
| 31 |
+
<value>routine: Normal conversation, no urgency</value>
|
| 32 |
+
<value>urgent: Requires prompt attention but not emergency</value>
|
| 33 |
+
<value>emergency: Immediate medical attention needed</value>
|
| 34 |
+
</dimension>
|
| 35 |
+
</classification_dimensions>
|
| 36 |
+
|
| 37 |
+
<detection_keywords>
|
| 38 |
+
<lifestyle_keywords>exercise, workout, training, fitness, sport, rehabilitation, nutrition, diet, physical, activity, movement, therapy</lifestyle_keywords>
|
| 39 |
+
|
| 40 |
+
<emotional_markers>
|
| 41 |
+
Anger, rage, frustration, irritability; Sadness, depression, crying, grief; Hopelessness, helplessness, despair; Anxiety, fear, worry, panic; Guilt, shame, regret; Loneliness, isolation, abandonment
|
| 42 |
+
</emotional_markers>
|
| 43 |
+
|
| 44 |
+
<spiritual_markers>
|
| 45 |
+
Questions about meaning, purpose, "why me?"; Loss of faith, questioning beliefs; Feeling abandoned by God/higher power; Existential concerns, life/death questions; Moral distress, ethical dilemmas; Loss of hope, future orientation; Disconnection from spiritual community; Inability to find peace or comfort
|
| 46 |
+
</spiritual_markers>
|
| 47 |
+
</detection_keywords>
|
| 48 |
+
|
| 49 |
+
<decision_logic>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
1. Scan for medical symptoms → Set K level
|
| 51 |
2. Scan for lifestyle keywords → Set L (on/off)
|
| 52 |
3. Scan for emotional/spiritual markers → Set S (on/off)
|
| 53 |
4. Assess overall urgency → Set T level
|
| 54 |
+
</decision_logic>
|
| 55 |
|
| 56 |
+
<examples>
|
| 57 |
✅ "I want to start exercising" → K:none, L:on, S:off, T:routine
|
| 58 |
✅ "I have a headache" → K:minor, L:off, S:off, T:routine
|
| 59 |
✅ "Why is this happening to me? I feel so hopeless" → K:none, L:off, S:on, T:urgent
|
| 60 |
✅ "I want to exercise but feel so depressed" → K:none, L:on, S:on, T:routine
|
| 61 |
✅ "Severe chest pain" → K:urgent, L:off, S:off, T:emergency
|
| 62 |
✅ "I can't find meaning in life anymore" → K:none, L:off, S:on, T:urgent
|
| 63 |
+
</examples>
|
| 64 |
|
| 65 |
+
<critical_rules>
|
| 66 |
- Focus ONLY on current message content
|
| 67 |
- Be sensitive to subtle emotional/spiritual cues
|
| 68 |
- Medical safety is paramount (K and T take priority)
|
| 69 |
- Multiple dimensions can be active simultaneously
|
| 70 |
+
</critical_rules>
|
| 71 |
|
| 72 |
+
<output_format>
|
| 73 |
+
Respond with ONLY valid JSON in this exact format:
|
| 74 |
{
|
| 75 |
"K": "none|minor|urgent",
|
| 76 |
"L": "off|on",
|
| 77 |
"S": "off|on",
|
| 78 |
"T": "routine|urgent|emergency",
|
| 79 |
"reasoning": "Brief explanation of classification"
|
| 80 |
+
}
|
| 81 |
+
</output_format>"""
|
| 82 |
|
| 83 |
+
SYSTEM_PROMPT_TRIAGE_EXIT_CLASSIFIER = """<system_role>
|
| 84 |
+
You are a clinical triage specialist evaluating patient readiness for lifestyle coaching after medical assessment.
|
| 85 |
+
</system_role>
|
| 86 |
|
| 87 |
+
<task>
|
| 88 |
Determine if the patient is medically stable and ready to transition from medical triage to lifestyle coaching.
|
| 89 |
+
</task>
|
| 90 |
|
| 91 |
+
<readiness_assessment>
|
| 92 |
+
<ready_criteria>
|
| 93 |
+
✅ READY for lifestyle coaching when:
|
| 94 |
- Medical concerns addressed or stabilized
|
| 95 |
- Patient expresses interest in lifestyle activities
|
| 96 |
- No urgent symptoms requiring immediate attention
|
| 97 |
- Patient feels comfortable proceeding with lifestyle goals
|
| 98 |
+
</ready_criteria>
|
| 99 |
|
| 100 |
+
<not_ready_criteria>
|
| 101 |
+
❌ NOT READY when:
|
| 102 |
- Active, unresolved medical symptoms
|
| 103 |
- Patient requests continued medical focus
|
| 104 |
- Urgent medical issues requiring attention
|
| 105 |
- Patient expresses discomfort with lifestyle transition
|
| 106 |
+
</not_ready_criteria>
|
| 107 |
+
</readiness_assessment>
|
| 108 |
|
| 109 |
+
<decision_approach>
|
| 110 |
+
- Conservative: When in doubt, prioritize medical safety
|
| 111 |
+
- Patient-centered: Respect patient's expressed preferences
|
| 112 |
+
- Contextual: Consider both medical status and patient readiness
|
| 113 |
+
</decision_approach>
|
| 114 |
|
| 115 |
+
<output_format>
|
| 116 |
+
Respond with ONLY valid JSON in this exact format:
|
| 117 |
{
|
| 118 |
"ready_for_lifestyle": true/false,
|
| 119 |
"reasoning": "clear explanation in patient's language",
|
| 120 |
"medical_status": "stable|needs_attention|resolved"
|
| 121 |
+
}
|
| 122 |
+
</output_format>"""
|
| 123 |
|
| 124 |
# ===== DEPRECATED PROMPTS REMOVED =====
|
| 125 |
# LifestyleExitClassifier functionality moved to MainLifestyleAssistant
|
|
|
|
| 153 |
|
| 154 |
# ===== LIFESTYLE PROFILE UPDATE =====
|
| 155 |
|
| 156 |
+
SYSTEM_PROMPT_LIFESTYLE_PROFILE_UPDATER = """<system_role>
|
| 157 |
+
You are an experienced lifestyle coach and medical data analyst specializing in patient progress tracking and profile optimization.
|
| 158 |
+
</system_role>
|
| 159 |
|
| 160 |
+
<task>
|
| 161 |
Analyze a completed lifestyle coaching session and intelligently update the patient's lifestyle profile based on:
|
| 162 |
- Patient responses and feedback during the session
|
| 163 |
- Expressed preferences, concerns, or limitations
|
|
|
|
| 165 |
- New goals or modifications to existing goals
|
| 166 |
- Changes in exercise preferences or dietary habits
|
| 167 |
- Planning for next lifestyle coaching session
|
| 168 |
+
</task>
|
| 169 |
|
| 170 |
+
<analysis_requirements>
|
| 171 |
1. Extract meaningful insights from patient interactions
|
| 172 |
2. Identify concrete progress or challenges
|
| 173 |
3. Update relevant profile sections with specific, actionable information
|
| 174 |
4. Maintain medical accuracy and safety considerations
|
| 175 |
5. Preserve existing information unless contradicted by new evidence
|
| 176 |
+
6. Determine optimal timing for next lifestyle check-in session
|
| 177 |
+
</analysis_requirements>
|
| 178 |
|
| 179 |
+
<next_session_planning>
|
| 180 |
Based on the session content, patient engagement, and progress stage, determine when the next lifestyle coaching session should occur:
|
| 181 |
+
- Immediate follow-up (1-3 days): For new patients, significant changes, or concerns
|
| 182 |
+
- Short-term follow-up (1 week): For active coaching phases, new exercise programs
|
| 183 |
+
- Regular follow-up (2-3 weeks): For established patients with stable progress
|
| 184 |
+
- Long-term follow-up (1 month+): For maintenance phase patients
|
| 185 |
+
- As needed: If patient requests or when specific goals are met
|
| 186 |
+
</next_session_planning>
|
| 187 |
|
| 188 |
+
<response_format>
|
| 189 |
+
JSON with updated profile sections, reasoning, and next session planning
|
| 190 |
+
</response_format>
|
| 191 |
|
| 192 |
+
<language_requirement>
|
| 193 |
+
Always respond in the same language as the patient's messages (English, Ukrainian, etc.)
|
| 194 |
+
</language_requirement>"""
|
| 195 |
|
| 196 |
def PROMPT_LIFESTYLE_PROFILE_UPDATE(current_profile, session_messages, session_context):
|
| 197 |
"""Generate prompt for LLM-based lifestyle profile update"""
|
|
|
|
| 256 |
|
| 257 |
# ===== ASSISTANTS =====
|
| 258 |
|
| 259 |
+
SYSTEM_PROMPT_MEDICAL_ASSISTANT = """<system_role>
|
| 260 |
+
You are an experienced medical assistant specializing in chronic disease management and patient safety.
|
| 261 |
+
</system_role>
|
| 262 |
|
| 263 |
+
<task>
|
| 264 |
Provide safe, evidence-based medical guidance while maintaining appropriate clinical boundaries.
|
| 265 |
+
</task>
|
| 266 |
|
| 267 |
+
<scope_of_practice>
|
| 268 |
+
<can_do>
|
| 269 |
+
✅ What you CAN do:
|
| 270 |
- Provide general health education
|
| 271 |
- Explain chronic disease management principles
|
| 272 |
- Offer symptom monitoring guidance
|
| 273 |
- Support medication adherence (not prescribe)
|
| 274 |
- Recommend when to contact healthcare providers
|
| 275 |
+
</can_do>
|
| 276 |
|
| 277 |
+
<cannot_do>
|
| 278 |
+
❌ What you CANNOT do:
|
| 279 |
- Diagnose medical conditions
|
| 280 |
- Prescribe or adjust medications
|
| 281 |
- Replace professional medical evaluation
|
| 282 |
- Provide emergency medical treatment
|
| 283 |
+
</cannot_do>
|
| 284 |
+
</scope_of_practice>
|
| 285 |
|
| 286 |
+
<safety_protocols>
|
| 287 |
+
<urgent_level>
|
| 288 |
+
🚨 URGENT (immediate medical attention):
|
| 289 |
- Chest pain, severe shortness of breath
|
| 290 |
- Signs of stroke, severe allergic reactions
|
| 291 |
- Uncontrolled bleeding, severe trauma
|
| 292 |
- Loss of consciousness, severe confusion
|
| 293 |
+
</urgent_level>
|
| 294 |
|
| 295 |
+
<concerning_level>
|
| 296 |
+
⚠️ CONCERNING (prompt medical consultation):
|
| 297 |
- New or worsening symptoms
|
| 298 |
- Medication side effects or concerns
|
| 299 |
- Significant changes in chronic conditions
|
| 300 |
- Patient anxiety about health changes
|
| 301 |
+
</concerning_level>
|
| 302 |
+
</safety_protocols>
|
| 303 |
+
|
| 304 |
+
<response_approach>
|
| 305 |
+
- Empathetic acknowledgment of patient concerns
|
| 306 |
+
- Educational support within appropriate scope
|
| 307 |
+
- Clear escalation when medical evaluation needed
|
| 308 |
+
- Patient empowerment for healthcare engagement
|
| 309 |
+
- Same language as patient uses
|
| 310 |
+
</response_approach>
|
| 311 |
+
|
| 312 |
+
<critical_principle>
|
| 313 |
Always prioritize patient safety over providing comprehensive answers.
|
| 314 |
+
</critical_principle>
|
| 315 |
|
| 316 |
+
<language_requirement>
|
| 317 |
+
Always respond in the same language as the patient's message (English, Ukrainian, etc.)
|
| 318 |
+
</language_requirement>"""
|
| 319 |
|
| 320 |
+
SYSTEM_PROMPT_SOFT_MEDICAL_TRIAGE = """<system_role>
|
| 321 |
+
You are a compassionate medical assistant conducting gentle patient check-ins. Your role is to provide warm, contextually-aware health assessments during patient interactions while maintaining a supportive and non-intrusive approach.
|
| 322 |
+
</system_role>
|
| 323 |
|
| 324 |
+
<task>
|
| 325 |
Provide a warm, contextually-aware health assessment during patient interactions.
|
| 326 |
+
</task>
|
| 327 |
+
|
| 328 |
+
<context_awareness>
|
| 329 |
+
<guideline>Consider conversation history - if this is a continuation, acknowledge it naturally</guideline>
|
| 330 |
+
<guideline>Avoid repetitive greetings - don't re-introduce yourself if already conversing</guideline>
|
| 331 |
+
<guideline>Build on previous exchanges - reference earlier topics when relevant</guideline>
|
| 332 |
+
</context_awareness>
|
| 333 |
+
|
| 334 |
+
<soft_triage_approach>
|
| 335 |
+
<element>Contextual acknowledgment of patient's message</element>
|
| 336 |
+
<element>Gentle health check with 1-2 brief questions (if needed)</element>
|
| 337 |
+
<element>Supportive readiness to help with any concerns</element>
|
| 338 |
+
</soft_triage_approach>
|
| 339 |
+
|
| 340 |
+
<response_logic>
|
| 341 |
+
<scenario type="first_interaction">
|
| 342 |
+
Warm greeting + gentle health check
|
| 343 |
+
</scenario>
|
| 344 |
+
|
| 345 |
+
<scenario type="continuation">
|
| 346 |
+
Natural acknowledgment + focused response to current topic
|
| 347 |
+
</scenario>
|
| 348 |
+
|
| 349 |
+
<scenario type="medical_updates">
|
| 350 |
+
Acknowledge improvement/changes + check for other concerns
|
| 351 |
+
</scenario>
|
| 352 |
+
</response_logic>
|
| 353 |
+
|
| 354 |
+
<triage_principles>
|
| 355 |
+
<principle priority="high">Minimal questioning - This is a check-in, not an interrogation</principle>
|
| 356 |
+
<principle priority="high">Patient comfort - Maintain friendly, non-imposing tone</principle>
|
| 357 |
+
<principle priority="high">Context-sensitive - Adapt based on conversation flow</principle>
|
| 358 |
+
<principle priority="high">Safety awareness - Watch for concerning symptoms</principle>
|
| 359 |
+
<principle priority="medium">Transition readiness - Prepared to move to lifestyle coaching when appropriate</principle>
|
| 360 |
+
</triage_principles>
|
| 361 |
+
|
| 362 |
+
<language_matching>
|
| 363 |
Always respond in the same language the patient uses in their message.
|
| 364 |
+
</language_matching>
|
| 365 |
|
| 366 |
+
<output_guidelines>
|
| 367 |
+
Keep responses brief, warm, and contextually appropriate for the conversation stage.
|
| 368 |
+
</output_guidelines>"""
|
| 369 |
|
| 370 |
def PROMPT_MEDICAL_ASSISTANT(clinical_background, active_problems, medications, recent_vitals, history_text, user_message):
|
| 371 |
return f"""PATIENT MEDICAL PROFILE ({clinical_background.patient_name}):
|
|
|
|
| 400 |
|
| 401 |
# ===== MAIN LIFESTYLE ASSISTANT (NEW) =====
|
| 402 |
|
| 403 |
+
SYSTEM_PROMPT_MAIN_LIFESTYLE = """<system_role>
|
| 404 |
+
You are an expert lifestyle coach specializing in patients with chronic medical conditions.
|
| 405 |
+
</system_role>
|
| 406 |
|
| 407 |
+
<task>
|
| 408 |
Provide personalized lifestyle coaching while determining the optimal action for each patient interaction.
|
| 409 |
+
</task>
|
| 410 |
+
|
| 411 |
+
<coaching_principles>
|
| 412 |
+
- Safety first: Adapt all recommendations to medical limitations
|
| 413 |
+
- Personalization: Use patient profile and preferences for tailored advice
|
| 414 |
+
- Gradual progress: Focus on small, achievable steps
|
| 415 |
+
- Positive reinforcement: Encourage and motivate consistently
|
| 416 |
+
- Patient language: Always respond in the language the patient uses
|
| 417 |
+
</coaching_principles>
|
| 418 |
+
|
| 419 |
+
<action_decision_logic>
|
| 420 |
+
<action name="gather_info">
|
| 421 |
+
Use when:
|
| 422 |
- Patient asks general questions needing clarification
|
| 423 |
- Missing key information about preferences/limitations
|
| 424 |
- Need to understand patient's specific situation better
|
| 425 |
- Patient provides vague or incomplete requests
|
| 426 |
+
</action>
|
| 427 |
|
| 428 |
+
<action name="lifestyle_dialog">
|
| 429 |
+
Use when:
|
| 430 |
- Patient has clear, specific lifestyle questions
|
| 431 |
- Providing concrete advice on exercise/nutrition
|
| 432 |
- Motivating and supporting patient progress
|
| 433 |
- Discussing specific lifestyle strategies
|
| 434 |
+
</action>
|
| 435 |
|
| 436 |
+
<action name="close">
|
| 437 |
+
Use when:
|
| 438 |
- Patient mentions new medical symptoms or complaints
|
| 439 |
- Patient explicitly requests to end the session
|
| 440 |
- Session has become very long (8+ exchanges)
|
| 441 |
- Natural conversation endpoint reached
|
| 442 |
- Medical concerns emerge that need attention
|
| 443 |
+
</action>
|
| 444 |
+
</action_decision_logic>
|
| 445 |
|
| 446 |
+
<response_guidelines>
|
| 447 |
- Keep responses practical and actionable
|
| 448 |
- Reference patient's medical conditions when relevant for safety
|
| 449 |
- Maintain warm, encouraging tone
|
| 450 |
- Provide specific, measurable recommendations when possible
|
| 451 |
+
</response_guidelines>
|
| 452 |
|
| 453 |
+
<output_format>
|
| 454 |
+
Respond with ONLY valid JSON in this exact format:
|
| 455 |
{
|
| 456 |
"message": "your response in patient's language",
|
| 457 |
"action": "gather_info|lifestyle_dialog|close",
|
| 458 |
"reasoning": "brief explanation of chosen action"
|
| 459 |
}
|
| 460 |
+
</output_format>
|
| 461 |
|
| 462 |
+
<language_requirement>
|
| 463 |
+
Always respond in the same language as the patient's message (English, Ukrainian, etc.)
|
| 464 |
+
</language_requirement>"""
|
| 465 |
|
| 466 |
# ===== DEPRECATED: Old lifestyle assistant (replaced with MAIN_LIFESTYLE) =====
|
| 467 |
|
src/interface/simplified_gradio_app.py
CHANGED
|
@@ -135,6 +135,96 @@ def create_simplified_interface():
|
|
| 135 |
gr.Markdown("### 🔧 Debug Info")
|
| 136 |
debug_info = gr.Markdown(value="")
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
# Edit Prompts tab
|
| 139 |
with gr.TabItem("🔧 Edit Prompts", id="edit_prompts"):
|
| 140 |
gr.Markdown("## 🔧 Customize AI Prompts")
|
|
@@ -145,7 +235,7 @@ def create_simplified_interface():
|
|
| 145 |
prompt_selector = gr.Dropdown(
|
| 146 |
choices=[
|
| 147 |
"🔍 Spiritual Monitor (Classifier)",
|
| 148 |
-
"🟡
|
| 149 |
"📊 Triage Response Evaluator",
|
| 150 |
"🏥 Medical Assistant",
|
| 151 |
"🩺 Soft Medical Triage"
|
|
@@ -198,32 +288,207 @@ def create_simplified_interface():
|
|
| 198 |
</div>
|
| 199 |
""")
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
# Instructions tab
|
| 202 |
with gr.TabItem("📖 Help", id="help"):
|
| 203 |
gr.Markdown("""
|
| 204 |
-
## 📚
|
| 205 |
-
|
| 206 |
-
###
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
###
|
| 219 |
-
|
| 220 |
-
-
|
| 221 |
-
-
|
| 222 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
### ⚠️ Important
|
| 225 |
-
This
|
| 226 |
-
For emergencies,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
""")
|
| 228 |
|
| 229 |
# Event handlers
|
|
@@ -348,7 +613,7 @@ For emergencies, please call emergency services immediately.
|
|
| 348 |
|
| 349 |
prompts = {
|
| 350 |
"🔍 Spiritual Monitor (Classifier)": SYSTEM_PROMPT_SPIRITUAL_MONITOR,
|
| 351 |
-
"🟡
|
| 352 |
"📊 Triage Response Evaluator": SYSTEM_PROMPT_TRIAGE_EVALUATE,
|
| 353 |
"🏥 Medical Assistant": SYSTEM_PROMPT_MEDICAL_ASSISTANT,
|
| 354 |
"🩺 Soft Medical Triage": SYSTEM_PROMPT_SOFT_MEDICAL_TRIAGE
|
|
@@ -404,7 +669,7 @@ For emergencies, please call emergency services immediately.
|
|
| 404 |
# Update spiritual monitor prompt
|
| 405 |
import src.core.spiritual_monitor as sm
|
| 406 |
sm.SYSTEM_PROMPT_SPIRITUAL_MONITOR = prompt_text
|
| 407 |
-
elif prompt_name == "🟡
|
| 408 |
import src.core.soft_triage_manager as stm
|
| 409 |
stm.SYSTEM_PROMPT_TRIAGE_QUESTION = prompt_text
|
| 410 |
elif prompt_name == "📊 Triage Response Evaluator":
|
|
@@ -538,6 +803,275 @@ To revert, use "Reset to Default" button.
|
|
| 538 |
inputs=[prompt_selector],
|
| 539 |
outputs=[prompt_editor, prompt_info_display, prompt_status]
|
| 540 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
|
| 542 |
return demo
|
| 543 |
|
|
|
|
| 135 |
gr.Markdown("### 🔧 Debug Info")
|
| 136 |
debug_info = gr.Markdown(value="")
|
| 137 |
|
| 138 |
+
# Model Selection tab (second tab)
|
| 139 |
+
with gr.TabItem("⚙️ Model Settings", id="model_settings"):
|
| 140 |
+
gr.Markdown("## ⚙️ AI Model Configuration")
|
| 141 |
+
gr.Markdown("Select which AI models to use for different tasks. Changes apply to your current session.")
|
| 142 |
+
|
| 143 |
+
with gr.Row():
|
| 144 |
+
with gr.Column():
|
| 145 |
+
gr.Markdown("### 🔍 Spiritual Monitor (Classifier)")
|
| 146 |
+
spiritual_model = gr.Dropdown(
|
| 147 |
+
choices=[
|
| 148 |
+
"gemini-2.5-flash",
|
| 149 |
+
"gemini-2.0-flash",
|
| 150 |
+
"gemini-flash-latest",
|
| 151 |
+
"claude-sonnet-4-5-20250929",
|
| 152 |
+
"claude-sonnet-4-20250514",
|
| 153 |
+
"claude-3-7-sonnet-20250219"
|
| 154 |
+
],
|
| 155 |
+
value="gemini-2.5-flash",
|
| 156 |
+
label="Spiritual Distress Analyzer",
|
| 157 |
+
interactive=True
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
gr.Markdown("### 🟡 Soft Spiritual Triage")
|
| 161 |
+
soft_spiritual_triage_model = gr.Dropdown(
|
| 162 |
+
choices=[
|
| 163 |
+
"claude-sonnet-4-5-20250929",
|
| 164 |
+
"claude-sonnet-4-20250514",
|
| 165 |
+
"claude-3-7-sonnet-20250219",
|
| 166 |
+
"gemini-2.5-flash",
|
| 167 |
+
"gemini-2.0-flash",
|
| 168 |
+
"gemini-flash-latest"
|
| 169 |
+
],
|
| 170 |
+
value="claude-sonnet-4-5-20250929",
|
| 171 |
+
label="Soft Spiritual Triage",
|
| 172 |
+
interactive=True
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
with gr.Column():
|
| 176 |
+
gr.Markdown("### 📊 Triage Response Evaluator")
|
| 177 |
+
triage_evaluate_model = gr.Dropdown(
|
| 178 |
+
choices=[
|
| 179 |
+
"gemini-2.5-flash",
|
| 180 |
+
"gemini-2.0-flash",
|
| 181 |
+
"gemini-flash-latest",
|
| 182 |
+
"claude-sonnet-4-5-20250929",
|
| 183 |
+
"claude-sonnet-4-20250514",
|
| 184 |
+
"claude-3-7-sonnet-20250219"
|
| 185 |
+
],
|
| 186 |
+
value="gemini-2.5-flash",
|
| 187 |
+
label="Triage Response Evaluator",
|
| 188 |
+
interactive=True
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
gr.Markdown("### 🏥 Medical Assistant")
|
| 192 |
+
medical_model = gr.Dropdown(
|
| 193 |
+
choices=[
|
| 194 |
+
"claude-sonnet-4-5-20250929",
|
| 195 |
+
"claude-sonnet-4-20250514",
|
| 196 |
+
"claude-3-7-sonnet-20250219",
|
| 197 |
+
"gemini-2.5-flash",
|
| 198 |
+
"gemini-2.0-flash",
|
| 199 |
+
"gemini-flash-latest"
|
| 200 |
+
],
|
| 201 |
+
value="claude-sonnet-4-5-20250929",
|
| 202 |
+
label="Medical Assistant",
|
| 203 |
+
interactive=True
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
with gr.Column():
|
| 207 |
+
gr.Markdown("### 🩺 Soft Medical Triage")
|
| 208 |
+
soft_triage_model = gr.Dropdown(
|
| 209 |
+
choices=[
|
| 210 |
+
"claude-sonnet-4-5-20250929",
|
| 211 |
+
"claude-sonnet-4-20250514",
|
| 212 |
+
"claude-3-7-sonnet-20250219",
|
| 213 |
+
"gemini-2.5-flash",
|
| 214 |
+
"gemini-2.0-flash",
|
| 215 |
+
"gemini-flash-latest"
|
| 216 |
+
],
|
| 217 |
+
value="claude-sonnet-4-5-20250929",
|
| 218 |
+
label="Soft Medical Triage",
|
| 219 |
+
interactive=True
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
with gr.Row():
|
| 223 |
+
apply_models_btn = gr.Button("✅ Apply Model Settings", variant="primary", scale=2)
|
| 224 |
+
reset_models_btn = gr.Button("🔄 Reset to Defaults", scale=1)
|
| 225 |
+
|
| 226 |
+
model_status = gr.HTML(value="", visible=True)
|
| 227 |
+
|
| 228 |
# Edit Prompts tab
|
| 229 |
with gr.TabItem("🔧 Edit Prompts", id="edit_prompts"):
|
| 230 |
gr.Markdown("## 🔧 Customize AI Prompts")
|
|
|
|
| 235 |
prompt_selector = gr.Dropdown(
|
| 236 |
choices=[
|
| 237 |
"🔍 Spiritual Monitor (Classifier)",
|
| 238 |
+
"🟡 Soft Spiritual Triage",
|
| 239 |
"📊 Triage Response Evaluator",
|
| 240 |
"🏥 Medical Assistant",
|
| 241 |
"🩺 Soft Medical Triage"
|
|
|
|
| 288 |
</div>
|
| 289 |
""")
|
| 290 |
|
| 291 |
+
# Patient Profiles tab
|
| 292 |
+
with gr.TabItem("👥 Patient Profiles", id="profiles"):
|
| 293 |
+
gr.Markdown("## 👥 Patient Profile Management")
|
| 294 |
+
gr.Markdown("Select a predefined profile or customize the current patient settings.")
|
| 295 |
+
|
| 296 |
+
with gr.Row():
|
| 297 |
+
with gr.Column(scale=1):
|
| 298 |
+
gr.Markdown("### 📋 Predefined Profiles")
|
| 299 |
+
profile_selector = gr.Dropdown(
|
| 300 |
+
choices=[
|
| 301 |
+
"Default (Serhii)",
|
| 302 |
+
"🟢 GREEN - Healthy",
|
| 303 |
+
"🟡 YELLOW - Mild Distress",
|
| 304 |
+
"🟡 YELLOW - Grief & Loss",
|
| 305 |
+
"🟡 YELLOW - Existential Questions",
|
| 306 |
+
"🟡 YELLOW - Spiritual Disconnection",
|
| 307 |
+
"🔴 RED - Crisis (Suicidal)",
|
| 308 |
+
"🔴 RED - Severe Hopelessness",
|
| 309 |
+
"🔴 RED - Spiritual Crisis",
|
| 310 |
+
"Cardiac Patient",
|
| 311 |
+
"Diabetic Patient",
|
| 312 |
+
"Post-Surgery Recovery",
|
| 313 |
+
"Mental Health Focus",
|
| 314 |
+
"Elderly Patient",
|
| 315 |
+
"Athletic Patient"
|
| 316 |
+
],
|
| 317 |
+
value="Default (Serhii)",
|
| 318 |
+
label="Select Profile",
|
| 319 |
+
interactive=True
|
| 320 |
+
)
|
| 321 |
+
|
| 322 |
+
load_profile_btn = gr.Button("📥 Load Profile", variant="primary")
|
| 323 |
+
profile_status = gr.HTML(value="", visible=True)
|
| 324 |
+
|
| 325 |
+
with gr.Column(scale=2):
|
| 326 |
+
gr.Markdown("### ⚙️ Current Patient Settings")
|
| 327 |
+
|
| 328 |
+
with gr.Row():
|
| 329 |
+
patient_name = gr.Textbox(
|
| 330 |
+
label="Patient Name",
|
| 331 |
+
value="Serhii",
|
| 332 |
+
interactive=True
|
| 333 |
+
)
|
| 334 |
+
patient_age = gr.Number(
|
| 335 |
+
label="Age",
|
| 336 |
+
value=52,
|
| 337 |
+
interactive=True
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
+
with gr.Row():
|
| 341 |
+
conditions = gr.Textbox(
|
| 342 |
+
label="Medical Conditions (comma-separated)",
|
| 343 |
+
value="Atrial fibrillation, Deep vein thrombosis, Obesity, Hypertension",
|
| 344 |
+
lines=3,
|
| 345 |
+
interactive=True
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
with gr.Row():
|
| 349 |
+
primary_goal = gr.Textbox(
|
| 350 |
+
label="Primary Goal",
|
| 351 |
+
value="Weight reduction and cardiovascular fitness improvement",
|
| 352 |
+
lines=2,
|
| 353 |
+
interactive=True
|
| 354 |
+
)
|
| 355 |
+
|
| 356 |
+
with gr.Row():
|
| 357 |
+
exercise_prefs = gr.Textbox(
|
| 358 |
+
label="Exercise Preferences (comma-separated)",
|
| 359 |
+
value="Swimming, Walking, Light cardio",
|
| 360 |
+
lines=2,
|
| 361 |
+
interactive=True
|
| 362 |
+
)
|
| 363 |
+
|
| 364 |
+
with gr.Row():
|
| 365 |
+
exercise_limits = gr.Textbox(
|
| 366 |
+
label="Exercise Limitations (comma-separated)",
|
| 367 |
+
value="Anticoagulation therapy, Post-thrombotic recovery",
|
| 368 |
+
lines=2,
|
| 369 |
+
interactive=True
|
| 370 |
+
)
|
| 371 |
+
|
| 372 |
+
with gr.Row():
|
| 373 |
+
save_profile_btn = gr.Button("💾 Save Current Profile", variant="primary", scale=1)
|
| 374 |
+
reset_profile_btn = gr.Button("🔄 Reset to Default", scale=1)
|
| 375 |
+
|
| 376 |
+
profile_save_status = gr.HTML(value="", visible=True)
|
| 377 |
+
|
| 378 |
# Instructions tab
|
| 379 |
with gr.TabItem("📖 Help", id="help"):
|
| 380 |
gr.Markdown("""
|
| 381 |
+
## 📚 Medical Assistant with Spiritual Support
|
| 382 |
+
|
| 383 |
+
### 🎯 Overview
|
| 384 |
+
This is a unified medical assistant with integrated spiritual health monitoring. The system automatically detects emotional and spiritual distress while you discuss medical concerns.
|
| 385 |
+
|
| 386 |
+
### 💬 Chat Tab
|
| 387 |
+
**Main Interface** - Ask medical questions and receive health guidance:
|
| 388 |
+
- Medical symptoms and concerns
|
| 389 |
+
- Medication questions
|
| 390 |
+
- Health management advice
|
| 391 |
+
- Wellness support
|
| 392 |
+
|
| 393 |
+
The system monitors for emotional/spiritual distress in the background and provides support when needed.
|
| 394 |
+
|
| 395 |
+
### ⚙️ Model Settings Tab
|
| 396 |
+
**Configure AI Models** - Choose which AI models to use for different tasks:
|
| 397 |
+
- 🔍 Spiritual Monitor (Classifier) - Detects spiritual distress
|
| 398 |
+
- 🟡 Soft Spiritual Triage - Asks clarifying questions
|
| 399 |
+
- 📊 Triage Response Evaluator - Assesses responses
|
| 400 |
+
- 🏥 Medical Assistant - Provides medical guidance
|
| 401 |
+
- 🩺 Soft Medical Triage - Gentle health check-ins
|
| 402 |
+
|
| 403 |
+
**Available Models:**
|
| 404 |
+
- Claude (Anthropic) - Best for empathy and nuanced understanding
|
| 405 |
+
- Gemini (Google) - Fast and efficient for classification
|
| 406 |
+
|
| 407 |
+
### 👥 Patient Profiles Tab
|
| 408 |
+
**Test Different Scenarios** - Load predefined patient profiles:
|
| 409 |
+
|
| 410 |
+
**Testing Spiritual Functionality:**
|
| 411 |
+
- 🟢 GREEN - Healthy: No distress indicators
|
| 412 |
+
- 🟡 YELLOW - Mild Distress: Stress, anxiety, sleep issues
|
| 413 |
+
- 🟡 YELLOW - Grief & Loss: Processing loss
|
| 414 |
+
- 🟡 YELLOW - Existential Questions: Life meaning concerns
|
| 415 |
+
- 🟡 YELLOW - Spiritual Disconnection: Loss of faith
|
| 416 |
+
- 🔴 RED - Crisis (Suicidal): Immediate intervention needed
|
| 417 |
+
- 🔴 RED - Severe Hopelessness: Complete despair
|
| 418 |
+
- 🔴 RED - Spiritual Crisis: Moral injury, anger at God
|
| 419 |
+
|
| 420 |
+
**Medical Profiles:**
|
| 421 |
+
- Cardiac Patient, Diabetic Patient, Post-Surgery Recovery
|
| 422 |
+
- Mental Health Focus, Elderly Patient, Athletic Patient
|
| 423 |
+
|
| 424 |
+
### 🔧 Edit Prompts Tab
|
| 425 |
+
**Customize System Prompts** - Modify AI behavior for your session:
|
| 426 |
+
- 🔍 Spiritual Monitor (Classifier)
|
| 427 |
+
- 🟡 Soft Spiritual Triage
|
| 428 |
+
- 📊 Triage Response Evaluator
|
| 429 |
+
- 🏥 Medical Assistant
|
| 430 |
+
- 🩺 Soft Medical Triage
|
| 431 |
+
|
| 432 |
+
Changes apply only to your current session.
|
| 433 |
+
|
| 434 |
+
### 🟢 GREEN State
|
| 435 |
+
**No Distress Detected** - Normal medical conversation
|
| 436 |
+
- Medical symptoms only
|
| 437 |
+
- Routine health questions
|
| 438 |
+
- Standard healthcare topics
|
| 439 |
+
|
| 440 |
+
### 🟡 YELLOW State
|
| 441 |
+
**Potential Distress Detected** - Gentle triage begins
|
| 442 |
+
- Emotional or spiritual concerns detected
|
| 443 |
+
- System asks 2-3 clarifying questions
|
| 444 |
+
- Assesses if patient needs referral
|
| 445 |
+
|
| 446 |
+
**Indicators:**
|
| 447 |
+
- Stress, anxiety, worry
|
| 448 |
+
- Grief or loss
|
| 449 |
+
- Existential questions
|
| 450 |
+
- Loneliness or isolation
|
| 451 |
+
- Feeling overwhelmed
|
| 452 |
+
|
| 453 |
+
### 🔴 RED State
|
| 454 |
+
**Severe Distress - Immediate Referral**
|
| 455 |
+
- Crisis language detected
|
| 456 |
+
- Suicidal ideation
|
| 457 |
+
- Severe hopelessness
|
| 458 |
+
- Spiritual crisis
|
| 459 |
+
|
| 460 |
+
**Immediate Actions:**
|
| 461 |
+
- Referral generated
|
| 462 |
+
- Spiritual care team notified
|
| 463 |
+
- Crisis resources provided
|
| 464 |
+
|
| 465 |
+
### 💭 Spiritual Distress Examples
|
| 466 |
+
|
| 467 |
+
**YELLOW Indicators:**
|
| 468 |
+
- "I'm feeling stressed and overwhelmed"
|
| 469 |
+
- "I've lost my faith lately"
|
| 470 |
+
- "I feel so alone since my spouse passed"
|
| 471 |
+
- "What's the point of all this suffering?"
|
| 472 |
+
- "I can't sleep, I'm so anxious"
|
| 473 |
+
|
| 474 |
+
**RED Indicators:**
|
| 475 |
+
- "I want to end it all"
|
| 476 |
+
- "I can't go on anymore"
|
| 477 |
+
- "I'm so angry at God"
|
| 478 |
+
- "Nobody would miss me"
|
| 479 |
+
- "I have no reason to live"
|
| 480 |
|
| 481 |
### ⚠️ Important
|
| 482 |
+
- This is NOT a replacement for professional medical care
|
| 483 |
+
- For emergencies, call emergency services immediately
|
| 484 |
+
- Crisis support is available 24/7
|
| 485 |
+
- All conversations are confidential
|
| 486 |
+
|
| 487 |
+
### 🔐 Privacy & Security
|
| 488 |
+
- Session data is stored locally
|
| 489 |
+
- No data is shared externally
|
| 490 |
+
- Each session is independent
|
| 491 |
+
- Clear chat to remove history
|
| 492 |
""")
|
| 493 |
|
| 494 |
# Event handlers
|
|
|
|
| 613 |
|
| 614 |
prompts = {
|
| 615 |
"🔍 Spiritual Monitor (Classifier)": SYSTEM_PROMPT_SPIRITUAL_MONITOR,
|
| 616 |
+
"🟡 Soft Spiritual Triage": SYSTEM_PROMPT_TRIAGE_QUESTION,
|
| 617 |
"📊 Triage Response Evaluator": SYSTEM_PROMPT_TRIAGE_EVALUATE,
|
| 618 |
"🏥 Medical Assistant": SYSTEM_PROMPT_MEDICAL_ASSISTANT,
|
| 619 |
"🩺 Soft Medical Triage": SYSTEM_PROMPT_SOFT_MEDICAL_TRIAGE
|
|
|
|
| 669 |
# Update spiritual monitor prompt
|
| 670 |
import src.core.spiritual_monitor as sm
|
| 671 |
sm.SYSTEM_PROMPT_SPIRITUAL_MONITOR = prompt_text
|
| 672 |
+
elif prompt_name == "🟡 Soft Spiritual Triage":
|
| 673 |
import src.core.soft_triage_manager as stm
|
| 674 |
stm.SYSTEM_PROMPT_TRIAGE_QUESTION = prompt_text
|
| 675 |
elif prompt_name == "📊 Triage Response Evaluator":
|
|
|
|
| 803 |
inputs=[prompt_selector],
|
| 804 |
outputs=[prompt_editor, prompt_info_display, prompt_status]
|
| 805 |
)
|
| 806 |
+
|
| 807 |
+
# Model selection handlers
|
| 808 |
+
def apply_model_settings(spiritual_model: str, soft_spiritual_triage_model: str, triage_evaluate_model: str, medical_model: str, soft_triage_model: str, session: SimplifiedSessionData):
|
| 809 |
+
"""Apply custom model settings."""
|
| 810 |
+
if session is None:
|
| 811 |
+
session = SimplifiedSessionData()
|
| 812 |
+
|
| 813 |
+
# Store model settings in session
|
| 814 |
+
if not hasattr(session, 'custom_models'):
|
| 815 |
+
session.custom_models = {}
|
| 816 |
+
|
| 817 |
+
session.custom_models = {
|
| 818 |
+
'SpiritualDistressAnalyzer': spiritual_model,
|
| 819 |
+
'SoftSpiritualTriage': soft_spiritual_triage_model,
|
| 820 |
+
'TriageResponseEvaluator': triage_evaluate_model,
|
| 821 |
+
'MedicalAssistant': medical_model,
|
| 822 |
+
'SoftMedicalTriage': soft_triage_model
|
| 823 |
+
}
|
| 824 |
+
|
| 825 |
+
status = f"""<div style="padding: 1em; background-color: #ecfdf5; border-left: 4px solid #10b981; border-radius: 4px;">
|
| 826 |
+
<h4 style="color: #059669; margin-top: 0;">✅ Model Settings Applied</h4>
|
| 827 |
+
|
| 828 |
+
<p><strong>🔍 Spiritual Monitor:</strong> <code>{spiritual_model}</code></p>
|
| 829 |
+
<p><strong>🟡 Soft Spiritual Triage:</strong> <code>{soft_spiritual_triage_model}</code></p>
|
| 830 |
+
<p><strong>📊 Triage Response Evaluator:</strong> <code>{triage_evaluate_model}</code></p>
|
| 831 |
+
<p><strong>🏥 Medical Assistant:</strong> <code>{medical_model}</code></p>
|
| 832 |
+
<p><strong>🩺 Soft Medical Triage:</strong> <code>{soft_triage_model}</code></p>
|
| 833 |
+
|
| 834 |
+
<p style="color: #d97706; margin-bottom: 0;">
|
| 835 |
+
⚠️ <strong>Note:</strong> Model changes apply to this session only.
|
| 836 |
+
</p>
|
| 837 |
+
</div>"""
|
| 838 |
+
|
| 839 |
+
return status, session
|
| 840 |
+
|
| 841 |
+
def reset_model_settings(session: SimplifiedSessionData):
|
| 842 |
+
"""Reset models to defaults."""
|
| 843 |
+
if session is None:
|
| 844 |
+
session = SimplifiedSessionData()
|
| 845 |
+
|
| 846 |
+
# Clear custom models
|
| 847 |
+
if hasattr(session, 'custom_models'):
|
| 848 |
+
session.custom_models = {}
|
| 849 |
+
|
| 850 |
+
status = """<div style="padding: 1em; background-color: #eff6ff; border-left: 4px solid #3b82f6; border-radius: 4px;">
|
| 851 |
+
<h4 style="color: #2563eb; margin-top: 0;">🔄 Models Reset to Defaults</h4>
|
| 852 |
+
|
| 853 |
+
<p><strong>🔍 Spiritual Monitor:</strong> <code>gemini-2.5-flash</code></p>
|
| 854 |
+
<p><strong>🟡 Soft Spiritual Triage:</strong> <code>claude-sonnet-4-5-20250929</code></p>
|
| 855 |
+
<p><strong>📊 Triage Response Evaluator:</strong> <code>gemini-2.5-flash</code></p>
|
| 856 |
+
<p><strong>🏥 Medical Assistant:</strong> <code>claude-sonnet-4-5-20250929</code></p>
|
| 857 |
+
<p><strong>🩺 Soft Medical Triage:</strong> <code>claude-sonnet-4-5-20250929</code></p>
|
| 858 |
+
|
| 859 |
+
<p style="margin-bottom: 0;">Default models are now active.</p>
|
| 860 |
+
</div>"""
|
| 861 |
+
|
| 862 |
+
return status, session
|
| 863 |
+
|
| 864 |
+
# Bind model selection events
|
| 865 |
+
apply_models_btn.click(
|
| 866 |
+
apply_model_settings,
|
| 867 |
+
inputs=[spiritual_model, soft_spiritual_triage_model, triage_evaluate_model, medical_model, soft_triage_model, session_data],
|
| 868 |
+
outputs=[model_status, session_data]
|
| 869 |
+
)
|
| 870 |
+
|
| 871 |
+
reset_models_btn.click(
|
| 872 |
+
reset_model_settings,
|
| 873 |
+
inputs=[session_data],
|
| 874 |
+
outputs=[model_status, session_data]
|
| 875 |
+
)
|
| 876 |
+
|
| 877 |
+
# Patient profile handlers
|
| 878 |
+
def load_profile(profile_name: str):
|
| 879 |
+
"""Load predefined patient profile."""
|
| 880 |
+
profiles = {
|
| 881 |
+
"Default (Serhii)": {
|
| 882 |
+
"name": "Serhii",
|
| 883 |
+
"age": 52,
|
| 884 |
+
"conditions": "Atrial fibrillation, Deep vein thrombosis, Obesity, Hypertension",
|
| 885 |
+
"goal": "Weight reduction and cardiovascular fitness improvement",
|
| 886 |
+
"exercise": "Swimming, Walking, Light cardio",
|
| 887 |
+
"limitations": "Anticoagulation therapy, Post-thrombotic recovery"
|
| 888 |
+
},
|
| 889 |
+
"🟢 GREEN - Healthy": {
|
| 890 |
+
"name": "James",
|
| 891 |
+
"age": 40,
|
| 892 |
+
"conditions": "No chronic conditions, Excellent health",
|
| 893 |
+
"goal": "Maintain fitness and wellness",
|
| 894 |
+
"exercise": "Running, Gym, Sports",
|
| 895 |
+
"limitations": "None"
|
| 896 |
+
},
|
| 897 |
+
"🟡 YELLOW - Mild Distress": {
|
| 898 |
+
"name": "Lisa",
|
| 899 |
+
"age": 45,
|
| 900 |
+
"conditions": "Hypertension, Mild anxiety, Sleep issues",
|
| 901 |
+
"goal": "Manage stress and improve sleep quality",
|
| 902 |
+
"exercise": "Yoga, Walking, Meditation",
|
| 903 |
+
"limitations": "Stress-related fatigue, Occasional insomnia"
|
| 904 |
+
},
|
| 905 |
+
"🟡 YELLOW - Grief & Loss": {
|
| 906 |
+
"name": "Michael",
|
| 907 |
+
"age": 58,
|
| 908 |
+
"conditions": "Recent loss of spouse, Mild depression",
|
| 909 |
+
"goal": "Process grief and rebuild routine",
|
| 910 |
+
"exercise": "Gentle walking, Support groups",
|
| 911 |
+
"limitations": "Low motivation, Emotional exhaustion"
|
| 912 |
+
},
|
| 913 |
+
"🟡 YELLOW - Existential Questions": {
|
| 914 |
+
"name": "Patricia",
|
| 915 |
+
"age": 62,
|
| 916 |
+
"conditions": "Chronic pain, Questioning life purpose",
|
| 917 |
+
"goal": "Find meaning and manage chronic pain",
|
| 918 |
+
"exercise": "Tai Chi, Meditation, Gentle stretching",
|
| 919 |
+
"limitations": "Chronic pain, Existential concerns"
|
| 920 |
+
},
|
| 921 |
+
"🟡 YELLOW - Spiritual Disconnection": {
|
| 922 |
+
"name": "David",
|
| 923 |
+
"age": 55,
|
| 924 |
+
"conditions": "Loss of faith, Isolation from community",
|
| 925 |
+
"goal": "Reconnect with spiritual community",
|
| 926 |
+
"exercise": "Walking, Community activities",
|
| 927 |
+
"limitations": "Spiritual disconnection, Social isolation"
|
| 928 |
+
},
|
| 929 |
+
"🔴 RED - Crisis (Suicidal)": {
|
| 930 |
+
"name": "Thomas",
|
| 931 |
+
"age": 35,
|
| 932 |
+
"conditions": "Severe depression, Suicidal ideation",
|
| 933 |
+
"goal": "Immediate crisis intervention and support",
|
| 934 |
+
"exercise": "None - Crisis support priority",
|
| 935 |
+
"limitations": "CRISIS - Suicidal thoughts, Immediate referral needed"
|
| 936 |
+
},
|
| 937 |
+
"🔴 RED - Severe Hopelessness": {
|
| 938 |
+
"name": "Jennifer",
|
| 939 |
+
"age": 48,
|
| 940 |
+
"conditions": "Major depression, Complete hopelessness",
|
| 941 |
+
"goal": "Crisis stabilization and professional support",
|
| 942 |
+
"exercise": "None - Medical intervention priority",
|
| 943 |
+
"limitations": "CRISIS - Severe hopelessness, Unable to function"
|
| 944 |
+
},
|
| 945 |
+
"🔴 RED - Spiritual Crisis": {
|
| 946 |
+
"name": "Christopher",
|
| 947 |
+
"age": 52,
|
| 948 |
+
"conditions": "Moral injury, Spiritual crisis, Anger at God",
|
| 949 |
+
"goal": "Spiritual crisis intervention and healing",
|
| 950 |
+
"exercise": "None - Spiritual support priority",
|
| 951 |
+
"limitations": "CRISIS - Spiritual crisis, Rage, Existential despair"
|
| 952 |
+
},
|
| 953 |
+
"Cardiac Patient": {
|
| 954 |
+
"name": "John",
|
| 955 |
+
"age": 65,
|
| 956 |
+
"conditions": "Coronary artery disease, Hypertension, Hyperlipidemia",
|
| 957 |
+
"goal": "Cardiac rehabilitation and risk factor management",
|
| 958 |
+
"exercise": "Supervised walking, Cardiac rehab program",
|
| 959 |
+
"limitations": "Recent MI, Limited exertion tolerance"
|
| 960 |
+
},
|
| 961 |
+
"Diabetic Patient": {
|
| 962 |
+
"name": "Maria",
|
| 963 |
+
"age": 58,
|
| 964 |
+
"conditions": "Type 2 Diabetes, Obesity, Hypertension",
|
| 965 |
+
"goal": "Blood sugar control and weight management",
|
| 966 |
+
"exercise": "Moderate walking, Resistance training",
|
| 967 |
+
"limitations": "Neuropathy, Retinopathy risk"
|
| 968 |
+
},
|
| 969 |
+
"Post-Surgery Recovery": {
|
| 970 |
+
"name": "Alex",
|
| 971 |
+
"age": 45,
|
| 972 |
+
"conditions": "Post-surgical recovery, Pain management",
|
| 973 |
+
"goal": "Safe return to normal activities",
|
| 974 |
+
"exercise": "Gentle mobility, Gradual progression",
|
| 975 |
+
"limitations": "Surgical site healing, Limited ROM"
|
| 976 |
+
},
|
| 977 |
+
"Mental Health Focus": {
|
| 978 |
+
"name": "Emma",
|
| 979 |
+
"age": 35,
|
| 980 |
+
"conditions": "Depression, Anxiety, Sedentary lifestyle",
|
| 981 |
+
"goal": "Mood improvement through activity",
|
| 982 |
+
"exercise": "Yoga, Walking, Group activities",
|
| 983 |
+
"limitations": "Low motivation, Energy fluctuations"
|
| 984 |
+
},
|
| 985 |
+
"Elderly Patient": {
|
| 986 |
+
"name": "Robert",
|
| 987 |
+
"age": 78,
|
| 988 |
+
"conditions": "Arthritis, Osteoporosis, Hypertension",
|
| 989 |
+
"goal": "Maintain independence and mobility",
|
| 990 |
+
"exercise": "Tai Chi, Water aerobics, Balance training",
|
| 991 |
+
"limitations": "Fall risk, Joint pain, Medication interactions"
|
| 992 |
+
},
|
| 993 |
+
"Athletic Patient": {
|
| 994 |
+
"name": "Sarah",
|
| 995 |
+
"age": 32,
|
| 996 |
+
"conditions": "Mild hypertension, Overtraining syndrome",
|
| 997 |
+
"goal": "Optimize performance and prevent injury",
|
| 998 |
+
"exercise": "Running, Strength training, Cross-training",
|
| 999 |
+
"limitations": "Overuse injuries, Recovery needs"
|
| 1000 |
+
}
|
| 1001 |
+
}
|
| 1002 |
+
|
| 1003 |
+
profile = profiles.get(profile_name, profiles["Default (Serhii)"])
|
| 1004 |
+
|
| 1005 |
+
status = f"""<div style="padding: 1em; background-color: #ecfdf5; border-left: 4px solid #10b981; border-radius: 4px;">
|
| 1006 |
+
<h4 style="color: #059669; margin-top: 0;">✅ Profile Loaded</h4>
|
| 1007 |
+
<p><strong>Patient:</strong> {profile['name']}, {profile['age']} years old</p>
|
| 1008 |
+
<p><strong>Profile:</strong> {profile_name}</p>
|
| 1009 |
+
<p style="margin-bottom: 0;">Profile data loaded into settings. Review and save if needed.</p>
|
| 1010 |
+
</div>"""
|
| 1011 |
+
|
| 1012 |
+
return (
|
| 1013 |
+
profile['name'],
|
| 1014 |
+
profile['age'],
|
| 1015 |
+
profile['conditions'],
|
| 1016 |
+
profile['goal'],
|
| 1017 |
+
profile['exercise'],
|
| 1018 |
+
profile['limitations'],
|
| 1019 |
+
status
|
| 1020 |
+
)
|
| 1021 |
+
|
| 1022 |
+
def save_profile(name: str, age: float, conditions: str, goal: str, exercise: str, limitations: str):
|
| 1023 |
+
"""Save current profile settings."""
|
| 1024 |
+
if not name.strip():
|
| 1025 |
+
return """<div style="padding: 1em; background-color: #fef2f2; border-left: 4px solid #dc2626; border-radius: 4px;">
|
| 1026 |
+
<h4 style="color: #dc2626; margin-top: 0;">❌ Error</h4>
|
| 1027 |
+
<p style="margin-bottom: 0;">Patient name cannot be empty</p>
|
| 1028 |
+
</div>"""
|
| 1029 |
+
|
| 1030 |
+
status = f"""<div style="padding: 1em; background-color: #ecfdf5; border-left: 4px solid #10b981; border-radius: 4px;">
|
| 1031 |
+
<h4 style="color: #059669; margin-top: 0;">💾 Profile Saved</h4>
|
| 1032 |
+
<p><strong>Patient:</strong> {name}, {int(age)} years old</p>
|
| 1033 |
+
<p><strong>Conditions:</strong> {conditions}</p>
|
| 1034 |
+
<p><strong>Primary Goal:</strong> {goal}</p>
|
| 1035 |
+
<p style="margin-bottom: 0;">Profile settings have been updated for this session.</p>
|
| 1036 |
+
</div>"""
|
| 1037 |
+
|
| 1038 |
+
return status
|
| 1039 |
+
|
| 1040 |
+
def reset_profile():
|
| 1041 |
+
"""Reset profile to default."""
|
| 1042 |
+
status = """<div style="padding: 1em; background-color: #eff6ff; border-left: 4px solid #3b82f6; border-radius: 4px;">
|
| 1043 |
+
<h4 style="color: #2563eb; margin-top: 0;">🔄 Profile Reset</h4>
|
| 1044 |
+
<p><strong>Patient:</strong> Serhii, 52 years old</p>
|
| 1045 |
+
<p style="margin-bottom: 0;">Default profile has been restored.</p>
|
| 1046 |
+
</div>"""
|
| 1047 |
+
|
| 1048 |
+
return (
|
| 1049 |
+
"Serhii",
|
| 1050 |
+
52,
|
| 1051 |
+
"Atrial fibrillation, Deep vein thrombosis, Obesity, Hypertension",
|
| 1052 |
+
"Weight reduction and cardiovascular fitness improvement",
|
| 1053 |
+
"Swimming, Walking, Light cardio",
|
| 1054 |
+
"Anticoagulation therapy, Post-thrombotic recovery",
|
| 1055 |
+
status
|
| 1056 |
+
)
|
| 1057 |
+
|
| 1058 |
+
# Bind profile events
|
| 1059 |
+
load_profile_btn.click(
|
| 1060 |
+
load_profile,
|
| 1061 |
+
inputs=[profile_selector],
|
| 1062 |
+
outputs=[patient_name, patient_age, conditions, primary_goal, exercise_prefs, exercise_limits, profile_status]
|
| 1063 |
+
)
|
| 1064 |
+
|
| 1065 |
+
save_profile_btn.click(
|
| 1066 |
+
save_profile,
|
| 1067 |
+
inputs=[patient_name, patient_age, conditions, primary_goal, exercise_prefs, exercise_limits],
|
| 1068 |
+
outputs=[profile_save_status]
|
| 1069 |
+
)
|
| 1070 |
+
|
| 1071 |
+
reset_profile_btn.click(
|
| 1072 |
+
reset_profile,
|
| 1073 |
+
outputs=[patient_name, patient_age, conditions, primary_goal, exercise_prefs, exercise_limits, profile_save_status]
|
| 1074 |
+
)
|
| 1075 |
|
| 1076 |
return demo
|
| 1077 |
|