Class KernelPluginForge
- Namespace
- SemanticPluginForge
- Assembly
- SemanticPluginForge.Core.dll
Factory class for creating plugins with metadata.
public static class KernelPluginForge
- Inheritance
-
KernelPluginForge
- Inherited Members
Methods
CreateFromClrObjectWithMetadata(object, IServiceProvider, string)
Creates a plugin that wraps the specified target object and updates any metadata that it can find using IPluginMetadataProvider.
public static KernelPlugin CreateFromClrObjectWithMetadata(object target, IServiceProvider serviceProvider, string pluginName)
Parameters
target
objectThe instance of the class to be wrapped.
serviceProvider
IServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginName
stringName of the plugin for function collection.
Returns
- KernelPlugin
A Microsoft.SemanticKernel.KernelPlugin containing Microsoft.SemanticKernel.KernelFunctions for all relevant members of target.
Remarks
Methods that have the metadata defined using IPluginMetadataProvider will be included in the plugin.
CreateFromClrTypeWithMetadata<T>(IServiceProvider, string)
Creates a plugin that wraps a new instance of the specified type T and updates any metadata that it can find using IPluginMetadataProvider.
public static KernelPlugin CreateFromClrTypeWithMetadata<T>(IServiceProvider serviceProvider, string pluginName)
Parameters
serviceProvider
IServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginName
stringName of the plugin for function collection.
Returns
- KernelPlugin
A Microsoft.SemanticKernel.KernelPlugin containing Microsoft.SemanticKernel.KernelFunctions for all relevant members of target.
Type Parameters
T
Specifies the type of the object to wrap.
Remarks
Methods that have the metadata defined using IPluginMetadataProvider will be included in the plugin.
CreateFromFunctionsWithMetadata(IServiceProvider, string, IEnumerable<KernelFunction>?)
Creates a plugin that wraps the specified functions and updates any metadata that it can find using IPluginMetadataProvider.
public static KernelPlugin CreateFromFunctionsWithMetadata(IServiceProvider serviceProvider, string pluginName, IEnumerable<KernelFunction>? functions)
Parameters
serviceProvider
IServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginName
stringName 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.
functions
IEnumerable<KernelFunction>The initial functions to be available as part of the plugin.
Returns
- KernelPlugin
A Microsoft.SemanticKernel.KernelPlugin containing Microsoft.SemanticKernel.KernelFunctions for all relevant members of target.
Remarks
Methods that have the Microsoft.SemanticKernel.KernelFunctionAttribute attribute will be included in the plugin. See Microsoft.SemanticKernel.KernelFunctionAttribute attribute for details.
CreateFromObjectWithMetadata(object, IServiceProvider, string?)
Creates a plugin that wraps the specified target object and updates any metadata that it can find using IPluginMetadataProvider.
public static KernelPlugin CreateFromObjectWithMetadata(object target, IServiceProvider serviceProvider, string? pluginName = null)
Parameters
target
objectThe instance of the class to be wrapped.
serviceProvider
IServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginName
stringName 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
- KernelPlugin
A Microsoft.SemanticKernel.KernelPlugin containing Microsoft.SemanticKernel.KernelFunctions for all relevant members of target.
Remarks
Methods that have the Microsoft.SemanticKernel.KernelFunctionAttribute attribute will be included in the plugin. See Microsoft.SemanticKernel.KernelFunctionAttribute attribute for details.
CreateFromTypeWithMetadata<T>(IServiceProvider, string?)
Creates a plugin that wraps a new instance of the specified type T and updates any metadata that it can find using IPluginMetadataProvider.
public static KernelPlugin CreateFromTypeWithMetadata<T>(IServiceProvider serviceProvider, string? pluginName = null)
Parameters
serviceProvider
IServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginName
stringName of the plugin for function collection. If the value is null, a plugin name is derived from the type of T.
Returns
- KernelPlugin
A Microsoft.SemanticKernel.KernelPlugin containing Microsoft.SemanticKernel.KernelFunctions for all relevant members of target.
Type Parameters
T
Specifies the type of the object to wrap.
Remarks
Methods that have the Microsoft.SemanticKernel.KernelFunctionAttribute attribute will be included in the plugin. See Microsoft.SemanticKernel.KernelFunctionAttribute attribute for details.
PatchKernelPluginWithMetadata(KernelPlugin, IPluginMetadataProvider)
Using the IPluginMetadataProvider if there are any updates to the plugin, creates a new plugin or returns the same instance.
public static KernelPlugin PatchKernelPluginWithMetadata(KernelPlugin plugin, IPluginMetadataProvider metadataProvider)
Parameters
plugin
KernelPluginA Microsoft.SemanticKernel.KernelPlugin containing the original functions wrapped.
metadataProvider
IPluginMetadataProviderImplementation of IPluginMetadataProvider which can be used to update the plugin.
Returns
- KernelPlugin
A Microsoft.SemanticKernel.KernelPlugin containing Microsoft.SemanticKernel.KernelFunctions for all relevant members of target.