Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ public static FunctionChoiceBehavior auto(boolean autoInvoke) {
return new AutoFunctionChoiceBehavior(autoInvoke, null, null);
}

/**
* Gets an instance of the FunctionChoiceBehavior that provides either all the Kernel's plugins functions to the AI model to call or specific functions.
*
* @param 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.
* @param functions Functions to provide to the model. If null, all the Kernel's plugins' functions are provided to the model.
* If empty, no functions are provided to the model, which is equivalent to disabling function calling.
*
* @return A new FunctionChoiceBehavior instance with all kernel functions allowed.
*/
public static FunctionChoiceBehavior auto(boolean autoInvoke,
@Nullable List<KernelFunction<?>> functions) {
return new AutoFunctionChoiceBehavior(autoInvoke, functions, null);
}

/**
* Gets an instance of the FunctionChoiceBehavior that provides either all the Kernel's plugins functions to the AI model to call or specific functions.
*
Expand All @@ -79,11 +95,25 @@ public static FunctionChoiceBehavior auto(boolean autoInvoke) {
* @return A new FunctionChoiceBehavior instance with all kernel functions allowed.
*/
public static FunctionChoiceBehavior auto(boolean autoInvoke,
List<KernelFunction<?>> functions,
@Nullable FunctionChoiceBehaviorOptions options) {
@Nullable List<KernelFunction<?>> functions,
@Nullable FunctionChoiceBehaviorOptions options) {
return new AutoFunctionChoiceBehavior(autoInvoke, functions, options);
}

/**
* Gets an instance of the FunctionChoiceBehavior that provides either all the Kernel's plugins functions to the AI model to call or specific functions.
* <p>
* 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).
*
* @return A new FunctionChoiceBehavior instance with the required function.
*/
public static FunctionChoiceBehavior required(boolean autoInvoke,
@Nullable List<KernelFunction<?>> functions) {
return new RequiredFunctionChoiceBehavior(autoInvoke, functions, null);
}

/**
* Gets an instance of the FunctionChoiceBehavior that provides either all the Kernel's plugins functions to the AI model to call or specific functions.
* <p>
Expand All @@ -96,11 +126,20 @@ public static FunctionChoiceBehavior auto(boolean autoInvoke,
* @return A new FunctionChoiceBehavior instance with the required function.
*/
public static FunctionChoiceBehavior required(boolean autoInvoke,
List<KernelFunction<?>> functions,
@Nullable FunctionChoiceBehaviorOptions options) {
@Nullable List<KernelFunction<?>> functions,
@Nullable FunctionChoiceBehaviorOptions options) {
return new RequiredFunctionChoiceBehavior(autoInvoke, functions, options);
}

/**
* Gets an instance of the FunctionChoiceBehavior that provides either all the Kernel's plugins functions to the AI model to call or specific functions.
* <p>
* This behavior is useful if the user should first validate what functions the model will use.
*/
public static FunctionChoiceBehavior none() {
return new NoneFunctionChoiceBehavior(null, null);
}

/**
* Gets an instance of the FunctionChoiceBehavior that provides either all the Kernel's plugins functions to the AI model to call or specific functions.
* <p>
Expand All @@ -109,7 +148,7 @@ public static FunctionChoiceBehavior required(boolean autoInvoke,
* @param functions Functions to provide to the model. If null, all the Kernel's plugins' functions are provided to the model.
* If empty, no functions are provided to the model, which is equivalent to disabling function calling.
*/
public static FunctionChoiceBehavior none(List<KernelFunction<?>> functions,
public static FunctionChoiceBehavior none(@Nullable List<KernelFunction<?>> functions,
@Nullable FunctionChoiceBehaviorOptions options) {
return new NoneFunctionChoiceBehavior(functions, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

import com.microsoft.semantickernel.semanticfunctions.KernelFunction;

import javax.annotation.Nullable;
import java.util.List;

public class NoneFunctionChoiceBehavior extends FunctionChoiceBehavior {

/**
* Create a new instance of NoneFunctionChoiceBehavior.
*/
public NoneFunctionChoiceBehavior(List<KernelFunction<?>> functions,
FunctionChoiceBehaviorOptions options) {
public NoneFunctionChoiceBehavior(@Nullable List<KernelFunction<?>> functions,
@Nullable FunctionChoiceBehaviorOptions options) {
super(functions, options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import com.microsoft.semantickernel.semanticfunctions.KernelFunction;

import javax.annotation.Nullable;
import java.util.List;

public class RequiredFunctionChoiceBehavior extends AutoFunctionChoiceBehavior {
Expand All @@ -14,8 +15,9 @@ public class RequiredFunctionChoiceBehavior extends AutoFunctionChoiceBehavior {
* @param functions A set of functions to advertise to the model.
* @param options Options for the function choice behavior.
*/
public RequiredFunctionChoiceBehavior(boolean autoInvoke, List<KernelFunction<?>> functions,
FunctionChoiceBehaviorOptions options) {
public RequiredFunctionChoiceBehavior(boolean autoInvoke,
@Nullable List<KernelFunction<?>> functions,
@Nullable FunctionChoiceBehaviorOptions options) {
super(autoInvoke, functions, options);
}
}