Endpoint to delete documents ingested (#1163)

A file that is ingested will be transformed into several documents (that
are organized into nodes).
This endpoint is deleting documents (bits of a file). These bits can be
retrieved thanks to the endpoint to list all the documents.
This commit is contained in:
lopagela
2023-11-06 15:47:42 +01:00
committed by GitHub
parent 6583dc84c0
commit 0c40cfb115
3 changed files with 45 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
import logging
from injector import inject, singleton
from llama_index.storage.docstore import BaseDocumentStore, SimpleDocumentStore
from llama_index.storage.index_store import SimpleIndexStore
@@ -5,6 +7,8 @@ from llama_index.storage.index_store.types import BaseIndexStore
from private_gpt.paths import local_data_path
logger = logging.getLogger(__name__)
@singleton
class NodeStoreComponent:
@@ -18,6 +22,7 @@ class NodeStoreComponent:
persist_dir=str(local_data_path)
)
except FileNotFoundError:
logger.debug("Local index store not found, creating a new one")
self.index_store = SimpleIndexStore()
try:
@@ -25,4 +30,5 @@ class NodeStoreComponent:
persist_dir=str(local_data_path)
)
except FileNotFoundError:
logger.debug("Local document store not found, creating a new one")
self.doc_store = SimpleDocumentStore()