kernel_function_decorator Module
Functions
kernel_function
Decorator for kernel functions.
Can be used directly as @kernel_function or with parameters @kernel_function(name='function', description='I am a function.').
This decorator is used to mark a function as a kernel function. It also provides metadata for the function. The name and description can be left empty, and then the function name and docstring will be used.
The parameters are parsed from the function signature, use typing.Annotated to provide a description for the parameter.
To parse the type, first it checks if the parameter is annotated, and get's the description from there. After that it checks recursively until it reaches the lowest level, and it combines the types into a single comma-separated string, a forwardRef is also supported. All of this is are stored in kernel_function_parameters.
The return type and description are parsed from the function signature, and that is stored in kernel_function_return_type, kernel_function_return_description and kernel_function_return_required.
It also checks if the function is a streaming type (generator or iterable, async or not), and that is stored as a bool in kernel_function_streaming.
kernel_function(func: Callable[[...], object] | None = None, name: str | None = None, description: str | None = None) -> Callable[[...], Any]
Parameters
| Name | Description |
|---|---|
|
func
|
The function to decorate, can be None (if used as @kernel_function Default value: None
|
|
name
|
<xref:<xref:semantic_kernel.functions.kernel_function_decorator.str | None>>
The name of the function, if not supplied, the function name will be used. Default value: None
|
|
description
|
<xref:<xref:semantic_kernel.functions.kernel_function_decorator.str | None>>
The description of the function, if not supplied, the function docstring will be used, can be None. Default value: None
|