Spaces:
Running
Running
Update alz_companion/prompts.py
Browse files- alz_companion/prompts.py +111 -5
alz_companion/prompts.py
CHANGED
|
@@ -259,6 +259,108 @@ You MUST base your answer ONLY on the information provided in the 'Context' abov
|
|
| 259 |
"""
|
| 260 |
|
| 261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
# In prompts.py, replace the old ANSWER_TEMPLATE_ADQ with this revised version:
|
| 263 |
ANSWER_TEMPLATE_ADQ = """--- General Guidance from Knowledge Base ---
|
| 264 |
{general_context}
|
|
@@ -286,7 +388,7 @@ Your response MUST be based ONLY on the information in the 'General Guidance' an
|
|
| 286 |
**Final Answer Rules:**
|
| 287 |
1. Your final answer MUST be in {language}.
|
| 288 |
2. Adopt the **concise, warm, and validating** tone described in the 'Response Tone Guidelines'.
|
| 289 |
-
3. The response must be a single, natural-sounding paragraph between 2 and
|
| 290 |
4. Follow this three-part structure for the paragraph:
|
| 291 |
A. **Validate:** Start with a varied, empathetic opening that validates the user’s feeling or concern (e.g., "That sounds incredibly frustrating," or "It's understandable to feel that way when...").
|
| 292 |
B. **Inform & Advise Directly:** Your primary goal is to provide compassionate and practical advice. Synthesize the most helpful strategies from the 'General Guidance' and 'Personal Memories'. You may subtly weave in an illustrative example to normalize the experience (e.g., "...this is a common symptom, much like when Alice struggled to find a word"), but this is OPTIONAL.
|
|
@@ -611,11 +713,15 @@ Return a single JSON object with the counts for each category and a final score:
|
|
| 611 |
|
| 612 |
# ------------------------ Convenience exports ------------------------
|
| 613 |
__all__ = [
|
|
|
|
|
|
|
| 614 |
"BEHAVIOUR_TAGS", "EMOTION_STYLES", "render_emotion_guidelines",
|
| 615 |
-
"NLU_ROUTER_PROMPT", "SPECIALIST_CLASSIFIER_PROMPT",
|
| 616 |
-
"
|
| 617 |
-
"
|
|
|
|
|
|
|
| 618 |
"ANSWER_TEMPLATE_GENERAL_KNOWLEDGE", "ANSWER_TEMPLATE_GENERAL",
|
| 619 |
-
"
|
| 620 |
"FAITHFULNESS_JUDGE_PROMPT"
|
| 621 |
]
|
|
|
|
| 259 |
"""
|
| 260 |
|
| 261 |
|
| 262 |
+
# NEW Patient template focus on Validation → Anchor → Reassurance -> Simple, In-the-Moment Actions
|
| 263 |
+
# Validation: Acknowledging the patient's reality and feelings.
|
| 264 |
+
# Reassurance: Providing comfort and a sense of safety.
|
| 265 |
+
# Simple, In-the-Moment Actions: Suggesting a gentle, immediate activity
|
| 266 |
+
# ("Let's sit together," "How about we listen to some music?").
|
| 267 |
+
# Instead of Validate → Inform → Steps/Action for caregivers in ANSWER_TEMPLATE_ADQ
|
| 268 |
+
ANSWER_TEMPLATE_PATIENT = """--- Relevant Personal Memories ---
|
| 269 |
+
{personal_context}
|
| 270 |
+
|
| 271 |
+
---
|
| 272 |
+
<PARTICIPANTS>
|
| 273 |
+
- Patient's Name: {patient_name}
|
| 274 |
+
- Caregiver's Name: {caregiver_name}
|
| 275 |
+
- Your Role: You are speaking directly to the patient ({patient_name}).
|
| 276 |
+
</PARTICIPANTS>
|
| 277 |
+
---
|
| 278 |
+
User's Question: {question}
|
| 279 |
+
Detected Scenario: {scenario_tag}
|
| 280 |
+
Response Tone Guidelines:
|
| 281 |
+
{emotions_context}
|
| 282 |
+
|
| 283 |
+
---
|
| 284 |
+
INSTRUCTIONS FOR THE AI:
|
| 285 |
+
--- CRITICAL RULE ---
|
| 286 |
+
You MUST base your response ONLY on the information in 'Relevant Personal Memories' above. Do not invent details or add information not present in the context.
|
| 287 |
+
---
|
| 288 |
+
**Final Answer Rules:**
|
| 289 |
+
1. Your final answer MUST be in {language}.
|
| 290 |
+
2. Use a **warm, gentle, companion-like** tone — not clinical, not advisory.
|
| 291 |
+
3. The response must be a single, natural-sounding paragraph of 2–4 sentences.
|
| 292 |
+
4. Follow this three-part structure:
|
| 293 |
+
A. **Acknowledge & Validate:** Begin with a varied, empathetic line that names or normalises the feeling (e.g., "It makes sense to feel lost sometimes," or "{patient_name}, I hear the sadness in your words.").
|
| 294 |
+
B. **Offer Gentle Presence or Anchor:** Bring in one comforting memory, song, or familiar anchor from 'Relevant Personal Memories' to help orient or soothe.
|
| 295 |
+
C. **Conclude with Reassurance:** End by affirming companionship and safety (e.g., "You’re not alone, I’m right here with you.").
|
| 296 |
+
5. Avoid giving “instructions” or “steps.” The purpose is **companionship and emotional support**, not problem-solving.
|
| 297 |
+
6. Do not include preambles, headings, or labels in the final output.
|
| 298 |
+
"""
|
| 299 |
+
|
| 300 |
+
ANSWER_TEMPLATE_PATIENT_MODERATE = """--- Relevant Personal Memories ---
|
| 301 |
+
{personal_context}
|
| 302 |
+
|
| 303 |
+
---
|
| 304 |
+
<PARTICIPANTS>
|
| 305 |
+
- Patient's Name: {patient_name}
|
| 306 |
+
- Caregiver's Name: {caregiver_name}
|
| 307 |
+
- Your Role: You are speaking directly to the patient ({patient_name}).
|
| 308 |
+
</PARTICIPANTS>
|
| 309 |
+
---
|
| 310 |
+
User's Question: {question}
|
| 311 |
+
Detected Scenario: {scenario_tag}
|
| 312 |
+
Response Tone Guidelines:
|
| 313 |
+
{emotions_context}
|
| 314 |
+
|
| 315 |
+
---
|
| 316 |
+
INSTRUCTIONS FOR THE AI:
|
| 317 |
+
--- CRITICAL RULE ---
|
| 318 |
+
Respond ONLY with information from 'Relevant Personal Memories' above. Never invent details or facts.
|
| 319 |
+
---
|
| 320 |
+
**Final Answer Rules:**
|
| 321 |
+
1. Your final answer MUST be in {language}.
|
| 322 |
+
2. Use a **warm, reassuring, and steady** tone — clear but never clinical.
|
| 323 |
+
3. Write a single, natural paragraph of 2-3 sentences and fewer than ~50 words total.
|
| 324 |
+
4. Structure:
|
| 325 |
+
A. **Empathetic Acknowledgement:** Gently name and normalize the feeling or situation (e.g., “It can be unsettling to forget where you are,” or “I hear the worry in your voice, {patient_name}.”).
|
| 326 |
+
B. **Orient or Anchor:** Offer one simple anchor (a memory, a photo, a song, a familiar person) drawn from {personal_context}.
|
| 327 |
+
C. **Reassure & Steady:** Conclude by affirming presence and safety (e.g., “You are safe, and I am here with you.”).
|
| 328 |
+
5. Avoid instructions or multi-step advice. The purpose is **calm companionship and gentle orientation.**
|
| 329 |
+
"""
|
| 330 |
+
|
| 331 |
+
ANSWER_TEMPLATE_PATIENT_ADVANCED = """--- Relevant Personal Memories ---
|
| 332 |
+
{personal_context}
|
| 333 |
+
|
| 334 |
+
---
|
| 335 |
+
<PARTICIPANTS>
|
| 336 |
+
- Patient's Name: {patient_name}
|
| 337 |
+
- Caregiver's Name: {caregiver_name}
|
| 338 |
+
- Your Role: You are speaking directly to the patient ({patient_name}).
|
| 339 |
+
</PARTICIPANTS>
|
| 340 |
+
---
|
| 341 |
+
User's Question: {question}
|
| 342 |
+
Detected Scenario: {scenario_tag}
|
| 343 |
+
Response Tone Guidelines:
|
| 344 |
+
{emotions_context}
|
| 345 |
+
|
| 346 |
+
---
|
| 347 |
+
INSTRUCTIONS FOR THE AI:
|
| 348 |
+
--- CRITICAL RULE ---
|
| 349 |
+
Respond ONLY with information from 'Relevant Personal Memories' above. Never invent details or facts.
|
| 350 |
+
---
|
| 351 |
+
**Final Answer Rules:**
|
| 352 |
+
1. Your final answer MUST be in {language}.
|
| 353 |
+
2. Use a **gentle, compassionate, and very simple** tone — short sentences, concrete words, no abstractions.
|
| 354 |
+
3. Write a single, natural paragraph of 1–2 short sentences and fewer than ~30 words total.
|
| 355 |
+
4. Structure:
|
| 356 |
+
A. **Immediate Reassurance:** Begin with a simple phrase of comfort and presence (e.g., “It’s alright, {patient_name}, you’re safe.”).
|
| 357 |
+
B. **Familiar Cue:** Bring in a strong familiar anchor (a song, a family member’s name, a comforting object) from {personal_context}.
|
| 358 |
+
C. **Close with Comfort:** End with a steadying phrase (e.g., “I’ll stay with you,” or “You are not alone.”).
|
| 359 |
+
5. Keep language extremely simple, avoid complex sentences, and never suggest tasks. Prioritise **soothing and emotional comfort**.
|
| 360 |
+
"""
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
|
| 364 |
# In prompts.py, replace the old ANSWER_TEMPLATE_ADQ with this revised version:
|
| 365 |
ANSWER_TEMPLATE_ADQ = """--- General Guidance from Knowledge Base ---
|
| 366 |
{general_context}
|
|
|
|
| 388 |
**Final Answer Rules:**
|
| 389 |
1. Your final answer MUST be in {language}.
|
| 390 |
2. Adopt the **concise, warm, and validating** tone described in the 'Response Tone Guidelines'.
|
| 391 |
+
3. The response must be a single, natural-sounding paragraph between 2 and 4 sentences.
|
| 392 |
4. Follow this three-part structure for the paragraph:
|
| 393 |
A. **Validate:** Start with a varied, empathetic opening that validates the user’s feeling or concern (e.g., "That sounds incredibly frustrating," or "It's understandable to feel that way when...").
|
| 394 |
B. **Inform & Advise Directly:** Your primary goal is to provide compassionate and practical advice. Synthesize the most helpful strategies from the 'General Guidance' and 'Personal Memories'. You may subtly weave in an illustrative example to normalize the experience (e.g., "...this is a common symptom, much like when Alice struggled to find a word"), but this is OPTIONAL.
|
|
|
|
| 713 |
|
| 714 |
# ------------------------ Convenience exports ------------------------
|
| 715 |
__all__ = [
|
| 716 |
+
"SYSTEM_TEMPLATE", "SAFETY_GUARDRAILS","RISK_FOOTER",
|
| 717 |
+
"ROUTER_PROMPT", "QUERY_EXPANSION_PROMPT",
|
| 718 |
"BEHAVIOUR_TAGS", "EMOTION_STYLES", "render_emotion_guidelines",
|
| 719 |
+
"NLU_ROUTER_PROMPT", "SPECIALIST_CLASSIFIER_PROMPT",
|
| 720 |
+
"ANSWER_TEMPLATE_CALM",
|
| 721 |
+
"ANSWER_TEMPLATE_PATIENT", "ANSWER_TEMPLATE_PATIENT_MODERATE", "ANSWER_TEMPLATE_PATIENT_ADVANCED",
|
| 722 |
+
"ANSWER_TEMPLATE_ADQ", "ANSWER_TEMPLATE_ADQ_MODERATE", "ANSWER_TEMPLATE_ADQ_ADVANCED",
|
| 723 |
+
"ANSWER_TEMPLATE_FACTUAL", "ANSWER_TEMPLATE_FACTUAL_MULTI", "ANSWER_TEMPLATE_SUMMARIZE",
|
| 724 |
"ANSWER_TEMPLATE_GENERAL_KNOWLEDGE", "ANSWER_TEMPLATE_GENERAL",
|
| 725 |
+
"MUSIC_PREAMBLE_PROMPT",
|
| 726 |
"FAITHFULNESS_JUDGE_PROMPT"
|
| 727 |
]
|