Browse Source

feat(ai): Add definition of workspace properties

pull/1421/head
colin 2 months ago
parent
commit
8bee13911a
  1. 60
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/ChatClientAgentFactory.cs
  2. 5
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/IChatClientAgentFactory.cs
  3. 59
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/WorkspaceAIAgent.cs
  4. 10
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/ChatClientFactory.cs
  5. 18
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/ChatClientProvider.cs
  6. 5
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/IChatClientFactory.cs
  7. 3
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/IChatClientProvider.cs
  8. 8
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/IWorkspaceChatClient.cs
  9. 24
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/OpenAIChatClientProvider.cs
  10. 69
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/WorkspaceChatClient.cs
  11. 86
      aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/Workspaces/WorkspaceDefinition.cs

60
aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/ChatClientAgentFactory.cs

@ -2,6 +2,8 @@
using Microsoft.Agents.AI; using Microsoft.Agents.AI;
using Microsoft.Extensions.AI; using Microsoft.Extensions.AI;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.AI; using Volo.Abp.AI;
@ -12,25 +14,27 @@ using Volo.Abp.SimpleStateChecking;
namespace LINGYUN.Abp.AI.Agent; namespace LINGYUN.Abp.AI.Agent;
public class ChatClientAgentFactory : IChatClientAgentFactory, ISingletonDependency public class ChatClientAgentFactory : IChatClientAgentFactory, ISingletonDependency
{ {
private readonly static ConcurrentDictionary<string, ChatClientAgent> _chatClientAgentCache = new(); private readonly static ConcurrentDictionary<string, WorkspaceAIAgent> _chatClientAgentCache = new();
protected IServiceProvider ServiceProvider { get; }
protected IChatClientFactory ChatClientFactory { get; } protected IChatClientFactory ChatClientFactory { get; }
protected IStringLocalizerFactory StringLocalizerFactory { get; } protected IStringLocalizerFactory StringLocalizerFactory { get; }
protected IWorkspaceDefinitionManager WorkspaceDefinitionManager { get; } protected IWorkspaceDefinitionManager WorkspaceDefinitionManager { get; }
protected ISimpleStateCheckerManager<WorkspaceDefinition> StateCheckerManager { get; } protected ISimpleStateCheckerManager<WorkspaceDefinition> StateCheckerManager { get; }
public ChatClientAgentFactory( public ChatClientAgentFactory(
IServiceProvider serviceProvider,
IChatClientFactory chatClientFactory, IChatClientFactory chatClientFactory,
IStringLocalizerFactory stringLocalizerFactory, IStringLocalizerFactory stringLocalizerFactory,
IWorkspaceDefinitionManager workspaceDefinitionManager, IWorkspaceDefinitionManager workspaceDefinitionManager,
ISimpleStateCheckerManager<WorkspaceDefinition> stateCheckerManager) ISimpleStateCheckerManager<WorkspaceDefinition> stateCheckerManager)
{ {
ServiceProvider = serviceProvider;
ChatClientFactory = chatClientFactory; ChatClientFactory = chatClientFactory;
StringLocalizerFactory = stringLocalizerFactory; StringLocalizerFactory = stringLocalizerFactory;
WorkspaceDefinitionManager = workspaceDefinitionManager; WorkspaceDefinitionManager = workspaceDefinitionManager;
StateCheckerManager = stateCheckerManager; StateCheckerManager = stateCheckerManager;
} }
public async virtual Task<ChatClientAgent> CreateAsync<TWorkspace>() public async virtual Task<WorkspaceAIAgent> CreateAsync<TWorkspace>()
{ {
var workspace = WorkspaceNameAttribute.GetWorkspaceName<TWorkspace>(); var workspace = WorkspaceNameAttribute.GetWorkspaceName<TWorkspace>();
if (_chatClientAgentCache.TryGetValue(workspace, out var chatClientAgent)) if (_chatClientAgentCache.TryGetValue(workspace, out var chatClientAgent))
@ -53,17 +57,33 @@ public class ChatClientAgentFactory : IChatClientAgentFactory, ISingletonDepende
description = workspaceDefine.Description.Localize(StringLocalizerFactory); description = workspaceDefine.Description.Localize(StringLocalizerFactory);
} }
chatClientAgent = chatClient.CreateAIAgent( var clientAgentOptions = new ChatClientAgentOptions
instructions: workspaceDefine?.SystemPrompt, {
name: workspaceDefine?.Name, ChatOptions = new ChatOptions
description: description); {
Instructions = workspaceDefine?.Instructions,
Temperature = workspaceDefine?.Temperature,
MaxOutputTokens = workspaceDefine?.MaxOutputTokens,
PresencePenalty = workspaceDefine?.PresencePenalty,
FrequencyPenalty = workspaceDefine?.FrequencyPenalty,
},
Name = workspaceDefine?.Name,
Description = description
};
chatClientAgent = new WorkspaceAIAgent(
new AIAgentBuilder(chatClient.CreateAIAgent(clientAgentOptions))
.UseLogging()
.UseOpenTelemetry()
.Build(ServiceProvider),
workspaceDefine);
_chatClientAgentCache.TryAdd(workspace, chatClientAgent); _chatClientAgentCache.TryAdd(workspace, chatClientAgent);
return chatClientAgent; return chatClientAgent;
} }
public async virtual Task<ChatClientAgent> CreateAsync(string workspace) public async virtual Task<WorkspaceAIAgent> CreateAsync(string workspace)
{ {
if (_chatClientAgentCache.TryGetValue(workspace, out var chatClientAgent)) if (_chatClientAgentCache.TryGetValue(workspace, out var chatClientAgent))
{ {
@ -81,10 +101,26 @@ public class ChatClientAgentFactory : IChatClientAgentFactory, ISingletonDepende
description = workspaceDefine.Description.Localize(StringLocalizerFactory); description = workspaceDefine.Description.Localize(StringLocalizerFactory);
} }
chatClientAgent = chatClient.CreateAIAgent( var clientAgentOptions = new ChatClientAgentOptions
instructions: workspaceDefine.SystemPrompt, {
name: workspaceDefine.Name, ChatOptions = new ChatOptions
description: description); {
Instructions = workspaceDefine.Instructions,
Temperature = workspaceDefine.Temperature,
MaxOutputTokens = workspaceDefine.MaxOutputTokens,
PresencePenalty = workspaceDefine.PresencePenalty,
FrequencyPenalty = workspaceDefine.FrequencyPenalty,
},
Name = workspaceDefine.Name,
Description = description
};
chatClientAgent = new WorkspaceAIAgent(
new AIAgentBuilder(chatClient.CreateAIAgent(clientAgentOptions))
.UseLogging()
.UseOpenTelemetry()
.Build(ServiceProvider),
workspaceDefine);
_chatClientAgentCache.TryAdd(workspace, chatClientAgent); _chatClientAgentCache.TryAdd(workspace, chatClientAgent);

5
aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/IChatClientAgentFactory.cs

@ -1,13 +1,12 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.Agents.AI;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LINGYUN.Abp.AI.Agent; namespace LINGYUN.Abp.AI.Agent;
public interface IChatClientAgentFactory public interface IChatClientAgentFactory
{ {
[NotNull] [NotNull]
Task<ChatClientAgent> CreateAsync<TWorkspace>(); Task<WorkspaceAIAgent> CreateAsync<TWorkspace>();
[NotNull] [NotNull]
Task<ChatClientAgent> CreateAsync(string workspace); Task<WorkspaceAIAgent> CreateAsync(string workspace);
} }

59
aspnet-core/modules/ai/LINGYUN.Abp.AI.Agent/LINGYUN/Abp/AI/Agent/WorkspaceAIAgent.cs

@ -0,0 +1,59 @@
using LINGYUN.Abp.AI.Workspaces;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.AI.Agent;
public class WorkspaceAIAgent : AIAgent
{
protected AIAgent InnerAIAgent { get; }
public WorkspaceDefinition? Workspace { get; }
public WorkspaceAIAgent(
AIAgent innerAIAgent,
WorkspaceDefinition? workspace = null)
{
InnerAIAgent = innerAIAgent;
Workspace = workspace;
}
public override AgentThread DeserializeThread(JsonElement serializedThread, JsonSerializerOptions? jsonSerializerOptions = null)
{
return InnerAIAgent.DeserializeThread(serializedThread, jsonSerializerOptions);
}
public override AgentThread GetNewThread()
{
return InnerAIAgent.GetNewThread();
}
protected override Task<AgentRunResponse> RunCoreAsync(IEnumerable<ChatMessage> messages, AgentThread? thread = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default)
{
return InnerAIAgent.RunAsync(GetChatMessages(messages), thread, options, cancellationToken);
}
protected override IAsyncEnumerable<AgentRunResponseUpdate> RunCoreStreamingAsync(IEnumerable<ChatMessage> messages, AgentThread? thread = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default)
{
return InnerAIAgent.RunStreamingAsync(GetChatMessages(messages), thread, options, cancellationToken);
}
protected virtual IEnumerable<ChatMessage> GetChatMessages(IEnumerable<ChatMessage> messages)
{
if (Workspace?.SystemPrompt?.IsNullOrWhiteSpace() == false &&
!messages.Any(msg => msg.Role == ChatRole.System))
{
// 加入系统提示词
messages = new List<ChatMessage>
{
new ChatMessage(ChatRole.System, Workspace.SystemPrompt)
}.Union(messages);
}
return messages;
}
}

10
aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/ChatClientFactory.cs

@ -12,7 +12,7 @@ using Volo.Abp.SimpleStateChecking;
namespace LINGYUN.Abp.AI; namespace LINGYUN.Abp.AI;
public class ChatClientFactory : IChatClientFactory, ISingletonDependency public class ChatClientFactory : IChatClientFactory, ISingletonDependency
{ {
private readonly static ConcurrentDictionary<string, IChatClient> _chatClientCache = new(); private readonly static ConcurrentDictionary<string, IWorkspaceChatClient> _chatClientCache = new();
protected ISimpleStateCheckerManager<WorkspaceDefinition> StateCheckerManager { get; } protected ISimpleStateCheckerManager<WorkspaceDefinition> StateCheckerManager { get; }
protected IWorkspaceDefinitionManager WorkspaceDefinitionManager { get; } protected IWorkspaceDefinitionManager WorkspaceDefinitionManager { get; }
protected IChatClientProviderManager ChatClientProviderManager { get; } protected IChatClientProviderManager ChatClientProviderManager { get; }
@ -30,7 +30,7 @@ public class ChatClientFactory : IChatClientFactory, ISingletonDependency
ServiceProvider = serviceProvider; ServiceProvider = serviceProvider;
} }
public async virtual Task<IChatClient> CreateAsync<TWorkspace>() public async virtual Task<IWorkspaceChatClient> CreateAsync<TWorkspace>()
{ {
var workspace = WorkspaceNameAttribute.GetWorkspaceName<TWorkspace>(); var workspace = WorkspaceNameAttribute.GetWorkspaceName<TWorkspace>();
if (_chatClientCache.TryGetValue(workspace, out var chatClient)) if (_chatClientCache.TryGetValue(workspace, out var chatClient))
@ -44,7 +44,7 @@ public class ChatClientFactory : IChatClientFactory, ISingletonDependency
chatClientAccessor is IChatClientAccessor accessor && chatClientAccessor is IChatClientAccessor accessor &&
accessor.ChatClient != null) accessor.ChatClient != null)
{ {
chatClient = accessor.ChatClient; chatClient = new WorkspaceChatClient(accessor.ChatClient);
_chatClientCache.TryAdd(workspace, chatClient); _chatClientCache.TryAdd(workspace, chatClient);
} }
else else
@ -54,7 +54,7 @@ public class ChatClientFactory : IChatClientFactory, ISingletonDependency
return chatClient; return chatClient;
} }
public async virtual Task<IChatClient> CreateAsync(string workspace) public async virtual Task<IWorkspaceChatClient> CreateAsync(string workspace)
{ {
if (_chatClientCache.TryGetValue(workspace, out var chatClient)) if (_chatClientCache.TryGetValue(workspace, out var chatClient))
{ {
@ -72,7 +72,7 @@ public class ChatClientFactory : IChatClientFactory, ISingletonDependency
return chatClient; return chatClient;
} }
protected async virtual Task<IChatClient> CreateChatClientAsync(WorkspaceDefinition workspace) protected async virtual Task<IWorkspaceChatClient> CreateChatClientAsync(WorkspaceDefinition workspace)
{ {
foreach (var provider in ChatClientProviderManager.Providers) foreach (var provider in ChatClientProviderManager.Providers)
{ {

18
aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/ChatClientProvider.cs

@ -0,0 +1,18 @@
using LINGYUN.Abp.AI.Workspaces;
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.AI;
public abstract class ChatClientProvider : IChatClientProvider, ITransientDependency
{
public abstract string Name { get; }
protected IServiceProvider ServiceProvider { get; }
protected ChatClientProvider(IServiceProvider serviceProvider)
{
ServiceProvider = serviceProvider;
}
public abstract Task<IWorkspaceChatClient> CreateAsync(WorkspaceDefinition workspace);
}

5
aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/IChatClientFactory.cs

@ -1,13 +1,12 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Microsoft.Extensions.AI;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LINGYUN.Abp.AI; namespace LINGYUN.Abp.AI;
public interface IChatClientFactory public interface IChatClientFactory
{ {
[NotNull] [NotNull]
Task<IChatClient> CreateAsync<TWorkspace>(); Task<IWorkspaceChatClient> CreateAsync<TWorkspace>();
[NotNull] [NotNull]
Task<IChatClient> CreateAsync(string workspace); Task<IWorkspaceChatClient> CreateAsync(string workspace);
} }

3
aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/IChatClientProvider.cs

@ -1,5 +1,4 @@
using LINGYUN.Abp.AI.Workspaces; using LINGYUN.Abp.AI.Workspaces;
using Microsoft.Extensions.AI;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LINGYUN.Abp.AI; namespace LINGYUN.Abp.AI;
@ -7,5 +6,5 @@ public interface IChatClientProvider
{ {
string Name { get; } string Name { get; }
Task<IChatClient> CreateAsync(WorkspaceDefinition workspace); Task<IWorkspaceChatClient> CreateAsync(WorkspaceDefinition workspace);
} }

8
aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/IWorkspaceChatClient.cs

@ -0,0 +1,8 @@
using LINGYUN.Abp.AI.Workspaces;
using Microsoft.Extensions.AI;
namespace LINGYUN.Abp.AI;
public interface IWorkspaceChatClient : IChatClient
{
WorkspaceDefinition? Workspace { get; }
}

24
aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/OpenAIChatClientProvider.cs

@ -5,17 +5,20 @@ using System;
using System.ClientModel; using System.ClientModel;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.AI; namespace LINGYUN.Abp.AI;
public class OpenAIChatClientProvider : IChatClientProvider, ITransientDependency public class OpenAIChatClientProvider : ChatClientProvider
{ {
private const string DefaultEndpoint = "https://api.openai.com/v1"; private const string DefaultEndpoint = "https://api.openai.com/v1";
public const string ProviderName = "OpenAI"; public const string ProviderName = "OpenAI";
public virtual string Name => ProviderName; public override string Name => ProviderName;
public OpenAIChatClientProvider(IServiceProvider serviceProvider)
: base(serviceProvider)
{
}
public virtual Task<IChatClient> CreateAsync(WorkspaceDefinition workspace) public override Task<IWorkspaceChatClient> CreateAsync(WorkspaceDefinition workspace)
{ {
Check.NotNull(workspace, nameof(workspace)); Check.NotNull(workspace, nameof(workspace));
Check.NotNullOrWhiteSpace(workspace.ApiKey, nameof(WorkspaceDefinition.ApiKey)); Check.NotNullOrWhiteSpace(workspace.ApiKey, nameof(WorkspaceDefinition.ApiKey));
@ -29,8 +32,17 @@ public class OpenAIChatClientProvider : IChatClientProvider, ITransientDependenc
var chatClient = openAIClient var chatClient = openAIClient
.GetChatClient(workspace.ModelName) .GetChatClient(workspace.ModelName)
.AsIChatClient(); .AsIChatClient()
.AsBuilder()
.UseLogging()
.UseOpenTelemetry()
.UseFunctionInvocation()
.UseDistributedCache()
.UseChatReducer()
.Build(ServiceProvider);
IWorkspaceChatClient workspaceChatClient = new WorkspaceChatClient(chatClient, workspace);
return Task.FromResult(chatClient); return Task.FromResult(workspaceChatClient);
} }
} }

69
aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/WorkspaceChatClient.cs

@ -0,0 +1,69 @@
using LINGYUN.Abp.AI.Tools;
using LINGYUN.Abp.AI.Workspaces;
using Microsoft.Extensions.AI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.AI;
public class WorkspaceChatClient : IWorkspaceChatClient
{
public IChatClient Client { get; }
public WorkspaceDefinition? Workspace { get; }
public WorkspaceChatClient(
IChatClient chatClient,
WorkspaceDefinition? workspace = null)
{
Workspace = workspace;
Client = chatClient;
}
public virtual Task<ChatResponse> GetResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
{
return Client.GetResponseAsync(GetChatMessages(messages), GetChatOptions(options), cancellationToken);
}
public virtual IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
{
return Client.GetStreamingResponseAsync(GetChatMessages(messages), GetChatOptions(options), cancellationToken);
}
public virtual object? GetService(Type serviceType, object? serviceKey = null)
{
return Client.GetService(serviceType, serviceKey);
}
public virtual void Dispose()
{
Client.Dispose();
}
protected virtual ChatOptions GetChatOptions(ChatOptions? options)
{
options ??= new ChatOptions();
options.Instructions = Workspace?.Instructions;
options.Temperature ??= Workspace?.Temperature;
options.MaxOutputTokens ??= Workspace?.MaxOutputTokens;
options.FrequencyPenalty ??= Workspace?.FrequencyPenalty;
options.PresencePenalty ??= Workspace?.PresencePenalty;
return options;
}
protected virtual IEnumerable<ChatMessage> GetChatMessages(IEnumerable<ChatMessage> messages)
{
if (Workspace?.SystemPrompt?.IsNullOrWhiteSpace() == false &&
!messages.Any(msg => msg.Role == ChatRole.System))
{
// 加入系统提示词
messages = new List<ChatMessage>
{
new ChatMessage(ChatRole.System, Workspace.SystemPrompt)
}.Union(messages);
}
return messages;
}
}

86
aspnet-core/modules/ai/LINGYUN.Abp.AI.Core/LINGYUN/Abp/AI/Workspaces/WorkspaceDefinition.cs

@ -41,16 +41,84 @@ public class WorkspaceDefinition : IHasSimpleStateCheckers<WorkspaceDefinition>
/// <summary> /// <summary>
/// API 身份验证密钥 /// API 身份验证密钥
/// </summary> /// </summary>
public string? ApiKey { get; set; } public string? ApiKey { get; private set; }
/// <summary> /// <summary>
/// 自定义端点 URL /// 自定义端点 URL
/// </summary> /// </summary>
public string? ApiBaseUrl { get; set; } public string? ApiBaseUrl { get; private set; }
/// <summary> /// <summary>
/// 系统提示词 /// 系统提示词
/// </summary> /// </summary>
public string? SystemPrompt { get; set; } public string? SystemPrompt { get; set; }
/// <summary> /// <summary>
/// 附加系统提示词
/// </summary>
public string? Instructions { get; set; }
/// <summary>
/// 聊天回复时所依据的温度值, 为空时由模型提供者决定默认值
/// </summary>
/// <remarks>
/// 范围在 0 到 2 之间, 数值越高(比如 0.8)会使输出更加随机,而数值越低(比如 0.2)则会使输出更加集中且更具确定性
/// </remarks>
public float? Temperature {
get => _temperature;
set {
if (value.HasValue)
{
_temperature = Check.Range(value.Value, nameof(value), 0, 2);
}
else
{
_temperature = value;
}
}
}
private float? _temperature;
/// <summary>
/// 限制一次请求中模型生成 completion 的最大 token 数
/// </summary>
public int? MaxOutputTokens { get; set; }
/// <summary>
/// 介于 -2.0 和 2.0 之间的数字
/// </summary>
/// <remarks>
/// 如果该值为正,那么新 token 会根据其在已有文本中的出现频率受到相应的惩罚,降低模型重复相同内容的可能性
/// </remarks>
public float? FrequencyPenalty {
get => _frequencyPenalty;
set {
if (value.HasValue)
{
_frequencyPenalty = Check.Range(value.Value, nameof(value), -2, 2);
}
else
{
_frequencyPenalty = value;
}
}
}
private float? _frequencyPenalty;
/// <summary>
/// 介于 -2.0 和 2.0 之间的数字
/// </summary>
/// <remarks>
/// 如果该值为正,那么新 token 会根据其是否已在已有文本中出现受到相应的惩罚,从而增加模型谈论新主题的可能性
/// </remarks>
public float? PresencePenalty {
get => _presencePenalty;
set {
if (value.HasValue)
{
_presencePenalty = Check.Range(value.Value, nameof(value), -2, 2);
}
else
{
_presencePenalty = value;
}
}
}
private float? _presencePenalty;
/// <summary>
/// 启用/禁用工作区 /// 启用/禁用工作区
/// </summary> /// </summary>
public bool IsEnabled { get; set; } public bool IsEnabled { get; set; }
@ -65,7 +133,13 @@ public class WorkspaceDefinition : IHasSimpleStateCheckers<WorkspaceDefinition>
string provider, string provider,
string modelName, string modelName,
ILocalizableString displayName, ILocalizableString displayName,
ILocalizableString? description = null) ILocalizableString? description = null,
string? systemPrompt = null,
string? instructions = null,
float? temperature = null,
int? maxOutputTokens = null,
float? frequencyPenalty = null,
float? presencePenalty = null)
{ {
Name = name; Name = name;
Provider = provider; Provider = provider;
@ -73,6 +147,12 @@ public class WorkspaceDefinition : IHasSimpleStateCheckers<WorkspaceDefinition>
_displayName = displayName; _displayName = displayName;
_displayName = displayName; _displayName = displayName;
Description = description; Description = description;
SystemPrompt = systemPrompt;
Instructions = instructions;
Temperature = temperature;
MaxOutputTokens = maxOutputTokens;
FrequencyPenalty = frequencyPenalty;
PresencePenalty = presencePenalty;
IsEnabled = true; IsEnabled = true;
Properties = new Dictionary<string, object>(); Properties = new Dictionary<string, object>();

Loading…
Cancel
Save