Browse Source

Allow resolving kernel with ChatClient configured only

pull/23895/head
Enis Necipoglu 1 year ago
parent
commit
0c81211fca
No known key found for this signature in database GPG Key ID: 1EC55E13241E1680
  1. 14
      framework/src/Volo.Abp.AI/Volo/Abp/AI/AbpAIModule.cs

14
framework/src/Volo.Abp.AI/Volo/Abp/AI/AbpAIModule.cs

@ -99,5 +99,19 @@ public class AbpAIModule : AbpModule
sp => sp.GetRequiredKeyedService<IChatClient>(serviceName)
);
}
if (workspaceConfig.Kernel.Builder is null)
{
context.Services.AddKeyedTransient<Kernel>(
AbpAIWorkspaceOptions.GetKernelServiceKeyName(workspaceConfig.Name),
(sp, _) =>
{
var chatClient = sp.GetRequiredKeyedService<IChatClient>(serviceName);
var builder = Kernel.CreateBuilder();
builder.Services.AddSingleton<IChatClient>(chatClient);
return builder.Build();
}
);
}
}
}
Loading…
Cancel
Save