KeenWoo commited on
Commit
980f481
·
verified ·
1 Parent(s): fcc6c2e

Update alz_companion/prompts.py

Browse files
Files changed (1) hide show
  1. 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'. If the Patient's Name is provided, use it to make the opening more personal and direct.
281
- 3. The response must be a single, natural-sounding paragraph between 2 and 4 sentences.
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.
289
  """
290
 
291
 
@@ -376,9 +377,12 @@ User Message: "{question}"
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
  ---
@@ -387,17 +391,18 @@ User's Request: {question}
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
 
 
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