PromptTemplateConfig Class

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.

Constructor

PromptTemplateConfig(*, name: str = '', description: str | None = '', template: str | None = None, template_format: Literal['semantic-kernel', 'handlebars', 'jinja2'] = 'semantic-kernel', input_variables: MutableSequence[InputVariable] = None, allow_dangerously_set_content: bool = False, execution_settings: MutableMapping[str, PromptExecutionSettings] = None)

Parameters

Name Description
name
Required

The name of the prompt template.

description
Required

The description of the prompt template.

template
Required

The template for the prompt.

template_format
Required

The format of the template, should be 'semantic-kernel', 'jinja2' or 'handlebars'.

input_variables
Required

The input variables for the prompt.

allow_dangerously_set_content
Required
<xref:<xref:semantic_kernel.prompt_template.prompt_template_config.bool = False>>

Allow content without encoding throughout, this overrides the same settings in the prompt template config and input variables. This reverts the behavior to unencoded input.

execution_settings
Required

The execution settings for the prompt.

Keyword-Only Parameters

Name Description
name
Required
description
Required
template
Required
template_format
Default value: semantic-kernel
input_variables
Required
allow_dangerously_set_content
Required
execution_settings
Required

Methods

add_execution_settings

Add execution settings to the prompt template.

check_input_variables

Verify that input variable default values are string only.

from_json

Create a PromptTemplateConfig instance from a JSON string.

get_kernel_parameter_metadata

Get the kernel parameter metadata for the input variables.

restore

Restore a PromptTemplateConfig instance from the specified parameters.

rewrite_execution_settings

Rewrite execution settings to a dictionary.

add_execution_settings

Add execution settings to the prompt template.

add_execution_settings(settings: PromptExecutionSettings, overwrite: bool = True) -> None

Parameters

Name Description
settings
Required
overwrite
Required
Default value: True

check_input_variables

Verify that input variable default values are string only.

check_input_variables()

from_json

Create a PromptTemplateConfig instance from a JSON string.

from_json(json_str: str) -> _T

Parameters

Name Description
json_str
Required

get_kernel_parameter_metadata

Get the kernel parameter metadata for the input variables.

get_kernel_parameter_metadata() -> Sequence[KernelParameterMetadata]

restore

Restore a PromptTemplateConfig instance from the specified parameters.

restore(name: str, description: str, template: str, template_format: Literal['semantic-kernel', 'handlebars', 'jinja2'] = 'semantic-kernel', input_variables: MutableSequence[InputVariable] = [], execution_settings: MutableMapping[str, PromptExecutionSettings] = {}, allow_dangerously_set_content: bool = False) -> _T

Parameters

Name Description
name
Required

The name of the prompt template.

description
Required

The description of the prompt template.

template
Required

The template for the prompt.

template_format
Required

The format of the template, should be 'semantic-kernel', 'jinja2' or 'handlebars'.

Default value: semantic-kernel
input_variables
Required

The input variables for the prompt.

Default value: []
execution_settings
Required

The execution settings for the prompt.

Default value: {}
allow_dangerously_set_content
Required

Allow content without encoding.

Default value: False

Returns

Type Description

A new PromptTemplateConfig instance.

rewrite_execution_settings

Rewrite execution settings to a dictionary.

rewrite_execution_settings(settings: PromptExecutionSettings | Sequence[PromptExecutionSettings] | MutableMapping[str, PromptExecutionSettings] | None) -> MutableMapping[str, PromptExecutionSettings]

Parameters

Name Description
settings
Required

Attributes

allow_dangerously_set_content

allow_dangerously_set_content: bool

description

description: str | None

execution_settings

execution_settings: MutableMapping[str, PromptExecutionSettings]

input_variables

input_variables: MutableSequence[InputVariable]

name

name: str

template

template: str | None

template_format

template_format: Literal['semantic-kernel', 'handlebars', 'jinja2']