Commit
·
3c4f305
1
Parent(s):
7b888fe
Improve RAG init & docs new3
Browse files- backend/main.py +11 -2
backend/main.py
CHANGED
|
@@ -64,8 +64,17 @@ def initialize_rag_system():
|
|
| 64 |
print(f"[RAG Init] ✓ Processed and indexed {num_docs} documents")
|
| 65 |
rag_ready = True
|
| 66 |
elif processed_json.exists():
|
| 67 |
-
print("[RAG Init] processed_documents.json found.
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
else:
|
| 70 |
print("[RAG Init] No PDFs or processed_documents.json found. RAG remains uninitialized.")
|
| 71 |
rag_ready = False
|
|
|
|
| 64 |
print(f"[RAG Init] ✓ Processed and indexed {num_docs} documents")
|
| 65 |
rag_ready = True
|
| 66 |
elif processed_json.exists():
|
| 67 |
+
print("[RAG Init] processed_documents.json found. Building vectorstore from existing summaries...")
|
| 68 |
+
# Call process_and_index_documents even without PDFs to build vectorstore from JSON
|
| 69 |
+
# The method will detect no new PDFs and build from existing processed_documents.json
|
| 70 |
+
docs_path = str(docs_folder) if docs_folder.exists() else "documents"
|
| 71 |
+
num_docs = rag_system.process_and_index_documents(docs_path)
|
| 72 |
+
if rag_system.vectorstore is not None:
|
| 73 |
+
print(f"[RAG Init] ✓ Built vectorstore from processed_documents.json")
|
| 74 |
+
rag_ready = True
|
| 75 |
+
else:
|
| 76 |
+
print("[RAG Init] Warning: Could not build vectorstore from processed_documents.json")
|
| 77 |
+
rag_ready = False
|
| 78 |
else:
|
| 79 |
print("[RAG Init] No PDFs or processed_documents.json found. RAG remains uninitialized.")
|
| 80 |
rag_ready = False
|