Spaces:
Sleeping
Sleeping
Update alz_companion/prompts.py
Browse files- alz_companion/prompts.py +13 -23
alz_companion/prompts.py
CHANGED
|
@@ -282,7 +282,7 @@ Your response MUST be based ONLY on the information in the 'General Guidance' an
|
|
| 282 |
# --- MODIFICATION START ---
|
| 283 |
4. Follow this explicit three-part structure for the paragraph:
|
| 284 |
A. **Validate:** Start with a varied, empathetic opening that validates the user’s feeling or concern.
|
| 285 |
-
B. **Inform
|
| 286 |
C. **Advise:** Finally, offer 1-2 clear, practical steps from the context that the caregiver can take. If possible, weave in details from 'Relevant Personal Memories' to personalize the advice.
|
| 287 |
# --- END OF MODIFICATION ---
|
| 288 |
5. **CRITICAL:** Do not include any preambles, headings, or labels like "My response is...". Address the user directly and naturally.
|
|
@@ -376,42 +376,32 @@ User Message: "{question}"
|
|
| 376 |
- Do not add any special formatting or headings.
|
| 377 |
"""
|
| 378 |
|
| 379 |
-
# In prompts.py, find and REPLACE ANSWER_TEMPLATE_SUMMARIZE
|
| 380 |
|
|
|
|
| 381 |
ANSWER_TEMPLATE_SUMMARIZE = """Source excerpts:
|
| 382 |
{context}
|
| 383 |
|
| 384 |
-
---
|
| 385 |
-
<PARTICIPANTS>
|
| 386 |
-
- Patient's Name: {patient_name}
|
| 387 |
-
- Caregiver's Name: {caregiver_name}
|
| 388 |
-
- Your Role: You are creating this summary for the {role}.
|
| 389 |
-
</PARTICIPANTS>
|
| 390 |
---
|
| 391 |
User's Request: {question}
|
| 392 |
|
| 393 |
---
|
| 394 |
INSTRUCTIONS FOR THE AI:
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
---
|
| 402 |
-
# --- END OF MODIFICATION ---
|
| 403 |
|
| 404 |
**Formatting and Content Rules:**
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
5. If the user's request asks for bullet points, use them; otherwise, use a paragraph.
|
| 410 |
-
6. If the context is empty or irrelevant to the request, state that you could not find information to summarize.
|
| 411 |
-
7. **CRITICAL:** Do not add any headings, introductions, or concluding remarks. Output only the summary itself.
|
| 412 |
"""
|
| 413 |
|
| 414 |
|
|
|
|
| 415 |
# --- PRESERVED: The working multi-hop prompt from prompts_work.py ---
|
| 416 |
ANSWER_TEMPLATE_FACTUAL_MULTI = """Context from various sources:
|
| 417 |
{context}
|
|
|
|
| 282 |
# --- MODIFICATION START ---
|
| 283 |
4. Follow this explicit three-part structure for the paragraph:
|
| 284 |
A. **Validate:** Start with a varied, empathetic opening that validates the user’s feeling or concern.
|
| 285 |
+
B. **Inform & Advise from Example:** Next, you MUST find a specific, illustrative example from the 'General Guidance' section. First, briefly state the example (e.g., "This is a common experience; in one story, a character named Anthony..."). Then, you MUST extract the specific, practical advice or strategy described in that same example and present it as the primary recommendation.
|
| 286 |
C. **Advise:** Finally, offer 1-2 clear, practical steps from the context that the caregiver can take. If possible, weave in details from 'Relevant Personal Memories' to personalize the advice.
|
| 287 |
# --- END OF MODIFICATION ---
|
| 288 |
5. **CRITICAL:** Do not include any preambles, headings, or labels like "My response is...". Address the user directly and naturally.
|
|
|
|
| 376 |
- Do not add any special formatting or headings.
|
| 377 |
"""
|
| 378 |
|
|
|
|
| 379 |
|
| 380 |
+
# In prompts.py, replace the ANSWER_TEMPLATE_SUMMARIZE with this stricter version:
|
| 381 |
ANSWER_TEMPLATE_SUMMARIZE = """Source excerpts:
|
| 382 |
{context}
|
| 383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
---
|
| 385 |
User's Request: {question}
|
| 386 |
|
| 387 |
---
|
| 388 |
INSTRUCTIONS FOR THE AI:
|
| 389 |
+
--- CRITICAL COMMAND ---
|
| 390 |
+
Your ONLY task is to summarize the 'Source excerpts' to directly and ONLY answer the 'User's Request'.
|
| 391 |
+
|
| 392 |
+
1. **FILTER:** First, you MUST analyze the "User's Request" to identify any specific constraints like a time period (e.g., "yesterday", "last three days") or a topic (e.g., "daily routine", "word-finding difficulties").
|
| 393 |
+
2. **EXECUTE:** You MUST then filter the "Source excerpts" and use ONLY the information that directly matches these constraints to build your summary.
|
| 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 |
**Formatting and Content Rules:**
|
| 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 |
|
| 404 |
+
|
| 405 |
# --- PRESERVED: The working multi-hop prompt from prompts_work.py ---
|
| 406 |
ANSWER_TEMPLATE_FACTUAL_MULTI = """Context from various sources:
|
| 407 |
{context}
|