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

72 lines
1.9 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-08-19 00:15:02 +00:00
namespace BotSharp.OpenAPI.ViewModels.Agents;
public class AgentUpdateModel
{
2023-09-15 20:19:44 +00:00
public string? Name { get; set; } = string.Empty;
2023-08-19 00:15:02 +00:00
public string? Description { get; set; }
/// <summary>
/// Instruction
/// </summary>
public string? Instruction { 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>
public string? Samples { get; set; }
/// <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
2023-09-18 23:14:24 +00:00
public bool IsPublic { get; set; }
public bool AllowRouting { get; set; }
public bool Disabled { get; set; }
/// <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
2023-09-19 18:18:29 +00:00
public List<RoutingRuleUpdateModel>? RoutingRules { get; set; }
2023-09-18 23:14:24 +00:00
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,
AllowRouting = AllowRouting,
Profiles = Profiles ?? new List<string>(),
2023-09-19 18:18:29 +00:00
RoutingRules = RoutingRules?
.Select(x => RoutingRuleUpdateModel.ToDomainElement(x))?
.ToList() ?? new List<RoutingRule>(),
2023-09-15 20:19:44 +00:00
Instruction = Instruction ?? string.Empty,
Templates = Templates ?? new List<AgentTemplate>(),
2023-09-27 20:49:44 +00:00
Functions = Functions ?? new List<FunctionDef>(),
2023-09-15 20:19:44 +00:00
Responses = Responses ?? new List<AgentResponse>()
2023-08-19 00:15:02 +00:00
};
return agent;
}
}