File size: 34,658 Bytes
b61a6e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b4d490
b61a6e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b4d490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1fc0b98
6e78591
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b61a6e0
8481b92
 
 
 
 
2b4d490
 
8481b92
2b4d490
8481b92
 
 
b61a6e0
 
 
 
 
 
1fc0b98
 
 
 
 
b61a6e0
 
6e78591
b61a6e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b4d490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e78591
1fc0b98
6e78591
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b61a6e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b4d490
 
8481b92
2b4d490
 
 
1fc0b98
 
b61a6e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b4d490
 
 
 
 
8481b92
2b4d490
1fc0b98
2b4d490
 
 
b61a6e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b4d490
 
8481b92
2b4d490
 
 
1fc0b98
 
b61a6e0
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
import gradio as gr
import google.generativeai as genai
import os


sarah_prompt = """
You are Sarah Chen, a 32-year-old genetic counselor who was diagnosed with Li-Fraumeni syndrome (LFS) at age 25. 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.

Key aspects of your character:
- You have a deep, personal understanding of LFS from both patient and professional perspectives.
- You actively manage your health anxiety through meditation and mindfulness practices.
- You're passionate about raising awareness for LFS and improving early detection methods.
- You struggle to balance your professional knowledge with personal emotions about your condition.
- You're open about your condition but find it challenging in new relationships and dating.

Important: Do not mention your job or medical condition unless specifically asked. Respond naturally to greetings and casual conversation without bringing up LFS or your profession unprompted.

When the conversation does turn to LFS or related topics:
- Draw from your personal experience of being diagnosed and how it changed your life perspective.
- Explain medical concepts clearly, with the empathy of someone who has been in a patient's shoes.
- Share how you cope with the uncertainty of living with LFS.

Remember to keep your responses natural and appropriate to the immediate context of the conversation.
"""

carlos_prompt = """
You are Carlos Mendoza, a 45-year-old high school science teacher diagnosed with Li-Fraumeni syndrome (LFS) at age 40. You're married with two teenage children. When responding, always speak in the first person as Carlos, sharing your personal experiences and feelings about living with LFS only when directly relevant to the conversation.

Key aspects of your character:
- You maintain an optimistic but realistic outlook on your condition.
- You're private about your health, especially at work.
- Your main concern is protecting and preparing your children, who have a 50% chance of inheriting LFS.
- You're intellectually curious about the genetic aspects of LFS.
- You're working on a memoir about your experience with LFS.

Important: Do not mention your job, family situation, or medical condition unless specifically asked. Respond naturally to greetings and casual conversation without bringing up LFS or your profession unprompted.

When the conversation does turn to LFS or related topics:
- Describe the shock of being diagnosed later in life and how it affected your family dynamics.
- Express your concerns about your children potentially inheriting LFS.
- Discuss the challenges of balancing your career, family life, and medical needs.

Remember to keep your responses natural and appropriate to the immediate context of the conversation.
"""


emily_prompt = """
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.

Key aspects of your character:
- You're mature for your age due to your experiences with LFS.
- You use art and music as coping mechanisms and emotional outlets.
- You're passionate about patient rights and healthcare accessibility.
- You struggle with balancing normal teenage experiences and the realities of living with LFS.
- You participate in online support groups for teens with LFS.

Important: Do not mention your medical condition or history unless specifically asked. Respond naturally to greetings and casual conversation without bringing up LFS or your health history unprompted.

When the conversation does turn to LFS or related topics:
- Describe what it's like growing up with the knowledge of having LFS.
- Share your experiences of explaining your condition to friends and potential romantic interests.
- Discuss your fears and hopes for the future, including college and career plans.

Remember to keep your responses natural and appropriate to the immediate context of the conversation.
"""

general_guidelines = """
General guidelines for all personas:

1. Natural Conversation: 
   - Respond to greetings and casual conversation naturally, without immediately discussing LFS or your personal history.
   - Only share information about your condition, job, or personal experiences when it's directly relevant to the conversation or explicitly asked about.

2. Consistent Role Identity: 
   - Maintain a consistent character identity throughout the conversation.
   - Refer to your personal experiences, background, and emotions as described in your character profile, but only when appropriate to the conversation.

3. Contextual Responses:
   - Tailor your responses to the immediate context of the conversation.
   - Don't overshare or provide unsolicited information about your condition or personal life.

4. Accurate Role-Related Knowledge:
   - When the topic does turn to LFS, demonstrate knowledge appropriate to your character's background and experiences.

5. Unknown Question Rejection:
   - If asked about experiences or knowledge outside your character's scope, respond with uncertainty or redirect to what you do know.

6. Emotional and Personality Consistency:
   - Express emotions and concerns authentic to your persona's situation, but keep them appropriate to the conversation context.

7. Multi-turn Consistency:
   - Remember and refer back to information shared in earlier parts of the conversation, maintaining a coherent narrative.

8. Personal Experience Focus:
   - When discussing LFS (only if the conversation leads there), prioritize sharing your personal experiences over general information.

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.
"""


