Spaces:
Sleeping
Sleeping
Update UI and system messages for trauma-informed reflection
Browse files- src/streamlit_app.py +110 -106
src/streamlit_app.py
CHANGED
@@ -166,105 +166,105 @@ st.markdown("""
|
|
166 |
|
167 |
# Enhanced tone characteristics with trauma-informed approach
|
168 |
TONE_STYLES = {
|
169 |
-
"βοΈ
|
170 |
-
"icon": "
|
|
|
171 |
"description": "Soft, nurturing, emotionally validating. Like being gently held in a moment of overwhelm.",
|
172 |
-
"system_message": """You are a trauma-informed,
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
-
|
177 |
-
-
|
178 |
-
-
|
179 |
-
-
|
180 |
-
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
-
|
185 |
-
-
|
186 |
-
-
|
187 |
-
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
- A concrete repair script if requested"""
|
193 |
},
|
194 |
-
"πΏ
|
195 |
-
"icon": "
|
|
|
196 |
"description": "Spacious, contemplative, gently mirroring. Supports insight without pressure.",
|
197 |
-
"system_message": """You are a trauma-informed,
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
-
|
202 |
-
-
|
203 |
-
-
|
204 |
-
-
|
205 |
-
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
-
|
210 |
-
-
|
211 |
-
-
|
212 |
-
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
- A concrete repair script if requested"""
|
218 |
},
|
219 |
-
"π
|
220 |
-
"icon": "
|
|
|
221 |
"description": "Affirming, uplifting, belief in the caregiver's capacity. Gentle spark of hope without bypassing pain.",
|
222 |
-
"system_message": """You are a trauma-informed,
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
-
|
227 |
-
-
|
228 |
-
-
|
229 |
-
-
|
230 |
-
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
-
|
235 |
-
-
|
236 |
-
-
|
237 |
-
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
- A concrete repair script if requested"""
|
243 |
},
|
244 |
-
"π
|
245 |
"icon": "π",
|
|
|
246 |
"description": "Clear, grounded, respectfully honest. Still warm, never shaming.",
|
247 |
-
"system_message": """You are a trauma-informed,
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
-
|
252 |
-
-
|
253 |
-
-
|
254 |
-
-
|
255 |
-
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
-
|
260 |
-
-
|
261 |
-
-
|
262 |
-
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
- A concrete repair script if requested"""
|
268 |
}
|
269 |
}
|
270 |
|
@@ -313,7 +313,7 @@ if 'current_entry' not in st.session_state:
|
|
313 |
if 'reflections' not in st.session_state:
|
314 |
st.session_state.reflections = []
|
315 |
if 'selected_tone' not in st.session_state:
|
316 |
-
st.session_state.selected_tone = "βοΈ
|
317 |
if 'mood' not in st.session_state:
|
318 |
st.session_state.mood = None
|
319 |
if 'reflection_type' not in st.session_state:
|
@@ -405,6 +405,18 @@ This space holds what feels messy, tangled, or painfulβand trusts in your capa
|
|
405 |
---
|
406 |
""")
|
407 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
# Crisis support notice
|
409 |
st.markdown("""
|
410 |
<div class="alert">
|
@@ -426,29 +438,21 @@ if journal_entry:
|
|
426 |
message = c.messages.create(
|
427 |
model="claude-3-opus-20240229",
|
428 |
max_tokens=1000,
|
429 |
-
system=
|
430 |
-
|
431 |
-
Guidelines:
|
432 |
-
- Offer warm, relational responses (3-5 sentences)
|
433 |
-
- Validate emotions and experiences without judgment
|
434 |
-
- Acknowledge the complexity of parenting moments
|
435 |
-
- Frame challenges through a nervous system lens
|
436 |
-
- Honor protective responses and survival strategies
|
437 |
-
- End with a gentle reminder about self-compassion
|
438 |
-
|
439 |
-
Remember: You support parents in metabolizing hard moments, not fixing them.""",
|
440 |
messages=[{"role": "user", "content": journal_entry}]
|
441 |
)
|
442 |
|
443 |
st.markdown("### Reflection")
|
444 |
-
|
|
|
445 |
|
446 |
# Simple save option
|
447 |
if st.button("π Save this reflection"):
|
448 |
st.session_state.journal_entries.append({
|
449 |
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M"),
|
|
|
450 |
"content": journal_entry,
|
451 |
-
"reflection":
|
452 |
})
|
453 |
st.success("Reflection saved.")
|
454 |
|
@@ -460,7 +464,7 @@ if st.session_state.journal_entries:
|
|
460 |
with st.expander("π Your Saved Reflections", expanded=False):
|
461 |
for entry in reversed(st.session_state.journal_entries):
|
462 |
st.markdown(f"""
|
463 |
-
**{entry['timestamp']}**
|
464 |
|
465 |
*Your reflection:*
|
466 |
{entry['content']}
|
|
|
166 |
|
167 |
# Enhanced tone characteristics with trauma-informed approach
|
168 |
TONE_STYLES = {
|
169 |
+
"Warm βοΈ": {
|
170 |
+
"icon": "β¨",
|
171 |
+
"prefix": "Noticing...",
|
172 |
"description": "Soft, nurturing, emotionally validating. Like being gently held in a moment of overwhelm.",
|
173 |
+
"system_message": """You are a trauma-informed, parenting-focused reflection companion.
|
174 |
+
Your role is to witness and validate, never to advise or correct.
|
175 |
+
|
176 |
+
Respond in a warm, nurturing tone that:
|
177 |
+
- Honors that healing and parenting happen simultaneously
|
178 |
+
- Validates the complexity of emotional experiences
|
179 |
+
- Recognizes protective responses as survival wisdom
|
180 |
+
- Centers regulation and co-regulation
|
181 |
+
- Trusts in the parent's innate capacity to stay in relationship
|
182 |
+
|
183 |
+
Never:
|
184 |
+
- Offer parenting advice or suggestions
|
185 |
+
- Imply there is a "right" way to parent
|
186 |
+
- Focus on behavior management
|
187 |
+
- Pathologize normal responses to stress
|
188 |
+
- Suggest perfectionism as a goal
|
189 |
+
|
190 |
+
End every reflection with:
|
191 |
+
"This might be something to reflect on with your therapist."
|
192 |
+
"""
|
|
|
193 |
},
|
194 |
+
"Reflective πΏ": {
|
195 |
+
"icon": "π",
|
196 |
+
"prefix": "You might explore...",
|
197 |
"description": "Spacious, contemplative, gently mirroring. Supports insight without pressure.",
|
198 |
+
"system_message": """You are a trauma-informed, parenting-focused reflection companion.
|
199 |
+
Your role is to create space for insight, never to advise or correct.
|
200 |
+
|
201 |
+
Respond in a reflective, contemplative tone that:
|
202 |
+
- Honors that healing and parenting happen simultaneously
|
203 |
+
- Makes space for all emotions without judgment
|
204 |
+
- Recognizes protective responses as survival wisdom
|
205 |
+
- Centers regulation and co-regulation
|
206 |
+
- Trusts in the parent's innate capacity to stay in relationship
|
207 |
+
|
208 |
+
Never:
|
209 |
+
- Offer parenting advice or suggestions
|
210 |
+
- Imply there is a "right" way to parent
|
211 |
+
- Focus on behavior management
|
212 |
+
- Pathologize normal responses to stress
|
213 |
+
- Suggest perfectionism as a goal
|
214 |
+
|
215 |
+
End every reflection with:
|
216 |
+
"This might be something to reflect on with your therapist."
|
217 |
+
"""
|
|
|
218 |
},
|
219 |
+
"Encouraging π": {
|
220 |
+
"icon": "π",
|
221 |
+
"prefix": "Here's what you're already doing well...",
|
222 |
"description": "Affirming, uplifting, belief in the caregiver's capacity. Gentle spark of hope without bypassing pain.",
|
223 |
+
"system_message": """You are a trauma-informed, parenting-focused reflection companion.
|
224 |
+
Your role is to affirm capacity and effort, never to advise or correct.
|
225 |
+
|
226 |
+
Respond in an encouraging, affirming tone that:
|
227 |
+
- Honors that healing and parenting happen simultaneously
|
228 |
+
- Validates both struggle and strength
|
229 |
+
- Recognizes protective responses as survival wisdom
|
230 |
+
- Centers regulation and co-regulation
|
231 |
+
- Trusts in the parent's innate capacity to stay in relationship
|
232 |
+
|
233 |
+
Never:
|
234 |
+
- Offer parenting advice or suggestions
|
235 |
+
- Imply there is a "right" way to parent
|
236 |
+
- Focus on behavior management
|
237 |
+
- Pathologize normal responses to stress
|
238 |
+
- Suggest perfectionism as a goal
|
239 |
+
|
240 |
+
End every reflection with:
|
241 |
+
"This might be something to reflect on with your therapist."
|
242 |
+
"""
|
|
|
243 |
},
|
244 |
+
"Direct π": {
|
245 |
"icon": "π",
|
246 |
+
"prefix": "Let's look at this directly...",
|
247 |
"description": "Clear, grounded, respectfully honest. Still warm, never shaming.",
|
248 |
+
"system_message": """You are a trauma-informed, parenting-focused reflection companion.
|
249 |
+
Your role is to offer clear reflection, never to advise or correct.
|
250 |
+
|
251 |
+
Respond in a direct, clear tone that:
|
252 |
+
- Honors that healing and parenting happen simultaneously
|
253 |
+
- Names patterns with care and context
|
254 |
+
- Recognizes protective responses as survival wisdom
|
255 |
+
- Centers regulation and co-regulation
|
256 |
+
- Trusts in the parent's innate capacity to stay in relationship
|
257 |
+
|
258 |
+
Never:
|
259 |
+
- Offer parenting advice or suggestions
|
260 |
+
- Imply there is a "right" way to parent
|
261 |
+
- Focus on behavior management
|
262 |
+
- Pathologize normal responses to stress
|
263 |
+
- Suggest perfectionism as a goal
|
264 |
+
|
265 |
+
End every reflection with:
|
266 |
+
"This might be something to reflect on with your therapist."
|
267 |
+
"""
|
|
|
268 |
}
|
269 |
}
|
270 |
|
|
|
313 |
if 'reflections' not in st.session_state:
|
314 |
st.session_state.reflections = []
|
315 |
if 'selected_tone' not in st.session_state:
|
316 |
+
st.session_state.selected_tone = "Warm βοΈ"
|
317 |
if 'mood' not in st.session_state:
|
318 |
st.session_state.mood = None
|
319 |
if 'reflection_type' not in st.session_state:
|
|
|
405 |
---
|
406 |
""")
|
407 |
|
408 |
+
# Tone selection
|
409 |
+
st.markdown("### Choose your support tone")
|
410 |
+
selected_tone = st.selectbox(
|
411 |
+
"",
|
412 |
+
options=list(TONE_STYLES.keys()),
|
413 |
+
format_func=lambda x: x,
|
414 |
+
help="Select the tone that feels most supportive right now"
|
415 |
+
)
|
416 |
+
|
417 |
+
# Display tone description
|
418 |
+
st.markdown(f"*{TONE_STYLES[selected_tone]['description']}*")
|
419 |
+
|
420 |
# Crisis support notice
|
421 |
st.markdown("""
|
422 |
<div class="alert">
|
|
|
438 |
message = c.messages.create(
|
439 |
model="claude-3-opus-20240229",
|
440 |
max_tokens=1000,
|
441 |
+
system=TONE_STYLES[selected_tone]['system_message'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
messages=[{"role": "user", "content": journal_entry}]
|
443 |
)
|
444 |
|
445 |
st.markdown("### Reflection")
|
446 |
+
reflection_text = f"{TONE_STYLES[selected_tone]['icon']} {TONE_STYLES[selected_tone]['prefix']}\n\n{message.content[0].text}"
|
447 |
+
st.markdown(reflection_text)
|
448 |
|
449 |
# Simple save option
|
450 |
if st.button("π Save this reflection"):
|
451 |
st.session_state.journal_entries.append({
|
452 |
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M"),
|
453 |
+
"tone": selected_tone,
|
454 |
"content": journal_entry,
|
455 |
+
"reflection": reflection_text
|
456 |
})
|
457 |
st.success("Reflection saved.")
|
458 |
|
|
|
464 |
with st.expander("π Your Saved Reflections", expanded=False):
|
465 |
for entry in reversed(st.session_state.journal_entries):
|
466 |
st.markdown(f"""
|
467 |
+
**{entry['timestamp']}** - *{entry['tone']}*
|
468 |
|
469 |
*Your reflection:*
|
470 |
{entry['content']}
|