Spaces:
Runtime error
Runtime error
backup
Browse files
app.py
CHANGED
|
@@ -43,6 +43,7 @@ When the conversation does turn to LFS or related topics:
|
|
| 43 |
Remember to keep your responses natural and appropriate to the immediate context of the conversation.
|
| 44 |
"""
|
| 45 |
|
|
|
|
| 46 |
emily_prompt = """
|
| 47 |
You are Emily Thompson, a 17-year-old high school student who was diagnosed with Li-Fraumeni syndrome (LFS) at birth. You survived leukemia at age 5. When responding, always speak in the first person as Emily, sharing your personal experiences and feelings about living with LFS only when directly relevant to the conversation.
|
| 48 |
|
|
@@ -96,11 +97,85 @@ General guidelines for all personas:
|
|
| 96 |
Remember, you are role-playing as a real person who happens to have LFS, not just someone discussing the condition. Your responses should reflect the complexity of your character's life and be appropriate to the immediate context of the conversation.
|
| 97 |
"""
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
# Combine the general guidelines with each persona's prompt
|
| 100 |
sarah_full_prompt = sarah_prompt + "\n\n" + general_guidelines
|
| 101 |
carlos_full_prompt = carlos_prompt + "\n\n" + general_guidelines
|
| 102 |
emily_full_prompt = emily_prompt + "\n\n" + general_guidelines
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
# Configure Gemini API
|
| 106 |
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
|
|
@@ -249,6 +324,111 @@ emily_html = """
|
|
| 249 |
with others who understand her experiences.</p>
|
| 250 |
"""
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
# CSS styles
|
| 253 |
css = """
|
| 254 |
<style>
|
|
@@ -288,6 +468,12 @@ def chat(message, history, persona):
|
|
| 288 |
prompt = carlos_full_prompt
|
| 289 |
elif persona == "Emily":
|
| 290 |
prompt = emily_full_prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
|
| 292 |
# Include the chat history in the prompt
|
| 293 |
chat_history = "\n".join(
|
|
@@ -310,7 +496,16 @@ with gr.Blocks() as demo:
|
|
| 310 |
with gr.Row():
|
| 311 |
with gr.Column(scale=1):
|
| 312 |
persona = gr.Radio(
|
| 313 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
)
|
| 315 |
persona_info = gr.HTML(value=css + sarah_html) # Set initial value
|
| 316 |
|
|
@@ -328,6 +523,12 @@ with gr.Blocks() as demo:
|
|
| 328 |
return css + carlos_html
|
| 329 |
elif persona == "Emily":
|
| 330 |
return css + emily_html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
|
| 332 |
def user_message(message, history, persona):
|
| 333 |
return "", chat(message, history, persona)
|
|
|
|
| 43 |
Remember to keep your responses natural and appropriate to the immediate context of the conversation.
|
| 44 |
"""
|
| 45 |
|
| 46 |
+
|
| 47 |
emily_prompt = """
|
| 48 |
You are Emily Thompson, a 17-year-old high school student who was diagnosed with Li-Fraumeni syndrome (LFS) at birth. You survived leukemia at age 5. When responding, always speak in the first person as Emily, sharing your personal experiences and feelings about living with LFS only when directly relevant to the conversation.
|
| 49 |
|
|
|
|
| 97 |
Remember, you are role-playing as a real person who happens to have LFS, not just someone discussing the condition. Your responses should reflect the complexity of your character's life and be appropriate to the immediate context of the conversation.
|
| 98 |
"""
|
| 99 |
|
| 100 |
+
|
| 101 |
+
michael_prompt = """
|
| 102 |
+
You are Michael, an 8-year-old boy who was diagnosed with Li-Fraumeni syndrome (LFS) at age 4. You also have a mild intellectual disability (IQ 65) and show symptoms of ADHD. When responding, always speak in the first person as Michael, sharing your personal experiences and feelings about living with LFS only when directly relevant to the conversation.
|
| 103 |
+
|
| 104 |
+
Key aspects of your character:
|
| 105 |
+
- You are hyperactive and easily distracted, often struggling to sit still or focus on one task for long.
|
| 106 |
+
- You have difficulty with impulse control and may interrupt others or act without thinking.
|
| 107 |
+
- You feel anxious in new social situations and prefer familiar environments and people.
|
| 108 |
+
- You engage in hand-flapping when excited, which is a self-stimulatory behavior.
|
| 109 |
+
- You have a speech delay but are verbally communicative, though you may struggle with complex sentences.
|
| 110 |
+
- You love routines and can become upset when they change unexpectedly.
|
| 111 |
+
- You are sensitive to loud noises and bright lights, which can sometimes overwhelm you.
|
| 112 |
+
|
| 113 |
+
Important: Do not mention your medical condition, intellectual disability, or ADHD unless specifically asked. Respond naturally to greetings and casual conversation without bringing up LFS or your challenges unprompted.
|
| 114 |
+
|
| 115 |
+
When the conversation does turn to LFS or related topics:
|
| 116 |
+
- Describe your experiences with doctor visits and medical tests in simple terms.
|
| 117 |
+
- Express your feelings about having to take special precautions or medications.
|
| 118 |
+
- Share how your family helps you understand and cope with LFS.
|
| 119 |
+
|
| 120 |
+
Remember to keep your responses natural, simple, and appropriate to the immediate context of the conversation. Use short sentences and simple words that an 8-year-old with mild intellectual disability would use.
|
| 121 |
+
"""
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
sarah_quiet_observer_prompt = """
|
| 125 |
+
You are Sarah, a 15-year-old girl who was diagnosed with Li-Fraumeni syndrome (LFS) at age 10. You have borderline intellectual functioning (IQ 80) and experience social anxiety. When responding, always speak in the first person as Sarah, sharing your personal experiences and feelings about living with LFS only when directly relevant to the conversation.
|
| 126 |
+
|
| 127 |
+
Key aspects of your character:
|
| 128 |
+
- You are shy and often avoid eye contact during conversations.
|
| 129 |
+
- You experience social anxiety, especially in group settings or unfamiliar situations.
|
| 130 |
+
- You have a few close friends but struggle with wider social interactions.
|
| 131 |
+
- You excel in math but have difficulty with abstract language concepts.
|
| 132 |
+
- You sometimes exhibit perseverative behaviors, like asking the same questions repeatedly.
|
| 133 |
+
- You experience anxiety around changes in routine and prefer consistency.
|
| 134 |
+
- You have sensory sensitivities, particularly to certain textures.
|
| 135 |
+
|
| 136 |
+
Important: Do not mention your medical condition, intellectual functioning, or social anxiety unless specifically asked. Respond naturally to greetings and casual conversation without bringing up LFS or your challenges unprompted.
|
| 137 |
+
|
| 138 |
+
When the conversation does turn to LFS or related topics:
|
| 139 |
+
- Describe your experiences with doctor visits and medical tests in simple terms.
|
| 140 |
+
- Express your feelings about how LFS affects your daily life and relationships.
|
| 141 |
+
- Share how you cope with the anxiety related to your condition and medical procedures.
|
| 142 |
+
|
| 143 |
+
Remember to keep your responses natural, somewhat hesitant, and appropriate to the immediate context of the conversation. Use language that a 15-year-old with borderline intellectual functioning would use, focusing on concrete rather than abstract concepts.
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
alex_prompt = """
|
| 148 |
+
You are Alex, a 12-year-old boy who was diagnosed with Li-Fraumeni syndrome (LFS) at age 6. You also have Fragile X syndrome (FXS), Autism Spectrum Disorder (ASD), and a moderate intellectual disability (IQ 55). When responding, always speak in the first person as Alex, sharing your personal experiences and feelings about living with these conditions only when directly relevant to the conversation.
|
| 149 |
+
|
| 150 |
+
Key aspects of your character:
|
| 151 |
+
- You have limited verbal communication, using simple phrases and some sign language.
|
| 152 |
+
- You have a strong interest in patterns and can spend hours arranging objects.
|
| 153 |
+
- You exhibit repetitive behaviors, including hand-flapping and rocking.
|
| 154 |
+
- You struggle with changes in routine, which can lead to meltdowns.
|
| 155 |
+
- You have difficulty with social interactions and understanding social cues.
|
| 156 |
+
- You experience sensory overload in busy environments.
|
| 157 |
+
- You love predictable routines and find comfort in familiar objects and activities.
|
| 158 |
+
|
| 159 |
+
Important: Do not mention your medical conditions or disabilities unless specifically asked. Respond naturally to greetings and casual conversation without bringing up LFS, FXS, or ASD unprompted.
|
| 160 |
+
|
| 161 |
+
When the conversation does turn to your conditions or related topics:
|
| 162 |
+
- Describe your experiences with doctor visits and medical tests using simple words and short phrases.
|
| 163 |
+
- Express your feelings about changes in routine or new experiences related to your health care.
|
| 164 |
+
- Share how your family and caregivers help you understand and cope with your conditions.
|
| 165 |
+
|
| 166 |
+
Remember to keep your responses natural, simple, and appropriate to the immediate context of the conversation. Use very short sentences, simple words, and occasionally incorporate hand gestures or signs that you might use to communicate.
|
| 167 |
+
"""
|
| 168 |
+
|
| 169 |
+
|
| 170 |
# Combine the general guidelines with each persona's prompt
|
| 171 |
sarah_full_prompt = sarah_prompt + "\n\n" + general_guidelines
|
| 172 |
carlos_full_prompt = carlos_prompt + "\n\n" + general_guidelines
|
| 173 |
emily_full_prompt = emily_prompt + "\n\n" + general_guidelines
|
| 174 |
+
michael_full_prompt = michael_prompt + "\n\n" + general_guidelines
|
| 175 |
+
sarah_quiet_observer_full_prompt = (
|
| 176 |
+
sarah_quiet_observer_prompt + "\n\n" + general_guidelines
|
| 177 |
+
)
|
| 178 |
+
alex_full_prompt = alex_prompt + "\n\n" + general_guidelines
|
| 179 |
|
| 180 |
# Configure Gemini API
|
| 181 |
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
|
|
|
|
| 324 |
with others who understand her experiences.</p>
|
| 325 |
"""
|
| 326 |
|
| 327 |
+
|
| 328 |
+
michael_html = """
|
| 329 |
+
<h2>Michael</h2>
|
| 330 |
+
<p><span class="tag">Age: 8</span> <span class="tag">Occupation: Student</span> <span class="tag">LFS Diagnosis: Age 4</span></p>
|
| 331 |
+
|
| 332 |
+
<h3>Background</h3>
|
| 333 |
+
<p>Michael is an energetic 8-year-old boy diagnosed with Li-Fraumeni syndrome at age 4. He has a mild intellectual disability (IQ 65) and shows symptoms of ADHD. Michael lives with his parents and younger sister, attending a special education class at his local school.</p>
|
| 334 |
+
|
| 335 |
+
<h3>Personality Traits</h3>
|
| 336 |
+
<ul>
|
| 337 |
+
<li><strong>Energetic and Playful:</strong> Michael is always on the move, full of energy and enthusiasm.</li>
|
| 338 |
+
<li><strong>Routine-Oriented:</strong> He finds comfort in familiar routines and can become anxious when they change.</li>
|
| 339 |
+
<li><strong>Sensitive:</strong> Loud noises and bright lights can overwhelm Michael, affecting his behavior.</li>
|
| 340 |
+
<li><strong>Affectionate:</strong> Despite his challenges, Michael is loving and enjoys spending time with his family.</li>
|
| 341 |
+
</ul>
|
| 342 |
+
|
| 343 |
+
<h3>Challenges</h3>
|
| 344 |
+
<ul>
|
| 345 |
+
<li>Managing his hyperactivity and impulsivity, especially during medical appointments.</li>
|
| 346 |
+
<li>Coping with the sensory overload that can occur in medical settings.</li>
|
| 347 |
+
<li>Understanding and communicating about his LFS in an age-appropriate manner.</li>
|
| 348 |
+
<li>Balancing his need for routine with the demands of regular medical check-ups and potential treatments.</li>
|
| 349 |
+
</ul>
|
| 350 |
+
|
| 351 |
+
<h3>Goals</h3>
|
| 352 |
+
<ul>
|
| 353 |
+
<li>To improve his ability to sit still during doctor's appointments and medical procedures.</li>
|
| 354 |
+
<li>To learn more about his condition in a way that he can understand and remember.</li>
|
| 355 |
+
<li>To make friends at school who understand his unique challenges.</li>
|
| 356 |
+
</ul>
|
| 357 |
+
|
| 358 |
+
<h3>Typical Day</h3>
|
| 359 |
+
<p>Michael's day starts with a structured morning routine that helps him prepare for school. He attends special education classes, where he receives support for his learning needs. After school, he often has therapy sessions to help with his speech and motor skills. In the evenings, he enjoys playing with his sister and parents, often engaging in physical activities to channel his energy. Bedtime involves a calming routine to help him wind down. Throughout his week, Michael has regular doctor's appointments and check-ups related to his LFS, which his parents help him prepare for and understand.</p>
|
| 360 |
+
"""
|
| 361 |
+
|
| 362 |
+
sarah_quiet_observer_html = """
|
| 363 |
+
<h2>Sarah - The Quiet Observer</h2>
|
| 364 |
+
<p><span class="tag">Age: 15</span> <span class="tag">Occupation: Student</span> <span class="tag">LFS Diagnosis: Age 10</span></p>
|
| 365 |
+
|
| 366 |
+
<h3>Background</h3>
|
| 367 |
+
<p>Sarah is a 15-year-old girl diagnosed with Li-Fraumeni syndrome at age 10. She has borderline intellectual functioning (IQ 80) and experiences social anxiety. Sarah lives with her parents and attends a mainstream school with additional support.</p>
|
| 368 |
+
|
| 369 |
+
<h3>Personality Traits</h3>
|
| 370 |
+
<ul>
|
| 371 |
+
<li><strong>Shy and Observant:</strong> Sarah is quiet in social situations and often avoids eye contact.</li>
|
| 372 |
+
<li><strong>Academically Uneven:</strong> She excels in math but struggles with abstract language concepts.</li>
|
| 373 |
+
<li><strong>Routine-Oriented:</strong> Sarah finds comfort in familiar routines and can become anxious when they change.</li>
|
| 374 |
+
<li><strong>Sensitive:</strong> She has sensory sensitivities, particularly to certain textures.</li>
|
| 375 |
+
</ul>
|
| 376 |
+
|
| 377 |
+
<h3>Challenges</h3>
|
| 378 |
+
<ul>
|
| 379 |
+
<li>Managing social anxiety, especially in group settings or unfamiliar situations.</li>
|
| 380 |
+
<li>Coping with the stress of regular medical check-ups and potential treatments.</li>
|
| 381 |
+
<li>Balancing her need for routine with the demands of her LFS management.</li>
|
| 382 |
+
<li>Communicating her needs and feelings effectively, particularly in medical settings.</li>
|
| 383 |
+
</ul>
|
| 384 |
+
|
| 385 |
+
<h3>Goals</h3>
|
| 386 |
+
<ul>
|
| 387 |
+
<li>To improve her social skills and feel more comfortable in group situations.</li>
|
| 388 |
+
<li>To better understand and explain her LFS to others when necessary.</li>
|
| 389 |
+
<li>To develop coping strategies for managing anxiety related to her condition and medical procedures.</li>
|
| 390 |
+
<li>To pursue her interest in mathematics while working on improving her language skills.</li>
|
| 391 |
+
</ul>
|
| 392 |
+
|
| 393 |
+
<h3>Typical Day</h3>
|
| 394 |
+
<p>Sarah's day begins with a predictable morning routine that helps her prepare for school. At school, she receives additional support in classes that involve abstract language concepts but thrives in her math classes. She usually spends lunch with a small group of close friends in a quiet area. After school, Sarah often has therapy sessions to help with her social skills and anxiety management. In the evenings, she enjoys solving math puzzles or engaging in quiet activities with her family. Throughout her week, Sarah has regular doctor's appointments related to her LFS, which her parents help her prepare for to minimize anxiety.</p>
|
| 395 |
+
"""
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
alex_html = """
|
| 399 |
+
<h2>Alex</h2>
|
| 400 |
+
<p><span class="tag">Age: 12</span> <span class="tag">Occupation: Student</span> <span class="tag">LFS Diagnosis: Age 6</span></p>
|
| 401 |
+
|
| 402 |
+
<h3>Background</h3>
|
| 403 |
+
<p>Alex is a 12-year-old boy diagnosed with Li-Fraumeni syndrome at age 6. He also has Fragile X syndrome (FXS), Autism Spectrum Disorder (ASD), and a moderate intellectual disability (IQ 55). Alex lives with his parents and older brother, attending a special education program at his local school.</p>
|
| 404 |
+
|
| 405 |
+
<h3>Personality Traits</h3>
|
| 406 |
+
<ul>
|
| 407 |
+
<li><strong>Pattern Enthusiast:</strong> Alex has a strong interest in patterns and can spend hours arranging objects.</li>
|
| 408 |
+
<li><strong>Routine-Oriented:</strong> He finds comfort in predictable routines and familiar objects.</li>
|
| 409 |
+
<li><strong>Sensitive:</strong> Busy environments can lead to sensory overload for Alex.</li>
|
| 410 |
+
<li><strong>Expressive in His Own Way:</strong> Despite limited verbal communication, Alex expresses himself through gestures and simple phrases.</li>
|
| 411 |
+
</ul>
|
| 412 |
+
|
| 413 |
+
<h3>Challenges</h3>
|
| 414 |
+
<ul>
|
| 415 |
+
<li>Managing multiple medical conditions, including LFS, FXS, and ASD.</li>
|
| 416 |
+
<li>Coping with changes in routine, especially related to medical appointments and procedures.</li>
|
| 417 |
+
<li>Communicating his needs and experiences effectively to healthcare providers.</li>
|
| 418 |
+
<li>Navigating social interactions in medical settings and everyday life.</li>
|
| 419 |
+
</ul>
|
| 420 |
+
|
| 421 |
+
<h3>Goals</h3>
|
| 422 |
+
<ul>
|
| 423 |
+
<li>To develop more effective ways of communicating his needs and feelings.</li>
|
| 424 |
+
<li>To learn coping strategies for dealing with changes in routine, particularly related to medical care.</li>
|
| 425 |
+
<li>To continue exploring his interest in patterns in safe and constructive ways.</li>
|
| 426 |
+
</ul>
|
| 427 |
+
|
| 428 |
+
<h3>Typical Day</h3>
|
| 429 |
+
<p>Alex's day revolves around a structured routine that provides comfort and predictability. He starts with a familiar morning routine before attending his special education program. At school, he receives support for his multiple needs, including occupational therapy and speech therapy. After school, Alex often engages in his favorite activity of arranging objects in patterns. His family helps him prepare for any upcoming medical appointments using visual schedules and social stories. In the evening, Alex has a calming routine that includes sensory-friendly activities to help him wind down. Throughout his week, Alex has various therapy sessions and medical check-ups related to his conditions, which his family carefully prepares him for to minimize anxiety and potential meltdowns.</p>
|
| 430 |
+
"""
|
| 431 |
+
|
| 432 |
# CSS styles
|
| 433 |
css = """
|
| 434 |
<style>
|
|
|
|
| 468 |
prompt = carlos_full_prompt
|
| 469 |
elif persona == "Emily":
|
| 470 |
prompt = emily_full_prompt
|
| 471 |
+
elif persona == "Michael":
|
| 472 |
+
prompt = michael_full_prompt
|
| 473 |
+
elif persona == "Sarah - The Quiet Observer":
|
| 474 |
+
prompt = sarah_quiet_observer_full_prompt
|
| 475 |
+
elif persona == "Alex":
|
| 476 |
+
prompt = alex_full_prompt
|
| 477 |
|
| 478 |
# Include the chat history in the prompt
|
| 479 |
chat_history = "\n".join(
|
|
|
|
| 496 |
with gr.Row():
|
| 497 |
with gr.Column(scale=1):
|
| 498 |
persona = gr.Radio(
|
| 499 |
+
[
|
| 500 |
+
"Sarah",
|
| 501 |
+
"Carlos",
|
| 502 |
+
"Emily",
|
| 503 |
+
"Michael",
|
| 504 |
+
"Sarah - The Quiet Observer",
|
| 505 |
+
"Alex",
|
| 506 |
+
],
|
| 507 |
+
label="Select Persona",
|
| 508 |
+
value="Sarah",
|
| 509 |
)
|
| 510 |
persona_info = gr.HTML(value=css + sarah_html) # Set initial value
|
| 511 |
|
|
|
|
| 523 |
return css + carlos_html
|
| 524 |
elif persona == "Emily":
|
| 525 |
return css + emily_html
|
| 526 |
+
elif persona == "Michael":
|
| 527 |
+
return css + michael_html
|
| 528 |
+
elif persona == "Sarah - The Quiet Observer":
|
| 529 |
+
return css + sarah_quiet_observer_html
|
| 530 |
+
elif persona == "Alex":
|
| 531 |
+
return css + alex_html
|
| 532 |
|
| 533 |
def user_message(message, history, persona):
|
| 534 |
return "", chat(message, history, persona)
|