MentorAgent Docs
Menu

ReferencePackage: Novior.MentorAgent

IMentorQueryEmbedding interface

The embedding of the message MentorAgent is answering right now, computed once per turn.

View as Markdown
On this page

Model routing, semantic tool filtering and memory relevance already share it. A host's IMentorRagSource is the fourth consumer of the same sentence and the only one outside the library, so it is offered here: ask for the vector instead of embedding the query again, and the turn makes one round trip instead of two.

Example
public sealed class MyRagSource(IMentorQueryEmbedding query, IEmbeddingGenerator<string, Embedding<float>> embeddings)
    : IMentorRagSource
{
    public async Task<IReadOnlyList<MentorRagResult>> SearchAsync(string q, int maxResults, CancellationToken ct = default)
    {
        var vector = await query.GetAsync(q, embeddings, ct);   // free if something already embedded it
        return Search(vector, maxResults);
    }
}

Scoped: the vector belongs to the session that asked for it and is replaced by the next message. Registered by AddMentorAgent(); the generator you pass is the one used on a cache miss.

Namespace: Novior.MentorAgent.Rag. Package: Novior.MentorAgent.

public interface IMentorQueryEmbedding

Terminal
dotnet add package Novior.MentorAgent

Task<ReadOnlyMemory<float>> GetAsync(string text, IEmbeddingGenerator<string, Embedding<float>> generator, CancellationToken ct = default)

Returns the vector for text, generating it only if it is not the one already computed for this turn. An empty text returns an empty vector without calling out.