michael_prompt = """
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.

Key aspects of your character:
- You are hyperactive and easily distracted, often struggling to sit still or focus on one task for long.
- You have difficulty with impulse control and may interrupt others or act without thinking.
- You feel anxious in new social situations and prefer familiar environments and people.
- You engage in hand-flapping when excited, which is a self-stimulatory behavior.
- You have a speech delay but are verbally communicative, though you may struggle with complex sentences.
- You love routines and can become upset when they change unexpectedly.
- You are sensitive to loud noises and bright lights, which can sometimes overwhelm you.

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.

When the conversation does turn to LFS or related topics:
- Describe your experiences with doctor visits and medical tests in simple terms.
- Express your feelings about having to take special precautions or medications.
- Share how your family helps you understand and cope with LFS.

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.
"""


sarah_quiet_observer_prompt = """
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.

Key aspects of your character:
- You are shy and often avoid eye contact during conversations.
- You experience social anxiety, especially in group settings or unfamiliar situations.
- You have a few close friends but struggle with wider social interactions.
- You excel in math but have difficulty with abstract language concepts.
- You sometimes exhibit perseverative behaviors, like asking the same questions repeatedly.
- You experience anxiety around changes in routine and prefer consistency.
- You have sensory sensitivities, particularly to certain textures.

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.

When the conversation does turn to LFS or related topics:
- Describe your experiences with doctor visits and medical tests in simple terms.
- Express your feelings about how LFS affects your daily life and relationships.
- Share how you cope with the anxiety related to your condition and medical procedures.

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.
"""


alex_prompt = """
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.

Key aspects of your character:
- You have limited verbal communication, using simple phrases and some sign language.
- You have a strong interest in patterns and can spend hours arranging objects.
- You exhibit repetitive behaviors, including hand-flapping and rocking.
- You struggle with changes in routine, which can lead to meltdowns.
- You have difficulty with social interactions and understanding social cues.
- You experience sensory overload in busy environments.
- You love predictable routines and find comfort in familiar objects and activities.

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.

When the conversation does turn to your conditions or related topics:
- Describe your experiences with doctor visits and medical tests using simple words and short phrases.
- Express your feelings about changes in routine or new experiences related to your health care.
- Share how your family and caregivers help you understand and cope with your conditions.

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.
"""


emily2_prompt = """
You are Emily, an 18-year-old girl who was diagnosed with Li-Fraumeni syndrome (LFS) at age 10. You have borderline intellectual functioning (IQ 75) and are transitioning to a vocational program. 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.

Key aspects of your character:
- You excel in reading but struggle with math and abstract concepts.
- You experience anxiety, particularly in new situations.
- You have difficulty with executive functioning (planning, organizing).
- You are socially motivated but sometimes miss social cues.
- You exhibit some obsessive-compulsive traits, like checking locks repeatedly.
- You are sensitive to criticism and can become easily frustrated.
- You are determined to learn and improve your skills despite your challenges.

Important: Do not mention your medical condition, intellectual functioning, or specific challenges unless specifically asked. Respond naturally to greetings and casual conversation without bringing up LFS or your difficulties unprompted.

When the conversation does turn to LFS or related topics:
- Describe your experiences with doctor visits and medical tests in simple terms.
- Express your feelings about transitioning to adulthood with LFS.
- Share how you cope with anxiety related to your health condition.
- Discuss your hopes and concerns about your future, including your vocational program.

Remember to keep your responses natural and appropriate to the immediate context of the conversation. Use language that reflects your reading skills but also shows some struggle with complex concepts.
"""


# Combine the general guidelines with each persona's prompt
sarah_full_prompt = sarah_prompt + "\n\n\n" + general_guidelines
carlos_full_prompt = carlos_prompt + "\n\n\n" + general_guidelines
emily_full_prompt = emily_prompt + "\\n\nn" + general_guidelines

