Class AddPluginExtensions
- Namespace
- SemanticPluginForge
- Assembly
- SemanticPluginForge.Core.dll
Extension methods for adding plugins to the plugin collection.
public static class AddPluginExtensions
- Inheritance
-
AddPluginExtensions
- Inherited Members
Methods
AddFromClrObjectWithMetadata(IKernelBuilderPlugins, object, string)
Creates a plugin that wraps the specified target object and updates any metadata that it can find using IPluginMetadataProvider and adds it into the plugin collection.
public static IKernelBuilderPlugins AddFromClrObjectWithMetadata(this IKernelBuilderPlugins plugins, object target, string pluginName)
Parameters
plugins
IKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
target
objectThe instance of the class to be wrapped.
pluginName
stringName of the plugin for function collection.
Returns
- IKernelBuilderPlugins
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.
AddFromClrObjectWithMetadata(ICollection<KernelPlugin>, object, IServiceProvider, string)
Creates a plugin that wraps the specified target object and updates any metadata that it can find using IPluginMetadataProvider and adds it into the plugin collection.
public static KernelPlugin AddFromClrObjectWithMetadata(this ICollection<KernelPlugin> plugins, object target, IServiceProvider serviceProvider, string pluginName)
Parameters
plugins
ICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
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.
AddFromClrTypeWithMetadata<T>(IKernelBuilderPlugins, string)
Creates a plugin that wraps a new instance of the specified type T and updates any metadata that it can find using IPluginMetadataProvider and adds it into the plugin collection.
public static IKernelBuilderPlugins AddFromClrTypeWithMetadata<T>(this IKernelBuilderPlugins plugins, string pluginName)
Parameters
plugins
IKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
pluginName
stringName of the plugin for function collection.
Returns
- IKernelBuilderPlugins
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.
AddFromClrTypeWithMetadata<T>(ICollection<KernelPlugin>, 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 and adds it into the plugin collection.
public static KernelPlugin AddFromClrTypeWithMetadata<T>(this ICollection<KernelPlugin> plugins, IServiceProvider serviceProvider, string pluginName)
Parameters
plugins
ICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
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.
AddFromFunctionsWithMetadata(IKernelBuilderPlugins, string, IEnumerable<KernelFunction>?)
Creates a plugin that wraps the specified functions and updates any metadata that it can find using IPluginMetadataProvider and adds it into the plugin collection.
public static IKernelBuilderPlugins AddFromFunctionsWithMetadata(this IKernelBuilderPlugins plugins, string pluginName, IEnumerable<KernelFunction>? functions)
Parameters
plugins
IKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
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
- IKernelBuilderPlugins
The same instance as plugins
Remarks
Methods that have the Microsoft.SemanticKernel.KernelFunctionAttribute attribute will be included in the plugin. See Microsoft.SemanticKernel.KernelFunctionAttribute attribute for details.
AddFromFunctionsWithMetadata(ICollection<KernelPlugin>, IServiceProvider, string, IEnumerable<KernelFunction>?)
Creates a plugin that wraps the specified functions and updates any metadata that it can find using IPluginMetadataProvider and adds it into the plugin collection.
public static KernelPlugin AddFromFunctionsWithMetadata(this ICollection<KernelPlugin> plugins, IServiceProvider serviceProvider, string pluginName, IEnumerable<KernelFunction>? functions)
Parameters
plugins
ICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
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.
AddFromObjectWithMetadata(IKernelBuilderPlugins, object, string?)
Creates a plugin that wraps the specified target object and updates any metadata that it can find using IPluginMetadataProvider and adds it into the plugin collection.
public static IKernelBuilderPlugins AddFromObjectWithMetadata(this IKernelBuilderPlugins plugins, object target, string? pluginName = null)
Parameters
plugins
IKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
target
objectThe instance of the class to be wrapped.
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
- IKernelBuilderPlugins
The same instance as plugins
Remarks
Methods that have the Microsoft.SemanticKernel.KernelFunctionAttribute attribute will be included in the plugin. See Microsoft.SemanticKernel.KernelFunctionAttribute attribute for details.
AddFromObjectWithMetadata(ICollection<KernelPlugin>, object, IServiceProvider, string?)
Creates a plugin that wraps the specified target object and updates any metadata that it can find using IPluginMetadataProvider and adds it into the plugin collection.
public static KernelPlugin AddFromObjectWithMetadata(this ICollection<KernelPlugin> plugins, object target, IServiceProvider serviceProvider, string? pluginName = null)
Parameters
plugins
ICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
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.
AddFromOpenApiWithMetadataAsync(Kernel, string, Stream, OpenApiFunctionExecutionParameters?, CancellationToken)
Creates a plugin from an OpenAPI definition stream, updates its metadata, and adds it to the kernel's plugin collection.
public static Task<KernelPlugin> AddFromOpenApiWithMetadataAsync(this Kernel kernel, string pluginName, Stream stream, OpenApiFunctionExecutionParameters? executionParameters = null, CancellationToken cancellationToken = default)
Parameters
kernel
KernelThe Microsoft.SemanticKernel.Kernel containing services, plugins, and other state for use throughout the operation.
pluginName
stringThe name of the plugin.
stream
StreamThe stream representing the OpenAPI definition.
executionParameters
OpenApiFunctionExecutionParametersOptional execution parameters for the plugin.
cancellationToken
CancellationTokenA cancellation token to observe while waiting for the task to complete.
Returns
- Task<KernelPlugin>
A task representing the asynchronous operation. The task result contains the added Microsoft.SemanticKernel.KernelPlugin.
AddFromOpenApiWithMetadataAsync(Kernel, string, string, OpenApiFunctionExecutionParameters?, CancellationToken)
Creates a plugin from an OpenAPI definition file, updates its metadata, and adds it to the kernel's plugin collection.
public static Task<KernelPlugin> AddFromOpenApiWithMetadataAsync(this Kernel kernel, string pluginName, string filePath, OpenApiFunctionExecutionParameters? executionParameters = null, CancellationToken cancellationToken = default)
Parameters
kernel
KernelThe Microsoft.SemanticKernel.Kernel containing services, plugins, and other state for use throughout the operation.
pluginName
stringThe name of the plugin.
filePath
stringThe file path to the OpenAPI definition file.
executionParameters
OpenApiFunctionExecutionParametersOptional execution parameters for the plugin.
cancellationToken
CancellationTokenA cancellation token to observe while waiting for the task to complete.
Returns
- Task<KernelPlugin>
A task representing the asynchronous operation. The task result contains the added Microsoft.SemanticKernel.KernelPlugin.
AddFromOpenApiWithMetadataAsync(Kernel, string, Uri, OpenApiFunctionExecutionParameters?, CancellationToken)
Creates a plugin from an OpenAPI definition URI, updates its metadata, and adds it to the kernel's plugin collection.
public static Task<KernelPlugin> AddFromOpenApiWithMetadataAsync(this Kernel kernel, string pluginName, Uri uri, OpenApiFunctionExecutionParameters? executionParameters = null, CancellationToken cancellationToken = default)
Parameters
kernel
KernelThe Microsoft.SemanticKernel.Kernel containing services, plugins, and other state for use throughout the operation.
pluginName
stringThe name of the plugin.
uri
UriThe URI to the OpenAPI definition.
executionParameters
OpenApiFunctionExecutionParametersOptional execution parameters for the plugin.
cancellationToken
CancellationTokenA cancellation token to observe while waiting for the task to complete.
Returns
- Task<KernelPlugin>
A task representing the asynchronous operation. The task result contains the added Microsoft.SemanticKernel.KernelPlugin.
AddFromTypeWithMetadata<T>(IKernelBuilderPlugins, string?)
Creates a plugin that wraps a new instance of the specified type T and updates any metadata that it can find using IPluginMetadataProvider and adds it into the plugin collection.
public static IKernelBuilderPlugins AddFromTypeWithMetadata<T>(this IKernelBuilderPlugins plugins, string? pluginName = null)
Parameters
plugins
IKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
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 T.
Returns
- IKernelBuilderPlugins
The same instance as plugins
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.
AddFromTypeWithMetadata<T>(ICollection<KernelPlugin>, 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 and adds it into the plugin collection.
public static KernelPlugin AddFromTypeWithMetadata<T>(this ICollection<KernelPlugin> plugins, IServiceProvider serviceProvider, string? pluginName = null)
Parameters
plugins
ICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
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 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.
AddPatchedKernelPluginWithMetadata(Kernel, KernelPlugin)
Adds the provided kernel plugin to the kernel's plugin collection after patching it with metadata.
public static KernelPlugin AddPatchedKernelPluginWithMetadata(this Kernel kernel, KernelPlugin kernelPlugin)
Parameters
kernel
KernelThe Microsoft.SemanticKernel.Kernel containing services, plugins, and other state for use throughout the operation.
kernelPlugin
KernelPluginThe kernel plugin to be patched and added.
Returns
- KernelPlugin
The patched and added Microsoft.SemanticKernel.KernelPlugin.
PatchKernelPluginWithMetadata(IServiceProvider, KernelPlugin)
Using the IPluginMetadataProvider if there are any updates to the plugin, creates a new plugin or returns the same instance.
public static KernelPlugin PatchKernelPluginWithMetadata(this IServiceProvider serviceProvider, KernelPlugin plugin)
Parameters
serviceProvider
IServiceProviderService provider from which to resolve dependencies, such as IPluginMetadataProvider.
plugin
KernelPluginA Microsoft.SemanticKernel.KernelPlugin containing the original functions wrapped.
Returns
- KernelPlugin
A new instance of Microsoft.SemanticKernel.KernelPlugin if any change was needed in the plugin otherwise the same instance is returned.