Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.13.0
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 casestriage_evaluator.txt- Evaluates patient responses during triage
Medical Prompts
medical_assistant.txt- Main medical assistant for patient consultationssoft_medical_triage.txt- Gentle medical check-ins and triage
How It Works
- File-based Loading: Prompts are loaded from markdown files at runtime
- Fallback System: If a file is missing, a minimal fallback prompt is used
- Caching: Prompts are cached in memory to avoid repeated file I/O
- 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
prompt_loader.pyloads prompts from files- Each module (e.g.,
spiritual_monitor.py) calls the loader - Constants like
SYSTEM_PROMPT_SPIRITUAL_MONITORare set - UI and AI clients use these constants
- 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:
- Create a new
.txtfile in this directory with XML-style formatting - Add loading logic to
prompt_loader.py - Update the relevant module to use the loader
- Add the prompt to UI mapping if needed
To reload prompts during development:
from src.config.prompt_loader import reload_prompts
reload_prompts()