Browse Source

Update AbpAIModule.cs

pull/23533/head
enisn 5 months ago
parent
commit
4c2b6059cb
No known key found for this signature in database GPG Key ID: A052619F04155D1C
  1. 4
      framework/src/Volo.Abp.AI/Volo/Abp/AI/AbpAIModule.cs
  2. 4
      framework/src/Volo.Abp.AI/Volo/Abp/AI/Extensions/ChatClientWithSystemMessageExtensions.cs

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

@ -67,6 +67,7 @@ public class AbpAIModule : AbpModule
builderConfigurer.Action(workspaceConfig.Kernel.Builder!);
}
// TODO: Check if we can use transient instead of singleton for Kernel
context.Services.AddKeyedTransient<Kernel>(
AbpAIOptions.GetKernelServiceKeyName(workspaceConfig.Name),
(provider, _) => workspaceConfig.Kernel.Builder!.Build());
@ -84,7 +85,8 @@ public class AbpAIModule : AbpModule
context.Services.AddKeyedTransient<IChatClient>(
AbpAIOptions.GetChatClientServiceKeyName(workspaceConfig.Name),
(sp, _) => sp.GetKeyedService<Kernel>(AbpAIOptions.GetKernelServiceKeyName(workspaceConfig.Name))?
.GetRequiredService<IChatClient>() ?? throw new InvalidOperationException("Kernel or IChatClient not found with workspace name: " + workspaceConfig.Name)
.GetRequiredService<IChatClient>()
?? throw new InvalidOperationException("Kernel or IChatClient not found with workspace name: " + workspaceConfig.Name)
);
}
}

4
framework/src/Volo.Abp.AI/Volo/Abp/AI/Extensions/ChatClientWithSystemMessageExtensions.cs

@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.AI;
using Volo.Abp.AI.Delegates;

Loading…
Cancel
Save