Table of Contents

Method RegisterHelper

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

RegisterHelper(string, PromptTemplateHelper)

Registers a custom helper function callable from the template.

public PromptTemplateContext RegisterHelper(string name, PromptTemplateHelper handler)

Parameters

name string

The helper name used in template expressions (e.g., "date").

handler PromptTemplateHelper

The function to execute when the helper is invoked.

Returns

PromptTemplateContext

This context instance.

Examples

var context = new PromptTemplateContext();
context.RegisterHelper("uppercase", args =>
    args.Length > 0 ? args[0]?.ToString().ToUpper() : "");

var template = PromptTemplate.Parse("{{uppercase name}}");
string result = template.Render(context.Set("name", "alice"));
// "ALICE"

Exceptions

ArgumentNullException

Thrown when name or handler is null.