KernelFunctionFromPrompt<T> Class
- java.
lang. Object - com.
microsoft. semantickernel. semanticfunctions. KernelFunction<T> - com.
microsoft. semantickernel. semanticfunctions. KernelFunctionFromPrompt<T>
- com.
- com.
Type Parameters
- T
the type of the return value of the function
public class KernelFunctionFromPrompt
extends KernelFunction<T>
A KernelFunction<T> implementation that is created from a prompt template.
Constructor Summary
Modifier | Constructor | Description |
---|---|---|
protected | KernelFunctionFromPrompt(PromptTemplate template, PromptTemplateConfig promptConfig, Map<String,PromptExecutionSettings> executionSettings) |
Creates a new instance of KernelFunctionFromPrompt<T>. |
Method Summary
Modifier and Type | Method and Description |
---|---|
static Builder<T> |
builder()
Creates a new instance of KernelFunctionFromPrompt.Builder<T>. |
static Builder<T> |
builder(Class<T> returnType)
Creates a new instance of KernelFunctionFromPrompt.Builder<T>. |
reactor.core.publisher.Mono<Function |
invokeAsync(Kernel kernel, KernelFunctionArguments arguments, ContextVariableType<T> variableType, InvocationContext invocationContext)
Invokes this Kernel |
Methods inherited from KernelFunction
Methods inherited from java.lang.Object
Constructor Details
KernelFunctionFromPrompt
protected KernelFunctionFromPrompt(PromptTemplate template, PromptTemplateConfig promptConfig, Map
Creates a new instance of KernelFunctionFromPrompt<T>.
Parameters:
Method Details
builder
public static KernelFunctionFromPrompt.Builder
Creates a new instance of KernelFunctionFromPrompt.Builder<T>.
Returns:
builder
public static KernelFunctionFromPrompt.Builder
Creates a new instance of KernelFunctionFromPrompt.Builder<T>.
Parameters:
Returns:
invokeAsync
public Mono
Invokes this KernelFunction.
If the variableType
parameter is provided, the ContextVariableType<T> is used to convert the result of the function to the appropriate FunctionResult<T>. The variableType
is not required for converting well-known types such as String and Integer which have pre-defined ContextVariableType
s.
The InvocationContext allows for customization of the behavior of function, including the ability to pass in KernelHooks PromptExecutionSettings, and ToolCallBehavior.
The difference between calling the KernelFunction.invokeAsync
method directly and calling the Kernel.invokeAsync
method is that the latter adds the global KernelHooks (if any) to the InvocationContext. Calling KernelFunction.invokeAsync
directly does not add the global hooks.
Overrides:
KernelFunctionFromPrompt<T>.invokeAsync(Kernel kernel, KernelFunctionArguments arguments, ContextVariableType<T> variableType, InvocationContext invocationContext)Parameters: