MemoryEmbeddingStorageService

Wisej.AI.Services.MemoryEmbeddingStorageService

Namespace: Wisej.AI.Services

Assembly: Wisej.AI (3.5.0.0)

Provides an in-memory implementation of the IEmbeddingStorageService interface.

public class MemoryEmbeddingStorageService : IEmbeddingStorageService

This service stores embedded documents in memory using a dictionary. It supports operations such as checking for existence, querying, removing, retrieving, and storing documents.

Constructors

MemoryEmbeddingStorageService()

Initializes a new instance of MemoryEmbeddingStorageService.

Methods

ExistsAsync(collectionName, documentName)

Checks if a document exists in the specified collection.

Parameter
Type
Description

collectionName

The name of the collection.

documentName

The name of the document.

Returns: Task<Boolean>. A task that represents the asynchronous operation. The task result contains a boolean indicating whether the document exists.

QueryAsync(collectionName, query, topN, minSimilarity, filter)

Queries the specified collection for documents similar to the provided query vector.

Parameter
Type
Description

collectionName

The name of the collection.

query

The query vector to compare against.

topN

The number of top similar documents to return.

minSimilarity

The minimum similarity threshold for documents to be considered.

filter

An optional filter predicate to apply to documents. Default is null.

Returns: Task<EmbeddedDocument[]>. A task that represents the asynchronous operation. The task result contains an array of EmbeddedDocument objects.

QueryAsync(collectionName, documentName, query, topN, minSimilarity)

Queries a specific document in the collection for similarity to the provided query vector.

Parameter
Type
Description

collectionName

The name of the collection.

documentName

The name of the document.

query

The query vector to compare against.

topN

The number of top similar chunks to return.

minSimilarity

The minimum similarity threshold for chunks to be considered.

Returns: Task<EmbeddedDocument>. A task that represents the asynchronous operation. The task result contains the EmbeddedDocument with the top similar chunks.

Throws:

RemoveAsync(collectionName, filter)

Removes documents from the specified collection that match the given filter.

Parameter
Type
Description

collectionName

The name of the collection.

filter

An optional filter predicate to apply to documents. Default is null.

Returns: Task. A task that represents the asynchronous operation.

RemoveAsync(collectionName, documentName)

Removes a specific document from the collection.

Parameter
Type
Description

collectionName

The name of the collection.

documentName

The name of the document.

Returns: Task. A task that represents the asynchronous operation.

RetrieveAsync(collectionName, documentName, includeEmbedding)

Retrieves a specific document from the collection.

Parameter
Type
Description

collectionName

The name of the collection.

documentName

The name of the document.

includeEmbedding

Indicates whether to include the embedding in the retrieved document.

Returns: Task<EmbeddedDocument>. A task that represents the asynchronous operation. The task result contains the EmbeddedDocument.

RetrieveAsync(collectionName, includeEmbedding, filter)

Retrieves all documents from the specified collection that match the given filter.

Parameter
Type
Description

collectionName

The name of the collection.

includeEmbedding

Indicates whether to include the embedding in the retrieved documents.

filter

An optional filter predicate to apply to documents. Default is null.

Returns: Task<EmbeddedDocument[]>. A task that represents the asynchronous operation. The task result contains an array of EmbeddedDocument objects.

StoreAsync(collectionName, document)

Stores a document in the specified collection.

Parameter
Type
Description

collectionName

The name of the collection.

document

The document to store.

Returns: Task. A task that represents the asynchronous operation.

Throws:

Implements

Name
Description

Represents a service for storing and querying embedded documents within specified collections.

Last updated