Share via


ToolCallBehavior Class

  • java.lang.Object
    • com.microsoft.semantickernel.orchestration.ToolCallBehavior

public class ToolCallBehavior

Defines the behavior of a tool call. Currently, the only tool available is function calling.

Field Summary

Modifier and Type Field and Description
static final java.lang.String FUNCTION_NAME_SEPARATOR

The separator between the plugin name and the function name.

Method Summary

Modifier and Type Method and Description
static ToolCallBehavior allowAllKernelFunctions(boolean autoInvoke)

Allow all kernel functions.

static ToolCallBehavior allowOnlyKernelFunctions(boolean autoInvoke, KernelFunction<?>[] functions)

Allow a set of kernel functions.

static ToolCallBehavior allowOnlyKernelFunctions(boolean autoInvoke, List<KernelFunction<?>> functions)

Allow a set of kernel functions.

static java.lang.String formFullFunctionName(String pluginName, String functionName)

Form the full function name.

int getMaximumAutoInvokeAttempts()

Get the maximum number of times that auto-invocation will be attempted.

boolean isAutoInvokeAllowed()

Check whether auto-invocation is enabled.

static ToolCallBehavior requireKernelFunction(KernelFunction<?> function)

Require a function.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

FUNCTION_NAME_SEPARATOR

public static final String FUNCTION_NAME_SEPARATOR

The separator between the plugin name and the function name.

Method Details

allowAllKernelFunctions

public static ToolCallBehavior allowAllKernelFunctions(boolean autoInvoke)

Allow all kernel functions. All Kernel functions will be passed to the model.

Parameters:

autoInvoke - Enable or disable auto-invocation. If auto-invocation is enabled, the model may request that the Semantic Kernel invoke the kernel functions and return the value to the model.

Returns:

A new ToolCallBehavior instance with all kernel functions allowed.

allowOnlyKernelFunctions

public static ToolCallBehavior allowOnlyKernelFunctions(boolean autoInvoke, KernelFunction[] functions)

Allow a set of kernel functions. If a function is allowed, it may be called. If it is not allowed, it will not be called. By default, all functions are not allowed.

Parameters:

autoInvoke - Enable or disable auto-invocation. If auto-invocation is enabled, the model may request that the Semantic Kernel invoke the kernel functions and return the value to the model.
functions - The functions to allow.

Returns:

A new ToolCallBehavior instance with the allowed functions.

allowOnlyKernelFunctions

public static ToolCallBehavior allowOnlyKernelFunctions(boolean autoInvoke, List> functions)

Allow a set of kernel functions. If a function is allowed, it may be called. If it is not allowed, it will not be called. By default, all functions are not allowed.

Parameters:

autoInvoke - Enable or disable auto-invocation. If auto-invocation is enabled, the model may request that the Semantic Kernel invoke the kernel functions and return the value to the model.
functions - The functions to allow.

Returns:

A new ToolCallBehavior instance with the allowed functions.

formFullFunctionName

public static String formFullFunctionName(String pluginName, String functionName)

Form the full function name.

Parameters:

pluginName - The name of the plugin that the function is in.
functionName - The name of the function.

Returns:

The key for the function.

getMaximumAutoInvokeAttempts

public int getMaximumAutoInvokeAttempts()

Get the maximum number of times that auto-invocation will be attempted.

Returns:

The maximum number of attempts.

isAutoInvokeAllowed

public boolean isAutoInvokeAllowed()

Check whether auto-invocation is enabled.

Returns:

Whether auto-invocation is enabled.

requireKernelFunction

public static ToolCallBehavior requireKernelFunction(KernelFunction function)

Require a function. The required function will be the only function passed to the model and forces the model to call the function. Only one function can be required.

Parameters:

function - The function to require.

Returns:

A new ToolCallBehavior instance with the required function.

Applies to