Share via


prompt_template Package

Packages

utils

Modules

const
handlebars_prompt_template
input_variable
jinja2_prompt_template
kernel_prompt_template
prompt_template_base
prompt_template_config

Classes

HandlebarsPromptTemplate

Create a Handlebars prompt template.

Handlebars are parsed as a whole and therefore do not have variables that can be extracted, also with handlebars there is no distinction in syntax between a variable and a value, a value that is encountered is tried to resolve with the arguments and the functions, if not found, the literal value is returned.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

InputVariable

Input variable for a prompt template.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Jinja2PromptTemplate

Creates and renders Jinja2 prompt templates to text.

Jinja2 templates support advanced features such as variable substitution, control structures, and inheritance, making it possible to dynamically generate text based on input arguments and predefined functions. This class leverages Jinja2's flexibility to render prompts that can include conditional logic, loops, and functions, based on the provided template configuration and arguments.

Note that the fully qualified function name (in the form of "plugin-function") is not allowed in Jinja2 because of the hyphen. Therefore, the function name is replaced with an underscore, which are allowed in Python function names.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

KernelPromptTemplate

Create a Kernel prompt template.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

PromptTemplateConfig

Configuration for a prompt template.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.