Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Fix inconsistency in Embeddings behavior in Applications, closes #571

davidmezzetti39d2b1e21c0e
diff --git a/src/python/txtai/app/base.py b/src/python/txtai/app/base.py
index e9500e3b..bad3de6c 100644
--- a/src/python/txtai/app/base.py
+++ b/src/python/txtai/app/base.py
@@ -432,7 +432,15 @@ class Application:
if self.embeddings:
with self.lock:
- return self.embeddings.delete(ids)
+ # Run delete operation
+ deleted = self.embeddings.delete(ids)
+
+ # Save index if path available, otherwise this is an memory-only index
+ if self.config.get("path"):
+ self.embeddings.save(self.config["path"], self.config.get("cloud"))
+
+ # Return deleted ids
+ return deleted
return None
@@ -457,6 +465,10 @@ class Application:
# Reindex
self.embeddings.reindex(config, function)
+ # Save index if path available, otherwise this is an memory-only index
+ if self.config.get("path"):
+ self.embeddings.save(self.config["path"], self.config.get("cloud"))
+
def count(self):
"""
Total number of elements in this embeddings index.