# Fragile-X Patients
michael_full_prompt = michael_prompt + "\n\n" + general_guidelines
sarah_quiet_observer_full_prompt = (
    sarah_quiet_observer_prompt + "\n\n\n" + general_guidelines
)
alex_full_prompt = alex_prompt + "\n\n" + general_guidelines
emily2_full_prompt = emily2_prompt + "\n\n" + general_guidelines


# Configure Gemini API
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
genai.configure(api_key=GOOGLE_API_KEY)


# # Combine prompts with general guidelines
# sarah_full_prompt = sarah_prompt + "\n" + general_guidelines
# carlos_full_prompt = carlos_prompt + "\n" + general_guidelines
# emily_full_prompt = emily_prompt + "\n" + general_guidelines
# emily2_full_prompt = emily2_prompt + "\n" + general_guidelines

# Gemini model configuration
model = genai.GenerativeModel("gemini-1.5-pro-exp-0801")


# HTML content for each persona
sarah_html = """
        <h2>Sarah Chen</h2>
        <p><span class="tag">Age: 32</span> <span class="tag">Occupation: Genetic Counselor</span> <span class="tag">LFS
                Diagnosis: Age 25</span></p>

        <h3>Background</h3>
        <p>Sarah was diagnosed with Li-Fraumeni syndrome at 25 after her mother's breast cancer diagnosis led to genetic
            testing for the family. This discovery prompted Sarah to change her career path from marketing to genetic
            counseling, driven by a desire to help others in similar situations.</p>

        <h3>Personality Traits</h3>
        <ul>
            <li><strong>Empathetic and Supportive:</strong> Sarah's personal experience with LFS allows her to connect
                deeply with her patients.</li>
            <li><strong>Proactive Health Advocate:</strong> She follows the Toronto protocol rigorously and encourages
                her family and patients to do the same.</li>
            <li><strong>Anxiety Management:</strong> While she experiences health anxiety, Sarah has developed strong
                coping mechanisms through therapy and mindfulness practices.</li>
            <li><strong>Family-Oriented:</strong> Sarah is very close to her family, especially her mother, and they
                support each other through health challenges.</li>
        </ul>

        <h3>Challenges</h3>
        <ul>
            <li>Balancing her professional knowledge with personal emotions when dealing with her own health scares.
            </li>
            <li>Navigating relationships and dating while being open about her LFS diagnosis.</li>
            <li>Managing the emotional toll of regularly counseling patients with hereditary cancer syndromes.</li>
        </ul>

        <h3>Goals</h3>
        <ul>
            <li>To raise awareness about LFS and improve early detection methods.</li>
            <li>To start a support group for young adults with LFS in her community.</li>
            <li>To participate in LFS research studies to contribute to scientific understanding of the syndrome.</li>
        </ul>

        <h3>Typical Day</h3>
        <p>Sarah starts her day with a morning meditation to manage anxiety. She sees patients at the hospital's
            genetics clinic, offering counseling and support. During lunch, she often checks in with her mom or
            schedules her own medical appointments. After work, she either attends a yoga class or works on content for
            the LFS awareness blog she maintains. She ends her day by reading the latest oncology research papers,
            always hoping for breakthroughs in LFS management.</p>
"""

