Partager via


Kernel Class

Definition

Provides state for use throughout a Semantic Kernel workload.

public sealed class Kernel
type Kernel = class
Public NotInheritable Class Kernel
Inheritance
Kernel

Remarks

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.

Constructors

Kernel(IServiceProvider, KernelPluginCollection)

Initializes a new instance of Kernel.

Properties

AutoFunctionInvocationFilters

Gets the collection of auto function invocation filters available through the kernel.

Culture

Gets the culture currently associated with this Kernel.

Data

Gets a dictionary for ambient data associated with the kernel.

FunctionInvocationFilters

Gets the collection of function filters available through the kernel.

LoggerFactory

Gets the ILoggerFactory associated with this Kernel.

Plugins

Gets the collection of plugins available through the kernel.

PromptRenderFilters

Gets the collection of function filters available through the kernel.

Services

Gets the service provider used to query for services available through the kernel.

ServiceSelector

Gets the IAIServiceSelector associated with this Kernel.

Methods

Clone()

Clone the Kernel object to create a new instance that may be mutated without affecting the current instance.

CreateBuilder()

Creates a builder for constructing Kernel instances.

GetAllServices<T>()

Gets all services of the specified type.

GetRequiredService<T>(Object)

Gets a required service from the Services provider.

InvokeAsync(KernelFunction, KernelArguments, CancellationToken)

Invokes the KernelFunction.

InvokeAsync(String, String, KernelArguments, CancellationToken)

Invokes a function from Plugins using the specified arguments.

InvokeAsync<TResult>(KernelFunction, KernelArguments, CancellationToken)

Invokes the KernelFunction.

InvokeAsync<TResult>(String, String, KernelArguments, CancellationToken)

Invokes a function from Plugins using the specified arguments.

InvokeStreamingAsync(KernelFunction, KernelArguments, CancellationToken)

Invokes the KernelFunction and streams its results.

InvokeStreamingAsync(String, String, KernelArguments, CancellationToken)

Invokes the KernelFunction and streams its results.

InvokeStreamingAsync<T>(KernelFunction, KernelArguments, CancellationToken)

Invokes the KernelFunction and streams its results.

InvokeStreamingAsync<T>(String, String, KernelArguments, CancellationToken)

Invokes the KernelFunction and streams its results.

Events

FunctionInvoked
Obsolete.

Provides an event that's raised after a function's invocation.

FunctionInvoking
Obsolete.

Provides an event that's raised prior to a function's invocation.

PromptRendered
Obsolete.

Provides an event that's raised after a prompt is rendered.

PromptRendering
Obsolete.

Provides an event that's raised prior to a prompt being rendered.

Extension Methods

InvokeHandlebarsPromptAsync(Kernel, String, KernelArguments, CancellationToken)

Invokes a prompt specified via a prompt template in the Handlebars prompt template format.

CreateFunctionFromMethod(Kernel, Delegate, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata)

Creates a KernelFunction instance for a method, specified via a delegate.

CreateFunctionFromMethod(Kernel, MethodInfo, Object, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata)

Creates a KernelFunction instance for a method, specified via an MethodInfo instance and an optional target object if the method is an instance method.

CreateFunctionFromPrompt(Kernel, PromptTemplateConfig, IPromptTemplateFactory)

Creates a KernelFunction instance for a prompt specified via a prompt template configuration.

CreateFunctionFromPrompt(Kernel, String, PromptExecutionSettings, String, String, String, IPromptTemplateFactory)

Creates a KernelFunction instance for a prompt specified via a prompt template.

CreateFunctionFromPrompt(Kernel, String, IEnumerable<PromptExecutionSettings>, String, String, String, IPromptTemplateFactory)

Creates a KernelFunction instance for a prompt specified via a prompt template.

CreatePluginFromFunctions(Kernel, String, IEnumerable<KernelFunction>)

Creates a plugin that contains the specified functions.

CreatePluginFromFunctions(Kernel, String, String, IEnumerable<KernelFunction>)

Creates a plugin that contains the specified functions.

CreatePluginFromObject(Kernel, Object, String)

Creates a plugin that wraps the specified target object.

CreatePluginFromPromptDirectory(Kernel, String, String, IPromptTemplateFactory)

Creates a plugin containing one function per child directory of the specified pluginDirectory.

CreatePluginFromType<T>(Kernel, String)

Creates a plugin that wraps a new instance of the specified type T.

ImportPluginFromFunctions(Kernel, String, IEnumerable<KernelFunction>)

Creates a plugin that contains the specified functions and imports it into the kernel's plugin collection.

