Table of Contents

Class PromptTemplateOptions

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

Configuration options for PromptTemplate parsing and rendering.

public sealed class PromptTemplateOptions
Inheritance
PromptTemplateOptions
Inherited Members

Examples

Using strict mode to catch missing variables:

using LMKit.TextGeneration.Prompts;

var options = new PromptTemplateOptions
{
    StrictVariables = true
};

var template = PromptTemplate.Parse("Hello {{name}}, role: {{role}}.", options);

// This will throw because "role" is not provided
try
{
    template.Render(new PromptTemplateContext { ["name"] = "Alice" });
}
catch (PromptTemplateException ex)
{
    Console.WriteLine(ex.Message); // "Missing required variable: role"
}

Using a custom default for missing variables:

using LMKit.TextGeneration.Prompts;

var options = new PromptTemplateOptions
{
    MissingVariableDefault = "[UNSET]"
};

var template = PromptTemplate.Parse("Hello {{name}}!", options);
string result = template.Render(); // "Hello [UNSET]!"

Properties

MissingVariableDefault

Gets or sets the default value for missing variables when StrictVariables is false and no inline default ({{var:fallback}}) is specified. Default: empty string.

StrictVariables

Gets or sets whether missing variables cause a PromptTemplateException. When false, missing variables render as MissingVariableDefault. Default: false.

Syntax

Gets or sets the template placeholder syntax. Default: Mustache.