Table of Contents

Class DelegateToolInvocationFilter

Namespace
LMKit.TextGeneration.Filters
Assembly
LM-Kit.NET.dll

A tool invocation filter backed by a delegate, enabling inline lambda registration.

public sealed class DelegateToolInvocationFilter : IToolInvocationFilter
Inheritance
DelegateToolInvocationFilter
Implements
Inherited Members

Examples

Registering a lambda tool filter:

pipeline.AddToolInvocationFilter(async (ctx, next) =>
{
    Console.WriteLine($"Calling tool: {ctx.ToolCall.Name}");
    await next(ctx);
    Console.WriteLine($"Result: {ctx.Result?.ResultType}");
});

Remarks

This class is created automatically by AddToolInvocationFilter(FilterPipeline, Func<ToolInvocationFilterContext, Func<ToolInvocationFilterContext, Task>, Task>). You do not need to instantiate it directly.

Constructors

DelegateToolInvocationFilter(Func<ToolInvocationFilterContext, Func<ToolInvocationFilterContext, Task>, Task>)

Initializes a new instance with the specified handler delegate.

Methods

OnToolInvocationAsync(ToolInvocationFilterContext, Func<ToolInvocationFilterContext, Task>)

Called when a tool is about to be invoked during the automatic tool-calling loop.