Spaces:
Sleeping
Sleeping
Update alz_companion/agent.py
Browse files- alz_companion/agent.py +8 -6
alz_companion/agent.py
CHANGED
|
@@ -705,34 +705,36 @@ def make_rag_chain(vs_general: FAISS, vs_personal: FAISS, *, for_evaluation: boo
|
|
| 705 |
# Implements the simple fallback logic for personal routes.
|
| 706 |
# the logic of it always returns a personal doc unless it's not loaded with personal memory
|
| 707 |
if filtered_personal_docs:
|
|
|
|
| 708 |
all_retrieved_docs = filtered_personal_docs
|
| 709 |
else:
|
|
|
|
| 710 |
all_retrieved_docs = filtered_general_docs
|
| 711 |
# --- END OF MODIFICATION ---
|
| 712 |
else: # caregiving_scenario
|
| 713 |
if disease_stage in ["Moderate Stage", "Advanced Stage"]:
|
| 714 |
# --- STAGE-AWARE LOGIC FOR CAREGIVING SCENARIOS ---
|
| 715 |
if filtered_general_docs:
|
| 716 |
-
print("[DEBUG]
|
| 717 |
all_retrieved_docs = filtered_general_docs
|
| 718 |
elif filtered_personal_docs:
|
| 719 |
-
print("[DEBUG]
|
| 720 |
all_retrieved_docs = filtered_personal_docs
|
| 721 |
else:
|
| 722 |
-
print("[DEBUG]
|
| 723 |
all_retrieved_docs = []
|
| 724 |
# --- END STAGE-AWARE BLOCK ---
|
| 725 |
else:
|
| 726 |
# --- NORMAL ROUTING LOGIC ---
|
| 727 |
# Conditional Blending logic for caregiving remains.
|
| 728 |
if abs(best_personal_score - best_general_score) <= SCORE_MARGIN:
|
| 729 |
-
print("[DEBUG]
|
| 730 |
all_retrieved_docs = list({doc.page_content: doc for doc in filtered_personal_docs + filtered_general_docs}.values())[:4]
|
| 731 |
elif best_personal_score < best_general_score:
|
| 732 |
-
print("[DEBUG]
|
| 733 |
all_retrieved_docs = filtered_personal_docs
|
| 734 |
else:
|
| 735 |
-
print("[DEBUG]
|
| 736 |
all_retrieved_docs = filtered_general_docs
|
| 737 |
|
| 738 |
# --- Prompt Generation and LLM Call ---
|
|
|
|
| 705 |
# Implements the simple fallback logic for personal routes.
|
| 706 |
# the logic of it always returns a personal doc unless it's not loaded with personal memory
|
| 707 |
if filtered_personal_docs:
|
| 708 |
+
print("[DEBUG] Factual/Sum/Multi: Prioritizing personal docs.")
|
| 709 |
all_retrieved_docs = filtered_personal_docs
|
| 710 |
else:
|
| 711 |
+
print("[DEBUG] Factual/Sum/Multi: Prioritizing general docs.")
|
| 712 |
all_retrieved_docs = filtered_general_docs
|
| 713 |
# --- END OF MODIFICATION ---
|
| 714 |
else: # caregiving_scenario
|
| 715 |
if disease_stage in ["Moderate Stage", "Advanced Stage"]:
|
| 716 |
# --- STAGE-AWARE LOGIC FOR CAREGIVING SCENARIOS ---
|
| 717 |
if filtered_general_docs:
|
| 718 |
+
print("[DEBUG] Moderate / Advanced: Prioritizing general documents.")
|
| 719 |
all_retrieved_docs = filtered_general_docs
|
| 720 |
elif filtered_personal_docs:
|
| 721 |
+
print("[DEBUG] Moderate / Advanced: Falling back to personal documents.")
|
| 722 |
all_retrieved_docs = filtered_personal_docs
|
| 723 |
else:
|
| 724 |
+
print("[DEBUG] Moderate / Advanced: No relevant documents found.")
|
| 725 |
all_retrieved_docs = []
|
| 726 |
# --- END STAGE-AWARE BLOCK ---
|
| 727 |
else:
|
| 728 |
# --- NORMAL ROUTING LOGIC ---
|
| 729 |
# Conditional Blending logic for caregiving remains.
|
| 730 |
if abs(best_personal_score - best_general_score) <= SCORE_MARGIN:
|
| 731 |
+
print("[DEBUG] Caregiving Case: Blending personal and general docs (scores are close).")
|
| 732 |
all_retrieved_docs = list({doc.page_content: doc for doc in filtered_personal_docs + filtered_general_docs}.values())[:4]
|
| 733 |
elif best_personal_score < best_general_score:
|
| 734 |
+
print("[DEBUG] Caregiving Case: Prioritizing personal docs (better score).")
|
| 735 |
all_retrieved_docs = filtered_personal_docs
|
| 736 |
else:
|
| 737 |
+
print("[DEBUG] Caregiving Case: Prioritizing general docs (better score).")
|
| 738 |
all_retrieved_docs = filtered_general_docs
|
| 739 |
|
| 740 |
# --- Prompt Generation and LLM Call ---
|