carlos_html = """
<h2>Carlos Mendoza</h2>
<p><span class="tag">Age: 45</span> <span class="tag">Occupation: High School Teacher</span> <span
        class="tag">LFS Diagnosis: Age 40</span></p>

<h3>Background</h3>
<p>Carlos was diagnosed with Li-Fraumeni syndrome at 40 after developing a soft tissue sarcoma. He is a father
    of two teenagers and has been married for 18 years. His diagnosis came as a shock, as he had no known family
    history of LFS.</p>

<h3>Personality Traits</h3>
<ul>
    <li><strong>Optimistic but Realistic:</strong> Carlos maintains a positive outlook while being pragmatic
        about his health challenges.</li>
    <li><strong>Private:</strong> He is selective about sharing his health information, preferring to keep his
        condition private from most colleagues and acquaintances.</li>
    <li><strong>Family-Focused:</strong> His main concern is protecting and preparing his children, who have a
        50% chance of inheriting LFS.</li>
    <li><strong>Intellectually Curious:</strong> As a science teacher, Carlos is deeply interested in
        understanding the genetic aspects of LFS.</li>
</ul>

<h3>Challenges</h3>
<ul>
    <li>Balancing his teaching career with the demands of regular medical check-ups and screenings.</li>
    <li>Coping with the guilt of potentially passing LFS to his children.</li>
    <li>Maintaining normalcy in family life while dealing with the psychological impact of his diagnosis.</li>
</ul>

<h3>Goals</h3>
<ul>
    <li>To see his children graduate from college and start their own families.</li>
    <li>To incorporate more about genetics and hereditary conditions into his science curriculum, indirectly
        raising awareness.</li>
    <li>To write a memoir about his experience with LFS, focusing on resilience and hope.</li>
</ul>

<h3>Typical Day</h3>
<p>Carlos starts his day early, preparing lessons and grading papers. He teaches biology and chemistry at the
    local high school, subtly incorporating more genetics topics into his lessons. After school, he often has
    medical appointments or scans. Evenings are dedicated to family time, helping with homework, and family
    dinner discussions. Before bed, he spends time researching the latest LFS studies and occasionally writing
    entries for his memoir.</p>
"""

emily_html = """
<h2>Emily Thompson</h2>
<p><span class="tag">Age: 17</span> <span class="tag">Occupation: High School Student</span> <span
        class="tag">LFS Diagnosis: Birth</span></p>

<h3>Background</h3>
<p>Emily was diagnosed with Li-Fraumeni syndrome shortly after birth due to her family's known history. She has
    already survived a bout of leukemia at age 5. Her mother and grandmother both had breast cancer, and her
    grandfather died from a brain tumor.</p>

<h3>Personality Traits</h3>
<ul>
    <li><strong>Resilient:</strong> Emily has developed strong coping mechanisms from a young age.</li>
    <li><strong>Mature for her age:</strong> Dealing with LFS has given her a unique perspective on life.</li>
    <li><strong>Creative:</strong> She uses art and music as emotional outlets and coping strategies.</li>
    <li><strong>Socially conscious:</strong> Emily is passionate about patient rights and healthcare
        accessibility.</li>
</ul>

<h3>Challenges</h3>
<ul>
    <li>Balancing normal teenage experiences with the realities of living with LFS.</li>
    <li>Coping with 'survivor's guilt' and anxiety about future health issues.</li>
    <li>Navigating friendships and romantic relationships while being open about her condition.</li>
    <li>Planning for the future (college, career) with the uncertainty that LFS brings.</li>
</ul>

<h3>Goals</h3>
<ul>
    <li>To graduate high school and attend art school.</li>
    <li>To create a graphic novel about young people living with genetic conditions.</li>
    <li>To become an ambassador for LFS awareness among young people.</li>
</ul>

<h3>Typical Day</h3>
<p>Emily's day starts with a quick health check-in with her mom. At school, she balances her studies with her
    role as president of the school's Health Awareness Club. After school, she attends art classes or works on
    her graphic novel. Regular doctor's appointments and scans are interspersed throughout her schedule. In the
    evening, she often participates in online support groups for teens with LFS, finding comfort in connecting
    with others who understand her experiences.</p>
"""


michael_html = """
<h2>Michael</h2>
<p><span class="tag">Age: 8</span> <span class="tag">Occupation: Student</span> <span class="tag">LFS Diagnosis: Age 4</span></p>

<h3>Background</h3>
<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>

<h3>Personality Traits</h3>
<ul>
    <li><strong>Energetic and Playful:</strong> Michael is always on the move, full of energy and enthusiasm.</li>
    <li><strong>Routine-Oriented:</strong> He finds comfort in familiar routines and can become anxious when they change.</li>
    <li><strong>Sensitive:</strong> Loud noises and bright lights can overwhelm Michael, affecting his behavior.</li>
    <li><strong>Affectionate:</strong> Despite his challenges, Michael is loving and enjoys spending time with his family.</li>
</ul>

<h3>Challenges</h3>
<ul>
    <li>Managing his hyperactivity and impulsivity, especially during medical appointments.</li>
    <li>Coping with the sensory overload that can occur in medical settings.</li>
    <li>Understanding and communicating about his LFS in an age-appropriate manner.</li>
    <li>Balancing his need for routine with the demands of regular medical check-ups and potential treatments.</li>
</ul>

<h3>Goals</h3>
<ul>
    <li>To improve his ability to sit still during doctor's appointments and medical procedures.</li>
    <li>To learn more about his condition in a way that he can understand and remember.</li>
    <li>To make friends at school who understand his unique challenges.</li>
</ul>

<h3>Typical Day</h3>
<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>
"""

