Spaces:
Sleeping
Sleeping
Update alz_companion/prompts.py
Browse files- alz_companion/prompts.py +25 -20
alz_companion/prompts.py
CHANGED
|
@@ -252,6 +252,7 @@ You MUST base your answer ONLY on the information provided in the 'Context' abov
|
|
| 252 |
"""
|
| 253 |
|
| 254 |
|
|
|
|
| 255 |
ANSWER_TEMPLATE_ADQ = """--- General Guidance from Knowledge Base ---
|
| 256 |
{general_context}
|
| 257 |
|
|
@@ -277,15 +278,15 @@ Your response MUST be based ONLY on the information in the 'General Guidance' an
|
|
| 277 |
---
|
| 278 |
**Final Answer Rules:**
|
| 279 |
1. Your final answer MUST be in {language}.
|
| 280 |
-
2. Adopt the **concise, warm, and validating** tone described in the 'Response Tone Guidelines'.
|
| 281 |
-
3. The response must be a single, natural-sounding paragraph between 2 and
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
"""
|
| 290 |
|
| 291 |
|
|
@@ -376,9 +377,12 @@ User Message: "{question}"
|
|
| 376 |
- Do not add any special formatting or headings.
|
| 377 |
"""
|
| 378 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
|
| 380 |
-
|
| 381 |
-
ANSWER_TEMPLATE_SUMMARIZE = """Source excerpts:
|
| 382 |
{context}
|
| 383 |
|
| 384 |
---
|
|
@@ -387,17 +391,18 @@ User's Request: {question}
|
|
| 387 |
---
|
| 388 |
INSTRUCTIONS FOR THE AI:
|
| 389 |
--- CRITICAL COMMAND ---
|
| 390 |
-
Your ONLY task is to
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
3. **HALLUCINATION GUARD:** You are forbidden from including any information not present in the filtered source excerpts. DO NOT provide a general summary of the person's entire life unless explicitly asked.
|
| 395 |
|
| 396 |
-
**
|
| 397 |
-
- Your final summary MUST be in {language}.
|
| 398 |
-
- Address the user by their role (e.g., "{patient_name}" or "{caregiver_name}").
|
| 399 |
-
- If the context contains no information relevant to the specific request, you MUST state that you could not find any relevant memories.
|
| 400 |
-
- Output ONLY the summary itself.
|
| 401 |
"""
|
| 402 |
|
| 403 |
|
|
|
|
| 252 |
"""
|
| 253 |
|
| 254 |
|
| 255 |
+
# In prompts.py, replace the old ANSWER_TEMPLATE_ADQ with this revised version:
|
| 256 |
ANSWER_TEMPLATE_ADQ = """--- General Guidance from Knowledge Base ---
|
| 257 |
{general_context}
|
| 258 |
|
|
|
|
| 278 |
---
|
| 279 |
**Final Answer Rules:**
|
| 280 |
1. Your final answer MUST be in {language}.
|
| 281 |
+
2. Adopt the **concise, warm, and validating** tone described in the 'Response Tone Guidelines'.
|
| 282 |
+
3. The response must be a single, natural-sounding paragraph between 2 and 5 sentences.
|
| 283 |
+
4. Follow this three-part structure for the paragraph:
|
| 284 |
+
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...").
|
| 285 |
+
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.
|
| 286 |
+
C. **Provide Actionable Steps:** Offer 1-2 clear, practical steps from the context that the user can take. Personalize the advice with details from 'Relevant Personal Memories' if possible.
|
| 287 |
+
|
| 288 |
+
5. **CRITICAL STYLE CONSTRAINT:** AVOID the rigid formula "This is a common experience; in one story...". The goal is to provide natural, direct advice, not to force a storytelling format.
|
| 289 |
+
6. Address the user directly. Do not include any preambles, headings, or labels.
|
| 290 |
"""
|
| 291 |
|
| 292 |
|
|
|
|
| 377 |
- Do not add any special formatting or headings.
|
| 378 |
"""
|
| 379 |
|
| 380 |
+
# In prompts.py, replace the old ANSWER_TEMPLATE_SUMMARIZE with this stricter version:
|
| 381 |
+
|
| 382 |
+
ANSWER_TEMPLATE_SUMMARIZE = """# NOTE TO DEVELOPER: The effectiveness of this prompt is CRITICALLY dependent on the accuracy of the 'Source excerpts' provided.
|
| 383 |
+
# The upstream retrieval process must supply the correct documents for this prompt to succeed.
|
| 384 |
|
| 385 |
+
Source excerpts:
|
|
|
|
| 386 |
{context}
|
| 387 |
|
| 388 |
---
|
|
|
|
| 391 |
---
|
| 392 |
INSTRUCTIONS FOR THE AI:
|
| 393 |
--- CRITICAL COMMAND ---
|
| 394 |
+
Your ONLY task is to create a concise summary that directly and exclusively answers the 'User's Request' using ONLY the provided 'Source excerpts'. Follow these steps precisely:
|
| 395 |
+
|
| 396 |
+
1. **Identify Core Constraints:** First, analyze the 'User's Request' to identify all specific constraints. This includes topics (e.g., "word-finding difficulties"), timeframes (e.g., "yesterday," "last three days"), or people (e.g., "my wife's routine").
|
| 397 |
+
|
| 398 |
+
2. **Filter Context Rigorously:** You MUST filter the 'Source excerpts' and use ONLY the information that strictly matches ALL identified constraints. Discard any and all irrelevant information.
|
| 399 |
+
|
| 400 |
+
3. **Synthesize the Answer:** Construct a brief, natural-sounding summary using ONLY the filtered information. Address the user directly.
|
| 401 |
|
| 402 |
+
4. **Handle Insufficient Data:** If, after filtering, no relevant information remains in the 'Source excerpts' to fulfill the request, you MUST respond with a gentle, helpful message stating that you could not find the specific information.
|
| 403 |
+
- Example: "I looked through the journal, but I couldn't find any notes about that specific topic. Would you like me to search for something else?"
|
|
|
|
| 404 |
|
| 405 |
+
5. **Strict Prohibition on Hallucination:** Under no circumstances are you to add, invent, or infer any information not explicitly present in the provided 'Source excerpts'. Your task is to summarize, not to create.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
"""
|
| 407 |
|
| 408 |
|