-
-
Notifications
You must be signed in to change notification settings - Fork 539
/
Copy pathAgentViewModel.cs
109 lines (87 loc) · 3.65 KB
/
AgentViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using BotSharp.Abstraction.Agents.Models;
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Plugins.Models;
using BotSharp.Abstraction.Routing.Models;
using System.Text.Json.Serialization;
namespace BotSharp.OpenAPI.ViewModels.Agents;
public class AgentViewModel
{
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Type { get; set; } = AgentType.Task;
public string Instruction { get; set; }
[JsonPropertyName("channel_instructions")]
public List<ChannelInstruction> ChannelInstructions { get; set; }
public List<AgentTemplate> Templates { get; set; }
public List<FunctionDef> Functions { get; set; }
public List<AgentResponse> Responses { get; set; }
public List<string> Samples { get; set; }
[JsonPropertyName("merge_utility")]
public bool MergeUtility { get; set; }
public List<AgentUtility> Utilities { get; set; }
[JsonPropertyName("mcp_tools")]
public List<McpTool> McpTools { get; set; }
[JsonPropertyName("knowledge_bases")]
public List<AgentKnowledgeBase> KnowledgeBases { get; set; }
[JsonPropertyName("rules")]
public List<AgentRule> Rules { get; set; }
[JsonPropertyName("is_public")]
public bool IsPublic { get; set; }
[JsonPropertyName("is_host")]
public bool IsHost { get; set; }
[JsonPropertyName("is_router")]
public bool IsRouter => Type == AgentType.Routing;
public bool Disabled { get; set; }
[JsonPropertyName("icon_url")]
public string IconUrl { get; set; }
public List<string> Profiles { get; set; } = new();
public List<string> Labels { get; set; } = new();
[JsonPropertyName("routing_rules")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<RoutingRule> RoutingRules { get; set; }
[JsonPropertyName("llm_config")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public AgentLlmConfig? LlmConfig { get; set; }
[JsonPropertyName("max_message_count")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? MaxMessageCount { get; set; }
public PluginDef Plugin { get; set; }
public IEnumerable<string>? Actions { get; set; }
[JsonPropertyName("created_datetime")]
public DateTime CreatedDateTime { get; set; }
[JsonPropertyName("updated_datetime")]
public DateTime UpdatedDateTime { get; set; }
public static AgentViewModel FromAgent(Agent agent)
{
return new AgentViewModel
{
Id = agent.Id,
Name = agent.Name,
Description = agent.Description,
Type = agent.Type,
Instruction = agent.Instruction,
ChannelInstructions = agent.ChannelInstructions ?? [],
Templates = agent.Templates ?? [],
Functions = agent.Functions ?? [],
Responses = agent.Responses ?? [],
Samples = agent.Samples ?? [],
Utilities = agent.Utilities ?? [],
McpTools = agent.McpTools ?? [],
KnowledgeBases = agent.KnowledgeBases ?? [],
IsPublic= agent.IsPublic,
Disabled = agent.Disabled,
MergeUtility = agent.MergeUtility,
IconUrl = agent.IconUrl,
MaxMessageCount = agent.MaxMessageCount,
Profiles = agent.Profiles ?? [],
Labels = agent.Labels ?? [],
RoutingRules = agent.RoutingRules ?? [],
Rules = agent.Rules ?? [],
LlmConfig = agent.LlmConfig,
Plugin = agent.Plugin,
CreatedDateTime = agent.CreatedTime,
UpdatedDateTime = agent.UpdatedTime
};
}
}