Share via


FunctionChoiceBehavior Class

Definition

Represents the base class for different function choice behaviors. These behaviors define the way functions are chosen by AI model and various aspects of their invocation by AI connectors.

[System.Text.Json.Serialization.JsonDerivedType(typeof(Microsoft.SemanticKernel.AutoFunctionChoiceBehavior), "auto")]
[System.Text.Json.Serialization.JsonDerivedType(typeof(Microsoft.SemanticKernel.RequiredFunctionChoiceBehavior), "required")]
[System.Text.Json.Serialization.JsonDerivedType(typeof(Microsoft.SemanticKernel.NoneFunctionChoiceBehavior), "none")]
[System.Text.Json.Serialization.JsonPolymorphic(TypeDiscriminatorPropertyName="type")]
public abstract class FunctionChoiceBehavior
[<System.Text.Json.Serialization.JsonDerivedType(typeof(Microsoft.SemanticKernel.AutoFunctionChoiceBehavior), "auto")>]
[<System.Text.Json.Serialization.JsonDerivedType(typeof(Microsoft.SemanticKernel.RequiredFunctionChoiceBehavior), "required")>]
[<System.Text.Json.Serialization.JsonDerivedType(typeof(Microsoft.SemanticKernel.NoneFunctionChoiceBehavior), "none")>]
[<System.Text.Json.Serialization.JsonPolymorphic(TypeDiscriminatorPropertyName="type")>]
type FunctionChoiceBehavior = class
Public MustInherit Class FunctionChoiceBehavior
Inheritance
FunctionChoiceBehavior
Attributes

Fields

DefaultOptions

The behavior default options.

FunctionNameSeparator

The separator used to separate plugin name and function name.

Methods

Auto(IEnumerable<KernelFunction>, Boolean, FunctionChoiceBehaviorOptions)

Gets an instance of the FunctionChoiceBehavior that provides either all of the Kernel's plugins' functions to the AI model to call or specified ones. This behavior allows the model to decide whether to call the functions and, if so, which ones to call.

GetConfiguration(FunctionChoiceBehaviorConfigurationContext)

Returns the configuration used by AI connectors to determine function choice and invocation behavior.

GetFunctions(IList<String>, Kernel, Boolean)

Returns functions AI connector should provide to the AI model.

None(IEnumerable<KernelFunction>, FunctionChoiceBehaviorOptions)

Gets an instance of the FunctionChoiceBehavior that provides either all of the Kernel's plugins' functions to AI model to call or specified ones but instructs it not to call any of them. The model may use the provided function in the response it generates. E.g. the model may describe which functions it would call and with what parameter values. This response is useful if the user should first validate what functions the model will use.

Required(IEnumerable<KernelFunction>, Boolean, FunctionChoiceBehaviorOptions)

Gets an instance of the FunctionChoiceBehavior that provides either all of the Kernel's plugins' functions to the AI model to call or specified ones. This behavior forces the model to call the provided functions. SK connectors will invoke a requested function or multiple requested functions if the model requests multiple ones in one request, while handling the first request, and stop advertising the functions for the following requests to prevent the model from repeatedly calling the same function(s).

Applies to