diff --git a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/AgentFactory.cs b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/AgentFactory.cs index 95b93584f..0a89027e3 100644 --- a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/AgentFactory.cs +++ b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/AgentFactory.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Localization; using System; using System.Threading.Tasks; using Volo.Abp.AI; -using Volo.Abp.Authorization; using Volo.Abp.DependencyInjection; using Volo.Abp.SimpleStateChecking; @@ -39,11 +38,6 @@ public class AgentFactory : IAgentFactory, IScopedDependency var workspaceDefine = await WorkspaceDefinitionManager.GetOrNullAsync(workspace); - if (workspaceDefine != null) - { - await CheckWorkspaceStateAsync(workspaceDefine); - } - return await CreateAgentAsync(chatClient, workspaceDefine); } @@ -51,8 +45,6 @@ public class AgentFactory : IAgentFactory, IScopedDependency { var workspaceDefine = await WorkspaceDefinitionManager.GetAsync(workspace); - await CheckWorkspaceStateAsync(workspaceDefine); - var chatClient = await ChatClientFactory.CreateAsync(workspace); return await CreateAgentAsync(chatClient, workspaceDefine); @@ -96,15 +88,4 @@ public class AgentFactory : IAgentFactory, IScopedDependency { return Task.FromResult([]); } - - protected async virtual Task CheckWorkspaceStateAsync(WorkspaceDefinition workspace) - { - if (!await StateCheckerManager.IsEnabledAsync(workspace)) - { - throw new AbpAuthorizationException( - $"Workspace is not enabled: {workspace.Name}!", - AbpAIErrorCodes.WorkspaceIsNotEnabled) - .WithData("Workspace", workspace.Name); - } - } } diff --git a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/Internal/ChatClientFactory.cs b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/Internal/ChatClientFactory.cs index a369c05e0..8df8f777f 100644 --- a/aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/Internal/ChatClientFactory.cs +++ b/aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/Internal/ChatClientFactory.cs @@ -70,7 +70,7 @@ public class ChatClientFactory : IChatClientFactory, IScopedDependency protected async virtual Task CheckWorkspaceStateAsync(WorkspaceDefinition workspace) { - if (!await StateCheckerManager.IsEnabledAsync(workspace)) + if (!workspace.IsEnabled || !await StateCheckerManager.IsEnabledAsync(workspace)) { throw new AbpAuthorizationException( $"Workspace is not enabled: {workspace.Name}!",