Partager via


KernelExtensions.AddFromType Method

Definition

Overloads

AddFromType<T>(IKernelBuilderPlugins, String)

Creates a plugin that wraps a new instance of the specified type T and adds it into the plugin collection.

AddFromType<T>(ICollection<KernelPlugin>, String, IServiceProvider)

Creates a plugin that wraps a new instance of the specified type T and adds it into the plugin collection.

AddFromType<T>(IKernelBuilderPlugins, String)

Creates a plugin that wraps a new instance of the specified type T and adds it into the plugin collection.

public static Microsoft.SemanticKernel.IKernelBuilderPlugins AddFromType<T> (this Microsoft.SemanticKernel.IKernelBuilderPlugins plugins, string? pluginName = default);
static member AddFromType : Microsoft.SemanticKernel.IKernelBuilderPlugins * string -> Microsoft.SemanticKernel.IKernelBuilderPlugins
<Extension()>
Public Function AddFromType(Of T) (plugins As IKernelBuilderPlugins, Optional pluginName As String = Nothing) As IKernelBuilderPlugins

Type Parameters

T

Specifies the type of the object to wrap.

Parameters

plugins
IKernelBuilderPlugins

The plugin collection to which the new plugin should be added.

pluginName
String

Name of the plugin for function collection and prompt templates. If the value is null, a plugin name is derived from the type of the T.

Returns

The same instance as plugins.

Remarks

Methods that have the KernelFunctionAttribute attribute will be included in the plugin. See KernelFunctionAttribute attribute for details.

Applies to

AddFromType<T>(ICollection<KernelPlugin>, String, IServiceProvider)

Creates a plugin that wraps a new instance of the specified type T and adds it into the plugin collection.

public static Microsoft.SemanticKernel.KernelPlugin AddFromType<T> (this System.Collections.Generic.ICollection<Microsoft.SemanticKernel.KernelPlugin> plugins, string? pluginName = default, IServiceProvider? serviceProvider = default);
static member AddFromType : System.Collections.Generic.ICollection<Microsoft.SemanticKernel.KernelPlugin> * string * IServiceProvider -> Microsoft.SemanticKernel.KernelPlugin
<Extension()>
Public Function AddFromType(Of T) (plugins As ICollection(Of KernelPlugin), Optional pluginName As String = Nothing, Optional serviceProvider As IServiceProvider = Nothing) As KernelPlugin

Type Parameters

T

Specifies the type of the object to wrap.

Parameters

plugins
ICollection<KernelPlugin>

The plugin collection to which the new plugin should be added.

pluginName
String

Name of the plugin for function collection and prompt templates. If the value is null, a plugin name is derived from the type of the T.

serviceProvider
IServiceProvider

Service provider from which to resolve dependencies, such as ILoggerFactory.

Returns

A KernelPlugin containing KernelFunctions for all relevant members of T.

Remarks

Methods that have the KernelFunctionAttribute attribute will be included in the plugin. See KernelFunctionAttribute attribute for details.

Applies to