CompositePromptTemplate

Models & Types · AiDotNet.PromptEngineering.Templates

Template that combines multiple prompt templates in sequence.

Implements: IPromptTemplate

For Beginners

Combines multiple templates into one.

Example:

How It Works

This template allows chaining multiple templates together, making it easier to build complex prompts from reusable components.

Constructors

Constructor Summary
CompositePromptTemplate(IPromptTemplate[] templates) Initializes a new instance of the CompositePromptTemplate class.
CompositePromptTemplate(string separator, IPromptTemplate[] templates) Initializes a new instance with a custom separator.

Properties

Property Summary
IReadOnlyList<string> InputVariables { get; } Gets the list of all variable names from all component templates.
string Template { get; } Gets the raw template string (combined from all components).

Methods

Method Summary
CompositePromptTemplate Add(IPromptTemplate template) Adds a template to the composite.
CompositeTemplateBuilder Builder() Creates a builder for constructing composite templates.
bool Validate(Dictionary<string, string> variables) Validates that all required variables are present.
string Format(Dictionary<string, string> variables) Formats all templates and combines them.