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
contextPromptTemplateContextThe 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
variablesIDictionary<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
variablesis null.