BotSharp/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs

120 lines
3.3 KiB
C#
Raw Normal View History

2023-08-19 00:15:02 +00:00
using BotSharp.Abstraction.Agents.Models;
2023-09-27 20:49:44 +00:00
using BotSharp.Abstraction.Functions.Models;
2023-09-18 23:14:24 +00:00
using BotSharp.Abstraction.Routing.Models;
2023-12-26 03:16:41 +00:00
using System.Text.Json.Serialization;
2023-08-19 00:15:02 +00:00
namespace BotSharp.OpenAPI.ViewModels.Agents;
public class AgentUpdateModel
{
2023-12-26 03:16:41 +00:00
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
2024-01-26 04:32:48 +00:00
public string Type { get; set; } = AgentType.Task;
2023-08-19 00:15:02 +00:00
/// <summary>
/// Instruction
/// </summary>
2023-12-26 03:16:41 +00:00
public string Instruction { get; set; } = string.Empty;
2023-08-19 00:15:02 +00:00
2024-08-13 21:36:12 +00:00
/// <summary>
/// Channel instructions
/// </summary>
[JsonPropertyName("channel_instructions")]
public List<ChannelInstruction>? ChannelInstructions { get; set; }
2023-09-12 22:08:58 +00:00
/// <summary>
/// Templates
/// </summary>
public List<AgentTemplate>? Templates { get; set; }
2023-08-19 00:15:02 +00:00
/// <summary>
/// Samples
/// </summary>
2023-12-26 03:16:41 +00:00
public List<string>? Samples { get; set; }
2023-08-19 00:15:02 +00:00
2024-11-20 23:57:44 +00:00
[JsonPropertyName("merge_utility")]
public bool MergeUtility { get; set; }
2024-06-25 03:46:13 +00:00
/// <summary>
2024-07-02 18:36:45 +00:00
/// Utilities
2024-06-25 03:46:13 +00:00
/// </summary>
2024-11-20 23:10:38 +00:00
public List<AgentUtility>? Utilities { get; set; }
2024-06-25 03:46:13 +00:00
2025-02-23 14:55:35 +00:00
/// <summary>
2025-02-24 01:04:44 +00:00
/// Acps
2025-02-23 14:55:35 +00:00
/// </summary>
2025-02-24 01:04:44 +00:00
public List<AgentCP>? Acps { get; set; }
2025-02-23 14:55:35 +00:00
2024-12-24 19:21:18 +00:00
/// <summary>
/// knowledge bases
/// </summary>
///
[JsonPropertyName("knowledge_bases")]
public List<AgentKnowledgeBase>? KnowledgeBases { get; set; }
2023-08-19 00:15:02 +00:00
/// <summary>
/// Functions
/// </summary>
2023-09-27 20:49:44 +00:00
public List<FunctionDef>? Functions { get; set; }
2023-08-19 00:15:02 +00:00
2023-08-28 05:28:14 +00:00
/// <summary>
/// Routes
/// </summary>
2023-09-12 22:08:58 +00:00
public List<AgentResponse>? Responses { get; set; }
2023-08-28 05:28:14 +00:00
2024-08-13 21:36:12 +00:00
[JsonPropertyName("is_public")]
2023-09-18 23:14:24 +00:00
public bool IsPublic { get; set; }
2024-08-13 21:36:12 +00:00
[JsonPropertyName("allow_routing")]
2023-09-18 23:14:24 +00:00
public bool AllowRouting { get; set; }
public bool Disabled { get; set; }
2024-12-13 20:34:17 +00:00
[JsonPropertyName("max_message_count")]
public int? MaxMessageCount { get; set; }
2023-09-18 23:14:24 +00:00
/// <summary>
/// Profile by channel
/// </summary>
2023-09-19 18:18:29 +00:00
public List<string>? Profiles { get; set; }
2023-09-18 23:14:24 +00:00
2025-01-30 17:14:52 +00:00
public List<string>? Labels { get; set; }
2024-08-13 21:36:12 +00:00
[JsonPropertyName("routing_rules")]
2023-09-19 18:18:29 +00:00
public List<RoutingRuleUpdateModel>? RoutingRules { get; set; }
2023-09-18 23:14:24 +00:00
2025-01-07 19:50:50 +00:00
[JsonPropertyName("rules")]
public List<AgentRule>? Rules { get; set; }
2025-01-06 05:54:48 +00:00
2024-01-14 04:48:26 +00:00
[JsonPropertyName("llm_config")]
2023-12-13 20:26:46 +00:00
public AgentLlmConfig? LlmConfig { get; set; }
2023-08-19 00:15:02 +00:00
public Agent ToAgent()
{
2023-09-15 20:19:44 +00:00
var agent = new Agent()
2023-08-19 00:15:02 +00:00
{
2023-09-15 20:19:44 +00:00
Name = Name ?? string.Empty,
Description = Description ?? string.Empty,
2023-09-18 23:14:24 +00:00
IsPublic = IsPublic,
Disabled = Disabled,
2024-11-20 23:57:44 +00:00
MergeUtility = MergeUtility,
2024-12-13 20:34:17 +00:00
MaxMessageCount = MaxMessageCount,
2024-01-26 04:32:48 +00:00
Type = Type,
2025-01-06 05:54:48 +00:00
Profiles = Profiles ?? [],
2025-01-30 17:14:52 +00:00
Labels = Labels ?? [],
2025-01-06 05:54:48 +00:00
RoutingRules = RoutingRules?.Select(x => RoutingRuleUpdateModel.ToDomainElement(x))?.ToList() ?? [],
2023-09-15 20:19:44 +00:00
Instruction = Instruction ?? string.Empty,
2025-01-06 05:54:48 +00:00
ChannelInstructions = ChannelInstructions ?? [],
Templates = Templates ?? [],
Functions = Functions ?? [],
Responses = Responses ?? [],
Utilities = Utilities ?? [],
2025-02-24 01:04:44 +00:00
Acps = Acps ?? [],
2024-12-24 19:21:18 +00:00
KnowledgeBases = KnowledgeBases ?? [],
2025-01-07 19:50:50 +00:00
Rules = Rules ?? [],
2025-02-05 23:50:32 +00:00
LlmConfig = LlmConfig ?? new()
2023-08-19 00:15:02 +00:00
};
return agent;
}
}