Files
Yi.Admin/Yi.Abp.Net8/module/chat-hub/Yi.Framework.ChatHub.Domain/YiFrameworkChatHubDomainModule.cs

43 lines
1.5 KiB
C#
Raw Normal View History

2025-03-21 18:24:59 +08:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Volo.Abp.Domain;
2024-04-04 19:28:18 +08:00
using Yi.Framework.Caching.FreeRedis;
2024-04-04 14:00:32 +08:00
using Yi.Framework.ChatHub.Domain.Shared;
2025-03-21 18:24:59 +08:00
using Yi.Framework.Core.Options;
2024-04-04 14:00:32 +08:00
namespace Yi.Framework.ChatHub.Domain
{
[DependsOn(
typeof(YiFrameworkChatHubDomainSharedModule),
2024-04-04 19:28:18 +08:00
typeof(YiFrameworkCachingFreeRedisModule),
2024-04-04 14:00:32 +08:00
typeof(AbpDddDomainModule)
)]
public class YiFrameworkChatHubDomainModule : AbpModule
{
2025-03-21 18:24:59 +08:00
public override void ConfigureServices(ServiceConfigurationContext context)
2024-04-04 14:00:32 +08:00
{
2025-03-21 18:24:59 +08:00
var configuration = context.Services.GetConfiguration();
var services = context.Services;
// 配置绑定
var semanticKernelSection = configuration.GetSection("SemanticKernel");
services.Configure<SemanticKernelOptions>(configuration.GetSection("SemanticKernel"));
#pragma warning disable SKEXP0010
// 从配置中获取值
var options = semanticKernelSection.Get<SemanticKernelOptions>();
foreach (var optionsModelId in options.ModelIds)
{
services.AddKernel()
.AddOpenAIChatCompletion(
serviceId: optionsModelId,
modelId: optionsModelId,
endpoint: new Uri(options.Endpoint),
apiKey: options.ApiKey);
}
#pragma warning restore SKEXP0010
2024-04-04 14:00:32 +08:00
}
}
}