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
pluginsIKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
targetobjectThe instance of the class to be wrapped.
pluginNamestringName 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
pluginsICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
targetobjectThe instance of the class to be wrapped.
serviceProviderIServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginNamestringName 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
pluginsIKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
pluginNamestringName of the plugin for function collection.
Returns
- IKernelBuilderPlugins
A Microsoft.SemanticKernel.KernelPlugin containing Microsoft.SemanticKernel.KernelFunctions for all relevant members of target.
Type Parameters
TSpecifies 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
pluginsICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
serviceProviderIServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginNamestringName of the plugin for function collection.
Returns
- KernelPlugin
A Microsoft.SemanticKernel.KernelPlugin containing Microsoft.SemanticKernel.KernelFunctions for all relevant members of target.
Type Parameters
TSpecifies 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
pluginsIKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
pluginNamestringName 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.
functionsIEnumerable<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
pluginsICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
serviceProviderIServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginNamestringName 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.
functionsIEnumerable<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
pluginsIKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
targetobjectThe instance of the class to be wrapped.
pluginNamestringName 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
pluginsICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
targetobjectThe instance of the class to be wrapped.
serviceProviderIServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginNamestringName 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
kernelKernelThe Microsoft.SemanticKernel.Kernel containing services, plugins, and other state for use throughout the operation.
pluginNamestringThe name of the plugin.
streamStreamThe stream representing the OpenAPI definition.
executionParametersOpenApiFunctionExecutionParametersOptional execution parameters for the plugin.
cancellationTokenCancellationTokenA 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
kernelKernelThe Microsoft.SemanticKernel.Kernel containing services, plugins, and other state for use throughout the operation.
pluginNamestringThe name of the plugin.
filePathstringThe file path to the OpenAPI definition file.
executionParametersOpenApiFunctionExecutionParametersOptional execution parameters for the plugin.
cancellationTokenCancellationTokenA 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
kernelKernelThe Microsoft.SemanticKernel.Kernel containing services, plugins, and other state for use throughout the operation.
pluginNamestringThe name of the plugin.
uriUriThe URI to the OpenAPI definition.
executionParametersOpenApiFunctionExecutionParametersOptional execution parameters for the plugin.
cancellationTokenCancellationTokenA 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
pluginsIKernelBuilderPluginsThe plugin collection to which the new plugin should be added.
pluginNamestringName 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
TSpecifies 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
pluginsICollection<KernelPlugin>The plugin collection to which the new plugin should be added.
serviceProviderIServiceProviderService provider from which to resolve dependencies, such as Microsoft.Extensions.Logging.ILoggerFactory.
pluginNamestringName 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
TSpecifies 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
kernelKernelThe Microsoft.SemanticKernel.Kernel containing services, plugins, and other state for use throughout the operation.
kernelPluginKernelPluginThe 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
serviceProviderIServiceProviderService provider from which to resolve dependencies, such as IPluginMetadataProvider.
pluginKernelPluginA 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.