KeenWoo commited on
Commit
fcc6c2e
·
verified ·
1 Parent(s): 8ec6b4d

Update alz_companion/prompts.py

Browse files
Files changed (1) hide show
  1. 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 with Example:** Next, provide helpful context by briefly referencing a specific, illustrative example from the 'General Guidance' section to show the user this is a known situation (e.g., "This is a common experience; in one story, a character named Anthony often hid his watch when he felt confused.").
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
- # --- MODIFICATION START ---
396
- --- CRITICAL INSTRUCTIONS ---
397
- 1. Your ONLY task is to summarize the 'Source excerpts' to directly answer the 'User's Request'.
398
- 2. **You MUST NOT add any facts or details that are not in the 'Source excerpts'.**
399
- 3. **CRITICAL:** If the user asks for a summary of a specific time period (e.g., "yesterday", "last three days") or a specific topic (e.g., "daily routine", "word-finding difficulties"), you MUST filter the context and summarize ONLY the information relevant to that specific request.
400
- 4. **DO NOT provide a general character summary of the person's entire life unless that is what was explicitly asked for.**
401
- ---
402
- # --- END OF MODIFICATION ---
403
 
404
  **Formatting and Content Rules:**
405
- 1. Your final summary MUST be in {language}.
406
- 2. Write a succinct summary that is tailored to the user's request, addressing the user by their role. For example, "Of course, {caregiver_name}, here is a summary about {patient_name}..."
407
- 3. The summary should be 5–7 sentences or up to ~120 words.
408
- 4. Preserve key people, places, and timelines from the source excerpts.
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}