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-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
|
|
|
|
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; }
|
|
|
|
|
|
|
|
|
|
/// <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
|
|
|
|
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
|
|
|
|
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-01-26 04:32:48 +00:00
|
|
|
Type = Type,
|
2023-09-18 23:14:24 +00:00
|
|
|
Profiles = Profiles ?? new List<string>(),
|
2024-08-13 21:36:12 +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,
|
2024-08-13 21:36:12 +00:00
|
|
|
ChannelInstructions = ChannelInstructions ?? new List<ChannelInstruction>(),
|
2023-09-15 20:19:44 +00:00
|
|
|
Templates = Templates ?? new List<AgentTemplate>(),
|
2023-09-27 20:49:44 +00:00
|
|
|
Functions = Functions ?? new List<FunctionDef>(),
|
2023-12-13 20:26:46 +00:00
|
|
|
Responses = Responses ?? new List<AgentResponse>(),
|
2024-11-20 23:10:38 +00:00
|
|
|
Utilities = Utilities ?? new List<AgentUtility>(),
|
2023-12-13 20:26:46 +00:00
|
|
|
LlmConfig = LlmConfig
|
2023-08-19 00:15:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return agent;
|
|
|
|
|
}
|
|
|
|
|
}
|