FileSystemEmbeddingStorageService
Namespace: Wisej.AI.Services
Assembly: Wisej.AI
Provides a file system-based implementation of the IEmbeddingStorageService interface.
- C#
- VB.NET
public class FileSystemEmbeddingStorageService : IEmbeddingStorageService
Public Class FileSystemEmbeddingStorageService
Inherits IEmbeddingStorageService
This service allows for storing, retrieving, querying, and removing embedded documents from a specified storage path in the file system. It uses JSON files to store metadata and embeddings for each document.
Constructors
FileSystemEmbeddingStorageService()
Initializes a new instance of FileSystemEmbeddingStorageService.
Properties
StoragePath
String: Gets or sets the storage path for embeddings. (Default: "~\AI\Embeddings")
Methods
ExistsAsync(collectionName, documentName)
Checks if a document exists in the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | 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 collection for documents similar to the provided query vector.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| query | Single[] | The query vector. |
| topN | Int32 | The number of top similar documents to retrieve. |
| minSimilarity | Single | The minimum similarity threshold. |
| filter | Predicate<EmbeddedDocument> | An optional filter predicate for 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 | String | The name of the collection. |
| documentName | String | The name of the document. |
| query | Single[] | The query vector. |
| topN | Int32 | The number of top similar chunks to retrieve. |
| minSimilarity | Single | The minimum similarity threshold. |
Returns: Task<EmbeddedDocument>. A task that represents the asynchronous operation. The task result contains the EmbeddedDocument with the top similar chunks.
Throws:
- ArgumentNullException Thrown when the document is null.
RemoveAsync(collectionName, filter)
Removes documents from the specified collection that match the filter predicate.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| filter | Predicate<EmbeddedDocument> | An optional filter predicate for documents. Default is null. |
Returns: Task. A task that represents the asynchronous operation.
RemoveAsync(collectionName, documentName)
Removes a specific document from the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
Returns: Task. A task that represents the asynchronous operation.
RetrieveAsync(collectionName, documentName, includeEmbedding)
Retrieves a specific document from the specified collection.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| documentName | String | The name of the document. |
| includeEmbedding | Boolean | 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 filter predicate.
| Parameter | Type | Description |
|---|---|---|
| collectionName | String | The name of the collection. |
| includeEmbedding | Boolean | Indicates whether to include embeddings in the retrieved documents. |
| filter | Predicate<EmbeddedDocument> | An optional filter predicate for 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 | String | The name of the collection. |
| document | EmbeddedDocument | The document to store. |
Returns: Task. A task that represents the asynchronous operation.
Throws:
- ArgumentNullException Thrown when the document is null.
Implements
| Name | Description |
|---|---|
| IEmbeddingStorageService | Represents a service for storing and querying embedded documents within specified collections. |