Spaces:
Sleeping
Sleeping
Update memory_store.py
Browse files- memory_store.py +6 -2
memory_store.py
CHANGED
|
@@ -24,12 +24,16 @@ model = SentenceTransformer(MODEL_PATH)
|
|
| 24 |
|
| 25 |
# === Load or Initialize FAISS Index ===
|
| 26 |
try:
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
except Exception as e:
|
| 30 |
print(f"⚠️ Failed to load FAISS index: {e}")
|
| 31 |
faiss_index = faiss.IndexFlatL2(EMBED_DIM)
|
| 32 |
print("🆕 Creating new empty FAISS index.")
|
|
|
|
| 33 |
|
| 34 |
# === Load or Init Hash Tracker ===
|
| 35 |
if os.path.exists(HASH_TRACK_FILE):
|
|
|
|
| 24 |
|
| 25 |
# === Load or Initialize FAISS Index ===
|
| 26 |
try:
|
| 27 |
+
if os.path.exists(FAISS_PATH):
|
| 28 |
+
faiss_index = faiss.read_index(FAISS_PATH)
|
| 29 |
+
print("✅ FAISS index loaded from file.")
|
| 30 |
+
else:
|
| 31 |
+
raise FileNotFoundError
|
| 32 |
except Exception as e:
|
| 33 |
print(f"⚠️ Failed to load FAISS index: {e}")
|
| 34 |
faiss_index = faiss.IndexFlatL2(EMBED_DIM)
|
| 35 |
print("🆕 Creating new empty FAISS index.")
|
| 36 |
+
faiss.write_index(faiss_index, FAISS_PATH) # <- this writes a valid index
|
| 37 |
|
| 38 |
# === Load or Init Hash Tracker ===
|
| 39 |
if os.path.exists(HASH_TRACK_FILE):
|