JVMFileVectorStorageBackend

A JVM-specific implementation of FileVectorStorageBackend for managing the storage of documents and associated vector embeddings on a file system.

This class utilizes a ai.koog.rag.base.files.JVMDocumentProvider along with a JVM-compatible ai.koog.rag.base.files.FileSystemProvider.ReadWrite to handle document operations and vector storage in a structured directory format. It uses a root directory as the base for storing documents and their associated embeddings in separate directories.

Use this class to persistently store and retrieve documents and their vector payloads to and from a file-based system in JVM environments.

Parameters

root

The root directory where all documents and vector embeddings will be stored.

Constructors

Link copied to clipboard
constructor(root: Path)

Initializes the JVMFileVectorStorageBackend with a specified root directory root.

Functions

Link copied to clipboard
open override fun allDocuments(): Flow<Path>

Retrieves a flow of all documents.

Link copied to clipboard

Retrieves a flow of all documents with their vector embeddings.

Link copied to clipboard
open suspend override fun delete(documentId: String): Boolean

Deletes the document with the specified ID.

Link copied to clipboard
suspend fun getPayload(documentId: String): Vector?

Retrieves the vector payload associated with the document identified by the given document ID.

Link copied to clipboard
open suspend override fun read(documentId: String): Path?

Reads a document by its unique identifier.

Link copied to clipboard
open suspend override fun readWithPayload(documentId: String): DocumentWithPayload<Path, Vector>?

Reads a document along with its vector embedding by document ID.

Link copied to clipboard
open suspend override fun store(document: Path, vector: Vector): String

Stores a document along with its pre-computed vector embedding.

open suspend override fun store(id: String, document: Path, vector: Vector): Boolean

Updates a document along with its pre-computed vector embedding under the specified ID. Only updates if a document with the given ID already exists.