SemanticPluginForge
adds functionality to dynamically alter the metadata for SemanticKernel plugins. This library introduces the IPluginMetadataProvider
interface, allowing for real-time updates to plugin metadata, including descriptions, return value descriptions, and parameter descriptions, without the need for redeployment.
-
Dynamic Metadata Updates:
- Make real-time updates to plugin metadata, enhancing flexibility and reducing downtime.
- Implement changes without redeployment, ensuring a seamless update process.
-
Extensible Architecture:
- Implement new metadata providers, such as a database-backed provider, to enable metadata changes without requiring a service restart.
- Support various use cases and future expansions.
-
Dynamic Tuning:
- Fine-tune plugin descriptions and parameters based on evolving requirements or user feedback.
- Quickly respond to changes in business logic or user expectations without interrupting service availability.
-
Custom Metadata Providers:
- Develop custom providers that fetch metadata from different sources, such as databases, remote services, or configuration management systems.
- Achieve higher levels of customization and control over plugin behavior.
Implement the IPluginMetadataProvider
interface. The following code is a sample provider that overrides the description of a function from the TimePlugin
.
public class CustomTimeYearMetadataProvider : IPluginMetadataProvider
{
public PluginMetadata? GetPluginMetadata(KernelPlugin plugin) => null;
public FunctionMetadata GetFunctionMetadata(KernelPlugin plugin, KernelFunctionMetadata metadata) =>
plugin.Name == "TimePlugin" && metadata.Name == "Year"
? new FunctionMetadata(metadata.Name) { Description = "Get the current year in 4-digit number format." }
: null;
}
Register the custom metadata provider with the service collection.
services.AddSingleton<IPluginMetadataProvider, CustomTimeYearMetadataProvider>();
Use the extension methods from this library to add plugins with patched metadata.
var kernelBuilder = services.AddKernel();
kernelBuilder.Plugins.AddFromTypeWithMetadata<TimePlugin>();
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.