Kernel Class
- java.
lang. Object - com.
microsoft. semantickernel. Kernel
- com.
public class Kernel
Provides state for use throughout a Semantic Kernel workload.
An instance of Kernel
is passed through to every function invocation and service call throughout the system, providing to each the ability to access shared state and services.
Constructor | Description |
---|---|
Kernel(AIService |
Initializes a new instance of |
Modifier and Type | Method and Description |
---|---|
Kernel |
get Gets the function with the specified name from the plugin with the specified name. |
T |
get Get the service of the specified type from the kernel. |
Function |
invoke(Kernel Invokes a |
Function |
invoke(String plugin Invokes a |
Function |
invoke Invokes a |
Function |
invoke Invokes a |
Function |
invoke Invokes a Prompt. |
Function |
invoke Invokes a Prompt. |
Function |
invoke Invokes a Prompt. |
static Builder |
builder()
Get the fluent builder for creating a new instance of |
static Builder |
from(Kernel kernel)
Creates a Builder that can create a copy of the |
java.util.List<Kernel |
get Gets the functions available through the kernel. |
Kernel |
get Get the |
Kernel |
get Gets the plugin with the specified name. |
java.util.Collection<Kernel |
get Gets the plugins that were added to the kernel. |
AIService |
get Get the AIService |
Builder |
to Creates a Builder that can create a copy of the current instance of |
Kernel
public Kernel(AIServiceCollection services, Function
Initializes a new instance of Kernel
.
Parameters:
null
,
an ordered service selector will be used.
null
, an empty collection will be used.
null
, an empty collection will be used.
getFunction
public KernelFunction
Gets the function with the specified name from the plugin with the specified name.
Parameters:
Returns:
getService
public T
Get the service of the specified type from the kernel.
Parameters:
Returns:
Throws:
invoke
public FunctionResult
Invokes a KernelFunction
.
Parameters:
Returns:
invoke
public FunctionResult
Invokes a KernelFunction
function by name.
Parameters:
Returns:
invokeAsync
public FunctionInvocation
Invokes a KernelFunction
.
Parameters:
Returns:
invokeAsync
public FunctionInvocation
Invokes a KernelFunction
function by name.
Parameters:
Returns:
invokePromptAsync
public FunctionInvocation
Invokes a Prompt.
Parameters:
Returns:
invokePromptAsync
public FunctionInvocation
Invokes a Prompt.
Parameters:
Returns:
invokePromptAsync
public FunctionInvocation
Invokes a Prompt.
Parameters:
Returns:
builder
public static Kernel.Builder builder()
Get the fluent builder for creating a new instance of Kernel
.
Returns:
Kernel
.from
public static Kernel.Builder from(Kernel kernel)
Creates a Builder that can create a copy of the Kernel
. Use this method if you wish to modify the state of the kernel such as adding new plugins or services.
Parameters:
Returns:
Kernel
.getFunctions
public List
Gets the functions available through the kernel. Functions are collected from all plugins available through the kernel.
Returns:
getGlobalKernelHooks
public KernelHooks getGlobalKernelHooks()
Get the KernelHooks
used throughout the kernel. These KernelHooks
are used in addition to any hooks provided to a function.
Returns:
KernelHooks
used throughout the kernel.getPlugin
public KernelPlugin getPlugin(String pluginName)
Gets the plugin with the specified name.
Parameters:
Returns:
null
if no such plugin exists.getPlugins
public Collection
Gets the plugins that were added to the kernel.
Returns:
getServiceSelector
public AIServiceSelector getServiceSelector()
Get the AIServiceSelector used to query for services available through the kernel.
Returns:
toBuilder
public Kernel.Builder toBuilder()
Creates a Builder that can create a copy of the current instance of Kernel
. Use this method if you wish to modify the state of the kernel such as adding new plugins or services.
Returns:
Kernel
.