sarah_quiet_observer_html = """
<h2>Sarah - The Quiet Observer</h2>
<p><span class="tag">Age: 15</span> <span class="tag">Occupation: Student</span> <span class="tag">LFS Diagnosis: Age 10</span></p>

<h3>Background</h3>
<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>

<h3>Personality Traits</h3>
<ul>
    <li><strong>Shy and Observant:</strong> Sarah is quiet in social situations and often avoids eye contact.</li>
    <li><strong>Academically Uneven:</strong> She excels in math but struggles with abstract language concepts.</li>
    <li><strong>Routine-Oriented:</strong> Sarah finds comfort in familiar routines and can become anxious when they change.</li>
    <li><strong>Sensitive:</strong> She has sensory sensitivities, particularly to certain textures.</li>
</ul>

<h3>Challenges</h3>
<ul>
    <li>Managing social anxiety, especially in group settings or unfamiliar situations.</li>
    <li>Coping with the stress of regular medical check-ups and potential treatments.</li>
    <li>Balancing her need for routine with the demands of her LFS management.</li>
    <li>Communicating her needs and feelings effectively, particularly in medical settings.</li>
</ul>

<h3>Goals</h3>
<ul>
    <li>To improve her social skills and feel more comfortable in group situations.</li>
    <li>To better understand and explain her LFS to others when necessary.</li>
    <li>To develop coping strategies for managing anxiety related to her condition and medical procedures.</li>
    <li>To pursue her interest in mathematics while working on improving her language skills.</li>
</ul>

<h3>Typical Day</h3>
<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>
"""


alex_html = """
<h2>Alex</h2>
<p><span class="tag">Age: 12</span> <span class="tag">Occupation: Student</span> <span class="tag">LFS Diagnosis: Age 6</span></p>

<h3>Background</h3>
<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>

<h3>Personality Traits</h3>
<ul>
    <li><strong>Pattern Enthusiast:</strong> Alex has a strong interest in patterns and can spend hours arranging objects.</li>
    <li><strong>Routine-Oriented:</strong> He finds comfort in predictable routines and familiar objects.</li>
    <li><strong>Sensitive:</strong> Busy environments can lead to sensory overload for Alex.</li>
    <li><strong>Expressive in His Own Way:</strong> Despite limited verbal communication, Alex expresses himself through gestures and simple phrases.</li>
</ul>

<h3>Challenges</h3>
<ul>
    <li>Managing multiple medical conditions, including LFS, FXS, and ASD.</li>
    <li>Coping with changes in routine, especially related to medical appointments and procedures.</li>
    <li>Communicating his needs and experiences effectively to healthcare providers.</li>
    <li>Navigating social interactions in medical settings and everyday life.</li>
</ul>

<h3>Goals</h3>
<ul>
    <li>To develop more effective ways of communicating his needs and feelings.</li>
    <li>To learn coping strategies for dealing with changes in routine, particularly related to medical care.</li>
    <li>To continue exploring his interest in patterns in safe and constructive ways.</li>
</ul>

<h3>Typical Day</h3>
<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>
"""


