Class InMemoryVectorStore
In-memory vector store for testing and lightweight use cases. Uses brute-force cosine similarity (O(n) per query).
public sealed class InMemoryVectorStore : IVectorStore
- Inheritance
-
InMemoryVectorStore
- Implements
- Inherited Members
Properties
Count
Number of stored entries.
public int Count { get; }
Property Value
Methods
CountAsync(CancellationToken)
Returns the total number of stored entries.
public Task<long> CountAsync(CancellationToken ct = default)
Parameters
Returns
DeleteAsync(IReadOnlyList<string>, CancellationToken)
Deletes entries by IDs.
public Task DeleteAsync(IReadOnlyList<string> ids, CancellationToken ct = default)
Parameters
idsIReadOnlyList<string>ctCancellationToken
Returns
SearchAsync(float[], int, string?, CancellationToken)
Searches for similar entries by embedding vector.
public Task<IReadOnlyList<MemorySearchResult>> SearchAsync(float[] queryEmbedding, int topK = 5, string? categoryFilter = null, CancellationToken ct = default)
Parameters
queryEmbeddingfloat[]topKintcategoryFilterstringctCancellationToken
Returns
UpsertAsync(IReadOnlyList<MemoryEntry>, CancellationToken)
Upserts entries with their embeddings.
public Task UpsertAsync(IReadOnlyList<MemoryEntry> entries, CancellationToken ct = default)
Parameters
entriesIReadOnlyList<MemoryEntry>ctCancellationToken