using BotSharp.Abstraction.Functions.Models; using BotSharp.Abstraction.Plugins.Models; using BotSharp.Abstraction.Routing.Models; using BotSharp.Abstraction.Tasks.Models; namespace BotSharp.Abstraction.Agents.Models; public class Agent { public string Id { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; /// /// Agent Type /// public string Type { get; set; } = AgentType.Task; public DateTime CreatedDateTime { get; set; } public DateTime UpdatedDateTime { get; set; } /// /// Default LLM settings /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public AgentLlmConfig LlmConfig { get; set; } = new AgentLlmConfig(); /// /// Instruction /// [JsonIgnore] public string? Instruction { get; set; } /// /// Templates /// [JsonIgnore] public List Templates { get; set; } = new List(); /// /// Agent tasks /// [JsonIgnore] public List Tasks { get; set; } = new List(); /// /// Samples /// [JsonIgnore] public List Samples { get; set; } = new List(); /// /// Functions /// [JsonIgnore] public List Functions { get; set; } = new List(); /// /// Responses /// [JsonIgnore] public List? Responses { get; set; } /// /// Domain knowledges /// [JsonIgnore] public string? Knowledges { get; set; } public bool IsPublic { get; set; } [JsonIgnore] public PluginDef Plugin { get; set; } [JsonIgnore] public bool Installed => Plugin.Enabled; /// /// Default is True, user will enable this by installing appropriate plugin. /// public bool Disabled { get; set; } = true; public string? IconUrl { get; set; } /// /// Profile by channel /// public List Profiles { get; set; } = new List(); /// /// Agent utilities /// public List Utilities { get; set; } = new List(); /// /// Inherit from agent /// public string? InheritAgentId { get; set; } public List RoutingRules { get; set; } = new List(); /// /// For rendering deferral /// [JsonIgnore] public Dictionary TemplateDict { get; set; } = new Dictionary(); public override string ToString() => $"{Name} {Id}"; public static Agent Clone(Agent agent) { return new Agent { Id = agent.Id, Name = agent.Name, Description = agent.Description, Type = agent.Type, Instruction = agent.Instruction, Functions = agent.Functions, Responses = agent.Responses, Samples = agent.Samples, Utilities = agent.Utilities, Knowledges = agent.Knowledges, IsPublic = agent.IsPublic, Disabled = agent.Disabled, Profiles = agent.Profiles, RoutingRules = agent.RoutingRules, LlmConfig = agent.LlmConfig, CreatedDateTime = agent.CreatedDateTime, UpdatedDateTime = agent.UpdatedDateTime, }; } public Agent SetInstruction(string instruction) { Instruction = instruction; return this; } public Agent SetTemplates(List templates) { Templates = templates ?? new List(); return this; } public Agent SetTasks(List tasks) { Tasks = tasks ?? new List(); return this; } public Agent SetFunctions(List functions) { Functions = functions ?? new List(); return this; } public Agent SetSamples(List samples) { Samples = samples ?? new List(); return this; } public Agent SetUtilities(List utilities) { Utilities = utilities ?? new List(); return this; } public Agent SetResponses(List responses) { Responses = responses ?? new List(); ; return this; } public Agent SetId(string id) { Id = id; return this; } public Agent SetName(string name) { Name = name; return this; } public Agent SetDescription(string description) { Description = description; return this; } public Agent SetIsPublic(bool isPublic) { IsPublic = isPublic; return this; } public Agent SetDisabled(bool disabled) { Disabled = disabled; return this; } public Agent SetAgentType(string type) { Type = type; return this; } public Agent SetProfiles(List profiles) { Profiles = profiles ?? new List(); return this; } public Agent SetRoutingRules(List rules) { RoutingRules = rules ?? new List(); return this; } public Agent SetLlmConfig(AgentLlmConfig? llmConfig) { LlmConfig = llmConfig; return this; } }