Bitzsoft.Integrations.SemanticKernel 1.1.2

dotnet add package Bitzsoft.Integrations.SemanticKernel --version 1.1.2
                    
NuGet\Install-Package Bitzsoft.Integrations.SemanticKernel -Version 1.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitzsoft.Integrations.SemanticKernel" Version="1.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.SemanticKernel" Version="1.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Bitzsoft.Integrations.SemanticKernel" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitzsoft.Integrations.SemanticKernel --version 1.1.2
                    
#r "nuget: Bitzsoft.Integrations.SemanticKernel, 1.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitzsoft.Integrations.SemanticKernel@1.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitzsoft.Integrations.SemanticKernel&version=1.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Bitzsoft.Integrations.SemanticKernel&version=1.1.2
                    
Install as a Cake Tool

Bitzsoft.Integrations.SemanticKernel

已弃用 / DEPRECATED(1.1.2 终版冻结,构建期诊断码 BITZAI0001):本包已完成历史使命并停止功能演进。新项目与存量系统请迁移至 Bitzsoft.Integrations.AI.Agents 1.2.0+ 与 Bitzsoft.Integrations.AI 1.2.0+(详情见 ADR-0015)。

迁移与命名空间对照表

弃用旧包 / 命名空间 (1.1.2) 替代新包 / 命名空间 (1.2.0+) 诊断码
Bitzsoft.Integrations.SemanticKernel Bitzsoft.Integrations.AI.Agents / Bitzsoft.Integrations.AI BITZAI0001
services.AddBitzSemanticKernel(...) services.AddBitzsoftAIAgent(...) / BitzAgentBuilder / services.AddBitzChatClient(...) BITZAI0001
ISemanticKernelClient.SendMessageAsync IAgentService.ChatInSessionAsync / AIAgent.RunAsync / IChatClient.GetResponseAsync BITZAI0001
ISemanticKernelClient.SendMessageStreamAsync IAgentService.SendMessageStreamAsync / IBitzAgentConversationService.ChatInSessionStreamAsync BITZAI0001
AddBitzSemanticKernelPlugin<TPlugin>() AIFunctionFactory.Create(...) + GuardedAIFunction / BitzAgentBuilder.WithTools(...) BITZAI0001
DateTimePlugin TimeProvider + AIFunctionFactory.Create(...) 受控只读工具 BITZAI0001

Semantic Kernel 插件兼容编排层仅用于尚待改造的历史项目过渡。它不再创建厂商客户端或持有 API Key,而是复用 Microsoft.Extensions.AI.IChatClient。

安装与兼容性

# 新项目与迁移目标(1.2.0+):
dotnet add package Bitzsoft.Integrations.AI
dotnet add package Bitzsoft.Integrations.AI.Agents

# 历史过渡终版(已标注 BITZAI0001 构建与编译告警,后续将移除):
dotnet add package Bitzsoft.Integrations.SemanticKernel --version 1.1.2
  • 目标框架:net8.0;net10.0;
  • 已启用四层弃用提示:NuGet.org Deprecated 元数据、包描述 [已弃用 / DEPRECATED]、buildTransitive 构建期告警 BITZAI0001 以及全部公开类型 [Obsolete(..., DiagnosticId = "BITZAI0001")];
  • 不提供 ApiKey、Endpoint、ProviderId 或 ModelId 配置。

迁移最小示例

完整最小示例

以下示例展示脱离 SemanticKernel 兼容层后,直接使用统一 Microsoft.Extensions.AI.IChatClient 与 AIFunctionFactory 完成租户隔离工具调用的最小迁移方式(无 BITZAI0001 过时警告;如需完整会话持久化、技能目录、HITL 审批与循环编排,请进一步接入 Bitzsoft.Integrations.AI.Agents):

using System.ComponentModel;
using Bitzsoft.Integrations.AI;
using Bitzsoft.Integrations.Core;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();

// 仅开发/测试:生产环境应注册对接 Vault、KMS 或云密钥服务的解析器。
services.AddInMemoryIntegrationCredentials();

// 直接注册租户感知 IChatClient,无需 SemanticKernel 包装层。
services.AddBitzChatClient(options =>
{
    options.ProviderId = "deepseek-dev";
    options.ProfileId = "deepseek";
    options.ModelId = "deepseek-flash";
});

await using var provider = services.BuildServiceProvider(
    new ServiceProviderOptions { ValidateScopes = true });

// 写入 tenant-a 的开发密钥;using 确保调用方持有的密钥快照被清理。
var credentialStore = provider.GetRequiredService<
    InMemoryIntegrationCredentialStore>();
using (var credential = new IntegrationCredential(
[
    new(AICredentialFieldNames.ApiKey, "<从 User Secrets 读取的开发密钥>")
]))
{
    credentialStore.Set(
        new IntegrationCredentialKey(
            tenantId: "tenant-a",
            providerKey: "AI:deepseek-dev",
            environment: IntegrationEnvironments.Development),
        credential);
}

// 每个业务请求建立自己的 Scope 和 IntegrationContext。
await using var scope = provider.CreateAsyncScope();
var contextAccessor = scope.ServiceProvider
    .GetRequiredService<IIntegrationContextAccessor>();
using var contextScope = contextAccessor.Push(
    new IntegrationContext(
        tenantId: "tenant-a",
        region: "cn-east",
        environment: IntegrationEnvironments.Development));

var chatClient = scope.ServiceProvider.GetRequiredService<IChatClient>();
var timeTool = AIFunctionFactory.Create(
    ([Description("IANA 或系统时区")] string? _) =>
        TimeProvider.System.GetUtcNow().ToString("O"),
    name: "get_utc_now",
    description: "获取当前 UTC 时间");

var chatOptions = new ChatOptions
{
    Instructions = "只回答当前租户已授权的业务问题。",
    Tools = [timeTool],
};

Console.WriteLine($"Ready for tenant {contextAccessor.Current?.TenantId}: {chatClient.GetType().Name} with {chatOptions.Tools.Count} tool(s).");

历史兼容层行为说明(退场参考)

存量代码在完成迁移前如需暂留兼容层,请知悉以下既有约束将在移除前保持不变:

  1. Scope 与插件隔离:旧版 AddBitzSemanticKernel(name, ...) 通过命名 Key 解析 IChatClient,并通过 AddBitzSemanticKernelPlugin<TPlugin> 将包含 [KernelFunction] 的插件绑定到对应命名管道,不自动扫描程序集。
  2. 工具调用护栏:SemanticKernelOptions 默认限制 MaximumFunctionInvocationIterations = 5 与 MaximumConsecutiveFunctionErrors = 1,不提供模型厂商密钥字段。
  3. 退场计划:所有公开类型 ISemanticKernelClient、SemanticKernelOptions、DateTimePlugin 与 SemanticKernelServiceCollectionExtensions 均已标注 CS0618 过时警告,后续主版本将正式移除本包及 Microsoft.SemanticKernel 传递依赖。
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.SemanticKernel:

Package Downloads
Bitzsoft.Integrations.All

Bitzsoft 第三方集成聚合包 — net5.0 包含传统连接器,net8.0+ 额外包含受上游 TFM 限制的 AI 模块

GitHub repositories

This package is not used by any popular GitHub repositories.