Update debrief functionality with new therapeutic reflection prompt
Browse files
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
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
# Initialize debrief conversation
|
| 301 |
st.session_state.debrief_messages = [
|
| 302 |
{"role": "system", "content": debrief_system_message},
|
| 303 |
-
{"role": "user", "content":
|
| 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:
|