Freigeben über


KernelExtensions.AddFromObject Method

Definition

Overloads

AddFromObject(IKernelBuilderPlugins, Object, String)

Creates a plugin that wraps the specified target object and adds it into the plugin collection.

AddFromObject(ICollection<KernelPlugin>, Object, String, IServiceProvider)

Creates a plugin that wraps the specified target object and adds it into the plugin collection.

AddFromObject(IKernelBuilderPlugins, Object, String)

Creates a plugin that wraps the specified target object and adds it into the plugin collection.

public static Microsoft.SemanticKernel.IKernelBuilderPlugins AddFromObject (this Microsoft.SemanticKernel.IKernelBuilderPlugins plugins, object target, string? pluginName = default);
static member AddFromObject : Microsoft.SemanticKernel.IKernelBuilderPlugins * obj * string -> Microsoft.SemanticKernel.IKernelBuilderPlugins
<Extension()>
Public Function AddFromObject (plugins As IKernelBuilderPlugins, target As Object, Optional pluginName As String = Nothing) As IKernelBuilderPlugins

Parameters

plugins
IKernelBuilderPlugins

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

target
Object

The instance of the class to be wrapped.

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 target.

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

AddFromObject(ICollection<KernelPlugin>, Object, String, IServiceProvider)

Creates a plugin that wraps the specified target object and adds it into the plugin collection.

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

Parameters

plugins
ICollection<KernelPlugin>

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

target
Object

The instance of the class to be wrapped.

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 target.

serviceProvider
IServiceProvider

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

Returns

A KernelPlugin containing KernelFunctions for all relevant members of target.

Remarks

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

Applies to