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

80 lines
2.5 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;
2024-01-13 21:17:40 +00:00
using BotSharp.Abstraction.Plugins.Models;
2023-09-19 18:18:29 +00:00
using BotSharp.Abstraction.Routing.Models;
2023-11-27 21:00:26 +00:00
using System.Text.Json.Serialization;
2023-08-19 00:15:02 +00:00
namespace BotSharp.OpenAPI.ViewModels.Agents;
public class AgentViewModel
{
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
2024-01-26 04:32:48 +00:00
public string Type { get; set; } = AgentType.Task;
2023-08-28 05:36:11 +00:00
public string Instruction { get; set; }
2023-09-12 22:08:58 +00:00
public List<AgentTemplate> Templates { get; set; }
2023-09-27 20:49:44 +00:00
public List<FunctionDef> Functions { get; set; }
2023-09-09 21:44:25 +00:00
public List<AgentResponse> Responses { get; set; }
public List<string> Samples { get; set; }
2024-06-25 03:46:13 +00:00
public List<string> Tools { get; set; }
2024-01-27 01:14:14 +00:00
2023-12-26 03:16:41 +00:00
[JsonPropertyName("is_public")]
2023-09-04 15:15:11 +00:00
public bool IsPublic { get; set; }
2023-11-27 21:00:26 +00:00
[JsonPropertyName("is_host")]
public bool IsHost { get; set; }
2023-09-19 18:18:29 +00:00
public bool Disabled { get; set; }
2023-12-28 15:20:18 +00:00
[JsonPropertyName("icon_url")]
public string IconUrl { get; set; }
2023-09-19 18:18:29 +00:00
public List<string> Profiles { get; set; }
= new List<string>();
2023-11-27 21:00:26 +00:00
[JsonPropertyName("routing_rules")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2023-09-19 18:18:29 +00:00
public List<RoutingRule> RoutingRules { get; set; }
2023-12-24 19:57:22 +00:00
[JsonPropertyName("llm_config")]
2023-12-13 20:26:46 +00:00
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public AgentLlmConfig? LlmConfig { get; set; }
2024-01-13 21:17:40 +00:00
public PluginDef Plugin { get; set; }
2024-05-15 20:54:08 +00:00
public bool Editable { get; set; }
2023-11-27 21:00:26 +00:00
[JsonPropertyName("created_datetime")]
2023-09-15 20:19:44 +00:00
public DateTime CreatedDateTime { get; set; }
2023-11-27 21:00:26 +00:00
[JsonPropertyName("updated_datetime")]
2023-08-19 00:15:02 +00:00
public DateTime UpdatedDateTime { get; set; }
public static AgentViewModel FromAgent(Agent agent)
{
return new AgentViewModel
{
Id = agent.Id,
Name = agent.Name,
Description = agent.Description,
2024-01-26 04:32:48 +00:00
Type = agent.Type,
2023-08-28 05:36:11 +00:00
Instruction = agent.Instruction,
2023-09-12 22:08:58 +00:00
Templates = agent.Templates,
2023-08-28 05:36:11 +00:00
Functions = agent.Functions,
2023-09-02 05:10:46 +00:00
Responses = agent.Responses,
Samples = agent.Samples,
2024-06-25 03:46:13 +00:00
Tools = agent.Tools,
2023-09-04 15:15:11 +00:00
IsPublic= agent.IsPublic,
2023-09-19 18:18:29 +00:00
Disabled = agent.Disabled,
2023-12-28 15:20:18 +00:00
IconUrl = agent.IconUrl,
Profiles = agent.Profiles ?? new List<string>(),
2023-09-19 18:18:29 +00:00
RoutingRules = agent.RoutingRules,
2023-12-13 20:26:46 +00:00
LlmConfig = agent.LlmConfig,
2024-01-13 21:17:40 +00:00
Plugin = agent.Plugin,
2023-09-15 20:19:44 +00:00
CreatedDateTime = agent.CreatedDateTime,
2023-08-19 00:15:02 +00:00
UpdatedDateTime = agent.UpdatedDateTime
};
}
}