Share via


utils Package

Modules

handlebars_system_helpers
jinja2_system_helpers
template_function_helpers

Functions

create_template_helper_from_function

Create a helper function for both the Handlebars and Jinja2 templating engines from a kernel function.

create_template_helper_from_function(function: KernelFunction, kernel: Kernel, base_arguments: KernelArguments, template_format: Literal['semantic-kernel', 'handlebars', 'jinja2'], allow_dangerously_set_content: bool = False, enable_async: bool = False) -> Callable[[...], Any]

Parameters

Name Description
function
Required
<xref:semantic_kernel.prompt_template.utils.KernelFunction>

The kernel function to create a helper for.

kernel
Required
<xref:semantic_kernel.prompt_template.utils.Kernel>

The kernel to use for invoking the function.

base_arguments
Required
<xref:semantic_kernel.prompt_template.utils.KernelArguments>

The base arguments to use when invoking the function.

template_format
Required
<xref:semantic_kernel.prompt_template.utils.TEMPLATE_FORMAT_TYPES>

The template format to create the helper for.

allow_dangerously_set_content
<xref:<xref:semantic_kernel.prompt_template.utils.bool, optional>>

Return the content of the function result without encoding it or not.

Default value: False
enable_async
<xref:<xref:semantic_kernel.prompt_template.utils.bool, optional>>

Enable async helper function. Defaults to False. Currently only works for Jinja2 templates.

Default value: False

Returns

Type Description

The function with args that are callable by the different templates.

Exceptions

Type Description

If the template format is not supported.