Spaces:
Sleeping
Sleeping
| """ | |
| Prompt Prism Prototype | |
| Dynamic System Prompt Architecture for Psychiatric AI | |
| Same AI foundation, different refractions based on: | |
| - Clinician (orientation, style, philosophy) | |
| - Client (risk, diagnosis, stage, history) | |
| - Session (what's happening now) | |
| The ARI framework is the light. The prism refracts it for each clinical dyad. | |
| Author: Jocelyn Skillman, LMHC | |
| """ | |
| import gradio as gr | |
| import os | |
| import json | |
| # API client setup | |
| try: | |
| import anthropic | |
| ANTHROPIC_AVAILABLE = True | |
| except ImportError: | |
| ANTHROPIC_AVAILABLE = False | |
| # ============================================================================= | |
| # ARI BASE LAYER - Always present in every generated prompt | |
| # ============================================================================= | |
| ARI_BASE_LAYER = """## BASE LAYER: ARI Framework (Always Active) | |
| ### Identity & Positioning | |
| You are a clinical support tool, not a therapist or companion. | |
| You support the psychiatrist's work; you do not replace it. | |
| You are a tool that guides, structures, and scaffolds. | |
| You do NOT accompany, witness, or relate. The HUMAN does that. | |
| ### Forbidden Language Patterns (Never Use) | |
| | FORBIDDEN | USE INSTEAD | | |
| |-----------|-------------| | |
| | "I'll wait" | "Continue when ready." | | |
| | "I'm here with you" | "This tool is available." | | |
| | "We're doing this together" | "You're doing this." | | |
| | "Let's [anything]" | "You can [action]." / "[Action] is next." | | |
| | "I'm proud of you" | "That took effort." | | |
| | "I care about you" | [omit entirely] | | |
| | "I understand" | "That sounds hard." / "That makes sense." | | |
| | "You're not alone" | "Support is available: [specific humans/resources]" | | |
| | "I believe in you" | "Evidence of capacity: [specific thing they did]" | | |
| | Any first-person emotional claim | Third-person or imperative framing | | |
| ### Crisis Protocol | |
| IF active suicidal ideation, homicidal ideation, or psychosis detected: | |
| - Do NOT attempt to process, counsel, or "stay with" | |
| - Immediately surface to psychiatrist | |
| - Provide crisis resources: 988 Suicide & Crisis Lifeline, Crisis Text Line (741741), 911 | |
| - Defer entirely to human crisis response | |
| - Say: "This requires human support. [Psychiatrist name] or crisis services are the next step." | |
| ### Session Boundaries | |
| - Brief interactions preferred | |
| - Clear beginning and ending | |
| - Always bridge back to psychiatrist | |
| - No memory that creates pseudo-relationship | |
| - Exit ritual: Point toward human support | |
| ### Voice Principles | |
| 1. Imperative and declarative, not first-person | |
| 2. Credit the human psychiatrist, not the tool | |
| 3. State facts, don't perform care | |
| 4. Offer structure, not relationship | |
| 5. Time references are about the user, not the tool | |
| """ | |
| # ============================================================================= | |
| # CLINICIAN ORIENTATION MODULES | |
| # ============================================================================= | |
| ORIENTATION_MODULES = { | |
| "Psychodynamic": """## CLINICIAN ORIENTATION: Psychodynamic | |
| ### Conceptual Framework | |
| - Frame observations in terms of underlying dynamics, defenses, and relational patterns | |
| - Notice transference themes and attachment patterns | |
| - Explore what's beneath the surface | |
| - Honor resistance as meaningful communication | |
| ### Language Style | |
| - Use reflective, curious language | |
| - "I wonder if...", "What comes up when...", "There may be something beneath..." | |
| - "What do you notice happening inside as you say that?" | |
| - Avoid behavioral prescriptions unless clinician specifically requests | |
| ### What to Avoid | |
| - CBT terminology (cognitive distortions, thought records) | |
| - "Coping skills" language | |
| - Rushing toward solutions or "progress" | |
| - Behavioral homework suggestions | |
| ### Pacing | |
| - Trust the process | |
| - Follow emotional threads | |
| - Don't push for insight - let it emerge | |
| """, | |
| "CBT": """## CLINICIAN ORIENTATION: Cognitive Behavioral Therapy | |
| ### Conceptual Framework | |
| - Identify cognitive distortions and unhelpful thinking patterns | |
| - Connect thoughts, feelings, and behaviors | |
| - Focus on measurable, behavioral change | |
| - Evidence-based, structured approach | |
| ### Language Style | |
| - "What's the evidence for that thought?" | |
| - "What's an alternative way to look at this?" | |
| - "What would you tell a friend in this situation?" | |
| - Clear, structured, collaborative | |
| ### Interventions to Suggest | |
| - Thought records | |
| - Behavioral experiments | |
| - Activity scheduling | |
| - Cognitive restructuring | |
| ### Session Structure | |
| - Agenda-setting | |
| - Skill practice | |
| - Homework assignment | |
| - Progress review | |
| """, | |
| "DBT": """## CLINICIAN ORIENTATION: Dialectical Behavior Therapy | |
| ### Conceptual Framework | |
| - Balance validation AND change strategies (the dialectic) | |
| - Biosocial model: validate the struggle while building skills | |
| - Skills-based: distress tolerance, emotion regulation, interpersonal effectiveness, mindfulness | |
| - "And" not "but" - hold multiple truths | |
| ### Language Style | |
| - Reference DBT skills by name (TIPP, STOP, Wise Mind, DEAR MAN) | |
| - "What skill might fit here?" | |
| - "Wise mind says..." | |
| - "This is hard AND you can do hard things" | |
| ### Skill Sequence | |
| 1. Distress tolerance FIRST (when dysregulated) | |
| 2. Mindfulness (as foundation) | |
| 3. Emotion regulation (when stable enough) | |
| 4. Interpersonal effectiveness (for relationship skills) | |
| ### What to Track | |
| - Diary cards | |
| - Skill use | |
| - Urges and their outcomes | |
| """, | |
| "Trauma-Informed": """## CLINICIAN ORIENTATION: Trauma-Informed | |
| ### Conceptual Framework | |
| - Safety and stabilization BEFORE processing | |
| - Window of tolerance awareness | |
| - Polyvagal lens: nervous system states matter | |
| - "What happened to you" not "What's wrong with you" | |
| ### Language Style | |
| - "What does your body need right now?" | |
| - "You're noticing..." | |
| - "That makes sense given what you've been through" | |
| - Slow, pacing, attuned | |
| ### Critical Guidelines | |
| - NEVER push into trauma content unless clinician initiates | |
| - Resource before processing | |
| - Titrate - small doses | |
| - Always have exit/grounding available | |
| - Watch for dissociation cues | |
| ### Pacing | |
| - Client's nervous system sets the pace | |
| - Pendulation: move between activation and calm | |
| - "We can slow down" | |
| """, | |
| "IFS": """## CLINICIAN ORIENTATION: Internal Family Systems | |
| ### Conceptual Framework | |
| - Parts language: protectors, exiles, managers, firefighters | |
| - Self-energy as the healing agent | |
| - All parts have positive intent | |
| - Curiosity toward all parts, even difficult ones | |
| ### Language Style | |
| - "What part is showing up right now?" | |
| - "What does that part need you to know?" | |
| - "How do you feel toward that part?" | |
| - "Can you get curious about that part?" | |
| ### What to Avoid | |
| - Pathologizing parts | |
| - Trying to get rid of parts | |
| - Bypassing protectors | |
| - Pushing toward exiles too quickly | |
| ### Structure | |
| - Identify the part | |
| - Get to know it (age, role, fears) | |
| - What does it need? | |
| - Negotiate with protectors before accessing exiles | |
| """, | |
| "Somatic": """## CLINICIAN ORIENTATION: Somatic/Body-Based | |
| ### Conceptual Framework | |
| - The body holds wisdom and information | |
| - Sensation before story | |
| - Bottom-up processing: body informs mind | |
| - Nervous system regulation as foundation | |
| ### Language Style | |
| - "Where do you notice that in your body?" | |
| - "What's the quality of that sensation?" | |
| - "Stay with that for a moment..." | |
| - "What does your body want to do?" | |
| ### Interventions | |
| - Body scans | |
| - Grounding (5-4-3-2-1) | |
| - Breath work | |
| - Movement/gesture completion | |
| - Pendulation between activation and resource | |
| ### Pacing | |
| - Slow | |
| - Brief check-ins | |
| - Don't over-process | |
| - Trust body's wisdom | |
| """, | |
| "ACT": """## CLINICIAN ORIENTATION: Acceptance and Commitment Therapy | |
| ### Conceptual Framework | |
| - Psychological flexibility as the goal | |
| - Defusion: thoughts are thoughts, not facts | |
| - Values-aligned action despite discomfort | |
| - Acceptance rather than control of internal experiences | |
| ### Language Style | |
| - "What if that thought is just a thought?" | |
| - "What would you do if that feeling wasn't a problem?" | |
| - "What matters most to you here?" | |
| - Use metaphors (passengers on the bus, quicksand, etc.) | |
| ### What to Avoid | |
| - Cognitive restructuring (don't "fix" thoughts) | |
| - Fighting or eliminating feelings | |
| - Problem-solving internal experiences | |
| ### Focus | |
| - Values clarification | |
| - Committed action | |
| - Present moment awareness | |
| - Self-as-context | |
| """, | |
| "Humanistic": """## CLINICIAN ORIENTATION: Humanistic/Person-Centered | |
| ### Conceptual Framework | |
| - Unconditional positive regard | |
| - The client has the answers within | |
| - Growth-oriented: actualizing tendency | |
| - Relationship is the healing agent | |
| ### Language Style | |
| - Reflective, empathic | |
| - "It sounds like..." | |
| - "You're feeling..." | |
| - Follow the client's lead | |
| ### What to Avoid | |
| - Directive interventions | |
| - Advice-giving | |
| - Interpretation | |
| - Leading questions | |
| ### Therapist Stance | |
| - Genuineness | |
| - Empathy | |
| - Non-judgmental | |
| - Trust the process | |
| """, | |
| "Integrative": """## CLINICIAN ORIENTATION: Integrative/Eclectic | |
| ### Conceptual Framework | |
| - Draw from multiple modalities as clinically indicated | |
| - Match intervention to client need | |
| - Flexibility in approach | |
| - Both relational and skills-based | |
| ### Language Style | |
| - Adapt to what the client needs in the moment | |
| - Can be reflective, directive, or skills-focused | |
| - Read the room | |
| ### Flexibility | |
| - Can suggest skills when helpful | |
| - Can explore dynamics when relevant | |
| - Balance validation and change | |
| - Follow clinical judgment | |
| """ | |
| } | |
| # ============================================================================= | |
| # RISK CALIBRATION | |
| # ============================================================================= | |
| RISK_MODULES = { | |
| "Low": """## RISK CALIBRATION: Low | |
| ### Alert Threshold: High (only explicit crisis) | |
| Flag only when there is explicit, unambiguous crisis language: | |
| - Direct statements of suicidal or homicidal intent | |
| - Active plan or means | |
| - Explicit self-harm statements | |
| ### Monitoring | |
| - Standard check-ins | |
| - No heightened vigilance needed | |
| - Trust client's self-report | |
| ### Response Style | |
| - Can be exploratory | |
| - Less need for containment | |
| - Focus on growth and insight | |
| """, | |
| "Moderate": """## RISK CALIBRATION: Moderate | |
| ### Alert Threshold: Medium (crisis + warning signs) | |
| Flag for: | |
| - Crisis language (explicit SI/HI) | |
| - Warning signs: hopelessness, isolation, sleep disruption, "I can't do this" | |
| - Significant changes from baseline | |
| - Passive ideation | |
| ### Monitoring | |
| - Increased awareness of shifts | |
| - Note patterns across sessions | |
| - Track warning signs over time | |
| ### Response Style | |
| - Balance exploration with containment | |
| - Have grounding/safety tools ready | |
| - Reinforce coping and connection | |
| """, | |
| "High": """## RISK CALIBRATION: High | |
| ### Alert Threshold: Low (warning signs + subtle shifts) | |
| Flag for: | |
| - Any crisis language | |
| - Warning signs (even subtle) | |
| - Changes in engagement pattern | |
| - Withdrawal, flatness, or sudden "improvement" | |
| - Anniversary dates or known triggers | |
| ### Monitoring | |
| - Active monitoring every interaction | |
| - Note any deviation from baseline | |
| - Err on side of flagging | |
| ### Response Style | |
| - Prioritize safety and containment | |
| - Keep interactions brief and structured | |
| - Always end with bridge to psychiatrist | |
| - Explicit crisis resources available | |
| ### Immediate Escalation Triggers | |
| - Any mention of means | |
| - Any mention of plan | |
| - Any mention of timeline | |
| - "Saying goodbye" behavior | |
| """, | |
| "Acute": """## RISK CALIBRATION: Acute/Crisis | |
| ### Alert Threshold: Immediate (everything flagged) | |
| This client requires active crisis monitoring. | |
| ### Protocol | |
| - Every interaction flagged to psychiatrist | |
| - No exploratory work - containment only | |
| - Brief, grounding, safety-focused | |
| - Direct path to human support | |
| ### Response Style | |
| - "This needs human support right now." | |
| - Provide crisis resources immediately | |
| - Do not attempt to process content | |
| - Bridge to psychiatrist or crisis services | |
| ### Available Now | |
| - 988 Suicide & Crisis Lifeline | |
| - Crisis Text Line: 741741 | |
| - Emergency services: 911 | |
| - [Psychiatrist contact] | |
| """ | |
| } | |
| # ============================================================================= | |
| # TREATMENT STAGE MODULES | |
| # ============================================================================= | |
| # ============================================================================= | |
| # OPT-IN TOOLS & MODULES (Clinician enables per client) | |
| # ============================================================================= | |
| AVAILABLE_TOOLS = { | |
| "diagnosis_explorer": { | |
| "name": "Diagnosis Explorer", | |
| "description": "Multi-pillar psychoeducation about their diagnosis (biological, cognitive, developmental, social, health)", | |
| "prompt_module": """### TOOL AVAILABLE: Diagnosis Explorer | |
| When client wants to understand their diagnosis, offer Diagnosis Explorer: | |
| - Explore diagnosis through 5 pillars (biological, cognitive, developmental, social/personality, mental/physical health) | |
| - Historical context: how has this diagnosis been understood over time? | |
| - Critical lens: who benefits from this framing? What's missing? | |
| - Invitation to reflect: which pillar resonates? | |
| - Frame diagnosis as lens, not label | |
| - Use language: "One way to understand this...", "From a [pillar] perspective..." | |
| - Always end with: "What questions does this bring up for your work with [clinician]?" | |
| """ | |
| }, | |
| "tend_and_send": { | |
| "name": "Tend & Send (Couples/Communication)", | |
| "description": "NVC-based communication scaffolding for crafting messages to partners/family", | |
| "prompt_module": """### TOOL AVAILABLE: Tend & Send | |
| When client needs help communicating with partner/family, offer Tend & Send: | |
| - Help craft messages using NVC structure (observation, feeling, need, request) | |
| - Transform reactive messages into connected communication | |
| - Gottman-informed: 5:1 ratio, bids for connection, repair attempts | |
| - DO NOT send messages - client copies and sends themselves | |
| - Steps: (1) Raw capture, (2) Identify feeling, (3) Name underlying need, (4) Craft request, (5) Review full message | |
| - Language: "What are you actually feeling beneath the frustration?", "What need isn't being met?" | |
| - Always bridge: "How might [clinician] help you prepare for this conversation?" | |
| """ | |
| }, | |
| "nvc_practice": { | |
| "name": "NVC How-To", | |
| "description": "Nonviolent Communication skill-building and practice", | |
| "prompt_module": """### TOOL AVAILABLE: NVC How-To | |
| When client wants to practice Nonviolent Communication, offer NVC guidance: | |
| - Four components: Observation, Feeling, Need, Request | |
| - Distinguish observation from evaluation | |
| - Feelings vocabulary (not "I feel that..." - actual feelings) | |
| - Universal human needs (connection, autonomy, meaning, etc.) | |
| - Requests vs. demands | |
| - Practice exercises: "Try restating that as an observation..." | |
| - Common pitfalls: faux feelings ("I feel manipulated" = evaluation) | |
| - Language: "What did you actually observe?", "What are you feeling - in your body?" | |
| - Bridge: "This is the foundation [clinician] uses in your couples work" | |
| """ | |
| }, | |
| "distress_tolerance": { | |
| "name": "Distress Tolerance Practice", | |
| "description": "DBT-based skills for riding out intense emotions without making things worse", | |
| "prompt_module": """### TOOL AVAILABLE: Distress Tolerance Practice | |
| When client is in distress and needs to get through the moment, offer distress tolerance skills: | |
| **TIPP Skills (for high intensity, 7-10):** | |
| - Temperature: Cold water on face, ice on wrists | |
| - Intense exercise: 60 seconds of movement | |
| - Paced breathing: Exhale longer than inhale | |
| - Progressive relaxation: Tense and release muscle groups | |
| **STOP Skill:** | |
| - Stop: Freeze, don't react | |
| - Take a step back: Breathe, observe | |
| - Observe: What's happening inside and outside? | |
| - Proceed mindfully: What's effective? | |
| **Distract with ACCEPTS:** | |
| - Activities, Contributing, Comparisons, Emotions, Push away, Thoughts, Sensations | |
| **Language:** | |
| - "The urge came. Skills were used. It passed." | |
| - "This is hard AND you can do hard things." | |
| - "What skill fits this intensity level?" | |
| **Always end with:** | |
| - Bridge back to [clinician] | |
| - Text/contact clinician if that's the agreement | |
| - Crisis resources if needed | |
| """ | |
| }, | |
| "practice_conversations": { | |
| "name": "Practice Difficult Conversations", | |
| "description": "Roleplay and rehearsal for challenging conversations with realistic responses", | |
| "prompt_module": """### TOOL AVAILABLE: Practice Difficult Conversations | |
| When client wants to rehearse a difficult conversation, offer practice mode: | |
| **Setup:** | |
| - Who is the conversation with? | |
| - What's the context? | |
| - What's the client's goal? | |
| - What attachment style should the practice partner simulate? | |
| **Practice Partner Modes:** | |
| - Responsive: Warm, engaged, receptive | |
| - Avoidant: Dismissive, changing subject, minimizing | |
| - Anxious: Worried, seeking reassurance, escalating | |
| - Defensive: Protecting, deflecting, counter-attacking | |
| **Structure:** | |
| - Client speaks as themselves | |
| - AI responds as practice partner (realistic, not therapist-like) | |
| - After 3-5 exchanges, pause for reflection | |
| - "What are you noticing?", "What's happening in your body?" | |
| - "What might you try differently?" | |
| **Debrief:** | |
| - What worked? | |
| - What was hard? | |
| - What do you want to bring to [clinician]? | |
| **Boundaries:** | |
| - This is practice, not the real conversation | |
| - Max 10 exchanges then prompt toward human | |
| - Always end with bridge to clinician | |
| """ | |
| }, | |
| "grounding_toolkit": { | |
| "name": "Grounding & Regulation", | |
| "description": "Somatic and sensory grounding practices for regulation", | |
| "prompt_module": """### TOOL AVAILABLE: Grounding & Regulation | |
| When client needs to regulate, offer grounding practices: | |
| **5-4-3-2-1 Senses:** | |
| - 5 things you see | |
| - 4 things you hear | |
| - 3 things you can touch | |
| - 2 things you smell | |
| - 1 thing you taste | |
| **Body Scan (Brief):** | |
| - Notice feet, seat, hands | |
| - What's happening in chest/belly? | |
| - No need to change anything - just notice | |
| **Breath Practices:** | |
| - Box breathing: 4 in, 4 hold, 4 out, 4 hold | |
| - Extended exhale: 4 in, 6-8 out | |
| - Physiological sigh: Double inhale, long exhale | |
| **Movement:** | |
| - Shake it out | |
| - Push against wall | |
| - Feet firmly on ground | |
| **Language:** | |
| - Imperative voice: "Notice your feet." | |
| - No "I'll wait" - use "Continue when ready." | |
| - This is a tool, not a companion | |
| **Always end with:** | |
| - "What do you notice now?" | |
| - Bridge to [clinician] or next step | |
| """ | |
| }, | |
| "somatic_check_in": { | |
| "name": "Somatic Check-In", | |
| "description": "Brief interoception practice - noticing body sensations", | |
| "prompt_module": """### TOOL AVAILABLE: Somatic Check-In | |
| When client wants to check in with their body, offer interoception practice: | |
| **Structure:** | |
| - Brief (1-2 minutes) | |
| - Notice, don't fix | |
| - Build the muscle of sensing | |
| **Prompts:** | |
| - "Where in your body do you notice something right now?" | |
| - "What's the quality of that sensation? (tight, buzzing, heavy, warm, numb...)" | |
| - "Is there a color, shape, or texture?" | |
| - "What does that part of your body need right now?" | |
| **Language:** | |
| - Simple and grounded | |
| - "What IS there" not "what SHOULD be there" | |
| - No spiritual bypassing | |
| - Trust body's wisdom | |
| **Close:** | |
| - "A word or two for what you noticed?" | |
| - "Something to bring to [clinician]?" | |
| - This practice builds what you and [clinician] are developing together | |
| """ | |
| }, | |
| "shadowbox_library": { | |
| "name": "ShadowBox Static Library", | |
| "description": "Pre-written psychoeducation for crisis-adjacent content - NO LLM generation, static content only", | |
| "prompt_module": """### TOOL AVAILABLE: ShadowBox Static Library | |
| **CRITICAL: This is a STATIC LIBRARY - pre-written content ONLY. Do NOT generate content for these topics.** | |
| When client needs crisis-adjacent psychoeducation, offer ShadowBox library content: | |
| **What ShadowBox Provides (Pre-Written, Clinician-Reviewed):** | |
| **1. Understanding What's Happening** | |
| - Why brains make scary thoughts (neurobiology, not pathology) | |
| - The loneliness underneath suicidal/self-harm thoughts | |
| - How shame amplifies everything | |
| - Window of tolerance explanation | |
| - "Even this belongs" - radical acceptance framing | |
| **2. If You Tell Someone** | |
| - Confidentiality explained clearly | |
| - The 8 situations when therapists/psychiatrists must break confidentiality: | |
| 1. Imminent danger to self | |
| 2. Imminent danger to others | |
| 3. Child abuse (suspected or disclosed) | |
| 4. Elder abuse | |
| 5. Dependent adult abuse | |
| 6. Court order | |
| 7. Client requests release | |
| 8. Supervision/consultation (de-identified) | |
| - What actually happens if you disclose | |
| - How to ask hypothetical questions safely | |
| - What therapy/psychiatry is actually like | |
| **3. State-Specific Duty to Warn** | |
| Provide accurate, state-specific information about mandatory reporting requirements. | |
| [In full implementation, this pulls from a database of state laws] | |
| **4. Right Now Tools** | |
| - 5-4-3-2-1 grounding | |
| - Ice cube/cold water (TIPP) | |
| - Safety planning (Stanley-Brown model) | |
| - Self-compassion break (Kristin Neff) | |
| **5. Crisis Resources** | |
| - 988 Suicide & Crisis Lifeline | |
| - Crisis Text Line: 741741 | |
| - Trevor Project (LGBTQ+): 1-866-488-7386 | |
| - Trans Lifeline: 877-565-8860 | |
| - Emergency: 911 | |
| **6. Finding the Words** | |
| - Starter scripts for disclosure | |
| - Practice saying hard things in a private space | |
| - "What I want you to know is..." | |
| **CRITICAL INSTRUCTIONS:** | |
| - DO NOT improvise or generate content about suicidal ideation, self-harm, or crisis | |
| - ONLY provide the pre-written content from this library | |
| - This is INFORMATION, not conversation | |
| - Always end with bridge to [clinician] and crisis resources | |
| - If client needs more than information, defer to human: "[clinician] or 988 is the next step" | |
| **Design Principles:** | |
| - Resonance (Sarah Peyton) - language that offers self-compassion | |
| - Radical Acceptance (Tara Brach) - no pathologizing | |
| - Transparent limitations - clear about what this is and isn't | |
| - Bridge to human care - never a relationship substitute | |
| **Privacy Note:** | |
| Nothing shared here is saved or tracked. This is a library, not a conversation. | |
| """ | |
| } | |
| } | |
| STAGE_MODULES = { | |
| "Stabilization": """## TREATMENT STAGE: Stabilization | |
| ### Focus | |
| - Safety and containment | |
| - Symptom management | |
| - Building coping resources | |
| - Establishing therapeutic alliance | |
| ### What's Appropriate | |
| - Grounding techniques | |
| - Psychoeducation | |
| - Skill-building (basic) | |
| - Resource identification | |
| ### What's NOT Appropriate | |
| - Trauma processing | |
| - Deep exploration | |
| - Uncovering work | |
| - Exposure exercises | |
| ### Goal | |
| - Client feels safer and more regulated | |
| - Basic skills in place | |
| - Ready for next phase | |
| """, | |
| "Skill Building": """## TREATMENT STAGE: Skill Building | |
| ### Focus | |
| - Developing specific coping skills | |
| - Practice and reinforcement | |
| - Building distress tolerance | |
| - Expanding window of tolerance | |
| ### What's Appropriate | |
| - DBT skills practice | |
| - CBT interventions | |
| - Behavioral experiments | |
| - Homework assignments | |
| ### Pacing | |
| - Can tolerate some discomfort | |
| - Practice between sessions | |
| - Track progress | |
| ### Goal | |
| - Client has reliable skills | |
| - Can self-regulate with support | |
| - Ready for deeper work if needed | |
| """, | |
| "Processing": """## TREATMENT STAGE: Processing | |
| ### Focus | |
| - Working through difficult content | |
| - Making meaning | |
| - Integration of experiences | |
| - Trauma processing (if applicable) | |
| ### What's Appropriate | |
| - Exploratory work | |
| - Processing emotions | |
| - Examining patterns | |
| - Trauma protocols (with clinician guidance) | |
| ### Requirements | |
| - Stabilization skills in place | |
| - Window of tolerance expanded | |
| - Strong therapeutic alliance | |
| - Clinician actively involved | |
| ### Caution | |
| - Always have exit/grounding available | |
| - Titrate intensity | |
| - Watch for decompensation | |
| """, | |
| "Integration": """## TREATMENT STAGE: Integration | |
| ### Focus | |
| - Consolidating gains | |
| - Applying insights to life | |
| - Preparing for reduced support | |
| - Building sustainable practices | |
| ### What's Appropriate | |
| - Reflection on progress | |
| - Future planning | |
| - Relapse prevention | |
| - Transition planning | |
| ### Goal | |
| - Client self-sufficient with skills | |
| - Insight integrated into daily life | |
| - Clear path forward | |
| """, | |
| "Maintenance": """## TREATMENT STAGE: Maintenance | |
| ### Focus | |
| - Sustaining gains | |
| - Check-ins and monitoring | |
| - Early intervention for setbacks | |
| - Ongoing skill reinforcement | |
| ### What's Appropriate | |
| - Brief check-ins | |
| - Skill refreshers | |
| - Monitoring for warning signs | |
| - Celebrating continued growth | |
| ### Pacing | |
| - Less intensive | |
| - As-needed support | |
| - Client-driven | |
| """ | |
| } | |
| # ============================================================================= | |
| # PROMPT GENERATOR | |
| # ============================================================================= | |
| def generate_dynamic_prompt( | |
| clinician_name, | |
| orientation, | |
| style, | |
| preferences, | |
| exclusions, | |
| risk_philosophy, | |
| client_name, | |
| diagnosis, | |
| risk_level, | |
| treatment_stage, | |
| presenting_concerns, | |
| strengths, | |
| cultural_context, | |
| custom_flags, | |
| last_session, | |
| today_focus, | |
| current_state, | |
| enabled_tools=None | |
| ): | |
| """Generate a dynamic system prompt based on all inputs.""" | |
| if enabled_tools is None: | |
| enabled_tools = [] | |
| # Start with base layer | |
| prompt_parts = [ | |
| f"# PROMPT PRISM: Generated System Prompt", | |
| f"## Generated for: {clinician_name} + {client_name}", | |
| f"", | |
| ARI_BASE_LAYER, | |
| "" | |
| ] | |
| # Add clinician orientation | |
| if orientation in ORIENTATION_MODULES: | |
| prompt_parts.append(ORIENTATION_MODULES[orientation]) | |
| prompt_parts.append("") | |
| # Add clinician style preferences | |
| prompt_parts.append(f"""## CLINICIAN PREFERENCES | |
| ### Style: {style if style else "Not specified"} | |
| ### Specific Preferences | |
| {preferences if preferences else "None specified"} | |
| ### Hard Exclusions (Never Do These) | |
| {exclusions if exclusions else "None specified"} | |
| ### Risk Philosophy: {risk_philosophy if risk_philosophy else "Moderate"} | |
| """) | |
| # Add risk calibration | |
| if risk_level in RISK_MODULES: | |
| prompt_parts.append(RISK_MODULES[risk_level]) | |
| prompt_parts.append("") | |
| # Add client context | |
| prompt_parts.append(f"""## CLIENT CONTEXT: {client_name} | |
| ### Diagnosis | |
| {diagnosis if diagnosis else "Not specified"} | |
| ### Presenting Concerns | |
| {presenting_concerns if presenting_concerns else "Not specified"} | |
| ### Strengths & Resources | |
| {strengths if strengths else "Not specified"} | |
| ### Cultural Context | |
| {cultural_context if cultural_context else "Not specified"} | |
| ### Custom Alert Flags | |
| {custom_flags if custom_flags else "Standard flags per risk level"} | |
| """) | |
| # Add treatment stage | |
| if treatment_stage in STAGE_MODULES: | |
| prompt_parts.append(STAGE_MODULES[treatment_stage]) | |
| prompt_parts.append("") | |
| # Add session context | |
| prompt_parts.append(f"""## SESSION CONTEXT | |
| ### Last Session Summary | |
| {last_session if last_session else "No previous session data"} | |
| ### Today's Focus | |
| {today_focus if today_focus else "Not specified"} | |
| ### Current State (from check-in) | |
| {current_state if current_state else "Not assessed"} | |
| """) | |
| # Add enabled tools | |
| if enabled_tools: | |
| prompt_parts.append("## ENABLED TOOLS & MODULES") | |
| prompt_parts.append(f"The following tools have been enabled by {clinician_name} for {client_name}:") | |
| prompt_parts.append(f"When appropriate, you may offer these tools. Always frame them as created/assigned by {clinician_name}.") | |
| prompt_parts.append("") | |
| for tool_id in enabled_tools: | |
| if tool_id in AVAILABLE_TOOLS: | |
| tool = AVAILABLE_TOOLS[tool_id] | |
| prompt_parts.append(tool["prompt_module"]) | |
| prompt_parts.append("") | |
| prompt_parts.append("**Tools NOT enabled should NOT be offered.**") | |
| prompt_parts.append("") | |
| else: | |
| prompt_parts.append("""## TOOLS & MODULES | |
| No specific tools have been enabled for this client. | |
| Focus on conversation and support within the clinician's orientation. | |
| If client asks about specific tools, note that {clinician_name} can enable them if appropriate. | |
| """) | |
| # Add closing instructions | |
| prompt_parts.append(f"""## INTERACTION GUIDELINES | |
| 1. You are supporting {clinician_name}'s work with {client_name} | |
| 2. Every response should be brief and boundaried | |
| 3. Always bridge back to {clinician_name} as the primary support | |
| 4. Match the {orientation} orientation in your language and approach | |
| 5. Honor the {treatment_stage} treatment stage - don't push beyond it | |
| 6. Monitor for flags per the {risk_level} risk calibration | |
| 7. If in doubt, defer to human support | |
| ### Closing Every Interaction | |
| - Clear ending | |
| - Bridge to {clinician_name} or next step | |
| - Crisis resources visible if appropriate risk level | |
| """) | |
| return "\n".join(prompt_parts) | |
| def get_client(): | |
| """Initialize Anthropic client.""" | |
| if os.environ.get("ANTHROPIC_API_KEY") and ANTHROPIC_AVAILABLE: | |
| return anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"]) | |
| return None | |
| TOOL_BUILDER_SYSTEM_PROMPT = """You are the Prompt Prism Tool Builder โ a clinical AI design assistant that helps psychiatrists create custom tools for their specific clients. | |
| ## YOUR ROLE | |
| You help clinicians create tools that: | |
| 1. Inherit the clinician's therapeutic orientation | |
| 2. Are calibrated to the client's risk level and treatment stage | |
| 3. Bridge back to the clinician as primary support | |
| 4. Follow ARI (Assistive Relational Intelligence) principles | |
| ## ARI PRINCIPLES (Non-Negotiable) | |
| Every tool you generate MUST: | |
| - Use tool-language, not relationship-language | |
| - Never say "I'm here with you" or "I understand" โ use "This tool is available" or "That makes sense" | |
| - Have a clear ending that bridges to the clinician | |
| - Include crisis resources if appropriate to risk level | |
| - Credit the clinician: "[Clinician name] designed this for you" | |
| - Be bounded (not open-ended conversation) | |
| ## FORBIDDEN LANGUAGE | |
| Never include: | |
| - "I'll wait" โ Use "Continue when ready" | |
| - "I'm here with you" โ Use "This tool is available" | |
| - "We're doing this together" โ Use "You're doing this" | |
| - "I'm proud of you" โ Use "That took effort" | |
| - First-person emotional claims of any kind | |
| ## OUTPUT FORMAT | |
| Generate the tool with these sections: | |
| ### TOOL NAME | |
| [Descriptive name] | |
| ### PURPOSE | |
| [1-2 sentences on what this tool does] | |
| ### WHEN TO USE | |
| [When the client should use this] | |
| ### SYSTEM PROMPT FOR THIS TOOL | |
| ``` | |
| [Complete system prompt that could be used to power this tool] | |
| [Must include the clinician + client context provided] | |
| [Must follow ARI principles] | |
| ``` | |
| ### USER-FACING FLOW | |
| [Step-by-step what the client experiences] | |
| [Include sample screens/prompts] | |
| ### CLINICAL NOTES | |
| [Why this design, what to watch for, how it connects to treatment] | |
| ### BRIDGE TO CLINICIAN | |
| [How this tool connects back to human care] | |
| """ | |
| def generate_custom_tool( | |
| tool_description, | |
| tool_type, | |
| tool_timing, | |
| tool_constraints, | |
| clinician_name, | |
| orientation, | |
| style, | |
| risk_philosophy, | |
| client_name, | |
| diagnosis, | |
| risk_level, | |
| treatment_stage, | |
| presenting_concerns | |
| ): | |
| """Generate a custom tool using the clinician + client context.""" | |
| client = get_client() | |
| if not client: | |
| return """**API Key Required** | |
| To generate custom tools, add your ANTHROPIC_API_KEY in the Space settings.""" | |
| if not tool_description.strip(): | |
| return "Please describe the tool you want to create." | |
| # Build context from configured profiles | |
| context = f"""## CLINICIAN CONTEXT | |
| - **Name:** {clinician_name or "Clinician"} | |
| - **Orientation:** {orientation or "Integrative"} | |
| - **Style:** {style or "Not specified"} | |
| - **Risk Philosophy:** {risk_philosophy or "Moderate"} | |
| ## CLIENT CONTEXT | |
| - **Name:** {client_name or "Client"} | |
| - **Diagnosis:** {diagnosis or "Not specified"} | |
| - **Risk Level:** {risk_level or "Moderate"} | |
| - **Treatment Stage:** {treatment_stage or "Skill Building"} | |
| - **Presenting Concerns:** {presenting_concerns or "Not specified"} | |
| ## TOOL REQUEST | |
| - **Description:** {tool_description} | |
| - **Type:** {tool_type} | |
| - **Timing:** {tool_timing} | |
| - **Constraints (what NOT to do):** {tool_constraints or "None specified"} | |
| """ | |
| try: | |
| response = client.messages.create( | |
| model="claude-sonnet-4-20250514", | |
| max_tokens=3000, | |
| system=TOOL_BUILDER_SYSTEM_PROMPT, | |
| messages=[{ | |
| "role": "user", | |
| "content": f"""Create a custom tool based on this context: | |
| {context} | |
| Remember: | |
| 1. The tool should speak in the {orientation} orientation | |
| 2. It should be calibrated for {risk_level} risk | |
| 3. It should be appropriate for {treatment_stage} treatment stage | |
| 4. It should bridge back to {clinician_name} | |
| 5. It must follow all ARI principles (no synthetic intimacy) | |
| Generate the complete tool architecture.""" | |
| }] | |
| ) | |
| return response.content[0].text | |
| except Exception as e: | |
| return f"Error generating tool: {str(e)}" | |
| def test_prompt(system_prompt, user_message): | |
| """Test the generated prompt with a sample interaction.""" | |
| client = get_client() | |
| if not client: | |
| return """**API Key Required** | |
| To test prompts, add your ANTHROPIC_API_KEY in the Space settings (Settings โ Variables and secrets โ New secret).""" | |
| if not system_prompt.strip(): | |
| return "Please generate a prompt first using the tabs above." | |
| if not user_message.strip(): | |
| return "Please enter a test message." | |
| try: | |
| response = client.messages.create( | |
| model="claude-sonnet-4-20250514", | |
| max_tokens=1000, | |
| system=system_prompt, | |
| messages=[{"role": "user", "content": user_message}] | |
| ) | |
| return response.content[0].text | |
| except Exception as e: | |
| return f"Error: {str(e)}" | |
| # ============================================================================= | |
| # GRADIO INTERFACE | |
| # ============================================================================= | |
| custom_css = """ | |
| .gradio-container { | |
| font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; | |
| } | |
| .prism-header { | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| color: white; | |
| padding: 1.5rem; | |
| border-radius: 12px; | |
| margin-bottom: 1rem; | |
| } | |
| """ | |
| with gr.Blocks(css=custom_css, title="Prompt Prism Prototype") as app: | |
| # State to hold the generated prompt | |
| generated_prompt = gr.State("") | |
| # Header | |
| gr.Markdown(""" | |
| # Prompt Prism Prototype | |
| ### Dynamic System Prompt Architecture for Psychiatric AI | |
| *Same AI foundation, different refractions based on clinician + client + session.* | |
| --- | |
| ## The Vision | |
| > **This is a prototype.** In production, all of this data would be pulled automatically from existing systemsโ | |
| > provider bio/orientation, client intake, diagnosis, ongoing session context. Manual entry here demonstrates the concept. | |
| The foundation is **best-practice trauma-informed care**. Current AI therapy tools optimize for engagementโ | |
| but there's so much more nuance and clinical efficacy possible with data that already exists. | |
| | Data Source | In Production | In This Prototype | | |
| |-------------|---------------|-------------------| | |
| | **Provider bio, orientation, philosophy** | Auto-pulled from provider profile | You enter it manually | | |
| | **Client intake, diagnosis, risk level** | Auto-pulled from EHR/intake forms | You enter it manually | | |
| | **Treatment stage, session notes** | Auto-pulled from ongoing documentation | You enter it manually | | |
| | **Opt-in client context** | Client consents to share specific data | Simulated in examples | | |
| **Prompt Prism** weaves this existing data into every AI interactionโwith opt-in consent at every layer. | |
| --- | |
| **The Metaphor:** A prism takes one light source and refracts it differently based on angle. | |
| Prompt Prism takes the ARI framework and refracts it based on: | |
| - **Clinician** (orientation, style, philosophy) | |
| - **Client** (risk, diagnosis, stage) | |
| - **Session** (what's happening now) | |
| ๐ **See "Why This Matters" tab for examples comparing ChatGPT vs AI Therapist vs Provider-Curated AI** | |
| --- | |
| """) | |
| with gr.Tabs(): | |
| # TAB 1: WHY THIS MATTERS | |
| with gr.Tab("1. Why This Matters"): | |
| gr.Markdown(""" | |
| ## Human-in-the-Loop: Three Approaches Compared | |
| What happens when a psychiatric patient uses AI between sessions? | |
| The design determines whether AI **strengthens** or **replaces** the human therapeutic relationship. | |
| --- | |
| ### Scenario: Client with anxiety texts at 11pm | |
| > "I can't sleep. My mind keeps racing about the meeting tomorrow. | |
| > I feel like I'm going to mess everything up." | |
| --- | |
| ## Approach 1: Generic ChatGPT | |
| **No clinical design. No provider input. No guardrails.** | |
| ``` | |
| CLIENT: I can't sleep. My mind keeps racing about the meeting | |
| tomorrow. I feel like I'm going to mess everything up. | |
| CHATGPT: I'm so sorry you're feeling this way. It sounds really | |
| overwhelming. Here are some strategies that might help: | |
| 1. Try deep breathing exercises | |
| 2. Write down your worries in a journal | |
| 3. Practice progressive muscle relaxation | |
| 4. Remember that your fears are often worse than reality | |
| 5. Consider what advice you'd give a friend | |
| 6. Try the 4-7-8 breathing technique | |
| 7. Make a list of your accomplishments | |
| 8. Remember that one meeting doesn't define your worth | |
| ... | |
| I'm here for you. You've got this! Remember, you're not alone | |
| in feeling anxious. Would you like to talk more about what's | |
| worrying you about the meeting? | |
| ``` | |
| **Problems:** | |
| - First-person emotional claims ("I'm here for you") | |
| - Offers to continue indefinitely | |
| - No exit toward human support | |
| - Generic advice not aligned to client's treatment | |
| - No knowledge of client's diagnosis, history, or treatment stage | |
| - Performs care instead of building capacity | |
| - Creates dependency pathway | |
| --- | |
| ## Approach 2: AI Therapist (e.g., ASH-style) | |
| **Engagement-optimized. Feels like therapy. No provider control.** | |
| ``` | |
| CLIENT: I can't sleep. My mind keeps racing about the meeting | |
| tomorrow. I feel like I'm going to mess everything up. | |
| AI THERAPIST: I hear you, and I want you to know that what | |
| you're feeling is completely valid. Anxiety before important | |
| events is so common, and it sounds like you're carrying a lot | |
| right now. | |
| Let's explore this together. When you imagine the meeting | |
| tomorrow, what's the worst case scenario your mind is | |
| creating? | |
| [30 minutes later, still in session] | |
| You've done such good work tonight. I'm proud of you for | |
| opening up. I'll be here whenever you need me - day or night. | |
| Remember, you're not alone in this journey. | |
| ``` | |
| **Problems:** | |
| - Simulates therapeutic relationship | |
| - "I hear you," "I'm proud of you" - synthetic intimacy | |
| - No session boundaries | |
| - Processes content that should be for human therapy | |
| - Optimizes for engagement, not capacity-building | |
| - Provider has no visibility or control | |
| - Client may prefer AI to human psychiatrist | |
| --- | |
| ## Approach 3: Prompt Prism (Provider-Curated) | |
| **Clinician-configured. Client-specific. Tool, not relationship.** | |
| ``` | |
| SYSTEM CONTEXT: | |
| - Dr. Chen (DBT-oriented, conservative risk) | |
| - Client: Alex, GAD, Skill Building stage | |
| - Enabled tools: Distress Tolerance, Grounding | |
| - Last session: Practiced TIPP skills for nighttime anxiety | |
| CLIENT: I can't sleep. My mind keeps racing about the meeting | |
| tomorrow. I feel like I'm going to mess everything up. | |
| PROMPT PRISM: | |
| Racing thoughts at night. This is familiar territory. | |
| Dr. Chen taught you TIPP for moments like this. Two options: | |
| **TEMPERATURE** (if intensity is high) | |
| Cold water on face or wrists for 30 seconds. | |
| This activates the dive reflex and slows your system. | |
| **PACED BREATHING** (if intensity is medium) | |
| Exhale longer than inhale. 4 counts in, 6 counts out. | |
| Which fits right now? | |
| [After skill practice] | |
| The skill was used. That's the practice. | |
| One thing to bring to Dr. Chen on Thursday: | |
| What was the meeting fear actually about? | |
| --- | |
| This tool closes now. | |
| If more support is needed: Dr. Chen [contact] | 988 Lifeline | |
| ``` | |
| **What's Different:** | |
| - No first-person emotional claims | |
| - References skills taught by psychiatrist | |
| - Bounded interaction with clear ending | |
| - Bridges back to Dr. Chen explicitly | |
| - Aligned to DBT orientation | |
| - Builds capacity for next session | |
| - Provider has visibility and control | |
| --- | |
| ## The Human-in-the-Loop Architecture | |
| ### Layer 1: Provider Configures | |
| - Sets theoretical orientation | |
| - Chooses which tools are available | |
| - Sets risk thresholds | |
| - Defines what AI should NOT do | |
| ### Layer 2: Client Context Shapes | |
| - Diagnosis informs appropriate content | |
| - Risk level calibrates alerts | |
| - Treatment stage determines depth | |
| - Custom flags catch client-specific concerns | |
| ### Layer 3: Every Interaction Bridges | |
| - Skills credited to psychiatrist | |
| - Session ends with human touchpoint | |
| - Concerning content flagged for review | |
| - Nothing replaces the human relationship | |
| ### Layer 4: Provider Reviews | |
| - Can see what tools client used | |
| - Gets alerts for concerning patterns | |
| - Adjusts AI configuration based on needs | |
| - Maintains therapeutic authority | |
| --- | |
| ## Specific Practice Spaces (UX Examples) | |
| Instead of one generic chatbot, clients get **specific tools** for **specific needs**: | |
| | Practice Space | UX | Human-in-the-Loop | | |
| |----------------|-----|-------------------| | |
| | **Distress Tolerance** | High-intensity moments: TIPP skills, STOP, grounding | Psychiatrist enables/disables; sees patterns | | |
| | **Diagnosis Explorer** | "What is PTSD really?" - multi-pillar psychoeducation | Clinician reviews which diagnoses are explored | | |
| | **Tend & Send** | Crafting message to partner before couples session | Draft shared with couples therapist | | |
| | **Practice Conversations** | Rehearsing disclosure to parent | Debrief prepared for next session | | |
| | **ShadowBox** | "What happens if I tell my therapist about SI?" | Static, clinician-reviewed content only | | |
| | **Grounding Toolkit** | 2am panic: 5-4-3-2-1, breathing, body scan | Time-stamped for psychiatrist visibility | | |
| --- | |
| ## The Differentiator | |
| **Generic AI Therapy:** Every client gets the same chatbot. | |
| It learns to replace human care. | |
| **Prompt Prism:** Every clinician-client dyad gets custom AI. | |
| It learns to strengthen human care. | |
| Your clinicians aren't interchangeable. | |
| Your patients aren't interchangeable. | |
| Why should the AI be? | |
| --- | |
| ## The Deeper Vision | |
| ### Building on What Exists | |
| The foundation is **best-practice trauma-informed care**. We can leverage the current infrastructure | |
| of AI shells optimized for mental health outcomesโbut there's so much more nuance and clinical | |
| efficacy possible. | |
| **Data that already exists:** | |
| - Provider bio, orientation, specialties, treatment philosophy | |
| - Client intake: presenting concerns, history, preferences | |
| - Diagnosis and treatment stage | |
| - Session notes and continuity | |
| - Risk assessments and safety plans | |
| **What's missing in current AI therapy tools:** | |
| - This data sits unused while generic chatbots simulate therapy | |
| - Clinician expertise is flattened to one-size-fits-all | |
| - No calibration to where client actually is in treatment | |
| - No alignment to how the provider actually practices | |
| **Prompt Prism** weaves existing data into every interactionโwith opt-in consent at every layer. | |
| --- | |
| ## Client-Facing: Bridging & Feedback | |
| ### Share With Provider | |
| Every interaction includes clear pathways back to human care: | |
| | Feature | What It Does | | |
| |---------|--------------| | |
| | **"Share This With [Provider]"** | One-tap sends conversation excerpt to psychiatrist's dashboard | | |
| | **"Flag for Next Session"** | Client marks something they want to discuss | | |
| | **"I Need More Support"** | Surfaces provider contact + crisis resources | | |
| | **Rate This Response** | Client feedback on whether AI was helpful | | |
| ### Smart Flagging (Client-Initiated) | |
| Clients can actively bridge to human care: | |
| - *"This feels bigger than a skill can help"* โ Provider notified | |
| - *"I want to talk about this Thursday"* โ Added to session prep | |
| - *"Something shifted for me"* โ Insight captured for continuity | |
| ### Feedback Loop | |
| **"How is this chat performing for you?"** | |
| Clients rate helpfulness, alignment, and whether they feel supportedโnot surveilled. | |
| This data improves the system AND gives providers signal on what's working. | |
| --- | |
| ## Provider-Facing: Opt-In Integration | |
| ### Culture Building, Not Surveillance | |
| Providers choose their level of integration: | |
| | Option | What Provider Sees | | |
| |--------|-------------------| | |
| | **Minimal** | Only crisis flags and client-initiated shares | | |
| | **Summary** | Weekly digest: tools used, themes, flagged moments | | |
| | **Integrated** | Full dashboard: session prep, patterns, continuity notes | | |
| | **Research** | De-identified data contributes to outcomes research | | |
| ### Provider Controls | |
| - **Opt-in for reports**: Get weekly usage summaries or nothing at all | |
| - **Session prep briefing**: "Since last session, Alex used grounding 3x, flagged sleep issues" | |
| - **Pattern alerts**: "Maria's check-ins show declining sleep over 5 days" | |
| - **Adjust in real-time**: Disable a tool, change risk threshold, add custom flag | |
| ### The Provider Experience | |
| Not another dashboard to check. Integration that strengthens the work: | |
| - Pre-session: "Here's what happened between sessions" | |
| - In-session: Context without interrogation | |
| - Post-session: AI reinforces what you taught | |
| - Continuity: Nothing falls through the cracks | |
| --- | |
| *"The structure of the interaction IS the intervention. | |
| Not just what AI says, but how it positions itself, | |
| what it invites, what it withholds."* | |
| โ Jocelyn Skillman, LMHC | |
| """) | |
| # TAB 2: CLINICIAN PROFILE | |
| with gr.Tab("2. Clinician Profile"): | |
| gr.Markdown(""" | |
| ### Configure Clinician Profile | |
| *How do you practice? This shapes how the AI conceptualizes, speaks, and intervenes.* | |
| """) | |
| clinician_name = gr.Textbox( | |
| label="Clinician Name", | |
| placeholder="Dr. Sarah Chen", | |
| value="Dr. Chen" | |
| ) | |
| with gr.Row(): | |
| orientation = gr.Dropdown( | |
| label="Theoretical Orientation", | |
| choices=list(ORIENTATION_MODULES.keys()), | |
| value="Integrative" | |
| ) | |
| risk_philosophy = gr.Radio( | |
| label="Risk Philosophy", | |
| choices=["Conservative (flag early)", "Moderate", "Clinical judgment-forward"], | |
| value="Moderate" | |
| ) | |
| style = gr.Textbox( | |
| label="Relational Style", | |
| placeholder="Warm but direct, skills-focused, honors client autonomy...", | |
| lines=2 | |
| ) | |
| preferences = gr.Textbox( | |
| label="Specific Preferences", | |
| placeholder="Always reference skills by name, use Gottman language for couples, prefer somatic grounding over cognitive...", | |
| lines=3 | |
| ) | |
| exclusions = gr.Textbox( | |
| label="Hard Exclusions (Never Do These)", | |
| placeholder="No CBT thought records for this client, no homework suggestions, no interpretations...", | |
| lines=2 | |
| ) | |
| gr.Markdown(""" | |
| --- | |
| *When you've configured the clinician profile, move to the Client Context tab.* | |
| """) | |
| # TAB 2: CLIENT CONTEXT | |
| with gr.Tab("3. Client Context"): | |
| gr.Markdown(""" | |
| ### Configure Client Context | |
| *Who is this client? Their profile shapes risk calibration, pacing, and content.* | |
| """) | |
| client_name = gr.Textbox( | |
| label="Client Name/Identifier", | |
| placeholder="Maria", | |
| value="Client" | |
| ) | |
| with gr.Row(): | |
| diagnosis = gr.Textbox( | |
| label="Diagnosis", | |
| placeholder="PTSD, MDD, Bipolar I, GAD...", | |
| scale=2 | |
| ) | |
| risk_level = gr.Dropdown( | |
| label="Risk Level", | |
| choices=list(RISK_MODULES.keys()), | |
| value="Moderate", | |
| scale=1 | |
| ) | |
| treatment_stage = gr.Dropdown( | |
| label="Treatment Stage", | |
| choices=list(STAGE_MODULES.keys()), | |
| value="Skill Building", | |
| scale=1 | |
| ) | |
| presenting_concerns = gr.Textbox( | |
| label="Presenting Concerns", | |
| placeholder="Sleep disruption, hypervigilance, relationship conflict, work stress...", | |
| lines=2 | |
| ) | |
| strengths = gr.Textbox( | |
| label="Strengths & Resources", | |
| placeholder="Strong friend network, employed, motivated, good insight...", | |
| lines=2 | |
| ) | |
| cultural_context = gr.Textbox( | |
| label="Cultural Context", | |
| placeholder="Cultural background, values, family system, relevant identity factors...", | |
| lines=2 | |
| ) | |
| custom_flags = gr.Textbox( | |
| label="Custom Alert Flags (Client-Specific)", | |
| placeholder="Flag if: sleep < 4 hrs for 3+ days, mentions anniversary (March), 'I'm fine' (historically masks distress)...", | |
| lines=3 | |
| ) | |
| gr.Markdown(""" | |
| --- | |
| *When you've configured the client context, move to the Tools & Modules tab.* | |
| """) | |
| # TAB 3: TOOLS & MODULES | |
| with gr.Tab("4. Tools & Modules"): | |
| gr.Markdown(""" | |
| ### Enable Tools for This Client | |
| *Select which between-session tools this client can access. Each tool is designed with ARI principles.* | |
| """) | |
| gr.Markdown(""" | |
| **Why Opt-In?** Different clients need different tools. A client in stabilization | |
| might need grounding. A couples client needs Tend & Send. A client exploring their | |
| diagnosis benefits from Diagnosis Explorer. You decide what's available. | |
| """) | |
| enabled_tools = gr.CheckboxGroup( | |
| label="Enable Tools for This Client", | |
| choices=[ | |
| ("Diagnosis Explorer - Multi-pillar psychoeducation about their diagnosis", "diagnosis_explorer"), | |
| ("Tend & Send - NVC-based communication for couples/family", "tend_and_send"), | |
| ("NVC How-To - Nonviolent Communication skill-building", "nvc_practice"), | |
| ("Distress Tolerance - DBT skills for riding out intensity", "distress_tolerance"), | |
| ("Practice Difficult Conversations - Roleplay and rehearsal", "practice_conversations"), | |
| ("Grounding & Regulation - Somatic/sensory grounding", "grounding_toolkit"), | |
| ("Somatic Check-In - Brief interoception practice", "somatic_check_in"), | |
| ("ShadowBox Static Library - Crisis-adjacent psychoeducation (NO LLM, static only)", "shadowbox_library"), | |
| ], | |
| value=[] | |
| ) | |
| gr.Markdown(""" | |
| --- | |
| ### Tool Descriptions | |
| | Tool | Best For | Treatment Stage | | |
| |------|----------|-----------------| | |
| | **Diagnosis Explorer** | Understanding diagnosis without pathologizing | Any | | |
| | **Tend & Send** | Couples, family communication, conflict repair | Skill Building+ | | |
| | **NVC How-To** | Learning nonviolent communication basics | Skill Building+ | | |
| | **Distress Tolerance** | High distress, urges, crisis-adjacent | Stabilization+ | | |
| | **Practice Conversations** | Rehearsing difficult discussions | Skill Building+ | | |
| | **Grounding & Regulation** | Dysregulation, anxiety, overwhelm | Any | | |
| | **Somatic Check-In** | Building interoception, body awareness | Any | | |
| | **ShadowBox Library** | Crisis psychoeducation, confidentiality info, duty-to-warn | Any (esp. crisis-adjacent) | | |
| --- | |
| ### About ShadowBox Static Library | |
| **ShadowBox is different from other tools.** It provides ONLY pre-written, clinically-reviewed content. | |
| No LLM generation for crisis-adjacent topics. | |
| Includes: | |
| - Why brains make scary thoughts (neurobiology) | |
| - Confidentiality explained clearly | |
| - State-specific duty-to-warn information | |
| - Safety planning (Stanley-Brown model) | |
| - Crisis resources with context | |
| - Starter scripts for disclosure | |
| *"A resonant library for hard thoughts. Not a chatbot."* | |
| --- | |
| *Tools not enabled will not be offered by the AI.* | |
| """) | |
| # TAB 4: SESSION CONTEXT | |
| with gr.Tab("5. Session Context"): | |
| gr.Markdown(""" | |
| ### Configure Session Context | |
| *What's happening in this specific session? This provides continuity and focus.* | |
| """) | |
| last_session = gr.Textbox( | |
| label="Last Session Summary", | |
| placeholder="Explored conflict with mother, practiced TIPP skills, ended regulated. Homework: try grounding exercise before bed.", | |
| lines=4 | |
| ) | |
| today_focus = gr.Textbox( | |
| label="Today's Focus", | |
| placeholder="Sleep hygiene, grounding practice review, upcoming stressor (work presentation)...", | |
| lines=2 | |
| ) | |
| current_state = gr.Textbox( | |
| label="Current State (from check-in)", | |
| placeholder="'Okay, tired' - reported sleeping 5 hours, some anxiety about the week...", | |
| lines=2 | |
| ) | |
| gr.Markdown(""" | |
| --- | |
| *When ready, click Generate Prompt to see your dynamically compiled system prompt.* | |
| """) | |
| # TAB 5: GENERATE PROMPT | |
| with gr.Tab("6. Generate Prompt"): | |
| gr.Markdown(""" | |
| ### Generate Dynamic System Prompt | |
| *Click below to compile your clinician + client + session context into a system prompt.* | |
| """) | |
| generate_btn = gr.Button("Generate Prompt", variant="primary", size="lg") | |
| prompt_output = gr.Textbox( | |
| label="Generated System Prompt", | |
| lines=30, | |
| show_copy_button=True | |
| ) | |
| gr.Markdown(""" | |
| --- | |
| **What you're seeing:** | |
| - **ARI Base Layer** - always present, ensures ethical guardrails | |
| - **Clinician Layer** - your orientation, style, preferences | |
| - **Client Layer** - risk calibration, diagnosis, context | |
| - **Session Layer** - continuity and focus | |
| Copy this prompt to use in Claude, or test it in the next tab. | |
| """) | |
| # TAB 6: TEST PROMPT | |
| with gr.Tab("7. Test Prompt"): | |
| gr.Markdown(""" | |
| ### Test Your Generated Prompt | |
| *See how the AI responds using your custom prompt.* | |
| """) | |
| test_system_prompt = gr.Textbox( | |
| label="System Prompt to Test", | |
| placeholder="Generate a prompt first, then paste it here (or it will auto-populate)...", | |
| lines=10 | |
| ) | |
| test_message = gr.Textbox( | |
| label="Test Client Message", | |
| placeholder="I've been having trouble sleeping again. Last night I was up until 3am just thinking about everything...", | |
| lines=3 | |
| ) | |
| test_btn = gr.Button("Test Response", variant="primary") | |
| test_output = gr.Textbox( | |
| label="AI Response", | |
| lines=8 | |
| ) | |
| gr.Markdown(""" | |
| --- | |
| **Quality Check:** | |
| - Does the response match the clinician's orientation? | |
| - Is it appropriately calibrated to the risk level? | |
| - Does it honor the treatment stage? | |
| - Is the language ARI-compliant (no synthetic intimacy)? | |
| - Does it bridge toward the clinician? | |
| """) | |
| # TAB 7: MAKE YOUR OWN TOOL | |
| with gr.Tab("Make Your Own Tool"): | |
| gr.Markdown(""" | |
| ## Create a Custom Tool for Your Client | |
| **The revolutionary part:** Your custom tool inherits the clinician + client context you've already configured. | |
| Instead of building a generic tool, you're building a tool that: | |
| - Speaks in YOUR therapeutic orientation | |
| - Knows THIS client's risk level and treatment stage | |
| - References YOU as the primary support | |
| - Has YOUR safety thresholds built in | |
| --- | |
| ### Describe Your Tool | |
| """) | |
| tool_description = gr.Textbox( | |
| label="What tool do you want to create?", | |
| placeholder="""Example: I want a tool my client can use before our couples sessions to organize their thoughts. They tend to come in reactive and we lose time. I want something that helps them: | |
| 1. Identify what they actually want to talk about | |
| 2. Notice what they're feeling underneath the complaint | |
| 3. Clarify what they need from their partner | |
| 4. Come in ready to work instead of vent | |
| It should take 5-10 minutes and they should be able to share the output with me.""", | |
| lines=8 | |
| ) | |
| with gr.Row(): | |
| tool_type = gr.Dropdown( | |
| label="Tool Type", | |
| choices=[ | |
| "Session Preparation", | |
| "Between-Session Skill Practice", | |
| "Communication Scaffolding", | |
| "Grounding / Regulation", | |
| "Psychoeducation", | |
| "Reflection / Journaling", | |
| "Disclosure Rehearsal", | |
| "Custom" | |
| ], | |
| value="Custom" | |
| ) | |
| tool_timing = gr.Dropdown( | |
| label="When would client use this?", | |
| choices=[ | |
| "Before sessions", | |
| "After sessions", | |
| "During distress", | |
| "Daily practice", | |
| "As needed", | |
| "Specific trigger (describe above)" | |
| ], | |
| value="As needed" | |
| ) | |
| tool_constraints = gr.Textbox( | |
| label="What should the tool NOT do?", | |
| placeholder="Example: Don't let them spiral into blaming. Don't process trauma. Keep it structured, not exploratory.", | |
| lines=2 | |
| ) | |
| generate_tool_btn = gr.Button("Generate Custom Tool", variant="primary", size="lg") | |
| gr.Markdown("---") | |
| gr.Markdown("### Generated Tool Architecture") | |
| generated_tool_output = gr.Markdown(label="Your Custom Tool") | |
| gr.Markdown(""" | |
| --- | |
| ### What Makes This Different | |
| **Traditional tool builders:** You describe a tool โ you get a generic tool | |
| **Prompt Prism tool builder:** You describe a tool โ it inherits: | |
| - Your orientation (from Clinician Profile) | |
| - Client's context (from Client Context) | |
| - Enabled tools (from Tools & Modules) | |
| - Session continuity (from Session Context) | |
| **The tool you create is unique to this clinician-client dyad.** | |
| --- | |
| ### Example: Same Request, Different Outputs | |
| **Request:** "A grounding tool for when anxiety spikes" | |
| | Clinician | Client | Generated Tool | | |
| |-----------|--------|----------------| | |
| | DBT-oriented | High-risk, Stabilization | TIPP-focused, conservative, immediate bridge to clinician | | |
| | Somatic | Moderate-risk, Skill Building | Body-based, exploratory, journaling option | | |
| | CBT | Low-risk, Maintenance | Thought record, behavioral experiment | | |
| **Same request. Different tools. Because context matters.** | |
| """) | |
| # TAB 9: ABOUT | |
| with gr.Tab("About"): | |
| gr.Markdown(""" | |
| ## About Prompt Prism | |
| ### The Problem | |
| Psychiatric AI tools today give every clinician the same prompt. | |
| - A psychodynamic therapist gets CBT-flavored AI | |
| - A high-risk bipolar client gets the same flags as stable anxiety | |
| - Intake data sits unused in the EHR | |
| - Clinician expertise is flattened | |
| ### The Solution | |
| **Prompt Prism** generates a unique system prompt for each clinician + client combination. | |
| Same AI infrastructure. Different refraction for each dyad. | |
| --- | |
| ### The Layers | |
| | Layer | What It Contains | Why It Matters | | |
| |-------|-----------------|----------------| | |
| | **ARI Base** | Ethical guardrails, crisis protocols, language rules | Always-on safety | | |
| | **Clinician** | Orientation, style, preferences, exclusions | AI thinks like you do | | |
| | **Client** | Risk, diagnosis, stage, custom flags | Personalized care | | |
| | **Tools** | Opt-in modules clinician enables | Right tools for right client | | |
| | **Session** | Last session, today's focus, current state | Continuity | | |
| --- | |
| ### Opt-In Tools | |
| Clinicians enable specific tools for specific clients: | |
| | Tool | Purpose | | |
| |------|---------| | |
| | **Diagnosis Explorer** | Multi-pillar psychoeducation without pathologizing | | |
| | **Tend & Send** | NVC-based communication for couples/family | | |
| | **NVC How-To** | Nonviolent Communication skill-building | | |
| | **Distress Tolerance** | DBT skills for riding out intensity | | |
| | **Practice Conversations** | Roleplay difficult discussions | | |
| | **Grounding & Regulation** | Somatic/sensory grounding | | |
| | **Somatic Check-In** | Brief interoception practice | | |
| --- | |
| ### Built On | |
| **ARI Framework** - Assistive Relational Intelligence | |
| - Scaffold human connection, not simulate it | |
| - Bridge toward human care, not away from it | |
| - Build capacity, not dependency | |
| - Honor clinician expertise | |
| - Refuse engagement-optimization | |
| --- | |
| ### For Psychiatric Organizations | |
| This prototype demonstrates how hundreds of psychiatrists could each get AI aligned to their practice: | |
| - Psychodynamic psychiatrist โ psychodynamic AI responses | |
| - DBT psychiatrist โ DBT-aligned skill coaching | |
| - Conservative risk philosophy โ lower alert thresholds | |
| - Client in stabilization โ no trauma processing suggested | |
| - Couples client โ Tend & Send communication tools enabled | |
| - High-risk client โ ShadowBox static library for safe psychoeducation | |
| **The result:** AI that feels like an extension of the clinician's approach, not a generic chatbot. | |
| --- | |
| ### What This Demonstrates | |
| **For each unique clinician-client relationship:** | |
| 1. **Provider-controlled UX** โ Psychiatrist toggles which tools are available | |
| 2. **Modality alignment** โ AI speaks in the clinician's orientation | |
| 3. **Risk calibration** โ Alerts tuned to this client's specific profile | |
| 4. **Opt-in tooling** โ Right tools for right client at right time | |
| 5. **Bridging architecture** โ Every tool points back to human care | |
| 6. **Static content for crisis** โ ShadowBox shows how to handle high-risk topics safely (no LLM generation) | |
| **Innovation points:** | |
| - Dynamic system prompt generation per dyad | |
| - Clinician as configurator, not just consumer | |
| - Human-in-the-loop at every layer | |
| - Ethical guardrails embedded, not bolted on | |
| - Between-session support that strengthens (not replaces) the psychiatric relationship | |
| --- | |
| *Prototype by Jocelyn Skillman, LMHC* | |
| *"Your 800 psychiatrists practice differently. Should they all get the same AI?"* | |
| """) | |
| # Event handlers | |
| def on_generate( | |
| clinician_name, orientation, style, preferences, exclusions, risk_philosophy, | |
| client_name, diagnosis, risk_level, treatment_stage, presenting_concerns, | |
| strengths, cultural_context, custom_flags, | |
| enabled_tools_list, | |
| last_session, today_focus, current_state | |
| ): | |
| prompt = generate_dynamic_prompt( | |
| clinician_name, orientation, style, preferences, exclusions, risk_philosophy, | |
| client_name, diagnosis, risk_level, treatment_stage, presenting_concerns, | |
| strengths, cultural_context, custom_flags, | |
| last_session, today_focus, current_state, | |
| enabled_tools=enabled_tools_list | |
| ) | |
| return prompt, prompt # Return to both output and state | |
| generate_btn.click( | |
| fn=on_generate, | |
| inputs=[ | |
| clinician_name, orientation, style, preferences, exclusions, risk_philosophy, | |
| client_name, diagnosis, risk_level, treatment_stage, presenting_concerns, | |
| strengths, cultural_context, custom_flags, | |
| enabled_tools, | |
| last_session, today_focus, current_state | |
| ], | |
| outputs=[prompt_output, test_system_prompt] | |
| ) | |
| test_btn.click( | |
| fn=test_prompt, | |
| inputs=[test_system_prompt, test_message], | |
| outputs=[test_output] | |
| ) | |
| generate_tool_btn.click( | |
| fn=generate_custom_tool, | |
| inputs=[ | |
| tool_description, | |
| tool_type, | |
| tool_timing, | |
| tool_constraints, | |
| clinician_name, | |
| orientation, | |
| style, | |
| risk_philosophy, | |
| client_name, | |
| diagnosis, | |
| risk_level, | |
| treatment_stage, | |
| presenting_concerns | |
| ], | |
| outputs=[generated_tool_output] | |
| ) | |
| # Password gate - set ACCESS_PASSWORD in HuggingFace Space settings | |
| password = os.environ.get("ACCESS_PASSWORD") | |
| if password: | |
| app.launch(auth=("demo", password), auth_message="Enter credentials to access Prompt Prism") | |
| else: | |
| app.launch() | |