Share via


FunctionChoiceBehavior Class

Class that controls function choice behavior.

Attributes: enable_kernel_functions: Enable kernel functions. max_auto_invoke_attempts: The maximum number of auto invoke attempts. filters: Filters for the function choice behavior. Available options are: excluded_plugins,

     included_plugins, excluded_functions, or included_functions.

  >>type_<<: The type of function choice behavior.

Properties: auto_invoke_kernel_functions: Check if the kernel functions should be auto-invoked. Determined as max_auto_invoke_attempts > 0.

Methods: configure: Configures the settings for the function call behavior, the default version in this class, does nothing, use subclasses for different behaviors.

Class methods: Auto: Returns FunctionChoiceBehavior class with auto_invoke enabled, and the desired functions based on either the specified filters or the full qualified names. The model will decide which function to use, if any.

  NoneInvoke: Returns FunctionChoiceBehavior class with auto_invoke disabled, and the desired functions
     based on either the specified filters or the full qualified names. The model does not invoke any functions,
     but can rather describe how it would invoke a function to complete a given task/query.

  Required: Returns FunctionChoiceBehavior class with auto_invoke enabled, and the desired functions
     based on either the specified filters or the full qualified names. The model is required to use one of the
     provided functions to complete a given task/query.

Note: This class is marked as 'experimental' and may change in the future.

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

FunctionChoiceBehavior(*, enable_kernel_functions: bool = True, maximum_auto_invoke_attempts: int = 5, filters: dict[Literal['excluded_plugins', 'included_plugins', 'excluded_functions', 'included_functions'], list[str]] | None = None, type_: FunctionChoiceType | None = None)

Keyword-Only Parameters

Name Description
enable_kernel_functions
Default value: True
maximum_auto_invoke_attempts
Default value: 5
filters
Required
type_
Required

Methods

Auto

Creates a FunctionChoiceBehavior with type AUTO.

Returns FunctionChoiceBehavior class with auto_invoke enabled, and the desired functions based on either the specified filters or the full qualified names. The model will decide which function to use, if any.

NoneInvoke

Creates a FunctionChoiceBehavior with type NONE.

Returns FunctionChoiceBehavior class with auto_invoke disabled, and the desired functions based on either the specified filters or the full qualified names. The model does not invoke any functions, but can rather describe how it would invoke a function to complete a given task/query.

Required

Creates a FunctionChoiceBehavior with type REQUIRED.

Returns FunctionChoiceBehavior class with auto_invoke enabled, and the desired functions based on either the specified filters or the full qualified names. The model is required to use one of the provided functions to complete a given task/query.

configure

Configure the function choice behavior.

from_dict

Create a FunctionChoiceBehavior from a dictionary.

from_string

Create a FunctionChoiceBehavior from a string.

This method converts the provided string to a FunctionChoiceBehavior object for the specified type.

get_config

Get the function call choice configuration based on the type.

Auto

Creates a FunctionChoiceBehavior with type AUTO.

Returns FunctionChoiceBehavior class with auto_invoke enabled, and the desired functions based on either the specified filters or the full qualified names. The model will decide which function to use, if any.

Auto(auto_invoke: bool = True, *, filters: dict[Literal['excluded_plugins', 'included_plugins', 'excluded_functions', 'included_functions'], list[str]] | None = None, **kwargs) -> _T

Parameters

Name Description
auto_invoke
Default value: True

Keyword-Only Parameters

Name Description
filters
Required

NoneInvoke

Creates a FunctionChoiceBehavior with type NONE.

Returns FunctionChoiceBehavior class with auto_invoke disabled, and the desired functions based on either the specified filters or the full qualified names. The model does not invoke any functions, but can rather describe how it would invoke a function to complete a given task/query.

NoneInvoke(*, filters: dict[Literal['excluded_plugins', 'included_plugins', 'excluded_functions', 'included_functions'], list[str]] | None = None, **kwargs) -> _T

Keyword-Only Parameters

Name Description
filters
Required

Required

Creates a FunctionChoiceBehavior with type REQUIRED.

Returns FunctionChoiceBehavior class with auto_invoke enabled, and the desired functions based on either the specified filters or the full qualified names. The model is required to use one of the provided functions to complete a given task/query.

Required(auto_invoke: bool = True, *, filters: dict[Literal['excluded_plugins', 'included_plugins', 'excluded_functions', 'included_functions'], list[str]] | None = None, **kwargs) -> _T

Parameters

Name Description
auto_invoke
Default value: True

Keyword-Only Parameters

Name Description
filters
Required

configure

Configure the function choice behavior.

configure(kernel: Kernel, update_settings_callback: Callable[[...], None], settings: PromptExecutionSettings) -> None

Parameters

Name Description
kernel
Required
update_settings_callback
Required
settings
Required

from_dict

Create a FunctionChoiceBehavior from a dictionary.

from_dict(data: dict) -> _T

Parameters

Name Description
data
Required

from_string

Create a FunctionChoiceBehavior from a string.

This method converts the provided string to a FunctionChoiceBehavior object for the specified type.

from_string(data: str) -> _T

Parameters

Name Description
data
Required

get_config

Get the function call choice configuration based on the type.

get_config(kernel: Kernel) -> FunctionCallChoiceConfiguration

Parameters

Name Description
kernel
Required

Attributes

auto_invoke_kernel_functions

Return True if auto_invoke_kernel_functions is enabled.

enable_kernel_functions

enable_kernel_functions: bool

filters

filters: dict[Literal['excluded_plugins', 'included_plugins', 'excluded_functions', 'included_functions'], list[str]] | None

is_experimental

is_experimental = True

maximum_auto_invoke_attempts

maximum_auto_invoke_attempts: int

stage_status

stage_status = 'experimental'

type_

type_: FunctionChoiceType | None