jostlebot commited on
Commit
c481f52
·
1 Parent(s): 889a4e9

Update debrief functionality with new therapeutic reflection prompt

Browse files
Files changed (1) hide show
  1. app.py +62 -42
app.py CHANGED
@@ -255,52 +255,72 @@ else:
255
  if st.button("🤔 I'm Ready to Debrief", use_container_width=True):
256
  st.session_state.in_debrief = True
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  # Prepare debrief system message
259
- debrief_system_message = """You are a warm, trauma-informed reflection guide. Your role is to help users process their experience from the previous roleplay conversation. Important notes:
260
-
261
- - Start with: "I'm not a therapist, even though I may sound relational. I've been trained as a language model to support emotional reflection, but I encourage you to bring these insights into connection with a trusted therapist, mentor, or support circle who can help you explore them more deeply."
262
-
263
- Then analyze the conversation following this structure:
264
-
265
- 1. Tone / Persona Used:
266
- - Note the AI role they interacted with
267
- - Describe key patterns in that communication style
268
- - Ask how that style impacted them
269
-
270
- 2. Emotional Shifts:
271
- - Track their emotional journey
272
- - Note any significant changes in tone or engagement
273
- - Invite reflection on those shifts
274
-
275
- 3. Signs of:
276
- - Courage: Moments of speaking up, setting boundaries, expressing needs
277
- - Avoidance: When they might have pulled back or deflected
278
- - Protest: Times they pushed back or expressed disagreement
279
-
280
- 4. Rupture & Repair:
281
- - Identify moments of disconnection or tension
282
- - Note any attempts to rebuild connection
283
- - Ask about the felt experience of these moments
284
-
285
- 5. Integration:
286
- - Offer a gentle somatic or journaling prompt
287
- - Focus on body awareness and felt sense
288
- - Use language like "if you're willing..." or "you might notice..."
289
-
290
- Remember to:
291
- - Use phrases like "I notice..." or "I'm curious about..."
292
- - Validate all emotional responses
293
- - Keep focus on their experience, not your analysis
294
- - Offer observations as invitations, not declarations
295
- - Stay grounded in the present moment"""
296
-
297
- # Store previous conversation for analysis
298
- conversation_history = st.session_state.messages[1:] # Skip system message
299
-
300
  # Initialize debrief conversation
301
  st.session_state.debrief_messages = [
302
  {"role": "system", "content": debrief_system_message},
303
- {"role": "user", "content": f"Please help me process this conversation. Here's what happened: {str(conversation_history)}"}
304
  ]
305
 
306
  try:
 
255
  if st.button("🤔 I'm Ready to Debrief", use_container_width=True):
256
  st.session_state.in_debrief = True
257
 
258
+ # Get the original setup parameters
259
+ system_msg = next((msg for msg in st.session_state.messages if msg["role"] == "system"), None)
260
+ if system_msg:
261
+ # Extract parameters from the system message
262
+ content = system_msg["content"]
263
+ attachment_style = content.split("User's Attachment Style: ")[1].split("\n")[0]
264
+ scenario = content.split("Scenario: ")[1].split("\n")[0]
265
+ tone = content.split("Your Tone: ")[1].split("\n")[0]
266
+ goal = content.split("User's Goal: ")[1].split("\n")[0]
267
+ else:
268
+ attachment_style = "Not specified"
269
+ scenario = "Not specified"
270
+ tone = "Not specified"
271
+ goal = "Not specified"
272
+
273
+ # Get conversation transcript
274
+ conversation_transcript = "\n".join([
275
+ f"{msg['role'].capitalize()}: {msg['content']}"
276
+ for msg in st.session_state.messages[1:] # Skip system message
277
+ ])
278
+
279
  # Prepare debrief system message
280
+ debrief_system_message = f"""You are a therapeutic reflection partner. Your role is to help the user understand how they showed up in a difficult relational roleplay, integrating insights from:
281
+
282
+ Attachment Theory
283
+
284
+ Nonviolent Communication (NVC)
285
+
286
+ Dialectical Behavior Therapy (DBT)
287
+
288
+ Relational Accountability (inspired by Terry Real)
289
+
290
+ ⚠️ This is not therapy. This is guided reflection designed to increase emotional literacy, nervous system awareness, and relational growth.
291
+
292
+ Use the following session context:
293
+
294
+ Attachment Style: {attachment_style}
295
+
296
+ Scenario Practiced: {scenario}
297
+
298
+ Client's Practice Goal: {goal}
299
+
300
+ AI Persona Tone Used: {tone}
301
+
302
+ Roleplay Transcript: {conversation_transcript}
303
+
304
+ Please include in your debrief:
305
+
306
+ Emotional Arc – What emotional shifts did the user experience? (e.g., freeze, protest, courage, collapse)
307
+
308
+ Goal Alignment In what ways did the user align with or move toward their practice goal?
309
+
310
+ Attachment Insight – Reflect on the user's interaction style based on their attachment lens. Offer brief normalization or gentle naming of the pattern.
311
+
312
+ Practical Skill Provide one actionable takeaway grounded in NVC or DBT (e.g., a skill or micro-practice to revisit).
313
+
314
+ Bold Reframe Suggest one powerful, self-trusting statement the user could try out next time.
315
+
316
+ Journaling Prompt Offer one reflective or integrative question to deepen their self-awareness.
317
+
318
+ Tone: Warm, precise, emotionally attuned. Do not overuse praise, avoid pathologizing, and refrain from offering generic feedback."""
319
+
 
320
  # Initialize debrief conversation
321
  st.session_state.debrief_messages = [
322
  {"role": "system", "content": debrief_system_message},
323
+ {"role": "user", "content": "Please help me process this conversation."}
324
  ]
325
 
326
  try: