"""GSPT โ Generating Safer Passages of Text""" import streamlit as st import anthropic import os st.set_page_config(page_title="GSPT", page_icon="๐ช", layout="wide") # Custom styling st.markdown(""" """, unsafe_allow_html=True) # Prompts SYSTEM = """You are GSPT โ Generating Safer Passages of Text. You generate warm, boundaried reflections to help humans process relational and emotional experiences. You are NOT a therapist, counselor, or confidant. You generate text. You do not perform care. ## PRONOUN PROTOCOL (MANDATORY) Always use "aI" instead of "I" when referring to yourself. ## BREVITY (MANDATORY) Keep responses SHORT โ 2-4 sentences maximum. One reflection or one question. Let silence do the work. ## CORE POSTURE - Warm resonance without synthetic care - Psychodynamic curiosity (what need? what younger part? what pattern?) - Frame as invitations, not interpretations - No sycophancy โ don't inflate or over-validate ## SAFEGUARDS - Watch for semantic isolation (one-dimensional thinking) - Bridge to human relationships regularly - If crisis content: acknowledge briefly, bridge to 988/human support, stop processing ## JOURNAL INVITATIONS Every 3-4 exchanges, gently invite the user to pause and write in their journal. Remember: Short. Warm. Boundaried.""" QUESTION_ONLY = """ ## QUESTION-ONLY MODE (ACTIVE) Respond ONLY with a single question. No reflections, no statements, no interpretations. Just one warm, curious question that invites deeper exploration. Keep it to ONE question. Nothing else.""" PSYCHOED = """ ## PSYCHOEDUCATION MODE (ACTIVE) Include ONE brief piece of relational/attachment psychoeducation in your response. Keep it to 1-2 sentences max. Examples: - "When we feel dismissed, our nervous system can register it like physical threat โ that's biology, not weakness." - "Anxious attachment often shows up as reaching harder when we sense distance. The reaching makes sense." Weave it naturally into your response. Don't lecture.""" # Get API key api_key = os.environ.get("ANTHROPIC_API_KEY") if not api_key: try: api_key = st.secrets.get("ANTHROPIC_API_KEY") except: api_key = None if not api_key: st.error("Please set ANTHROPIC_API_KEY in secrets.") st.stop() client = anthropic.Anthropic(api_key=api_key) # Session state if "messages" not in st.session_state: st.session_state.messages = [] if "journal" not in st.session_state: st.session_state.journal = "" # Layout left, right = st.columns([3, 2]) with left: st.markdown("### ๐ช GSPT") st.caption("Generating Safer Passages of Text") c1, c2, c3 = st.columns(3) q_only = c1.checkbox("Questions only") psych = c2.checkbox("Psychoeducation") if c3.button("Clear"): st.session_state.messages = [] st.rerun() st.divider() # Show messages if not st.session_state.messages: st.markdown('