KeenWoo commited on
Commit
a85ae32
·
verified ·
1 Parent(s): 89e5800

Update alz_companion/agent.py

Browse files
Files changed (1) hide show
  1. alz_companion/agent.py +20 -6
alz_companion/agent.py CHANGED
@@ -810,10 +810,24 @@ def make_rag_chain(vs_general: FAISS, vs_personal: FAISS, *, for_evaluation: boo
810
  print("[DEBUG] Personal Route Factual / Sum / Multi PROMPT")
811
  else: # caregiving_scenario
812
 
813
- if disease_stage == "Advanced Stage": template = ANSWER_TEMPLATE_ADQ_ADVANCED
814
- elif disease_stage == "Moderate Stage": template = ANSWER_TEMPLATE_ADQ_MODERATE
815
- else: template = ANSWER_TEMPLATE_ADQ
816
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
817
  # template = ANSWER_TEMPLATE_ADQ
818
  # NEXT evolution
819
  # if settings.get("role") == "patient":
@@ -822,11 +836,11 @@ def make_rag_chain(vs_general: FAISS, vs_personal: FAISS, *, for_evaluation: boo
822
  # else :
823
  # template = ANSWER_TEMPLATE_ADQ
824
  # print("[DEBUG] Use ANSWER_TEMPLATE_ADQ")
825
-
826
- emotions_context = render_emotion_guidelines(kwargs.get("emotion_tag"))
827
  # NEXT evolution
828
  # if emotion in ["confusion", "sadness", "anxiety", "orientation_check"]:
829
  # template = ANSWER_TEMPLATE_CALM
 
830
  user_prompt = template.format(general_context=general_context, personal_context=personal_context, question=query, scenario_tag=kwargs.get("scenario_tag"), emotions_context=emotions_context, role=role, language=language, patient_name=p_name, caregiver_name=c_name, emotion_tag=kwargs.get("emotion_tag"))
831
  print("[DEBUG] Caregiving Scenario PROMPT")
832
  # end
 
810
  print("[DEBUG] Personal Route Factual / Sum / Multi PROMPT")
811
  else: # caregiving_scenario
812
 
813
+ #if disease_stage == "Advanced Stage": template = ANSWER_TEMPLATE_ADQ_ADVANCED
814
+ #elif disease_stage == "Moderate Stage": template = ANSWER_TEMPLATE_ADQ_MODERATE
815
+ #else: template = ANSWER_TEMPLATE_ADQ
816
+
817
+ # NEW --- START: REVISED LOGIC ---
818
+ # Select the template based on the user's role.
819
+ if role == "patient":
820
+ # Use the appropriate patient template based on disease stage
821
+ if disease_stage == "Advanced Stage": template = ANSWER_TEMPLATE_PATIENT_ADVANCED
822
+ elif disease_stage == "Moderate Stage": template = ANSWER_TEMPLATE_PATIENT_MODERATE
823
+ else: template = ANSWER_TEMPLATE_PATIENT
824
+ print("[DEBUG] Using PATIENT response template.")
825
+ else: # role == "caregiver"
826
+ # Use the single, clear caregiver template based original ADQ
827
+ template = ANSWER_TEMPLATE_CAREGIVER
828
+ print("[DEBUG] Using CAREGIVER response template.")
829
+ # --- END: REVISED LOGIC ---
830
+
831
  # template = ANSWER_TEMPLATE_ADQ
832
  # NEXT evolution
833
  # if settings.get("role") == "patient":
 
836
  # else :
837
  # template = ANSWER_TEMPLATE_ADQ
838
  # print("[DEBUG] Use ANSWER_TEMPLATE_ADQ")
839
+
 
840
  # NEXT evolution
841
  # if emotion in ["confusion", "sadness", "anxiety", "orientation_check"]:
842
  # template = ANSWER_TEMPLATE_CALM
843
+ emotions_context = render_emotion_guidelines(kwargs.get("emotion_tag"))
844
  user_prompt = template.format(general_context=general_context, personal_context=personal_context, question=query, scenario_tag=kwargs.get("scenario_tag"), emotions_context=emotions_context, role=role, language=language, patient_name=p_name, caregiver_name=c_name, emotion_tag=kwargs.get("emotion_tag"))
845
  print("[DEBUG] Caregiving Scenario PROMPT")
846
  # end