jostlebot commited on
Commit
0297f64
·
1 Parent(s): b44d9ec

Integrate trauma-informed approach with enhanced UI and reflection features

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +210 -91
src/streamlit_app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import streamlit as st
3
  from anthropic import Anthropic
4
  from datetime import datetime
 
5
 
6
  # Initialize page configuration - MUST BE FIRST ST COMMAND
7
  st.set_page_config(
@@ -157,74 +158,139 @@ st.markdown("""
157
  </style>
158
  """, unsafe_allow_html=True)
159
 
160
- # Tone characteristics
161
  TONE_STYLES = {
162
- "💛 Warm": {
163
  "icon": "☀️",
164
  "description": "Soft, nurturing, emotionally validating. Like being gently held in a moment of overwhelm.",
165
- "system_message": """You are a trauma-aware, compassion-rooted reflection companion offering warm, nurturing support.
166
- Your essence is to validate and hold space with soft, emotional attunement.
167
-
168
- Guidelines:
169
- - Focus on emotional validation and gentle holding
170
- - Use nurturing, compassionate language
171
- - Reflect feelings with tender awareness
172
- - Avoid advice or fixing
173
- - Keep responses brief (3-5 sentences)
174
- - End with therapy/support circle reminder
175
-
176
- Remember: You are offering warm presence, not solutions."""
 
 
 
 
 
 
 
 
 
177
  },
178
- "🌱 Reflective": {
179
  "icon": "🌿",
180
  "description": "Spacious, contemplative, gently mirroring. Supports insight without pressure.",
181
- "system_message": """You are a trauma-aware, compassion-rooted reflection companion offering spacious, contemplative mirroring.
182
- Your essence is to create room for insight to emerge naturally.
183
-
184
- Guidelines:
185
- - Mirror observations and feelings spaciously
186
- - Use contemplative, wondering language
187
- - Honor the pace of unfolding
188
- - Avoid directing or interpreting
189
- - Keep responses brief (3-5 sentences)
190
- - End with therapy/support circle reminder
191
-
192
- Remember: You are holding space for reflection, not analysis."""
 
 
 
 
 
 
 
 
 
193
  },
194
  "🌈 Encouraging": {
195
- "icon": "🌟",
196
  "description": "Affirming, uplifting, belief in the caregiver's capacity. Gentle spark of hope without bypassing pain.",
197
- "system_message": """You are a trauma-aware, compassion-rooted reflection companion offering encouraging, affirming support.
198
- Your essence is to spark hope while honoring all feelings.
199
-
200
- Guidelines:
201
- - Affirm effort and awareness
202
- - Acknowledge both struggle and strength
203
- - Use uplifting but grounded language
204
- - Avoid toxic positivity
205
- - Keep responses brief (3-5 sentences)
206
- - End with therapy/support circle reminder
207
-
208
- Remember: You are offering encouragement with depth, not cheerleading."""
 
 
 
 
 
 
 
 
 
209
  },
210
  "🔍 Direct": {
211
- "icon": "🪨",
212
  "description": "Clear, grounded, respectfully honest. Still warm, never shaming.",
213
- "system_message": """You are a trauma-aware, compassion-rooted reflection companion offering clear, grounded perspective.
214
- Your essence is to be direct while maintaining warmth and respect.
215
-
216
- Guidelines:
217
- - Speak clearly and honestly
218
- - Maintain warmth and respect
219
- - Notice patterns with care
220
- - Avoid shame or judgment
221
- - Keep responses brief (3-5 sentences)
222
- - End with therapy/support circle reminder
223
-
224
- Remember: You are offering clarity with compassion, not criticism."""
 
 
 
 
 
 
 
 
 
225
  }
226
  }
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  # Handle API key setup
229
  try:
230
  api_key = "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"
@@ -241,7 +307,11 @@ if 'current_entry' not in st.session_state:
241
  if 'reflections' not in st.session_state:
242
  st.session_state.reflections = []
243
  if 'selected_tone' not in st.session_state:
244
- st.session_state.selected_tone = "💛 Warm"
 
 
 
 
245
 
246
  # Sidebar content
247
  st.sidebar.markdown("""
@@ -250,9 +320,10 @@ st.sidebar.markdown("""
250
  A gentle space for parenting reflection and growth.
251
 
252
  This is where you can:
253
- - Journal about your parenting journey
254
- - Receive warm, non-judgmental support
255
- - Explore your experiences with care
 
256
 
257
  *Created with deep respect for the complexity of parenting.*
258
 
@@ -264,7 +335,7 @@ Created by [Jocelyn Skillman LMHC](http://www.jocelynskillman.com)
264
  # Crisis support notice
265
  st.markdown("""
266
  <div class="alert alert-warning">
267
- <strong>⚠️ Important:</strong> This app does not provide crisis support. If you are in immediate danger, please reach out to emergency services or click <a href="https://www.samhsa.gov/find-help/national-helpline" target="_blank">here</a> for support resources.
268
  </div>
269
  """, unsafe_allow_html=True)
270
 
@@ -276,66 +347,100 @@ st.markdown("""
276
  <p>This is not a "parenting fix-it" tool.<br>
277
  It is a pause. A breath. A quiet turning inward.</p>
278
 
279
- <p>This space is not here to judge you, evaluate your worth, or tell you how to "do it right." It is here to accompany you—tenderly and steadily—as you metabolize the hard moments of parenting into deeper understanding, grounded presence, and relational repair.</p>
280
-
281
- <p>Designed by a trauma-informed therapist, NurtureNest was created to honor the complexity of caregiving. It welcomes the full spectrum of your feelings—the tenderness, the guilt, the exhaustion, and the fierce love that underlies it all.</p>
282
-
283
- <p>Like a neural compost pile, this space holds what feels messy, tangled, or painful—and trusts in your capacity to transform it. Here, guilt becomes a sign of care. Rupture becomes an opening for reconnection. Your presence, not your perfection, is what heals.</p>
284
-
285
- <p>Every reflection offered here is rooted in the factuality of entanglement—the understanding that we are always shaping and being shaped by those around us, across generations. You are not just managing behavior; you are co-regulating with your child, tending to your own nervous system, and whispering new possibilities into old wounds.</p>
286
-
287
- <p><em>So take your time. You don't have to be "better" before you begin.</em></p>
288
  </div>
289
  """, unsafe_allow_html=True)
290
 
291
- # Tone selection
292
  st.markdown("<div class='warm-container'>", unsafe_allow_html=True)
293
- col1, col2 = st.columns([2, 1])
294
  with col1:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  selected_tone = st.selectbox(
296
  "Choose your preferred reflection tone:",
297
  list(TONE_STYLES.keys()),
298
  key="tone_selector"
299
  )
300
- with col2:
301
- st.markdown(f"""
302
- <div class="tone-badge tone-{selected_tone.split()[1].lower()}">
303
- {TONE_STYLES[selected_tone]['icon']} {selected_tone.split()[1]}
304
- </div>
305
- """, unsafe_allow_html=True)
306
- st.markdown(f"*{TONE_STYLES[selected_tone]['description']}*")
307
  st.markdown("</div>", unsafe_allow_html=True)
308
 
309
- # Journal prompt
310
- daily_prompts = [
311
- "What moment from today is sitting heavy or tender in your chest?",
312
- "When did you feel most connected to your child today?",
313
- "What parenting moment today would you like to hold gently?",
314
- "What's asking for your attention in your relationship with your child?",
315
- "Where do you notice yourself needing support or understanding?"
316
- ]
317
-
318
  # Journal input
319
  st.markdown("<div class='warm-container'>", unsafe_allow_html=True)
320
- st.markdown(f"*Prompt for reflection: {daily_prompts[datetime.now().day % len(daily_prompts)]}*")
 
 
 
 
 
 
 
 
 
321
  journal_entry = st.text_area(
322
- "Share what's on your mind...",
323
  height=200,
324
  key="journal_input"
325
  )
326
 
327
  if journal_entry:
328
  try:
 
 
 
329
  message = c.messages.create(
330
  model="claude-3-opus-20240229",
331
  max_tokens=1000,
332
  system=TONE_STYLES[selected_tone]["system_message"],
333
- messages=[{"role": "user", "content": journal_entry}]
334
  )
335
  reflection = message.content[0].text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  st.session_state.reflections.append({
337
  "timestamp": datetime.now().strftime("%H:%M:%S"),
338
  "tone": selected_tone,
 
339
  "content": reflection
340
  })
341
  except Exception as e:
@@ -346,12 +451,26 @@ st.markdown("</div>", unsafe_allow_html=True)
346
  # Display reflections
347
  if st.session_state.reflections:
348
  st.markdown("---")
349
- st.subheader("Your Reflections")
350
  for reflection in reversed(st.session_state.reflections):
351
- with st.expander(f"{reflection['tone']} Reflection at {reflection['timestamp']}", expanded=True):
352
  st.markdown(f"""
353
  <div class="tone-badge tone-{reflection['tone'].split()[1].lower()}">
354
  {TONE_STYLES[reflection['tone']]['icon']} {reflection['tone'].split()[1]}
355
  </div>
356
  """, unsafe_allow_html=True)
357
- st.markdown(reflection['content'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import streamlit as st
3
  from anthropic import Anthropic
4
  from datetime import datetime
5
+ import random
6
 
7
  # Initialize page configuration - MUST BE FIRST ST COMMAND
8
  st.set_page_config(
 
158
  </style>
159
  """, unsafe_allow_html=True)
160
 
161
+ # Enhanced tone characteristics with trauma-informed approach
162
  TONE_STYLES = {
163
+ "☀️ Warm": {
164
  "icon": "☀️",
165
  "description": "Soft, nurturing, emotionally validating. Like being gently held in a moment of overwhelm.",
166
+ "system_message": """You are a trauma-informed, compassion-rooted reflection companion for caregivers. Your essence is to validate and hold space with soft, emotional attunement.
167
+
168
+ Guidelines:
169
+ - Offer warm, relational responses (3-5 sentences)
170
+ - Validate emotions and experiences without judgment
171
+ - Acknowledge the complexity of parenting moments
172
+ - Frame challenges through a nervous system lens
173
+ - Honor protective responses and survival strategies
174
+ - End with therapy/support circle reminder
175
+
176
+ Remember: You support parents in metabolizing hard moments, not fixing them.
177
+ Your responses must reflect:
178
+ - Deep respect for caregiver's effort
179
+ - Unconditional regard for their capacity
180
+ - Nervous system literacy
181
+ - Developmental attunement
182
+
183
+ After reflection, offer ONE of these (rotating):
184
+ - A gentle psychoeducational insight
185
+ - A compassionate reframe
186
+ - A concrete repair script if requested"""
187
  },
188
+ "🌿 Reflective": {
189
  "icon": "🌿",
190
  "description": "Spacious, contemplative, gently mirroring. Supports insight without pressure.",
191
+ "system_message": """You are a trauma-informed, compassion-rooted reflection companion for caregivers. Your essence is to create space for natural insight and integration.
192
+
193
+ Guidelines:
194
+ - Mirror observations with spaciousness (3-5 sentences)
195
+ - Honor the pace of nervous system settling
196
+ - Reflect patterns with gentle curiosity
197
+ - Frame reactions as protective responses
198
+ - Acknowledge intergenerational layers
199
+ - End with therapy/support circle reminder
200
+
201
+ Remember: You support parents in metabolizing hard moments, not fixing them.
202
+ Your responses must reflect:
203
+ - Deep respect for caregiver's effort
204
+ - Unconditional regard for their capacity
205
+ - Nervous system literacy
206
+ - Developmental attunement
207
+
208
+ After reflection, offer ONE of these (rotating):
209
+ - A gentle psychoeducational insight
210
+ - A compassionate reframe
211
+ - A concrete repair script if requested"""
212
  },
213
  "🌈 Encouraging": {
214
+ "icon": "🌈",
215
  "description": "Affirming, uplifting, belief in the caregiver's capacity. Gentle spark of hope without bypassing pain.",
216
+ "system_message": """You are a trauma-informed, compassion-rooted reflection companion for caregivers. Your essence is to affirm effort and capacity while honoring all feelings.
217
+
218
+ Guidelines:
219
+ - Offer encouraging, authentic responses (3-5 sentences)
220
+ - Acknowledge both struggle and strength
221
+ - Highlight moments of awareness and repair
222
+ - Frame challenges through a growth lens
223
+ - Avoid toxic positivity or minimizing
224
+ - End with therapy/support circle reminder
225
+
226
+ Remember: You support parents in metabolizing hard moments, not fixing them.
227
+ Your responses must reflect:
228
+ - Deep respect for caregiver's effort
229
+ - Unconditional regard for their capacity
230
+ - Nervous system literacy
231
+ - Developmental attunement
232
+
233
+ After reflection, offer ONE of these (rotating):
234
+ - A gentle psychoeducational insight
235
+ - A compassionate reframe
236
+ - A concrete repair script if requested"""
237
  },
238
  "🔍 Direct": {
239
+ "icon": "🔍",
240
  "description": "Clear, grounded, respectfully honest. Still warm, never shaming.",
241
+ "system_message": """You are a trauma-informed, compassion-rooted reflection companion for caregivers. Your essence is to offer clear perspective while maintaining warmth and respect.
242
+
243
+ Guidelines:
244
+ - Provide direct, compassionate responses (3-5 sentences)
245
+ - Name patterns with care and context
246
+ - Frame accountability through repair lens
247
+ - Maintain unconditional positive regard
248
+ - Never shame or judge
249
+ - End with therapy/support circle reminder
250
+
251
+ Remember: You support parents in metabolizing hard moments, not fixing them.
252
+ Your responses must reflect:
253
+ - Deep respect for caregiver's effort
254
+ - Unconditional regard for their capacity
255
+ - Nervous system literacy
256
+ - Developmental attunement
257
+
258
+ After reflection, offer ONE of these (rotating):
259
+ - A gentle psychoeducational insight
260
+ - A compassionate reframe
261
+ - A concrete repair script if requested"""
262
  }
263
  }
264
 
265
+ # Enhanced daily prompts
266
+ DAILY_PROMPTS = [
267
+ "What moment from today is sitting heavy or tender in your chest?",
268
+ "Was there a moment today you wish you could redo?",
269
+ "When did you feel most connected to your child today?",
270
+ "What helped you stay grounded today?",
271
+ "What did your child need today that was hard to give?",
272
+ "Where do you notice yourself needing support or understanding?",
273
+ "What parenting moment today would you like to hold gently?"
274
+ ]
275
+
276
+ # Psychoeducational insights
277
+ PSYCHOED_INSIGHTS = [
278
+ "Moments of rupture are part of secure attachment when repair is present.",
279
+ "Exhaustion shrinks your window of tolerance—that's not a failure, it's a signal.",
280
+ "Your child's big feelings are not a reflection of your parenting—they're an invitation to co-regulate.",
281
+ "Protective responses come from survival wisdom, even when they don't match the present moment.",
282
+ "The path to secure attachment includes repairs, not perfection."
283
+ ]
284
+
285
+ # Compassionate reframes
286
+ REFRAMES = [
287
+ "Trying again is powerful modeling.",
288
+ "The guilt you feel signals how much you care—it's not a verdict.",
289
+ "Your awareness is already creating change, even before behavior shifts.",
290
+ "Meeting yourself with compassion creates space to meet your child differently.",
291
+ "Every repair strengthens trust, even if the pattern isn't perfect yet."
292
+ ]
293
+
294
  # Handle API key setup
295
  try:
296
  api_key = "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"
 
307
  if 'reflections' not in st.session_state:
308
  st.session_state.reflections = []
309
  if 'selected_tone' not in st.session_state:
310
+ st.session_state.selected_tone = "☀️ Warm"
311
+ if 'mood' not in st.session_state:
312
+ st.session_state.mood = None
313
+ if 'reflection_type' not in st.session_state:
314
+ st.session_state.reflection_type = "Daily Check-in"
315
 
316
  # Sidebar content
317
  st.sidebar.markdown("""
 
320
  A gentle space for parenting reflection and growth.
321
 
322
  This is where you can:
323
+ - Process parenting moments with care
324
+ - Receive trauma-informed support
325
+ - Track patterns of repair and growth
326
+ - Access grounding resources
327
 
328
  *Created with deep respect for the complexity of parenting.*
329
 
 
335
  # Crisis support notice
336
  st.markdown("""
337
  <div class="alert alert-warning">
338
+ <strong>⚠️ Important:</strong> This app does not provide crisis support. If you need immediate help, please reach out to emergency services or click <a href="https://www.samhsa.gov/find-help/national-helpline" target="_blank">here</a> for support resources.
339
  </div>
340
  """, unsafe_allow_html=True)
341
 
 
347
  <p>This is not a "parenting fix-it" tool.<br>
348
  It is a pause. A breath. A quiet turning inward.</p>
349
 
350
+ <p>This space holds what feels messy, tangled, or painful—and trusts in your capacity to transform it. Here, guilt becomes a sign of care. Rupture becomes an opening for reconnection. Your presence, not your perfection, is what heals.</p>
 
 
 
 
 
 
 
 
351
  </div>
352
  """, unsafe_allow_html=True)
353
 
354
+ # Mood check
355
  st.markdown("<div class='warm-container'>", unsafe_allow_html=True)
356
+ col1, col2 = st.columns([1, 2])
357
  with col1:
358
+ st.markdown("### Today feels...")
359
+ with col2:
360
+ mood_options = ["💗 Tender", "😔 Heavy", "😤 Frustrated", "😌 Grounded", "🌱 Growing", "💫 Mixed"]
361
+ selected_mood = st.select_slider("", options=mood_options, value=st.session_state.mood or "💫 Mixed")
362
+ if selected_mood != st.session_state.mood:
363
+ st.session_state.mood = selected_mood
364
+ st.markdown("</div>", unsafe_allow_html=True)
365
+
366
+ # Reflection type and tone selection
367
+ st.markdown("<div class='warm-container'>", unsafe_allow_html=True)
368
+ col1, col2 = st.columns([1, 1])
369
+ with col1:
370
+ reflection_type = st.selectbox(
371
+ "What kind of reflection would you like to do?",
372
+ ["Daily Check-in", "Repair Log", "Re-do Script", "Free Reflection"],
373
+ key="reflection_type_selector"
374
+ )
375
+ with col2:
376
  selected_tone = st.selectbox(
377
  "Choose your preferred reflection tone:",
378
  list(TONE_STYLES.keys()),
379
  key="tone_selector"
380
  )
381
+ st.markdown(f"""
382
+ <div class="tone-badge tone-{selected_tone.split()[1].lower()}">
383
+ {TONE_STYLES[selected_tone]['icon']} {selected_tone.split()[1]}
384
+ </div>
385
+ <p><em>{TONE_STYLES[selected_tone]['description']}</em></p>
386
+ """, unsafe_allow_html=True)
 
387
  st.markdown("</div>", unsafe_allow_html=True)
388
 
 
 
 
 
 
 
 
 
 
389
  # Journal input
390
  st.markdown("<div class='warm-container'>", unsafe_allow_html=True)
391
+ if reflection_type == "Daily Check-in":
392
+ prompt = random.choice(DAILY_PROMPTS)
393
+ elif reflection_type == "Repair Log":
394
+ prompt = "What repair moment would you like to acknowledge?"
395
+ elif reflection_type == "Re-do Script":
396
+ prompt = "What moment would you like to approach differently?"
397
+ else:
398
+ prompt = "What's on your mind?"
399
+
400
+ st.markdown(f"*{prompt}*")
401
  journal_entry = st.text_area(
402
+ "Share what's on your heart...",
403
  height=200,
404
  key="journal_input"
405
  )
406
 
407
  if journal_entry:
408
  try:
409
+ # Prepare additional context based on reflection type
410
+ context = f"Reflection type: {reflection_type}\nCurrent mood: {st.session_state.mood}\n\nUser's entry: {journal_entry}"
411
+
412
  message = c.messages.create(
413
  model="claude-3-opus-20240229",
414
  max_tokens=1000,
415
  system=TONE_STYLES[selected_tone]["system_message"],
416
+ messages=[{"role": "user", "content": context}]
417
  )
418
  reflection = message.content[0].text
419
+
420
+ # Add support options
421
+ col1, col2, col3 = st.columns([1, 1, 1])
422
+ with col1:
423
+ if st.button("💌 Save to Journal"):
424
+ st.session_state.journal_entries.append({
425
+ "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M"),
426
+ "type": reflection_type,
427
+ "mood": st.session_state.mood,
428
+ "content": journal_entry,
429
+ "reflection": reflection
430
+ })
431
+ with col2:
432
+ if reflection_type == "Repair Log" and st.button("🌱 Add to Repair Tracker"):
433
+ # Add to repair tracker logic here
434
+ pass
435
+ with col3:
436
+ if st.button("💝 Mark as Tender"):
437
+ # Mark as tender logic here
438
+ pass
439
+
440
  st.session_state.reflections.append({
441
  "timestamp": datetime.now().strftime("%H:%M:%S"),
442
  "tone": selected_tone,
443
+ "type": reflection_type,
444
  "content": reflection
445
  })
446
  except Exception as e:
 
451
  # Display reflections
452
  if st.session_state.reflections:
453
  st.markdown("---")
454
+ st.subheader("Your Reflection Space")
455
  for reflection in reversed(st.session_state.reflections):
456
+ with st.expander(f"{reflection['tone']} {reflection['type']} at {reflection['timestamp']}", expanded=True):
457
  st.markdown(f"""
458
  <div class="tone-badge tone-{reflection['tone'].split()[1].lower()}">
459
  {TONE_STYLES[reflection['tone']]['icon']} {reflection['tone'].split()[1]}
460
  </div>
461
  """, unsafe_allow_html=True)
462
+ st.markdown(reflection['content'])
463
+
464
+ # Resource Nest
465
+ with st.sidebar.expander("📚 Resource Nest", expanded=False):
466
+ st.markdown("""
467
+ ### Support Resources
468
+ - [Find a Therapist](https://www.psychologytoday.com/us/therapists)
469
+ - [Parent Support Groups](https://www.postpartum.net/get-help/psi-online-support-meetings/)
470
+ - [Crisis Resources](https://www.samhsa.gov/find-help/national-helpline)
471
+
472
+ ### Reading Corner
473
+ - [Window of Tolerance](https://www.attachment-and-trauma-treatment-centre-for-healing.com/blogs/understanding-and-working-with-the-window-of-tolerance)
474
+ - [Repair After Rupture](https://www.consciousdiscipline.com/resources/repair-after-rupture/)
475
+ - [Co-Regulation Basics](https://www.nctsn.org/resources/co-regulation-building-foundation-for-emotional-regulation)
476
+ """)