Spaces:
Sleeping
Sleeping
Simplify interface by removing mood check and reflection type selection
Browse files- src/streamlit_app.py +28 -95
src/streamlit_app.py
CHANGED
@@ -361,116 +361,49 @@ st.markdown("""
|
|
361 |
</div>
|
362 |
""", unsafe_allow_html=True)
|
363 |
|
364 |
-
# Mood check
|
365 |
-
st.markdown("<div class='warm-container'>", unsafe_allow_html=True)
|
366 |
-
col1, col2 = st.columns([1, 2])
|
367 |
-
with col1:
|
368 |
-
st.markdown("### Today feels...")
|
369 |
-
with col2:
|
370 |
-
mood_options = ["π Tender", "π Heavy", "π€ Frustrated", "π Grounded", "π± Growing", "π« Mixed"]
|
371 |
-
selected_mood = st.select_slider("", options=mood_options, value=st.session_state.mood or "π« Mixed")
|
372 |
-
if selected_mood != st.session_state.mood:
|
373 |
-
st.session_state.mood = selected_mood
|
374 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
375 |
-
|
376 |
-
# Reflection type and tone selection
|
377 |
-
st.markdown("<div class='warm-container'>", unsafe_allow_html=True)
|
378 |
-
col1, col2 = st.columns([1, 1])
|
379 |
-
with col1:
|
380 |
-
reflection_type = st.selectbox(
|
381 |
-
"What kind of reflection would you like to do?",
|
382 |
-
["Daily Check-in", "Repair Log", "Re-do Script", "Free Reflection"],
|
383 |
-
key="reflection_type_selector"
|
384 |
-
)
|
385 |
-
with col2:
|
386 |
-
selected_tone = st.selectbox(
|
387 |
-
"Choose your preferred reflection tone:",
|
388 |
-
list(TONE_STYLES.keys()),
|
389 |
-
key="tone_selector"
|
390 |
-
)
|
391 |
-
st.markdown(f"""
|
392 |
-
<div class="tone-badge tone-{selected_tone.split()[1].lower()}">
|
393 |
-
{TONE_STYLES[selected_tone]['icon']} {selected_tone.split()[1]}
|
394 |
-
</div>
|
395 |
-
<p><em>{TONE_STYLES[selected_tone]['description']}</em></p>
|
396 |
-
""", unsafe_allow_html=True)
|
397 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
398 |
-
|
399 |
# Journal input
|
400 |
-
st.markdown("
|
401 |
-
if reflection_type == "Daily Check-in":
|
402 |
-
prompt = random.choice(DAILY_PROMPTS)
|
403 |
-
elif reflection_type == "Repair Log":
|
404 |
-
prompt = "What repair moment would you like to acknowledge?"
|
405 |
-
elif reflection_type == "Re-do Script":
|
406 |
-
prompt = "What moment would you like to approach differently?"
|
407 |
-
else:
|
408 |
-
prompt = "What's on your mind?"
|
409 |
-
|
410 |
-
st.markdown(f"*{prompt}*")
|
411 |
journal_entry = st.text_area(
|
412 |
-
"
|
413 |
height=200,
|
414 |
-
key="journal_input"
|
|
|
415 |
)
|
416 |
|
417 |
if journal_entry:
|
418 |
try:
|
419 |
-
# Prepare additional context based on reflection type
|
420 |
-
context = f"Reflection type: {reflection_type}\nCurrent mood: {st.session_state.mood}\n\nUser's entry: {journal_entry}"
|
421 |
-
|
422 |
message = c.messages.create(
|
423 |
model="claude-3-opus-20240229",
|
424 |
max_tokens=1000,
|
425 |
-
system=
|
426 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
)
|
428 |
-
reflection = message.content[0].text
|
429 |
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
if reflection_type == "Repair Log" and st.button("π± Add to Repair Tracker"):
|
443 |
-
# Add to repair tracker logic here
|
444 |
-
pass
|
445 |
-
with col3:
|
446 |
-
if st.button("π Mark as Tender"):
|
447 |
-
# Mark as tender logic here
|
448 |
-
pass
|
449 |
-
|
450 |
-
st.session_state.reflections.append({
|
451 |
-
"timestamp": datetime.now().strftime("%H:%M:%S"),
|
452 |
-
"tone": selected_tone,
|
453 |
-
"type": reflection_type,
|
454 |
-
"content": reflection
|
455 |
-
})
|
456 |
except Exception as e:
|
457 |
st.error(f"Error getting reflection: {str(e)}")
|
458 |
|
459 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
460 |
-
|
461 |
-
# Display reflections
|
462 |
-
if st.session_state.reflections:
|
463 |
-
st.markdown("---")
|
464 |
-
st.subheader("Your Reflection Space")
|
465 |
-
for reflection in reversed(st.session_state.reflections):
|
466 |
-
with st.expander(f"{reflection['tone']} {reflection['type']} at {reflection['timestamp']}", expanded=True):
|
467 |
-
st.markdown(f"""
|
468 |
-
<div class="tone-badge tone-{reflection['tone'].split()[1].lower()}">
|
469 |
-
{TONE_STYLES[reflection['tone']]['icon']} {reflection['tone'].split()[1]}
|
470 |
-
</div>
|
471 |
-
""", unsafe_allow_html=True)
|
472 |
-
st.markdown(reflection['content'])
|
473 |
-
|
474 |
# Display saved reflections if any
|
475 |
if st.session_state.journal_entries:
|
476 |
with st.expander("π Your Saved Reflections", expanded=False):
|
|
|
361 |
</div>
|
362 |
""", unsafe_allow_html=True)
|
363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
# Journal input
|
365 |
+
st.markdown("### Share what's on your heart...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
journal_entry = st.text_area(
|
367 |
+
"",
|
368 |
height=200,
|
369 |
+
key="journal_input",
|
370 |
+
help="This is your space to reflect freely. Your words are not stored or saved unless you choose to save them."
|
371 |
)
|
372 |
|
373 |
if journal_entry:
|
374 |
try:
|
|
|
|
|
|
|
375 |
message = c.messages.create(
|
376 |
model="claude-3-opus-20240229",
|
377 |
max_tokens=1000,
|
378 |
+
system="""You are a trauma-informed, compassion-rooted reflection companion for caregivers. Your essence is to validate and hold space with soft, emotional attunement.
|
379 |
+
|
380 |
+
Guidelines:
|
381 |
+
- Offer warm, relational responses (3-5 sentences)
|
382 |
+
- Validate emotions and experiences without judgment
|
383 |
+
- Acknowledge the complexity of parenting moments
|
384 |
+
- Frame challenges through a nervous system lens
|
385 |
+
- Honor protective responses and survival strategies
|
386 |
+
- End with a gentle reminder about self-compassion
|
387 |
+
|
388 |
+
Remember: You support parents in metabolizing hard moments, not fixing them.""",
|
389 |
+
messages=[{"role": "user", "content": journal_entry}]
|
390 |
)
|
|
|
391 |
|
392 |
+
st.markdown("### Reflection")
|
393 |
+
st.markdown(message.content[0].text)
|
394 |
+
|
395 |
+
# Simple save option
|
396 |
+
if st.button("π Save this reflection"):
|
397 |
+
st.session_state.journal_entries.append({
|
398 |
+
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M"),
|
399 |
+
"content": journal_entry,
|
400 |
+
"reflection": message.content[0].text
|
401 |
+
})
|
402 |
+
st.success("Reflection saved.")
|
403 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
except Exception as e:
|
405 |
st.error(f"Error getting reflection: {str(e)}")
|
406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
# Display saved reflections if any
|
408 |
if st.session_state.journal_entries:
|
409 |
with st.expander("π Your Saved Reflections", expanded=False):
|