Table of Contents

Method Render

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

Render(PromptTemplateContext)

Renders the template with the given context.

public string Render(PromptTemplateContext context = null)

Parameters

context PromptTemplateContext

The context providing variable values and helpers. If null, an empty context is used.

Returns

string

The rendered prompt string.

Examples

var template = PromptTemplate.Parse("Hello {{name}}!");
string result = template.Render(new PromptTemplateContext { ["name"] = "World" });
// "Hello World!"

Exceptions

PromptTemplateException

Thrown when StrictVariables is true and a required variable is missing.

Render(IDictionary<string, object>)

Renders the template with a dictionary of variable values.

public string Render(IDictionary<string, object> variables)

Parameters

variables IDictionary<string, object>

A dictionary mapping variable names to values. Values can be strings, numbers, booleans, arrays, or objects.

Returns

string

The rendered prompt string.

Examples

var template = PromptTemplate.Parse("Hello {{name}}!");
string result = template.Render(new Dictionary<string, object>
{
    ["name"] = "World"
});
// "Hello World!"

Exceptions

ArgumentNullException

Thrown when variables is null.