Spaces:
Build error
Build error
Update alz_companion/agent.py
Browse files- 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 |
-
#
|
| 666 |
-
|
| 667 |
-
|
| 668 |
if vs_personal and vs_personal.docstore and len(vs_personal.index_to_docstore_id) > 0:
|
| 669 |
-
|
| 670 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|