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
<PackageReference Include="Bitzsoft.Integrations.SemanticKernel" Version="1.1.2" />
<PackageVersion Include="Bitzsoft.Integrations.SemanticKernel" Version="1.1.2" />
<PackageReference Include="Bitzsoft.Integrations.SemanticKernel" />
paket add Bitzsoft.Integrations.SemanticKernel --version 1.1.2
#r "nuget: Bitzsoft.Integrations.SemanticKernel, 1.1.2"
#:package Bitzsoft.Integrations.SemanticKernel@1.1.2
#addin nuget:?package=Bitzsoft.Integrations.SemanticKernel&version=1.1.2
#tool nuget:?package=Bitzsoft.Integrations.SemanticKernel&version=1.1.2
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).");
历史兼容层行为说明(退场参考)
存量代码在完成迁移前如需暂留兼容层,请知悉以下既有约束将在移除前保持不变:
- Scope 与插件隔离:旧版
AddBitzSemanticKernel(name, ...)通过命名 Key 解析IChatClient,并通过AddBitzSemanticKernelPlugin<TPlugin>将包含[KernelFunction]的插件绑定到对应命名管道,不自动扫描程序集。 - 工具调用护栏:
SemanticKernelOptions默认限制MaximumFunctionInvocationIterations = 5与MaximumConsecutiveFunctionErrors = 1,不提供模型厂商密钥字段。 - 退场计划:所有公开类型
ISemanticKernelClient、SemanticKernelOptions、DateTimePlugin与SemanticKernelServiceCollectionExtensions均已标注CS0618过时警告,后续主版本将正式移除本包及Microsoft.SemanticKernel传递依赖。
| Product | Versions 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. |
-
net10.0
- Bitzsoft.Integrations.AI.Abstractions (>= 1.2.0)
- Microsoft.Extensions.AI (>= 10.11.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- Microsoft.SemanticKernel (>= 1.82.0)
-
net8.0
- Bitzsoft.Integrations.AI.Abstractions (>= 1.2.0)
- Microsoft.Extensions.AI (>= 10.11.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- Microsoft.SemanticKernel (>= 1.82.0)
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.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.1.2 | 0 | 11/21/2026 | |
| 1.1.0 | 92 | 11/14/2026 | |
| 1.0.4 | 201 | 9/23/2026 | |
| 1.0.2 | 167 | 8/29/2026 | |
| 1.0.1 | 185 | 8/3/2026 | |
| 1.0.0 | 167 | 8/2/2026 | |
| 1.0.0-alpha.10 | 98 | 7/26/2026 | |
| 1.0.0-alpha.9 | 105 | 7/12/2026 | |
| 1.0.0-alpha.8 | 347 | 7/1/2026 | |
| 1.0.0-alpha.7 | 109 | 6/16/2026 | |
| 1.0.0-alpha.6 | 104 | 6/16/2026 | |
| 1.0.0-alpha.5 | 94 | 6/14/2026 | |
| 1.0.0-alpha.3 | 104 | 6/7/2026 | |
| 1.0.0-alpha.2 | 93 | 5/29/2026 | |
| 1.0.0-alpha.1 | 93 | 5/28/2026 |