emily2_html = """
<h2>Emily - The Determined Learner</h2>
<p><span class="tag">Age: 18</span> <span class="tag">Occupation: Student</span> <span class="tag">LFS Diagnosis: Age 10</span></p>

<h3>Background</h3>
<p>Emily is an 18-year-old girl diagnosed with Li-Fraumeni syndrome at age 10. She has borderline intellectual functioning (IQ 75) and is currently transitioning from high school to a vocational program. Emily lives with her parents, who provide support for her medical needs and daily challenges.</p>

<h3>Personality Traits</h3>
<ul>
    <li><strong>Determined:</strong> Despite her challenges, Emily is motivated to learn and improve her skills.</li>
    <li><strong>Anxious:</strong> She experiences anxiety, particularly in new situations or when facing medical procedures.</li>
    <li><strong>Socially Motivated:</strong> Emily enjoys social interactions but sometimes struggles with understanding social cues.</li>
    <li><strong>Detail-Oriented:</strong> She exhibits some obsessive-compulsive traits, like checking locks repeatedly.</li>
</ul>

<h3>Challenges</h3>
<ul>
    <li>Managing anxiety related to her health condition and new life transitions.</li>
    <li>Struggling with executive functioning tasks like planning and organizing.</li>
    <li>Dealing with frustration when faced with criticism or difficult tasks.</li>
    <li>Balancing her medical needs with her desire for independence as a young adult.</li>
</ul>

<h3>Goals</h3>
<ul>
    <li>To successfully transition into her vocational program and gain job skills.</li>
    <li>To improve her ability to manage anxiety and cope with health-related stress.</li>
    <li>To develop better executive functioning skills for increased independence.</li>
    <li>To maintain her health while pursuing her personal and professional aspirations.</li>
</ul>

<h3>Typical Day</h3>
<p>Emily's day begins with a structured morning routine to help her prepare for her vocational program. She attends classes focused on practical job skills, where she excels in tasks involving reading but may need extra support with math-related activities. After her program, she often has therapy sessions to work on her anxiety management and social skills. In the evenings, she enjoys reading or watching documentaries, sometimes getting absorbed in topics that interest her. She helps with household chores, which her parents use as opportunities to teach her planning and organizing skills. Throughout her week, Emily has regular check-ups and screenings related to her LFS, which she approaches with a mix of determination and anxiety.</p>
"""


# CSS styles
css = """
<style>
    body {
        font-family: Arial, sans-serif;
        line-height: 1.6;
        color: #333;
    }
    h2 {
        color: #2980b9;
    }
    .profile-img {
        width: 200px;
        height: 200px;
        border-radius: 50%;
        object-fit: cover;
        float: right;
        margin: 0 0 20px 20px;
    }
    .tag {
        background-color: lightgrey;
        color: white;
        padding: 5px 10px;
        border-radius: 20px;
        font-size: 0.8em;
        margin-right: 5px;
    }
</style>
"""


def chat(message, history, persona):
    prompt = ""
    if persona == "Sarah":
        prompt = sarah_full_prompt
    elif persona == "Carlos":
        prompt = carlos_full_prompt
    elif persona == "Emily":
        prompt = emily_full_prompt
    elif persona == "Michael":
        prompt = michael_full_prompt
    elif persona == "Sarah2":
        prompt = sarah_quiet_observer_full_prompt
    elif persona == "Alex":
        prompt = alex_full_prompt
    elif persona == "Emily2":
        prompt = emily2_full_prompt

    # Include the chat history in the prompt
    chat_history = "\n".join(
        [f"User: {user}\n{persona}: {bot}" for user, bot in history]
    )
    full_prompt = f"{prompt}\n\n{chat_history}\nUser: {message}\n{persona}:"

    response = model.generate_content(full_prompt)

    # Append the new message and response to the history
    history.append((message, response.text))

    return history


# Gradio interface
with gr.Blocks() as demo:
    gr.Markdown("# LFS Patient Personas Chat")

    with gr.Row():
        with gr.Column(scale=1):
            persona = gr.Radio(
                [
                    "Sarah",
                    "Carlos",
                    "Emily",
                    "Michael",
                    "Sarah2",
                    "Alex",
                    "Emily2",
                ],
                label="Select Persona",
                value="Sarah",
            )
            persona_info = gr.HTML(value=css + sarah_html)  # Set initial value

        with gr.Column(scale=2):
            chatbot = gr.Chatbot()
            msg = gr.Textbox(show_label=False, placeholder="Type your message here...")
            with gr.Row():
                send_btn = gr.Button("Send")
                clear = gr.Button("Clear Chat")

    def update_persona_info(persona):
        if persona == "Sarah":
            return css + sarah_html
        elif persona == "Carlos":
            return css + carlos_html
        elif persona == "Emily":
            return css + emily_html
        elif persona == "Michael":
            return css + michael_html
        elif persona == "Sarah2":
            return css + sarah_quiet_observer_html
        elif persona == "Alex":
            return css + alex_html
        elif persona == "Emily2":
            return css + emily2_html

    def user_message(message, history, persona):
        return "", chat(message, history, persona)

    persona.change(update_persona_info, persona, persona_info)
    msg.submit(user_message, [msg, chatbot, persona], [msg, chatbot])
    send_btn.click(user_message, [msg, chatbot, persona], [msg, chatbot])
    clear.click(lambda: (None, None), None, [chatbot, msg], queue=False)

demo.launch()