Table of Contents

Property Filters

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

Filters

Gets or sets the filter pipeline that intercepts prompt, completion, and tool invocation stages.

public FilterPipeline Filters { get; set; }

Property Value

FilterPipeline

Examples

Adding a logging filter pipeline:

using LMKit.TextGeneration;
using LMKit.TextGeneration.Filters;

var chat = new MultiTurnConversation(model);
chat.Filters = new FilterPipeline();

chat.Filters.AddPromptFilter(async (ctx, next) =>
{
    Console.WriteLine($"[Prompt] {ctx.Prompt}");
    await next(ctx);
    Console.WriteLine($"[Done] {ctx.Result?.GeneratedTokenCount} tokens");
});

Remarks

Filters execute in a middleware (onion) pattern around the inference and tool invocation stages. They run in the order they are added to the pipeline lists.

Filters are complementary to events (BeforeToolInvocation, AfterToolInvocation, etc.). Filters execute first; events fire afterward.