Class InMemoryKnowledgeStore

Assembly: redb.Route.Llm.dll

In-memory knowledge store — does an O(N) cosine-similarity scan on every
query. Suitable for unit tests and small fixtures only; swap in the
production store for anything larger than a few thousand chunks.

public sealed class InMemoryKnowledgeStore : IKnowledgeStore

Inheritance

Object→InMemoryKnowledgeStore

Implements

Methods

DeleteAsync(string, IExchange?, CancellationToken)

Drops a chunk by id; no-op when not found.

public Task DeleteAsync(string chunkId, IExchange? exchange = null, CancellationToken ct = default)

SearchAsync(ReadOnlyMemory<float>, int, string?, IExchange?, CancellationToken)

Returns the topK most-similar chunks for the query embedding.

public Task<IReadOnlyList<KnowledgeSearchResult>> SearchAsync(ReadOnlyMemory<float> queryEmbedding, int topK, string? collection = null, IExchange? exchange = null, CancellationToken ct = default)

SearchTextAsync(string, int, string?, IExchange?, CancellationToken)

Keyword fallback — returns up to topK chunks whose text

public Task<IReadOnlyList<KnowledgeSearchResult>> SearchTextAsync(string query, int topK, string? collection = null, IExchange? exchange = null, CancellationToken ct = default)

UpsertAsync(KnowledgeChunk, IExchange?, CancellationToken)

Persists or replaces a chunk by its .

public Task UpsertAsync(KnowledgeChunk chunk, IExchange? exchange = null, CancellationToken ct = default)