KeenWoo commited on
Commit
c528068
·
verified ·
1 Parent(s): 3e66184

Update alz_companion/agent.py

Browse files
Files changed (1) hide show
  1. alz_companion/agent.py +18 -6
alz_companion/agent.py CHANGED
@@ -661,13 +661,25 @@ def make_rag_chain(vs_general: FAISS, vs_personal: FAISS, *, for_evaluation: boo
661
 
662
  # --- NEW: DEDICATED LOGIC PATHS FOR RETRIEVAL ---
663
  if is_personal_route:
664
-
665
- # For personal queries, semantic search is unreliable. We retrieve ALL personal documents.
666
- print("[DEBUG] Personal Memory Route Activated. Retrieving all personal documents.")
667
- # --- START: FAISS-COMPATIBLE FIX ---
668
  if vs_personal and vs_personal.docstore and len(vs_personal.index_to_docstore_id) > 0:
669
- all_retrieved_docs.extend(list(vs_personal.docstore._dict.values()))
670
- # --- END: FAISS-COMPATIBLE FIX ---
 
 
 
 
 
 
 
 
 
 
 
 
671
 
672
  else:
673
  # For caregiving scenarios, use our powerful Multi-Stage Retrieval algorithm.
 
661
 
662
  # --- NEW: DEDICATED LOGIC PATHS FOR RETRIEVAL ---
663
  if is_personal_route:
664
+ # --- START OF MODIFICATION ---
665
+ # This logic retrieves all documents from the personal FAISS store and then
666
+ # filters them to include ONLY text-based sources, excluding media files.
667
+ print("[DEBUG] Personal Memory Route Activated. Retrieving all personal text documents...")
668
  if vs_personal and vs_personal.docstore and len(vs_personal.index_to_docstore_id) > 0:
669
+ # 1. Get all documents from the FAISS docstore
670
+ all_personal_docs = list(vs_personal.docstore._dict.values())
671
+
672
+ # 2. Filter this list to keep only text-based files
673
+ text_based_docs = []
674
+ text_extensions = ('.txt', '.jsonl') # Define what counts as a text source
675
+ for doc in all_personal_docs:
676
+ source = doc.metadata.get("source", "").lower()
677
+ if source.endswith(text_extensions):
678
+ text_based_docs.append(doc)
679
+
680
+ # 3. Extend the final list with only the filtered, text-based documents
681
+ all_retrieved_docs.extend(text_based_docs)
682
+ # --- END OF MODIFICATION ---
683
 
684
  else:
685
  # For caregiving scenarios, use our powerful Multi-Stage Retrieval algorithm.