InMemoryTextDocumentEmbeddingStorage

Implementation of an in-memory storage solution for text document embeddings.

This class leverages the functionality of an embedder and a document provider to compute embeddings for text documents and store them in memory for efficient retrieval. It combines a TextDocumentEmbedder for embedding computation and an InMemoryVectorStorage for vector storage, enabling lightweight and fast operations.

Parameters

Document

The type representing the document being managed.

Path

The type representing the path or identifier for locating documents.

embedder

The embedder used for generating vectorized representations of text.

documentReader

The document provider facilitating access to document contents.

Constructors

Link copied to clipboard
constructor(embedder: Embedder, documentReader: DocumentProvider<Path, Document>)

Functions

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

Retrieves a flow of all documents stored in the system.

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

Deletes the document with the specified ID from the storage.

Link copied to clipboard
open suspend override fun getPayload(documentId: String)
Link copied to clipboard
open override fun rankDocuments(query: String): Flow<RankedDocument<Document>>

Ranks documents based on their similarity to a given query string.

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

Reads a document by its unique identifier.

Link copied to clipboard
open suspend override fun readWithPayload(documentId: String): DocumentWithPayload<Document, Unit>?
Link copied to clipboard
open suspend fun store(document: Document): String

open suspend override fun store(document: Document, data: Unit): String

Stores the given document after embedding it into a vector representation.