DocUA's picture
feat: Enhance spiritual state management and UI for provider summaries
f91e0d7

A newer version of the Gradio SDK is available: 6.13.0

Upgrade

AI Prompts Configuration

This directory contains system prompts for various AI agents in the medical assistant application.

Structure

Spiritual Health Prompts

  • spiritual_monitor.txt - Main classifier for spiritual distress detection (GREEN/YELLOW/RED)
  • triage_question.txt - Generates empathetic follow-up questions for YELLOW cases
  • triage_evaluator.txt - Evaluates patient responses during triage

Medical Prompts

  • medical_assistant.txt - Main medical assistant for patient consultations
  • soft_medical_triage.txt - Gentle medical check-ins and triage

How It Works

  1. File-based Loading: Prompts are loaded from markdown files at runtime
  2. Fallback System: If a file is missing, a minimal fallback prompt is used
  3. Caching: Prompts are cached in memory to avoid repeated file I/O
  4. Customize AI Prompts: The UI feature still works - it overrides the loaded prompts per session

Editing Prompts

Method 1: Edit Files Directly

Edit the .txt files in this directory. Changes take effect on next application restart.

Method 2: Use UI (Session-only)

Use the "🔧 Edit Prompts" tab in the application interface. Changes apply only to your current session.

File Format

Prompts are written in XML-style format for LLM compatibility. The entire file content is used as the system prompt.

Example Structure:

<system_role>
Description of the agent's role...
</system_role>

<guidelines>
<guideline priority="high">Guideline 1</guideline>
<guideline priority="medium">Guideline 2</guideline>
</guidelines>

<examples>
<example>Example interaction 1</example>
<example>Example interaction 2</example>
</examples>

Prompt Loading Process

  1. prompt_loader.py loads prompts from files
  2. Each module (e.g., spiritual_monitor.py) calls the loader
  3. Constants like SYSTEM_PROMPT_SPIRITUAL_MONITOR are set
  4. UI and AI clients use these constants
  5. Session overrides (from UI) take precedence when set

Benefits

  • Maintainability: Easier to edit and version control prompts
  • Readability: Markdown format with syntax highlighting
  • Modularity: Separate files for different concerns
  • Backward Compatibility: Existing code continues to work
  • UI Integration: Customize AI Prompts feature still functional

Development

To add a new prompt:

  1. Create a new .txt file in this directory with XML-style formatting
  2. Add loading logic to prompt_loader.py
  3. Update the relevant module to use the loader
  4. Add the prompt to UI mapping if needed

To reload prompts during development:

from src.config.prompt_loader import reload_prompts
reload_prompts()