Search Results for

    Show / Hide Table of Contents

    Class AdaptiveInstructionsUpdater

    Embedding-based dynamic instructions updater.

    Register multiple InstructionsRule entries; before each request the updater embeds the user message, computes cosine similarity against every rule description, and returns the instructions of the best-matching rule.

    Returns null (leaving instructions unchanged) when no rule exceeds MinSimilarity.

    var updater = new AdaptiveInstructionsUpdater(embeddingModel)
        .AddRule("user is asking about billing or payments", billingInstructions)
        .AddRule("user is reporting a bug or technical issue", techSupportInstructions)
        .SetMinSimilarity(0.72f);
    

    agent.SetInstructionsUpdater(updater);

    Inheritance
    object
    InstructionsUpdaterBase<IAdaptiveInstructionsUpdaterSettings>
    AdaptiveInstructionsUpdater
    Implements
    IInstructionsUpdater
    Inherited Members
    InstructionsUpdaterBase<IAdaptiveInstructionsUpdaterSettings>.DefaultMinMessageLength
    InstructionsUpdaterBase<IAdaptiveInstructionsUpdaterSettings>.DefaultMinQuestionLength
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Glitch9.AIDevKit.Agents
    Assembly: Glitch9.AIDevKit.dll
    Syntax
    public sealed class AdaptiveInstructionsUpdater : InstructionsUpdaterBase<IAdaptiveInstructionsUpdaterSettings>, IInstructionsUpdater

    Constructors

    | Edit this page View Source

    AdaptiveInstructionsUpdater(IAdaptiveInstructionsUpdaterSettings, ILogger)

    Declaration
    public AdaptiveInstructionsUpdater(IAdaptiveInstructionsUpdaterSettings settings, ILogger logger)
    Parameters
    Type Name Description
    IAdaptiveInstructionsUpdaterSettings settings
    ILogger logger

    Methods

    | Edit this page View Source

    Invalidate()

    Forces the embedding index to be rebuilt on the next call. Call this manually when rules are replaced at runtime.

    Declaration
    public void Invalidate()
    | Edit this page View Source

    ShouldSkip(string)

    Returns true if the message is trivially short or meaningless and should skip instruction update. Override in subclasses to add additional skip conditions; call base.ShouldSkip() first.

    Declaration
    public override bool ShouldSkip(string lastUserMessage)
    Parameters
    Type Name Description
    string lastUserMessage
    Returns
    Type Description
    bool
    Overrides
    InstructionsUpdaterBase<IAdaptiveInstructionsUpdaterSettings>.ShouldSkip(string)
    | Edit this page View Source

    UpdateInstructionsAsync(string, CancellationToken)

    Returns updated system instructions for the next request. Called automatically before every SendAsync(string, int, CancellationToken) call. Return null to keep the current instructions unchanged.

    Declaration
    public override UniTask<string> UpdateInstructionsAsync(string lastUserMessage, CancellationToken ct = default)
    Parameters
    Type Name Description
    string lastUserMessage

    The user's message that triggered this request.

    CancellationToken ct

    Cancellation token.

    Returns
    Type Description
    UniTask<string>
    Overrides
    InstructionsUpdaterBase<IAdaptiveInstructionsUpdaterSettings>.UpdateInstructionsAsync(string, CancellationToken)

    Implements

    IInstructionsUpdater

    Extension Methods

    ArrayExtensions.ToArrayOrEmpty<T>(T)
    ArrayExtensions.ToArrayOrNull<T>(T)
    EventExtensions.ToDelta<T>(T, string, int, string, bool)
    EventExtensions.ToDone<T>(T, string, int, string)
    EventExtensions.ToEvent<T>(T)
    EventExtensions.UpcastDelta<T1, T2>(T1, string, int, string, bool)
    FallbackExtensions.IsOr<TParent, TChild>(TParent, TChild)
    ResponseCastingExtensions.GetResult<T>(T)
    SystemExtensions.GetName(object)
    • Edit this page
    • View Source
    In this article
    Back to top AI DevKit Documentation