Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Modify file delete

davidmezzetti7d5921060d0c
diff --git a/src/python/txtai/embeddings/base.py b/src/python/txtai/embeddings/base.py
index d34491aa..d0381349 100644
--- a/src/python/txtai/embeddings/base.py
+++ b/src/python/txtai/embeddings/base.py
@@ -115,10 +115,8 @@ class Embeddings:
if not reindex and not self.database:
self.config["ids"] = ids
- # Delete mmap buffer file
- path = embeddings.filename
- del embeddings
- os.remove(path)
+ # Delete embeddings memmap buffer
+ transform.remove(embeddings)
def upsert(self, documents):
"""
@@ -151,10 +149,8 @@ class Embeddings:
if not self.database:
self.config["ids"] = self.config["ids"] + ids
- # Delete mmap buffer file
- path = embeddings.filename
- del embeddings
- os.remove(path)
+ # Delete embeddings memmap buffer
+ transform.remove(embeddings)
def delete(self, ids):
"""
diff --git a/src/python/txtai/embeddings/transform.py b/src/python/txtai/embeddings/transform.py
index 3c074124..42fcce6c 100644
--- a/src/python/txtai/embeddings/transform.py
+++ b/src/python/txtai/embeddings/transform.py
@@ -138,6 +138,18 @@ class Transform:
self.database.insert(batch, self.offset)
self.offset += len(batch)
+ def remove(self, embeddings):
+ """
+ Deletes an embeddings buffer and it's underlying file.
+
+ Args:
+ embeddings: embeddings
+ """
+
+ path = embeddings.filename
+ del embeddings
+ os.remove(path)
+
class Action(Enum):
"""