ImportPluginFromFunctions(Kernel, String, String, IEnumerable<KernelFunction>)

Creates a plugin that contains the specified functions and imports it into the kernel's plugin collection.

ImportPluginFromObject(Kernel, Object, String)

Creates a plugin that wraps the specified target object and imports it into the kernel's plugin collection.

ImportPluginFromPromptDirectory(Kernel, String, String, IPromptTemplateFactory)

Creates a plugin containing one function per child directory of the specified pluginDirectory and imports it into the kernel's plugin collection.

ImportPluginFromType<T>(Kernel, String)

Creates a plugin that wraps a new instance of the specified type T and imports it into the kernel's plugin collection.

InvokePromptAsync(Kernel, String, KernelArguments, String, IPromptTemplateFactory, CancellationToken)

Invokes a prompt specified via a prompt template.

InvokePromptAsync<T>(Kernel, String, KernelArguments, String, IPromptTemplateFactory, CancellationToken)

Invokes a prompt specified via a prompt template and returns the results of type T.

InvokePromptAsync<T>(Kernel, String, KernelArguments, String, IPromptTemplateFactory)

Invokes a prompt specified via a prompt template and returns the results of type T.

InvokePromptStreamingAsync(Kernel, String, KernelArguments, String, IPromptTemplateFactory, CancellationToken)

Invokes a prompt specified via a prompt template and streams its results.

InvokePromptStreamingAsync<T>(Kernel, String, KernelArguments, String, IPromptTemplateFactory, CancellationToken)

Invokes a prompt specified via a prompt template and streams its results of type T.

CreateFunctionFromMarkdown(Kernel, String, String, IPromptTemplateFactory)

Creates a KernelFunction instance for a prompt function using the specified markdown text.

CreatePluginFromGrpc(Kernel, Stream, String)

Registers an gRPC plugin.

CreatePluginFromGrpcDirectory(Kernel, String, String)

Imports gRPC document from a directory.

CreatePluginFromGrpcFile(Kernel, String, String)

Imports gRPC document from a file.

ImportPluginFromGrpc(Kernel, Stream, String)

Registers an gRPC plugin.

ImportPluginFromGrpcDirectory(Kernel, String, String)

Imports gRPC document from a directory.

ImportPluginFromGrpcFile(Kernel, String, String)

Imports gRPC document from a file.

CreatePluginFromApiManifestAsync(Kernel, String, String, ApiManifestPluginParameters, CancellationToken)

Creates a kernel plugin from an API manifest file asynchronously.

ImportPluginFromApiManifestAsync(Kernel, String, String, ApiManifestPluginParameters, CancellationToken)

Imports a plugin from an API manifest asynchronously.

CreatePluginFromOpenApiAsync(Kernel, String, Stream, OpenApiFunctionExecutionParameters, CancellationToken)

Creates a plugin from an OpenAPI specification.

CreatePluginFromOpenApiAsync(Kernel, String, String, OpenApiFunctionExecutionParameters, CancellationToken)

Creates a plugin from an OpenAPI specification.

CreatePluginFromOpenApiAsync(Kernel, String, Uri, OpenApiFunctionExecutionParameters, CancellationToken)

Creates a plugin from an OpenAPI specification.

ImportPluginFromOpenApiAsync(Kernel, String, Stream, OpenApiFunctionExecutionParameters, CancellationToken)

Creates a plugin from an OpenAPI specification and adds it to the kernel's plugins collection.

ImportPluginFromOpenApiAsync(Kernel, String, String, OpenApiFunctionExecutionParameters, CancellationToken)

Creates a plugin from an OpenAPI specification and adds it to the kernel's plugins collection.

ImportPluginFromOpenApiAsync(Kernel, String, Uri, OpenApiFunctionExecutionParameters, CancellationToken)

Creates a plugin from an OpenAPI specification and adds it to the kernel's plugins collection.

CreateFunctionFromPromptYaml(Kernel, String, IPromptTemplateFactory)

Creates a KernelFunction instance for a prompt function using the specified YAML.

CreateFunctionFromPrompty(Kernel, String, IPromptTemplateFactory)

Create a KernelFunction from a prompty template.

CreateFunctionFromPromptyFile(Kernel, IFileInfo, IPromptTemplateFactory)

Create a KernelFunction from a prompty template file.

CreateFunctionFromPromptyFile(Kernel, String, IFileProvider, IPromptTemplateFactory)

Create a KernelFunction from a prompty template file.

CreateFunctionFromPromptyFile(Kernel, String, IPromptTemplateFactory)

Create a KernelFunction from a prompty template file.

Applies to