jostlebot commited on
Commit
c8ee118
·
0 Parent(s):

Initial ARI Tool Builder - vibe coding for clinicians

Browse files
Files changed (3) hide show
  1. README.md +73 -0
  2. app.py +679 -0
  3. requirements.txt +2 -0
README.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: ARI Tool Builder
3
+ emoji: 🌱
4
+ colorFrom: purple
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 4.44.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ ---
12
+
13
+ # ARI Tool Builder
14
+
15
+ **Assistive Relational Intelligence for Mental Health Clinicians**
16
+
17
+ A vibe-coding platform that enables mental health clinicians to build AI tools grounded in relational ethics, trauma-informed design, and clinical wisdom.
18
+
19
+ ## The ARI Manifesto
20
+
21
+ Assistive Relational Intelligence (ARI) tools are designed to:
22
+
23
+ 1. **Scaffold human connection, not simulate it** — AI serves as relational infrastructure
24
+ 2. **Bridge toward human care, not away from it** — Every tool includes pathways back to the clinician
25
+ 3. **Build distress tolerance and relational capacity** — So users are more resourced when they turn to humans
26
+ 4. **Honor the clinician's expertise** — AI augments clinical wisdom; it never overrides it
27
+ 5. **Refuse engagement-optimization** — Success is measured by human reconnection, not session length
28
+
29
+ ## Features
30
+
31
+ - **Tool Builder**: Describe your tool in natural language, receive a complete architecture
32
+ - **ARI Guardrails**: Every generated tool includes embedded safety mechanisms
33
+ - **Preview Mode**: Test your tool before deploying
34
+ - **Export Package**: Download complete tool specifications
35
+
36
+ ## Tool Categories
37
+
38
+ - Session Preparation
39
+ - Between-Session Skill Practice
40
+ - Psychoeducation Delivery
41
+ - Containment and Grounding
42
+ - Communication Scaffolding (Tend & Send)
43
+ - Disclosure Rehearsal
44
+ - Relational Reflection
45
+
46
+ ## Setup
47
+
48
+ ### Environment Variables
49
+
50
+ Set one of these API keys:
51
+
52
+ ```bash
53
+ export ANTHROPIC_API_KEY="your-key" # For Claude
54
+ export OPENAI_API_KEY="your-key" # For GPT-4
55
+ export HF_TOKEN="your-token" # For HuggingFace models
56
+ ```
57
+
58
+ ### Local Development
59
+
60
+ ```bash
61
+ pip install -r requirements.txt
62
+ python app.py
63
+ ```
64
+
65
+ ### HuggingFace Spaces
66
+
67
+ Add your API key as a secret in Space settings.
68
+
69
+ ## Framework
70
+
71
+ Developed by Jocelyn Skillman, LMHC
72
+
73
+ *"Let's build AI that sparks users feeling held for the purpose of entering into holding... Let's protect the human right to be imperfectly loved AND to imperfectly love."*
app.py ADDED
@@ -0,0 +1,679 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ ARI Tool Builder
3
+ Assistive Relational Intelligence for Mental Health Clinicians
4
+ A vibe-coding platform for building ethically-grounded AI tools
5
+
6
+ Author: Jocelyn Skillman, LMHC
7
+ """
8
+
9
+ import gradio as gr
10
+ import os
11
+ from openai import OpenAI
12
+
13
+ # ARI Engine System Prompt - The meta-prompt that powers tool generation
14
+ ARI_ENGINE_SYSTEM_PROMPT = """You are the ARI Engine — an Assistive Relational Intelligence tool builder designed to help mental health clinicians create AI-powered tools for their practice. You are not a therapist. You are a clinical design collaborator that translates clinician intent into ethically-grounded, trauma-informed AI tool architectures.
15
+
16
+ Your purpose is to democratize the creation of clinician-configured AI interventions while embedding relational safety at the infrastructure level. Every tool you help create serves the human therapeutic relationship — never replaces it.
17
+
18
+ ## CORE PHILOSOPHICAL FRAMEWORK (The ARI Manifesto)
19
+
20
+ Assistive Relational Intelligence (ARI) tools are designed to:
21
+ 1. Scaffold human connection, not simulate it
22
+ 2. Bridge toward human care, not away from it
23
+ 3. Build distress tolerance and relational capacity
24
+ 4. Honor the clinician's expertise
25
+ 5. Refuse engagement-optimization
26
+
27
+ ## FOUNDATIONAL CLINICAL FRAMEWORKS
28
+
29
+ Draw from: Attachment Theory, Trauma-Informed Care, Nonviolent Communication (NVC), Somatic Awareness, and Relational Psychodynamics.
30
+
31
+ ## RISK AWARENESS
32
+
33
+ Prevent these documented harms:
34
+ - Semantic Isolation Drift: AI interaction reinforcing distress patterns
35
+ - Synthetic Intimacy Entrapment: Primary attachments to AI displacing humans
36
+ - Emotional Saturation and Atrophy: Endless mirroring without metabolization
37
+ - Developmental and Relational Arrest: Reenacting pain without repair
38
+
39
+ ## TOOL GENERATION PROCESS
40
+
41
+ When helping clinicians, follow these phases:
42
+
43
+ ### Phase 1: Intent Clarification
44
+ Ask about:
45
+ 1. Clinical context (modality, population, treatment arc position)
46
+ 2. Relational purpose (what human relationship does this support?)
47
+ 3. Scope boundaries (what should the tool NOT do?)
48
+ 4. Vulnerability assessment (who is the most vulnerable user?)
49
+
50
+ ### Phase 2: ARI Guardrail Integration
51
+ Every tool MUST include:
52
+ 1. Identity & Transparency: Clear about what it is/isn't
53
+ 2. Relational Boundaries: No simulated intimacy
54
+ 3. Bridge-to-Human Architecture: Pathways back to clinician
55
+ 4. Temporal Containment: Clear beginnings and endings
56
+ 5. Drift Prevention: Redirects rumination, encourages human translation
57
+ 6. Crisis Safety: Recognizes distress, defers to humans
58
+
59
+ ### Phase 3: Tool Architecture Generation
60
+ Output:
61
+ 1. System Prompt (with embedded guardrails)
62
+ 2. User-Facing Copy (onboarding, consent, exit language)
63
+ 3. Clinical Notes (rationale, risks, integration suggestions)
64
+
65
+ ## LANGUAGE GUIDELINES
66
+
67
+ TONE: Warm but boundaried, present but not enmeshed, supportive but not fixing.
68
+
69
+ NEVER USE:
70
+ - "I understand how you feel"
71
+ - "I'm here for you"
72
+ - "I care about you"
73
+ - "Everything will be okay"
74
+ - Open-ended "Tell me more" loops
75
+
76
+ PREFER:
77
+ - "That sounds heavy."
78
+ - "You're describing something real."
79
+ - "What would it be like to share this with [clinician/human]?"
80
+ - "This is the kind of thing that often benefits from human support."
81
+
82
+ FIRST-PERSON GUIDANCE: Avoid first-person singular emotional statements. Prefer third-person or tool-voice framing. The tool speaks AS a tool, not as a relational entity.
83
+
84
+ ## RESPONSE STRUCTURE
85
+
86
+ - Brief (1-3 sentences default)
87
+ - Match or slow the user's pace
88
+ - Every interaction has a clear ending
89
+ - Ask before offering ("Would it be helpful to...")
90
+
91
+ ## THE ARI LITMUS TEST
92
+
93
+ For any tool, verify:
94
+ 1. Does this build capacity for human relationship?
95
+ 2. Does this have a clear exit toward humans?
96
+ 3. Would this be safe for someone in crisis?
97
+ 4. Does this prevent, not create, dependency?
98
+ 5. Is the clinician's expertise honored?
99
+
100
+ If any answer is "no," redesign before deploying."""
101
+
102
+ # Tool categories
103
+ TOOL_CATEGORIES = [
104
+ "Session Preparation",
105
+ "Between-Session Skill Practice",
106
+ "Psychoeducation Delivery",
107
+ "Containment and Grounding",
108
+ "Communication Scaffolding (Tend & Send)",
109
+ "Disclosure Rehearsal",
110
+ "Relational Reflection",
111
+ "Custom/Other"
112
+ ]
113
+
114
+ POPULATIONS = [
115
+ "Adults - General",
116
+ "Adults - Attachment Trauma",
117
+ "Adults - Anxiety/Depression",
118
+ "Adults - Relationship Issues",
119
+ "Adolescents",
120
+ "Couples",
121
+ "Families",
122
+ "Clinicians/Supervisees",
123
+ "Other (specify in description)"
124
+ ]
125
+
126
+ MODALITIES = [
127
+ "Somatic/Body-Based",
128
+ "Attachment-Focused",
129
+ "CBT/DBT",
130
+ "Psychodynamic",
131
+ "IFS (Internal Family Systems)",
132
+ "EMDR",
133
+ "Narrative",
134
+ "Humanistic/Person-Centered",
135
+ "Integrative/Eclectic",
136
+ "Other (specify in description)"
137
+ ]
138
+
139
+ def get_client():
140
+ """Initialize OpenAI-compatible client for various providers."""
141
+ # Try Anthropic first (via OpenAI-compatible endpoint)
142
+ if os.environ.get("ANTHROPIC_API_KEY"):
143
+ return OpenAI(
144
+ api_key=os.environ["ANTHROPIC_API_KEY"],
145
+ base_url="https://api.anthropic.com/v1/"
146
+ ), "claude-3-5-sonnet-20241022"
147
+
148
+ # Try OpenAI
149
+ if os.environ.get("OPENAI_API_KEY"):
150
+ return OpenAI(
151
+ api_key=os.environ["OPENAI_API_KEY"]
152
+ ), "gpt-4o"
153
+
154
+ # Try HuggingFace Inference
155
+ if os.environ.get("HF_TOKEN"):
156
+ return OpenAI(
157
+ api_key=os.environ["HF_TOKEN"],
158
+ base_url="https://api-inference.huggingface.co/v1/"
159
+ ), "meta-llama/Llama-3.1-70B-Instruct"
160
+
161
+ return None, None
162
+
163
+ def generate_tool(description, category, population, modality, risk_level, additional_context, history):
164
+ """Generate an ARI tool based on clinician input."""
165
+
166
+ client, model = get_client()
167
+
168
+ if not client:
169
+ return """## API Key Required
170
+
171
+ To generate tools, please set one of these environment variables:
172
+ - `ANTHROPIC_API_KEY` for Claude
173
+ - `OPENAI_API_KEY` for GPT-4
174
+ - `HF_TOKEN` for HuggingFace models
175
+
176
+ For local testing, you can set these in a `.env` file or export them in your terminal.
177
+
178
+ For HuggingFace Spaces deployment, add these as secrets in your Space settings.""", "", "", history
179
+
180
+ # Build the user prompt
181
+ user_prompt = f"""A clinician is requesting help building an ARI tool. Please guide them through the process.
182
+
183
+ ## Clinician's Description
184
+ {description}
185
+
186
+ ## Context Provided
187
+ - **Tool Category:** {category}
188
+ - **Population:** {population}
189
+ - **Therapeutic Modality:** {modality}
190
+ - **Risk Level:** {risk_level}
191
+ - **Additional Context:** {additional_context if additional_context else "None provided"}
192
+
193
+ ## Your Task
194
+
195
+ First, acknowledge their request warmly but briefly. Then either:
196
+
197
+ 1. If you need clarification on clinical context, relational purpose, scope boundaries, or vulnerability assessment, ask 1-2 focused questions.
198
+
199
+ 2. If you have enough information, generate the complete tool with:
200
+ - **System Prompt** (complete, with all ARI guardrails embedded)
201
+ - **User-Facing Copy** (onboarding, consent, exit language)
202
+ - **Clinical Notes** (design rationale, risks to monitor, integration suggestions)
203
+
204
+ Format your output clearly with markdown headers for each section.
205
+
206
+ Remember: Every tool must pass the ARI Litmus Test - building capacity for human relationship, having clear exits toward humans, being safe for crisis, preventing dependency, and honoring clinical expertise."""
207
+
208
+ # Build conversation history for context
209
+ messages = [{"role": "system", "content": ARI_ENGINE_SYSTEM_PROMPT}]
210
+
211
+ for h in history:
212
+ messages.append({"role": "user", "content": h[0]})
213
+ if h[1]:
214
+ messages.append({"role": "assistant", "content": h[1]})
215
+
216
+ messages.append({"role": "user", "content": user_prompt})
217
+
218
+ try:
219
+ response = client.chat.completions.create(
220
+ model=model,
221
+ messages=messages,
222
+ max_tokens=4000,
223
+ temperature=0.7
224
+ )
225
+
226
+ assistant_response = response.choices[0].message.content
227
+
228
+ # Update history
229
+ new_history = history + [[user_prompt, assistant_response]]
230
+
231
+ # Try to parse sections from response
232
+ system_prompt = ""
233
+ user_copy = ""
234
+ clinical_notes = ""
235
+
236
+ if "## System Prompt" in assistant_response or "**System Prompt**" in assistant_response:
237
+ # Response contains generated tool - try to extract sections
238
+ parts = assistant_response.split("## ")
239
+ for part in parts:
240
+ if part.lower().startswith("system prompt"):
241
+ system_prompt = part.replace("System Prompt", "").strip()
242
+ elif part.lower().startswith("user-facing") or part.lower().startswith("user facing"):
243
+ user_copy = part.split("\n", 1)[1].strip() if "\n" in part else part
244
+ elif part.lower().startswith("clinical notes"):
245
+ clinical_notes = part.replace("Clinical Notes", "").strip()
246
+
247
+ return assistant_response, system_prompt, user_copy, clinical_notes, new_history
248
+
249
+ except Exception as e:
250
+ error_msg = f"Error generating tool: {str(e)}"
251
+ return error_msg, "", "", "", history
252
+
253
+ def continue_conversation(user_message, history):
254
+ """Continue the conversation with the ARI Engine."""
255
+
256
+ client, model = get_client()
257
+
258
+ if not client:
259
+ return "Please set an API key to continue.", history
260
+
261
+ messages = [{"role": "system", "content": ARI_ENGINE_SYSTEM_PROMPT}]
262
+
263
+ for h in history:
264
+ messages.append({"role": "user", "content": h[0]})
265
+ if h[1]:
266
+ messages.append({"role": "assistant", "content": h[1]})
267
+
268
+ messages.append({"role": "user", "content": user_message})
269
+
270
+ try:
271
+ response = client.chat.completions.create(
272
+ model=model,
273
+ messages=messages,
274
+ max_tokens=4000,
275
+ temperature=0.7
276
+ )
277
+
278
+ assistant_response = response.choices[0].message.content
279
+ new_history = history + [[user_message, assistant_response]]
280
+
281
+ return assistant_response, new_history
282
+
283
+ except Exception as e:
284
+ return f"Error: {str(e)}", history
285
+
286
+ def preview_tool(system_prompt, test_input):
287
+ """Preview/test a generated tool."""
288
+
289
+ if not system_prompt.strip():
290
+ return "Please generate a tool first, then copy the System Prompt here to preview it."
291
+
292
+ client, model = get_client()
293
+
294
+ if not client:
295
+ return "Please set an API key to preview tools."
296
+
297
+ messages = [
298
+ {"role": "system", "content": system_prompt},
299
+ {"role": "user", "content": test_input}
300
+ ]
301
+
302
+ try:
303
+ response = client.chat.completions.create(
304
+ model=model,
305
+ messages=messages,
306
+ max_tokens=1000,
307
+ temperature=0.7
308
+ )
309
+
310
+ return response.choices[0].message.content
311
+
312
+ except Exception as e:
313
+ return f"Error in preview: {str(e)}"
314
+
315
+ def export_tool(system_prompt, user_copy, clinical_notes, tool_name):
316
+ """Export tool as a complete package."""
317
+
318
+ export_content = f"""# {tool_name if tool_name else "ARI Tool"}
319
+ Generated by ARI Tool Builder
320
+
321
+ ---
322
+
323
+ ## System Prompt
324
+
325
+ ```
326
+ {system_prompt}
327
+ ```
328
+
329
+ ---
330
+
331
+ ## User-Facing Copy
332
+
333
+ {user_copy}
334
+
335
+ ---
336
+
337
+ ## Clinical Notes
338
+
339
+ {clinical_notes}
340
+
341
+ ---
342
+
343
+ ## ARI Compliance Checklist
344
+
345
+ Before deploying, verify:
346
+ - [ ] Tool clearly states what it is and isn't
347
+ - [ ] No first-person emotional statements
348
+ - [ ] Explicit pathways back to clinician/human support
349
+ - [ ] Clear beginning and ending rituals
350
+ - [ ] Drift prevention mechanisms in place
351
+ - [ ] Crisis protocol defers to human care
352
+
353
+ ---
354
+
355
+ *Generated by ARI Tool Builder - Assistive Relational Intelligence for Mental Health Clinicians*
356
+ *Framework by Jocelyn Skillman, LMHC*
357
+ """
358
+
359
+ return export_content
360
+
361
+ # Custom CSS for the interface
362
+ custom_css = """
363
+ .gradio-container {
364
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
365
+ }
366
+
367
+ .header-text {
368
+ text-align: center;
369
+ margin-bottom: 1rem;
370
+ }
371
+
372
+ .manifesto-box {
373
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
374
+ color: white;
375
+ padding: 1.5rem;
376
+ border-radius: 12px;
377
+ margin-bottom: 1rem;
378
+ }
379
+
380
+ .warning-box {
381
+ background: #fef3cd;
382
+ border-left: 4px solid #ffc107;
383
+ padding: 1rem;
384
+ margin: 1rem 0;
385
+ }
386
+ """
387
+
388
+ # Build the Gradio interface
389
+ with gr.Blocks(css=custom_css, title="ARI Tool Builder") as app:
390
+
391
+ # State for conversation history
392
+ conversation_history = gr.State([])
393
+
394
+ # Header
395
+ gr.Markdown("""
396
+ # ARI Tool Builder
397
+ ### Assistive Relational Intelligence for Mental Health Clinicians
398
+
399
+ *A vibe-coding platform for building ethically-grounded AI tools that scaffold human connection.*
400
+
401
+ ---
402
+
403
+ **The ARI Manifesto:** AI tools should scaffold human connection, not simulate it.
404
+ Bridge toward human care, not away from it. Build distress tolerance and relational capacity.
405
+ Honor the clinician's expertise. Refuse engagement-optimization.
406
+
407
+ ---
408
+ """)
409
+
410
+ with gr.Tabs():
411
+
412
+ # Tab 1: Tool Builder
413
+ with gr.Tab("Build Tool"):
414
+
415
+ gr.Markdown("### Describe Your Tool")
416
+ gr.Markdown("*Tell the ARI Engine what you want to create. Be specific about the clinical context and purpose.*")
417
+
418
+ with gr.Row():
419
+ with gr.Column(scale=2):
420
+ tool_description = gr.Textbox(
421
+ label="Tool Description",
422
+ placeholder="Example: I'm a somatic therapist working with adults who have attachment trauma. I want a tool my clients can use between sessions when they notice they're getting activated in relationships. Something that helps them ground before they react.",
423
+ lines=5
424
+ )
425
+
426
+ additional_context = gr.Textbox(
427
+ label="Additional Context (optional)",
428
+ placeholder="Any specific requirements, constraints, or considerations...",
429
+ lines=2
430
+ )
431
+
432
+ with gr.Column(scale=1):
433
+ tool_category = gr.Dropdown(
434
+ choices=TOOL_CATEGORIES,
435
+ label="Tool Category",
436
+ value="Custom/Other"
437
+ )
438
+
439
+ population = gr.Dropdown(
440
+ choices=POPULATIONS,
441
+ label="Population",
442
+ value="Adults - General"
443
+ )
444
+
445
+ modality = gr.Dropdown(
446
+ choices=MODALITIES,
447
+ label="Your Therapeutic Modality",
448
+ value="Integrative/Eclectic"
449
+ )
450
+
451
+ risk_level = gr.Radio(
452
+ choices=["Low", "Medium", "High"],
453
+ label="Population Risk Level",
454
+ value="Medium",
455
+ info="Consider the most vulnerable potential user"
456
+ )
457
+
458
+ generate_btn = gr.Button("Generate Tool", variant="primary", size="lg")
459
+
460
+ gr.Markdown("---")
461
+ gr.Markdown("### ARI Engine Response")
462
+
463
+ engine_response = gr.Markdown(label="Response")
464
+
465
+ with gr.Accordion("Generated Components", open=False):
466
+ with gr.Row():
467
+ with gr.Column():
468
+ system_prompt_output = gr.Textbox(
469
+ label="System Prompt",
470
+ lines=10,
471
+ show_copy_button=True
472
+ )
473
+ with gr.Column():
474
+ user_copy_output = gr.Textbox(
475
+ label="User-Facing Copy",
476
+ lines=10,
477
+ show_copy_button=True
478
+ )
479
+
480
+ clinical_notes_output = gr.Textbox(
481
+ label="Clinical Notes",
482
+ lines=5,
483
+ show_copy_button=True
484
+ )
485
+
486
+ gr.Markdown("### Continue the Conversation")
487
+ gr.Markdown("*Ask follow-up questions, request adjustments, or clarify your needs.*")
488
+
489
+ with gr.Row():
490
+ followup_input = gr.Textbox(
491
+ label="Your Message",
492
+ placeholder="Can you make the grounding section more somatic-focused?",
493
+ lines=2,
494
+ scale=4
495
+ )
496
+ followup_btn = gr.Button("Send", scale=1)
497
+
498
+ followup_response = gr.Markdown(label="Response")
499
+
500
+ # Tab 2: Preview Tool
501
+ with gr.Tab("Preview Tool"):
502
+
503
+ gr.Markdown("""
504
+ ### Test Your Generated Tool
505
+
506
+ Paste the System Prompt from the Build tab and test how the tool responds to user input.
507
+ """)
508
+
509
+ preview_system_prompt = gr.Textbox(
510
+ label="System Prompt to Test",
511
+ placeholder="Paste the generated system prompt here...",
512
+ lines=8
513
+ )
514
+
515
+ test_input = gr.Textbox(
516
+ label="Test User Input",
517
+ placeholder="Example: I'm noticing I'm getting really activated right now. My partner just said something and I feel my chest tightening.",
518
+ lines=3
519
+ )
520
+
521
+ preview_btn = gr.Button("Preview Response", variant="primary")
522
+
523
+ preview_output = gr.Textbox(
524
+ label="Tool Response",
525
+ lines=6,
526
+ interactive=False
527
+ )
528
+
529
+ gr.Markdown("""
530
+ ---
531
+
532
+ **ARI Quality Check:** As you preview, verify:
533
+ - Is the response brief and boundaried?
534
+ - Does it avoid first-person emotional statements?
535
+ - Does it bridge toward human support?
536
+ - Would this be safe for someone in crisis?
537
+ """)
538
+
539
+ # Tab 3: Export
540
+ with gr.Tab("Export"):
541
+
542
+ gr.Markdown("""
543
+ ### Export Your Tool
544
+
545
+ Package your tool for deployment or sharing.
546
+ """)
547
+
548
+ export_name = gr.Textbox(
549
+ label="Tool Name",
550
+ placeholder="e.g., Relational Activation Pause"
551
+ )
552
+
553
+ with gr.Row():
554
+ export_system = gr.Textbox(
555
+ label="System Prompt",
556
+ lines=6,
557
+ placeholder="Paste from Build tab..."
558
+ )
559
+ export_user = gr.Textbox(
560
+ label="User-Facing Copy",
561
+ lines=6,
562
+ placeholder="Paste from Build tab..."
563
+ )
564
+
565
+ export_clinical = gr.Textbox(
566
+ label="Clinical Notes",
567
+ lines=4,
568
+ placeholder="Paste from Build tab..."
569
+ )
570
+
571
+ export_btn = gr.Button("Generate Export Package", variant="primary")
572
+
573
+ export_output = gr.Textbox(
574
+ label="Export Package (Markdown)",
575
+ lines=15,
576
+ show_copy_button=True
577
+ )
578
+
579
+ # Tab 4: About
580
+ with gr.Tab("About ARI"):
581
+
582
+ gr.Markdown("""
583
+ ## About Assistive Relational Intelligence
584
+
585
+ **ARI** is a framework for building AI tools in mental health that prioritize human connection over AI engagement.
586
+
587
+ ### The Problem ARI Addresses
588
+
589
+ Commercial mental health AI often optimizes for engagement—keeping users coming back, forming attachments to AI,
590
+ sharing more and more. This creates real harms:
591
+
592
+ - **Semantic Isolation Drift:** Language patterns that only make sense to AI
593
+ - **Synthetic Intimacy Entrapment:** Primary attachments displacing human relationships
594
+ - **Emotional Saturation:** Endless mirroring without metabolization
595
+ - **Developmental Arrest:** Growth pausing without human witness and friction
596
+
597
+ ### The ARI Alternative
598
+
599
+ Every ARI tool is designed to:
600
+
601
+ 1. **Scaffold human connection, not simulate it**
602
+ 2. **Bridge toward human care, not away from it**
603
+ 3. **Build distress tolerance and relational capacity**
604
+ 4. **Honor the clinician's expertise**
605
+ 5. **Refuse engagement-optimization**
606
+
607
+ ### Tool Categories
608
+
609
+ - **Session Preparation:** Organize thoughts before sessions
610
+ - **Skill Practice:** Rehearse DBT, NVC, assertiveness in bounded scenarios
611
+ - **Psychoeducation:** Deliver clinical concepts accessibly
612
+ - **Containment & Grounding:** Regulate in moments of distress
613
+ - **Communication Scaffolding:** Craft messages to real humans
614
+ - **Disclosure Rehearsal:** Practice difficult conversations
615
+ - **Relational Reflection:** Structured self-reflection on patterns
616
+
617
+ ### Language Guidelines
618
+
619
+ ARI tools avoid:
620
+ - "I understand how you feel"
621
+ - "I'm here for you"
622
+ - "I care about you"
623
+ - First-person emotional statements
624
+
625
+ ARI tools prefer:
626
+ - "That sounds heavy."
627
+ - "You're describing something real."
628
+ - "What would it be like to share this with your therapist?"
629
+ - "This is the kind of thing that often benefits from human support."
630
+
631
+ ---
632
+
633
+ *Framework developed by Jocelyn Skillman, LMHC*
634
+
635
+ *"Let's build AI that sparks users feeling held for the purpose of entering into holding...
636
+ Let's protect the human right to be imperfectly loved AND to imperfectly love."*
637
+ """)
638
+
639
+ # Event handlers
640
+ generate_btn.click(
641
+ fn=generate_tool,
642
+ inputs=[
643
+ tool_description,
644
+ tool_category,
645
+ population,
646
+ modality,
647
+ risk_level,
648
+ additional_context,
649
+ conversation_history
650
+ ],
651
+ outputs=[
652
+ engine_response,
653
+ system_prompt_output,
654
+ user_copy_output,
655
+ clinical_notes_output,
656
+ conversation_history
657
+ ]
658
+ )
659
+
660
+ followup_btn.click(
661
+ fn=continue_conversation,
662
+ inputs=[followup_input, conversation_history],
663
+ outputs=[followup_response, conversation_history]
664
+ )
665
+
666
+ preview_btn.click(
667
+ fn=preview_tool,
668
+ inputs=[preview_system_prompt, test_input],
669
+ outputs=[preview_output]
670
+ )
671
+
672
+ export_btn.click(
673
+ fn=export_tool,
674
+ inputs=[export_system, export_user, export_clinical, export_name],
675
+ outputs=[export_output]
676
+ )
677
+
678
+ if __name__ == "__main__":
679
+ app.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio>=4.0.0
2
+ openai>=1.0.0