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?
- ๐ Read the Introduction - Understand what SemanticPluginForge can do
- ๐ฏ Follow Getting Started - Get up and running in minutes
- ๐งช Try the Samples - Explore practical examples
- โก Explore Advanced Features - Unlock the full potential
๐ค Contributing
Contributions are welcome! Please open an issue or submit a pull request.