PromptTemplateFactory

Helpers & Utilities · AiDotNet.Factories

Factory for creating prompt template instances based on template type.

For Beginners

A factory that creates the right kind of template for you.

Example:

// Create a simple template
var simpleTemplate = PromptTemplateFactory.Create(
PromptTemplateType.Simple,
"Translate {text} to {language}"
);

// Create a chat template
var chatTemplate = PromptTemplateFactory.Create(
PromptTemplateType.Chat
) as ChatPromptTemplate;
chatTemplate.AddSystemMessage("You are a helpful assistant");

How It Works

This factory creates prompt templates based on the specified type, following the factory pattern used throughout the AiDotNet library.

Methods

Method Summary
IPromptTemplate Create(PromptTemplateType templateType, string template, IFewShotExampleSelector<T> exampleSelector, int exampleCount) Creates a prompt template of the specified type with a strongly-typed few-shot example selector.
IPromptTemplate Create(PromptTemplateType templateType, string template, int exampleCount) Creates a prompt template of the specified type.