InMemoryDocumentEmbeddingStorage

An in-memory implementation of document embedding storage.

This class facilitates the storage and retrieval of documents and their corresponding vector embeddings entirely in memory. It utilizes an InMemoryVectorStorage for managing the document embeddings and extends EmbeddingBasedDocumentStorage, inheriting capabilities such as ranking, storing, and deleting documents based on their embeddings.

Parameters

Document

The type of the documents being stored.

embedder

A mechanism responsible for embedding the documents into vector representations.

Inheritors

Constructors

Link copied to clipboard
constructor(embedder: DocumentEmbedder<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.