import os import streamlit as st from anthropic import Anthropic from datetime import datetime import random # Initialize page configuration - MUST BE FIRST ST COMMAND st.set_page_config( page_title="NurtureNest: Inner Child Mirror", page_icon="🪴", layout="wide", initial_sidebar_state="expanded" ) # Age context dictionary AGE_CONTEXT = { "3-5": { "voice": "Very simple, sensory-focused reassurance", "example": "Your body was so tight. That's okay. You're safe now.", "description": "Simple words and gentle comfort for your littlest self", "color": "#FFF5E6", "border": "#FFB366" }, "6-8": { "voice": "Gentle relational reflection", "example": "Sometimes big feelings come when we feel alone. I hear how hard that was.", "description": "Warm understanding for your grade school self", "color": "#F0F7F4", "border": "#88C6B6" }, "9-12": { "voice": "Emotionally attuned validation", "example": "It makes sense that you felt that way. Your feelings matter.", "description": "Respectful reflection for your older child self", "color": "#F5F8FC", "border": "#9FB7E3" } } # Handle API key setup try: # Try multiple ways to get the API key api_key = None # Try environment variable api_key = os.getenv("ANTHROPIC_KEY") # Try Streamlit secrets if env var not found if not api_key and hasattr(st, 'secrets'): api_key = st.secrets.get("ANTHROPIC_KEY") if not api_key: st.error(""" ⚠️ Anthropic API key not found. Please make sure: 1. You've added the secret in Hugging Face Space settings 2. The secret is named exactly 'ANTHROPIC_KEY' 3. The Space has been rebuilt after adding the secret """) st.stop() c = Anthropic(api_key=api_key) except Exception as e: st.error(f"Error initializing Anthropic client: {str(e)}") st.stop() # Initialize session state if 'chat_history' not in st.session_state: st.session_state.chat_history = [] if 'journal_entries' not in st.session_state: st.session_state.journal_entries = [] # Sidebar content st.sidebar.markdown(""" # Welcome to NurtureNest: Inner Child Mirror 🪴 A gentle space for re-parenting through connection with your inner child. Here you can: - Connect with your younger self - Process parenting moments with deep understanding - Experience the healing power of being truly seen - Learn to parent from a place of wholeness *Created with deep respect for the healing journey of parents.* --- Created by [Jocelyn Skillman LMHC](http://www.jocelynskillman.com) [@jocelynskillmanlmhc](https://jocelynskillmanlmhc.substack.com/) """) # Main content area st.markdown(""" # NurtureNest # Welcome to the Inner Child Mirror ## A gentle place to be held, not fixed. Parenting isn't just about raising our children. It's also about meeting the younger parts of ourselves—the ones who didn't always get the co-regulation, safety, or softness they needed. These parts don't disappear when we grow up. They often rise up when we're stressed, overwhelmed, or when our child's behavior echoes an old wound. The Inner Child Mirror is a simple but powerful tool in your parenting toolkit. ### Here's how it works: 1. You write a brief note about a hard moment from today or how you are feeling right now 2. You choose an age (3–12) that feels connected to how you were feeling 3. You receive a warm, developmentally attuned reflection—as if spoken to that younger you This practice is grounded in trauma-informed care, attachment science, and the work of experts like Dr. Dan Siegel, Sarah Peyton, and Dr. Becky Kennedy. It helps you: - Build compassion for yourself—especially after rupture moments - Expand your capacity for repair (with your child and yourself) - Notice and tend to your own nervous system with care - Interrupt inherited patterns with love and attunement You're not just "using an app"—you're doing intergenerational work in the most tender, doable way. Not by being perfect. But by practicing presence—even with the parts of you that were once overwhelmed, scared, or unseen.
This is not therapy. It's not performance. It's a ritual of repair.
You're not alone in this.
{AGE_CONTEXT[selected_age]['voice']}
Example: {AGE_CONTEXT[selected_age]['example']}