Delegate PromptTemplateHelper
- Namespace
- LMKit.TextGeneration.Prompts
- Assembly
- LM-Kit.NET.dll
Delegate for custom template helper functions that can be invoked from within a template.
public delegate string PromptTemplateHelper(object[] arguments)
Parameters
argumentsobject[]The arguments passed from the template expression.
Returns
- string
The string result to insert into the rendered output.
Examples
Registering a custom date helper:
using LMKit.TextGeneration.Prompts;
var context = new PromptTemplateContext();
context.RegisterHelper("now", args =>
{
string format = args.Length > 0 ? args[0]?.ToString() : "yyyy-MM-dd";
return DateTime.Now.ToString(format);
});
var template = PromptTemplate.Parse("Today is {{now yyyy-MM-dd}}.");
string result = template.Render(context);
// "Today is 2026-02-18."