Table of Contents

Method Register

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

Register(string, Func<string, string[], string>)

Registers a custom global filter available to all templates.

public static void Register(string name, Func<string, string[], string> filter)

Parameters

name string

The filter name used in template expressions (e.g., "shout" for {{var|shout}}).

filter Func<string, string[], string>

A function that receives the input string and any colon-separated arguments, and returns the transformed string.

Examples

A filter with arguments:

using LMKit.TextGeneration.Prompts;

// Register a "pad" filter: {{value|pad:10:*}}
PromptTemplateFilters.Register("pad", (value, args) =>
{
    int width = args.Length > 0 ? int.Parse(args[0]) : 10;
    char ch = args.Length > 1 && args[1].Length > 0 ? args[1][0] : ' ';
    return value.PadRight(width, ch);
});

Exceptions

ArgumentNullException

Thrown when name or filter is null.