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.
- Inheritance
-
PromptTemplateConfig
Constructor
PromptTemplateConfig(*, name: str = '', description: str | None = '', template: str | None = None, template_format: Literal['semantic-kernel', 'handlebars', 'jinja2'] = 'semantic-kernel', input_variables: list[InputVariable] = None, allow_dangerously_set_content: bool = False, execution_settings: dict[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
|
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) -> PromptTemplateConfig
Parameters
Name | Description |
---|---|
json_str
Required
|
|
get_kernel_parameter_metadata
Get the kernel parameter metadata for the input variables.
get_kernel_parameter_metadata() -> list[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: list[InputVariable] = [], execution_settings: dict[str, PromptExecutionSettings] = {}, allow_dangerously_set_content: bool = False) -> PromptTemplateConfig
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
|
The format of the template, should be 'semantic-kernel', 'jinja2' or 'handlebars'. Default value: semantic-kernel
|
input_variables
|
The input variables for the prompt. Default value: []
|
execution_settings
|
The execution settings for the prompt. Default value: {}
|
allow_dangerously_set_content
|
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: None | PromptExecutionSettings | list[PromptExecutionSettings] | dict[str, PromptExecutionSettings]) -> dict[str, PromptExecutionSettings]
Parameters
Name | Description |
---|---|
settings
Required
|
|
Attributes
model_computed_fields
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
model_config
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'populate_by_name': True, 'validate_assignment': True}
model_fields
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.fields from Pydantic V1.
model_fields: ClassVar[Dict[str, FieldInfo]] = {'allow_dangerously_set_content': FieldInfo(annotation=bool, required=False, default=False), 'description': FieldInfo(annotation=Union[str, NoneType], required=False, default=''), 'execution_settings': FieldInfo(annotation=dict[str, PromptExecutionSettings], required=False, default_factory=dict), 'input_variables': FieldInfo(annotation=list[InputVariable], required=False, default_factory=list), 'name': FieldInfo(annotation=str, required=False, default=''), 'template': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'template_format': FieldInfo(annotation=Literal['semantic-kernel', 'handlebars', 'jinja2'], required=False, default='semantic-kernel')}
allow_dangerously_set_content
allow_dangerously_set_content: bool
description
description: str | None
execution_settings
execution_settings: dict[str, PromptExecutionSettings]
input_variables
input_variables: list[InputVariable]
name
name: str
template
template: str | None
template_format
template_format: Literal['semantic-kernel', 'handlebars', 'jinja2']