Octopus
Enabling the Plugin
Enabling the SemanticKernelPlugin requires the NuGet package, plugin registration, and an appsettings section that references API key credential IDs rather than raw keys.
Package Reference
<PackageReference Include="BizFirst.Octopus.SemanticKernelPlugin" Version="*" />
<!-- Pulls in Microsoft.SemanticKernel transitively -->
Plugin Registration
builder.Services.AddOctopus(config =>
{
config.AddPlugin<SqlServerPlugin>(); // Must be before SemanticKernelPlugin
config.AddPlugin<SemanticKernelPlugin>(); // Requires IAgentStore from SqlServerPlugin
config.AddPlugin<ChatbotUIPlugin>();
});
appsettings.json Configuration
{
"SemanticKernelPlugin": {
"DefaultProvider": "AzureOpenAI",
"AzureOpenAI": {
"ApiKeyCredentialId": 10,
"Endpoint": "https://myoai.openai.azure.com/",
"ChatDeployment": "gpt-4o",
"EmbeddingDeployment": "text-embedding-3-large"
},
"OpenAI": {
"ApiKeyCredentialId": 11,
"ChatModel": "gpt-4o",
"EmbeddingModel": "text-embedding-3-large"
},
"Planner": {
"Enabled": true,
"MaxSteps": 10,
"AllowLoops": false
},
"Memory": {
"BridgeToOctopusStore": true,
"CollectionPrefix": "sk_"
}
}
}
Config Properties
| Property | Type | Description |
|---|---|---|
DefaultProvider | string | AzureOpenAI or OpenAI — which provider the SK kernel uses by default |
AzureOpenAI.ApiKeyCredentialId | int | Credential ID for the Azure OpenAI API key |
AzureOpenAI.Endpoint | string | Azure OpenAI resource endpoint URL |
AzureOpenAI.ChatDeployment | string | Deployment name for the chat completion model |
AzureOpenAI.EmbeddingDeployment | string | Deployment name for the embedding model |
Planner.Enabled | bool | Whether to activate the SK stepwise planner |
Planner.MaxSteps | int | Maximum steps the planner may execute (safety cap) |
Memory.BridgeToOctopusStore | bool | If true, SK memory calls go through ISemanticMemoryStore |
OnStartAsync — Kernel Construction
public async Task OnStartAsync(IServiceProvider sp, CancellationToken ct)
{
var config = sp.GetRequiredService<IOptions<SemanticKernelPluginConfig>>().Value;
var creds = sp.GetRequiredService<ICredentialResolver>();
// Resolve API key at startup
var apiKey = await creds.GetPasswordAsync(
config.AzureOpenAI.ApiKeyCredentialId);
// Build the SK kernel
var kernelBuilder = Kernel.CreateBuilder();
if (config.DefaultProvider == "AzureOpenAI")
{
kernelBuilder.AddAzureOpenAIChatCompletion(
deploymentName: config.AzureOpenAI.ChatDeployment,
endpoint: config.AzureOpenAI.Endpoint,
apiKey: apiKey);
kernelBuilder.AddAzureOpenAITextEmbeddingGeneration(
deploymentName: config.AzureOpenAI.EmbeddingDeployment,
endpoint: config.AzureOpenAI.Endpoint,
apiKey: apiKey);
}
else
{
kernelBuilder.AddOpenAIChatCompletion(config.OpenAI.ChatModel, apiKey);
kernelBuilder.AddOpenAITextEmbeddingGeneration(config.OpenAI.EmbeddingModel, apiKey);
}
var kernel = kernelBuilder.Build();
// Register kernel as singleton for other components
var kernelRegistry = sp.GetRequiredService<ISKKernelRegistry>();
kernelRegistry.Register("default", kernel);
}