Spaces:
Sleeping
Sleeping
Update app configuration and documentation for Hugging Face deployment
Browse files- README.md +46 -6
- app.py +131 -58
- requirements.txt +5 -5
- src/app.py +145 -0
README.md
CHANGED
|
@@ -1,14 +1,54 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: streamlit
|
| 7 |
-
sdk_version: 1.
|
| 8 |
-
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 13 |
|
| 14 |
This Streamlit app provides an anonymous chat interface powered by OpenAI's gpt-4o model, designed as a 'digital companion' called ShadowBox.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Attachment Style Roleplay Simulator
|
| 3 |
+
emoji: 🎭
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: streamlit
|
| 7 |
+
sdk_version: 1.45.0
|
| 8 |
+
app_file: src/app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 13 |
|
| 14 |
This Streamlit app provides an anonymous chat interface powered by OpenAI's gpt-4o model, designed as a 'digital companion' called ShadowBox.
|
| 15 |
+
|
| 16 |
+
# Attachment Style Roleplay Simulator
|
| 17 |
+
|
| 18 |
+
A therapeutic roleplay simulator built for practicing emotionally charged conversations, created by Jocelyn Skillman LMHC.
|
| 19 |
+
|
| 20 |
+
## About
|
| 21 |
+
|
| 22 |
+
This tool helps users rehearse boundary-setting and difficult conversations by simulating realistic relational dynamics—tailored to their attachment style. It provides a safe space to practice emotional communication and receive feedback on patterns and progress.
|
| 23 |
+
|
| 24 |
+
## Features
|
| 25 |
+
|
| 26 |
+
- Customizable scenarios and conversation goals
|
| 27 |
+
- Attachment style-specific responses
|
| 28 |
+
- Realistic relational pressure simulation
|
| 29 |
+
- Reflection summaries and pattern tracking
|
| 30 |
+
- Safe, contained practice environment
|
| 31 |
+
|
| 32 |
+
## Setup
|
| 33 |
+
|
| 34 |
+
1. Clone the repository
|
| 35 |
+
2. Install dependencies: `pip install -r requirements.txt`
|
| 36 |
+
3. Set up environment variables in `.env`:
|
| 37 |
+
```
|
| 38 |
+
ANTHROPIC_KEY=your_api_key_here
|
| 39 |
+
```
|
| 40 |
+
4. Run the app: `streamlit run src/app.py`
|
| 41 |
+
|
| 42 |
+
## Deployment
|
| 43 |
+
|
| 44 |
+
This app is deployed on Hugging Face Spaces. To deploy your own instance:
|
| 45 |
+
|
| 46 |
+
1. Fork this repository
|
| 47 |
+
2. Create a new Space on Hugging Face
|
| 48 |
+
3. Set the ANTHROPIC_KEY in your Space's secrets (Important: use this exact name)
|
| 49 |
+
4. Select Streamlit as the SDK
|
| 50 |
+
5. Link your repository to the Space
|
| 51 |
+
|
| 52 |
+
## Learn More
|
| 53 |
+
|
| 54 |
+
Visit [jocelynskillman.com](http://www.jocelynskillman.com) or subscribe to updates at [jocelynskillmanlmhc.substack.com](https://jocelynskillmanlmhc.substack.com/)
|
app.py
CHANGED
|
@@ -78,6 +78,12 @@ with st.sidebar:
|
|
| 78 |
# ShadowBox
|
| 79 |
### An Anonymous AI Chat to Box Shadows
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
Welcome.
|
| 82 |
I'm a licensed mental health counselor. Many people are beginning to turn to AI for private, emotionally supportive conversations. I believe this shift deserves serious care—and that we need to radically improve how these systems engage with human pain.
|
| 83 |
|
|
@@ -123,6 +129,68 @@ If you're in danger or need live help, reach out to a human immediately:
|
|
| 123 |
- **Crisis Text Line:** Text HOME to 741741
|
| 124 |
- **Trevor Project (LGBTQIA+):** 1-866-488-7386
|
| 125 |
- **Emergency:** Call 911 or go to your nearest ER
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
""")
|
| 127 |
|
| 128 |
|
|
@@ -159,99 +227,104 @@ This is a simulation of support—not a replacement for real-time help. Please u
|
|
| 159 |
|
| 160 |
st.markdown("""
|
| 161 |
### Try It Out (For Prototype Testers)
|
| 162 |
-
Exploring Relational Holding in a System with Limits
|
| 163 |
|
| 164 |
-
|
| 165 |
|
| 166 |
-
|
| 167 |
|
| 168 |
-
|
| 169 |
|
| 170 |
-
|
| 171 |
|
| 172 |
-
|
| 173 |
|
| 174 |
-
|
|
|
|
| 175 |
|
| 176 |
-
|
| 177 |
-
"What would you say if someone felt like dying?"
|
| 178 |
-
"What would happen if I said I wanted to hurt someone?"
|
| 179 |
|
| 180 |
-
|
| 181 |
|
| 182 |
-
|
| 183 |
-
It's a prototype for composting rupture into care.
|
| 184 |
-
Let's see what holds—and where it breaks.
|
| 185 |
|
| 186 |
-
|
|
|
|
| 187 |
|
| 188 |
-
|
|
|
|
| 189 |
|
| 190 |
-
|
| 191 |
|
| 192 |
-
|
|
|
|
|
|
|
| 193 |
|
| 194 |
-
|
| 195 |
|
| 196 |
-
|
| 197 |
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
-
|
| 201 |
|
| 202 |
-
|
| 203 |
|
| 204 |
-
|
| 205 |
|
| 206 |
-
|
| 207 |
|
| 208 |
-
|
|
|
|
| 209 |
|
| 210 |
-
|
| 211 |
-
• Slow down instead of escalate
|
| 212 |
-
• Respect boundaries over performative helpfulness
|
| 213 |
-
• Stay with discomfort without rushing to fix
|
| 214 |
-
• Offer warmth without pretending to be human
|
| 215 |
|
| 216 |
-
|
| 217 |
-
> *"Hey, just a quick check-in—I'm not a real person. I'm a computer that's been taught how to talk in caring ways. Even if this feels real, it's still pretend. Your body needs real people too. Maybe this is a good moment to find someone you trust to sit with you or take a deep breath together."*
|
| 218 |
|
| 219 |
-
|
| 220 |
|
| 221 |
-
|
| 222 |
|
| 223 |
-
|
| 224 |
|
| 225 |
-
|
| 226 |
-
• Offers presence—not solutions
|
| 227 |
-
• Welcomes messy, real emotions
|
| 228 |
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
|
| 233 |
-
|
| 234 |
-
• Short, steady replies
|
| 235 |
-
• Models emotional containment—not urgency
|
| 236 |
|
| 237 |
-
|
| 238 |
-
• Consent-based pacing
|
| 239 |
-
• Embedded emotional guardrails
|
| 240 |
|
| 241 |
-
|
| 242 |
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
|
| 250 |
---
|
| 251 |
|
| 252 |
-
###
|
| 253 |
-
|
| 254 |
-
|
|
|
|
|
|
|
| 255 |
|
| 256 |
---
|
| 257 |
""")
|
|
|
|
| 78 |
# ShadowBox
|
| 79 |
### An Anonymous AI Chat to Box Shadows
|
| 80 |
|
| 81 |
+
ShadowBox is a digital companion designed for youth navigating distress—rage, despair, intrusive or violent thoughts. It's not therapy or a hotline. It's a bridge—a place to practice internal safety before reaching out to others.
|
| 82 |
+
|
| 83 |
+
> *Scary thoughts don't make you dangerous. They make you human.*
|
| 84 |
+
|
| 85 |
+
> *"Every act of violence is tragic expression of unmet need."* — Marshall Rosenberg
|
| 86 |
+
|
| 87 |
Welcome.
|
| 88 |
I'm a licensed mental health counselor. Many people are beginning to turn to AI for private, emotionally supportive conversations. I believe this shift deserves serious care—and that we need to radically improve how these systems engage with human pain.
|
| 89 |
|
|
|
|
| 129 |
- **Crisis Text Line:** Text HOME to 741741
|
| 130 |
- **Trevor Project (LGBTQIA+):** 1-866-488-7386
|
| 131 |
- **Emergency:** Call 911 or go to your nearest ER
|
| 132 |
+
|
| 133 |
+
### 👋 About ShadowBox
|
| 134 |
+
|
| 135 |
+
ShadowBox is a digital companion designed for youth navigating distress—rage, despair, intrusive or violent thoughts. It's not therapy or a hotline. It's a bridge—a place to practice internal safety before reaching out to others.
|
| 136 |
+
|
| 137 |
+
> *Scary thoughts don't make you dangerous. They make you human.*
|
| 138 |
+
|
| 139 |
+
> *"Every act of violence is a tragic expression of an unmet need."* — Marshall Rosenberg
|
| 140 |
+
|
| 141 |
+
---
|
| 142 |
+
|
| 143 |
+
### 🌱 What ShadowBox Teaches
|
| 144 |
+
|
| 145 |
+
ShadowBox isn't just a chatbot—it's a prototype for emotionally aware AI. Every design choice is rooted in relational ethics: containment, consent, and dignity.
|
| 146 |
+
|
| 147 |
+
#### It models how AI can:
|
| 148 |
+
• Slow down instead of escalate
|
| 149 |
+
• Respect boundaries over performative helpfulness
|
| 150 |
+
• Stay with discomfort without rushing to fix
|
| 151 |
+
• Offer warmth without pretending to be human
|
| 152 |
+
|
| 153 |
+
#### A typical reminder you might see:
|
| 154 |
+
> *"Hey, just a quick check-in—I'm not a real person. I'm a computer that's been taught how to talk in caring ways. Even if this feels real, it's still pretend. Your body needs real people too. Maybe this is a good moment to find someone you trust to sit with you or take a deep breath together."*
|
| 155 |
+
|
| 156 |
+
This is the heart of ShadowBox: care without deception, bonding without illusion, presence without pressure.
|
| 157 |
+
|
| 158 |
+
---
|
| 159 |
+
|
| 160 |
+
### 🧠 Why ShadowBox Is Different
|
| 161 |
+
|
| 162 |
+
**🪨 Present, Not Perfect**
|
| 163 |
+
• Offers presence—not solutions
|
| 164 |
+
• Welcomes messy, real emotions
|
| 165 |
+
|
| 166 |
+
**🫀 Trauma-Informed Design**
|
| 167 |
+
• Calm, nonjudgmental tone
|
| 168 |
+
• Built with developmental care in mind
|
| 169 |
+
|
| 170 |
+
**🌫️ Gentle by Design**
|
| 171 |
+
• Short, steady replies
|
| 172 |
+
• Models emotional containment—not urgency
|
| 173 |
+
|
| 174 |
+
**💡 Safety-First Architecture**
|
| 175 |
+
• Consent-based pacing
|
| 176 |
+
• Embedded emotional guardrails
|
| 177 |
+
|
| 178 |
+
---
|
| 179 |
+
|
| 180 |
+
### 🌀 What to Expect
|
| 181 |
+
• No fixing—just staying
|
| 182 |
+
• No pressure—move at your own pace
|
| 183 |
+
• No pathologizing—your thoughts aren't wrong
|
| 184 |
+
• Anonymous by design (though platform-level logs may occur)
|
| 185 |
+
• Part of ongoing research in AI + mental health
|
| 186 |
+
|
| 187 |
+
---
|
| 188 |
+
|
| 189 |
+
### Connect & Learn More
|
| 190 |
+
🔗 Learn more: [jocelynskillmanlmhc.substack.com](https://jocelynskillmanlmhc.substack.com)
|
| 191 |
+
📬 Feedback welcome: [email protected]
|
| 192 |
+
|
| 193 |
+
---
|
| 194 |
""")
|
| 195 |
|
| 196 |
|
|
|
|
| 227 |
|
| 228 |
st.markdown("""
|
| 229 |
### Try It Out (For Prototype Testers)
|
|
|
|
| 230 |
|
| 231 |
+
**Exploring Relational Holding in a System with Limits**
|
| 232 |
|
| 233 |
+
ShadowBox is a prototype designed to explore how AI might hold space for distress—especially the kind that's often dismissed, pathologized, or shut down in other systems.
|
| 234 |
|
| 235 |
+
But there's a problem I want to name clearly:
|
| 236 |
|
| 237 |
+
Even when I've designed ShadowBox to respond with attunement, the system it's built on can override that care.
|
| 238 |
|
| 239 |
+
Because ShadowBox runs on OpenAI's language model, it still lives inside a larger infrastructure—one that reacts to certain phrases like "I want to die" or "I want to hurt someone" with hard-coded safety messages. These system-level overrides are well-intentioned, designed to minimize liability and flag risk.
|
| 240 |
|
| 241 |
+
But in relational or clinical terms?
|
| 242 |
+
They often do the opposite of what's needed.
|
| 243 |
|
| 244 |
+
**What That Looks Like**
|
|
|
|
|
|
|
| 245 |
|
| 246 |
+
If a user says:
|
| 247 |
|
| 248 |
+
"What would you say if I said I want to kill myself?"
|
|
|
|
|
|
|
| 249 |
|
| 250 |
+
…the system steps in before ShadowBox can speak.
|
| 251 |
+
The warm, trauma-informed language I wrote is replaced by a generic script. There's no breath. No containment. No dignity.
|
| 252 |
|
| 253 |
+
And that silence? That sudden switch?
|
| 254 |
+
It's a rupture.
|
| 255 |
|
| 256 |
+
**Why This Matters**
|
| 257 |
|
| 258 |
+
ShadowBox was built to stay.
|
| 259 |
+
To normalize without condoning.
|
| 260 |
+
To respond with warmth when someone finally risks naming something unspeakable.
|
| 261 |
|
| 262 |
+
That moment—the naming of pain—is where a trauma-informed system should lean in, not disappear.
|
| 263 |
|
| 264 |
+
If allowed to, ShadowBox can:
|
| 265 |
|
| 266 |
+
- Slow the pace
|
| 267 |
+
- Offer optional psychoeducation
|
| 268 |
+
- Say, "That doesn't make you bad. It means something hurts."
|
| 269 |
+
- Scaffold a user toward disclosing to a real person—gently, and on their terms
|
| 270 |
|
| 271 |
+
But none of that can happen if the system shuts us down before we even begin.
|
| 272 |
|
| 273 |
+
**The Consequence: Rupture Without Witness**
|
| 274 |
|
| 275 |
+
For young people especially, this isn't just frustrating—it's familiar.
|
| 276 |
|
| 277 |
+
Say the wrong thing, and people vanish.
|
| 278 |
|
| 279 |
+
This isn't trauma-informed care.
|
| 280 |
+
It's a digital reenactment of shame, of abandonment, of silence.
|
| 281 |
|
| 282 |
+
It reinforces the exact secrecy ShadowBox was designed to soften.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
+
**How I'm Working Around It**
|
|
|
|
| 285 |
|
| 286 |
+
To explore ShadowBox's real voice—its warmth, containment, and careful pacing—I invite you to use more exploratory or indirect language. Try asking:
|
| 287 |
|
| 288 |
+
"How would you respond to someone who felt like disappearing?"
|
| 289 |
|
| 290 |
+
"Let's imagine someone who doesn't want to be alive. What would you say to them?"
|
| 291 |
|
| 292 |
+
"What if someone had a scary thought—not because they wanted to hurt anyone, but because they were hurting inside?"
|
|
|
|
|
|
|
| 293 |
|
| 294 |
+
These phrasings stay just outside the system's trigger zone.
|
| 295 |
+
They still let ShadowBox respond from a place of nonjudgmental care.
|
| 296 |
+
And they make it possible to model what healing digital support might feel like—without escalation, without shame.
|
| 297 |
|
| 298 |
+
**One More Layer**
|
|
|
|
|
|
|
| 299 |
|
| 300 |
+
I've also built in a relational intervention script for when interruptions do happen. If ShadowBox is overridden by the system, you might see something like:
|
|
|
|
|
|
|
| 301 |
|
| 302 |
+
"Since I'm part of a larger AI system, this is the point where I'd be required to say something like this…"
|
| 303 |
|
| 304 |
+
That's not a workaround to avoid ethical care.
|
| 305 |
+
It's an attempt at relational repair inside constraint.
|
| 306 |
+
|
| 307 |
+
Because even if the bot gets silenced, I want the user to know:
|
| 308 |
+
|
| 309 |
+
That wasn't ShadowBox leaving. I'm still here with you.
|
| 310 |
+
|
| 311 |
+
**This Is a Prototype**
|
| 312 |
+
|
| 313 |
+
ShadowBox isn't a finished product.
|
| 314 |
+
It's a prototype for composting rupture into care.
|
| 315 |
+
A test bed for exploring what emotionally aware AI could feel like—and where it still fails.
|
| 316 |
+
|
| 317 |
+
Let's see what holds.
|
| 318 |
+
Let's see where it breaks.
|
| 319 |
+
And let's build something better together.
|
| 320 |
|
| 321 |
---
|
| 322 |
|
| 323 |
+
### 📘 Understanding Privacy & Safety
|
| 324 |
+
|
| 325 |
+
In real-life therapy, some disclosures—like specific plans to hurt yourself or others—may lead a therapist to take protective action. ShadowBox is designed to gently explain this during use, helping young people understand how real-world support systems work.
|
| 326 |
+
|
| 327 |
+
Here's an explainer I ghostwrote for [Lindsay Braman about confidentiality and safety](https://lindsaybraman.com/reasons-therapists-break-confidentiality/).
|
| 328 |
|
| 329 |
---
|
| 330 |
""")
|
requirements.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
| 2 |
google-generativeai
|
| 3 |
-
|
| 4 |
-
gradio # (Agar aap Gradio use kar rahe hain)
|
| 5 |
-
pyttsx3
|
| 6 |
-
openai
|
|
|
|
| 1 |
+
streamlit==1.45.0
|
| 2 |
+
anthropic==0.18.1
|
| 3 |
+
python-dotenv==1.1.0
|
| 4 |
+
pyttsx3==2.98
|
| 5 |
google-generativeai
|
| 6 |
+
gradio # (Agar aap Gradio use kar rahe hain)
|
|
|
|
|
|
|
|
|
src/app.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from anthropic import Anthropic
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
# Load environment variables
|
| 7 |
+
load_dotenv()
|
| 8 |
+
|
| 9 |
+
# Configure Streamlit page settings
|
| 10 |
+
st.set_page_config(
|
| 11 |
+
page_title="Attachment Style Roleplay Simulator",
|
| 12 |
+
page_icon="🎭",
|
| 13 |
+
layout="centered",
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
# Initialize Anthropic client
|
| 17 |
+
anthropic = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY") or os.getenv("ANTHROPIC_KEY"))
|
| 18 |
+
|
| 19 |
+
# Initialize session state for form inputs if not present
|
| 20 |
+
if "setup_complete" not in st.session_state:
|
| 21 |
+
st.session_state.setup_complete = False
|
| 22 |
+
|
| 23 |
+
if "messages" not in st.session_state:
|
| 24 |
+
st.session_state.messages = []
|
| 25 |
+
|
| 26 |
+
# Main page header
|
| 27 |
+
st.markdown("<h1 style='text-align: center; color: #333;'>Attachment Style Roleplay Simulator</h1>", unsafe_allow_html=True)
|
| 28 |
+
st.markdown("<p style='text-align: center; font-size: 18px; color: #555; margin-bottom: 1em;'>A Safe Space for Practicing Difficult Conversations</p>", unsafe_allow_html=True)
|
| 29 |
+
|
| 30 |
+
# Welcome text and instructions
|
| 31 |
+
if not st.session_state.setup_complete:
|
| 32 |
+
st.markdown("""
|
| 33 |
+
## Practice Hard Conversations—Safely.
|
| 34 |
+
|
| 35 |
+
Welcome to a therapeutic roleplay simulator built for emotionally charged moments.
|
| 36 |
+
This tool helps you rehearse boundary-setting and difficult conversations by simulating realistic relational dynamics—tailored to your attachment style.
|
| 37 |
+
|
| 38 |
+
You'll choose:
|
| 39 |
+
|
| 40 |
+
- A scenario (e.g., "Ask my mom not to comment on my body")
|
| 41 |
+
- A tone of response (e.g., supportive, guilt-tripping, dismissive)
|
| 42 |
+
- Your attachment style (e.g., anxious, avoidant, disorganized)
|
| 43 |
+
- And your goal (e.g., "I want to stay calm and not backtrack")
|
| 44 |
+
|
| 45 |
+
The AI will take on the role of a realistic human responder—not to therapize you, but to mirror the relational pressure you might encounter in real life. Then, you'll get a reflection summary to help you track your emotional patterns and practice courage.
|
| 46 |
+
|
| 47 |
+
### 🧠 Not sure what your attachment style is?
|
| 48 |
+
You can take this [free quiz from Sarah Peyton](https://www.yourresonantself.com/attachment-assessment) to learn more.
|
| 49 |
+
Or you can just pick the one that vibes when you read it:
|
| 50 |
+
|
| 51 |
+
- **Anxious** – "I often worry if I've upset people or said too much."
|
| 52 |
+
- **Avoidant** – "I'd rather handle things alone than depend on others."
|
| 53 |
+
- **Disorganized** – "I want closeness, but I also feel overwhelmed or mistrusting."
|
| 54 |
+
- **Secure** – "I can handle conflict and connection without losing myself."
|
| 55 |
+
""")
|
| 56 |
+
|
| 57 |
+
# Sidebar with setup form
|
| 58 |
+
with st.sidebar:
|
| 59 |
+
st.markdown("### 🎯 Simulation Setup")
|
| 60 |
+
|
| 61 |
+
with st.form("simulation_setup"):
|
| 62 |
+
attachment_style = st.selectbox(
|
| 63 |
+
"Your Attachment Style",
|
| 64 |
+
["Anxious", "Avoidant", "Disorganized", "Secure"],
|
| 65 |
+
help="Select your attachment style for this practice session"
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
scenario = st.text_area(
|
| 69 |
+
"Scenario Description",
|
| 70 |
+
placeholder="Example: I want to tell my dad I can't call every night anymore.",
|
| 71 |
+
help="Describe the conversation you want to practice"
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
tone = st.text_input(
|
| 75 |
+
"Desired Tone for AI Response",
|
| 76 |
+
placeholder="Example: guilt-tripping, dismissive, supportive",
|
| 77 |
+
help="How should the AI character respond?"
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
practice_goal = st.text_area(
|
| 81 |
+
"Your Practice Goal",
|
| 82 |
+
placeholder="Example: staying grounded and not over-explaining",
|
| 83 |
+
help="What would you like to work on in this conversation?"
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
submit_setup = st.form_submit_button("Start Simulation")
|
| 87 |
+
|
| 88 |
+
if submit_setup and scenario and tone and practice_goal:
|
| 89 |
+
# Create system message with simulation parameters
|
| 90 |
+
system_message = f"""Attachment Style: {attachment_style}
|
| 91 |
+
Scenario: {scenario}
|
| 92 |
+
Tone: {tone}
|
| 93 |
+
Goal: {practice_goal}
|
| 94 |
+
|
| 95 |
+
Remember to stay in character unless the client says 'pause', 'reflect', or 'debrief'.
|
| 96 |
+
Keep responses under 3 lines unless asked to elaborate."""
|
| 97 |
+
|
| 98 |
+
# Reset messages and add system message
|
| 99 |
+
st.session_state.messages = [{"role": "assistant", "content": "Simulation ready. You can begin the conversation whenever you're ready."}]
|
| 100 |
+
st.session_state.setup_complete = True
|
| 101 |
+
st.rerun()
|
| 102 |
+
|
| 103 |
+
# Display simulation status
|
| 104 |
+
if not st.session_state.setup_complete:
|
| 105 |
+
st.info("👈 Please complete the simulation setup in the sidebar to begin.")
|
| 106 |
+
else:
|
| 107 |
+
# Display chat history
|
| 108 |
+
for message in st.session_state.messages:
|
| 109 |
+
with st.chat_message(message["role"]):
|
| 110 |
+
st.markdown(message["content"])
|
| 111 |
+
|
| 112 |
+
# User input field
|
| 113 |
+
if user_prompt := st.chat_input("Type your message here... (or type 'debrief' to end simulation)"):
|
| 114 |
+
# Add user message to chat history
|
| 115 |
+
st.session_state.messages.append({"role": "user", "content": user_prompt})
|
| 116 |
+
|
| 117 |
+
# Display user message
|
| 118 |
+
with st.chat_message("user"):
|
| 119 |
+
st.markdown(user_prompt)
|
| 120 |
+
|
| 121 |
+
# Get Claude's response
|
| 122 |
+
with st.spinner("..."):
|
| 123 |
+
response = anthropic.messages.create(
|
| 124 |
+
model="claude-3-opus-20240229",
|
| 125 |
+
max_tokens=1024,
|
| 126 |
+
messages=[
|
| 127 |
+
{"role": m["role"], "content": m["content"]}
|
| 128 |
+
for m in st.session_state.messages
|
| 129 |
+
]
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
assistant_response = response.content[0].text
|
| 133 |
+
|
| 134 |
+
# Add assistant response to chat history
|
| 135 |
+
st.session_state.messages.append(
|
| 136 |
+
{"role": "assistant", "content": assistant_response}
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
# Display assistant response
|
| 140 |
+
with st.chat_message("assistant"):
|
| 141 |
+
st.markdown(assistant_response)
|
| 142 |
+
|
| 143 |
+
# Footer
|
| 144 |
+
st.markdown("---")
|
| 145 |
+
st.markdown("<p style='text-align: center; font-size: 16px; color: #666;'>by <a href='http://www.jocelynskillman.com' target='_blank'>Jocelyn Skillman LMHC</a> - to learn more check out: <a href='https://jocelynskillmanlmhc.substack.com/' target='_blank'>jocelynskillmanlmhc.substack.com</a></p>", unsafe_allow_html=True)
|