Class KernelFunctionFromPrompt<T>
- java.lang.Object
-
- com.microsoft.semantickernel.semanticfunctions.KernelFunction<T>
-
- com.microsoft.semantickernel.semanticfunctions.KernelFunctionFromPrompt<T>
-
- Type Parameters:
T- the type of the return value of the function
public class KernelFunctionFromPrompt<T> extends KernelFunction<T>
AKernelFunctionimplementation that is created from a prompt template.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKernelFunctionFromPrompt.Builder<T>A builder for creating aKernelFunctionfrom a prompt template.-
Nested classes/interfaces inherited from class com.microsoft.semantickernel.semanticfunctions.KernelFunction
KernelFunction.FromPromptBuilder<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> KernelFunctionFromPrompt.Builder<T>builder()Creates a new instance ofKernelFunctionFromPrompt.Builder.static <T> KernelFunctionFromPrompt.Builder<T>builder(Class<T> returnType)Creates a new instance ofKernelFunctionFromPrompt.Builder.reactor.core.publisher.Mono<FunctionResult<T>>invokeAsync(Kernel kernel, KernelFunctionArguments arguments, ContextVariableType<T> variableType, InvocationContext invocationContext)Invokes this KernelFunction.-
Methods inherited from class com.microsoft.semantickernel.semanticfunctions.KernelFunction
createFromMethod, createFromPrompt, createFromPrompt, getDescription, getExecutionSettings, getMetadata, getName, getPluginName, invoke, invoke, invokeAsync, toEmbeddingString, toManualString
-
-
-
-
Method Detail
-
builder
public static <T> KernelFunctionFromPrompt.Builder<T> builder()
Creates a new instance ofKernelFunctionFromPrompt.Builder.- Type Parameters:
T- The type of the return value of the function- Returns:
- a new instance of
KernelFunctionFromPrompt.Builder
-
builder
public static <T> KernelFunctionFromPrompt.Builder<T> builder(Class<T> returnType)
Creates a new instance ofKernelFunctionFromPrompt.Builder.- Type Parameters:
T- The type of the return value of the function- Parameters:
returnType- The type of the return value of the function- Returns:
- a new instance of
KernelFunctionFromPrompt.Builder
-
invokeAsync
public reactor.core.publisher.Mono<FunctionResult<T>> invokeAsync(Kernel kernel, @Nullable KernelFunctionArguments arguments, @Nullable ContextVariableType<T> variableType, @Nullable InvocationContext invocationContext)
Description copied from class:KernelFunctionInvokes this KernelFunction.If the
variableTypeparameter is provided, theContextVariableTypeis used to convert the result of the function to the appropriateFunctionResult. ThevariableTypeis not required for converting well-known types such asStringandIntegerwhich have pre-definedContextVariableTypes.The
InvocationContextallows for customization of the behavior of function, including the ability to pass inKernelHooksPromptExecutionSettings, andToolCallBehavior.The difference between calling the
KernelFunction.invokeAsyncmethod directly and calling theKernel.invokeAsyncmethod is that the latter adds the global KernelHooks (if any) to theInvocationContext. CallingKernelFunction.invokeAsyncdirectly does not add the global hooks.- Specified by:
invokeAsyncin classKernelFunction<T>- Parameters:
kernel- The Kernel containing services, plugins, and other state for use throughout the operation.arguments- The arguments to pass to the function's invocationvariableType- The type of theContextVariablereturned in theFunctionResultinvocationContext- The arguments to pass to the function's invocation- Returns:
- The result of the function's execution.
- See Also:
FunctionResult.getResultVariable()
-
-