SemanticPluginForge

Dynamically enhance your Semantic Kernel plugins with powerful metadata capabilities

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.

๐Ÿš€ Key Features

  • ๐Ÿ”„ Dynamic Metadata Updates: Make real-time updates to plugin metadata without redeployment
  • ๐Ÿ—๏ธ Extensible Architecture: Implement custom metadata providers from databases, APIs, or configuration
  • ๐ŸŽฏ Function & Parameter Suppression: Hide functions or parameters while maintaining functionality
  • โšก CLR Type Support: Use any .NET class as a plugin without KernelFunction attributes
  • ๐Ÿท๏ธ Function Name Override: Change function names without modifying source code
  • โš™๏ธ Context-Aware Defaults: Provide intelligent default values based on runtime conditions

๐Ÿ“ฆ Quick Installation

dotnet add package SemanticPluginForge.Core

๐ŸŽฏ Quick Start

1. Create a Metadata Provider

public class CustomMetadataProvider : IPluginMetadataProvider
{
    public PluginMetadata? GetPluginMetadata(KernelPlugin plugin) =>
        plugin.Name == "TimePlugin" ? new PluginMetadata
        {
            Description = "Enhanced time and date operations"
        } : 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 format" 
            }
            : null;
}

2. Register and Use

// Register the metadata provider
services.AddSingleton<IPluginMetadataProvider, CustomMetadataProvider>();

// Add plugins with enhanced metadata
var kernelBuilder = services.AddKernel();
kernelBuilder.Plugins.AddFromTypeWithMetadata<TimePlugin>();

๐Ÿ“š Documentation

Section Description
๐ŸŽฏ Getting Started Step-by-step setup and basic usage
๐Ÿง  Core Concepts Understand the fundamentals
โšก Advanced Features Suppression, CLR types, and more
๐Ÿ“– Samples Practical examples and tutorials
๐Ÿ“‹ API Reference Complete API documentation

๐ŸŽช Live Examples

Suppress Parameters with Smart Defaults

public FunctionMetadata? GetFunctionMetadata(KernelPlugin plugin, KernelFunctionMetadata metadata)
{
    if (plugin.Name == "WeatherPlugin" && metadata.Name == "GetWeather")
    {
        return new FunctionMetadata(metadata.Name)
        {
            Description = "Gets weather for user's location (auto-detected)",
            Parameters = new List<ParameterMetadata>
            {
                new ParameterMetadata("location") 
                { 
                    Suppress = true, 
                    DefaultValue = "user_current_location"
                }
            }
        };
    }
    return null;
}

Use Any Class as a Plugin

public class MathUtils
{
    public double Add(double a, double b) => a + b;
    public double Multiply(double a, double b) => a * b;
}

// No attributes needed!
kernelBuilder.Plugins.AddFromClrTypeWithMetadata<MathUtils>("MathPlugin");

Override Function Names

return new FunctionMetadata(metadata.Name)
{
    OverrideFunctionName = "CalculateSum", // Better name for AI
    Description = "Adds two numbers together"
};

๐Ÿ† Benefits

For Developers

  • Legacy Integration: Turn existing code into AI-callable functions
  • Clean Architecture: Keep AI concerns separate from business logic
  • Rapid Prototyping: Quickly expose any functionality to AI

For Operations

  • Zero Downtime Updates: Change plugin behavior without restarts
  • Environment-Specific Config: Different metadata per environment
  • A/B Testing: Test different function descriptions and parameters

For AI Applications

  • Better Function Discovery: More descriptive names and descriptions
  • Context-Aware Behavior: Functions adapt to user context
  • Simplified Interfaces: Hide technical complexity from AI models

๐ŸŽฏ Sample Projects

Explore our comprehensive samples:

Sample Focus Key Learning
DefaultValue Parameter handling Smart defaults and suppression
UseClrType Legacy integration CLR types as plugins
AzureAiSearchPlugin Production patterns Multiple instances, different configs

๐Ÿš€ Getting Started

Ready to enhance your Semantic Kernel plugins?

  1. ๐Ÿ“– Read the Introduction - Understand what SemanticPluginForge can do
  2. ๐ŸŽฏ Follow Getting Started - Get up and running in minutes
  3. ๐Ÿงช Try the Samples - Explore practical examples
  4. โšก Explore Advanced Features - Unlock the full potential

๐Ÿค Contributing

Contributions are welcome! Please open an issue or submit a pull request.