BotSharp/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs

165 lines
3.7 KiB
C#
Raw Normal View History

2023-09-18 18:13:49 +00:00
using BotSharp.Abstraction.Routing.Models;
2023-09-12 04:27:04 +00:00
2023-06-11 15:22:48 +00:00
namespace BotSharp.Abstraction.Agents.Models;
public class Agent
{
public string Id { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
2023-09-18 23:14:24 +00:00
public string Description { get; set; } = string.Empty;
2023-06-11 15:22:48 +00:00
public DateTime CreatedDateTime { get; set; }
public DateTime UpdatedDateTime { get; set; }
2023-06-23 04:43:00 +00:00
/// <summary>
/// Instruction
/// </summary>
2023-09-12 04:27:04 +00:00
[JsonIgnore]
2023-06-23 04:43:00 +00:00
public string Instruction { get; set; }
2023-09-12 22:08:58 +00:00
/// <summary>
/// Templates
/// </summary>
[JsonIgnore]
public List<AgentTemplate> Templates { get; set; }
2023-06-23 04:43:00 +00:00
/// <summary>
/// Samples
/// </summary>
2023-09-12 04:27:04 +00:00
[JsonIgnore]
2023-06-23 04:43:00 +00:00
public string Samples { get; set; }
2023-06-29 23:14:57 +00:00
/// <summary>
2023-07-26 21:05:30 +00:00
/// Functions
2023-06-29 23:14:57 +00:00
/// </summary>
2023-09-12 04:27:04 +00:00
[JsonIgnore]
2023-09-02 05:10:46 +00:00
public List<string> Functions { get; set; }
2023-06-29 23:14:57 +00:00
2023-06-11 15:22:48 +00:00
/// <summary>
2023-09-02 05:10:46 +00:00
/// Responses
2023-06-11 15:22:48 +00:00
/// </summary>
2023-09-12 04:27:04 +00:00
[JsonIgnore]
2023-09-09 21:44:25 +00:00
public List<AgentResponse> Responses { get; set; }
2023-08-17 04:04:23 +00:00
2023-08-28 05:28:14 +00:00
/// <summary>
2023-09-02 05:10:46 +00:00
/// Domain knowledges
2023-08-28 05:28:14 +00:00
/// </summary>
2023-09-12 04:27:04 +00:00
[JsonIgnore]
2023-09-02 05:10:46 +00:00
public string Knowledges { get; set; }
2023-08-28 05:28:14 +00:00
2023-09-04 15:15:11 +00:00
public bool IsPublic { get; set; }
2023-09-18 18:13:49 +00:00
/// <summary>
/// Allow to be routed
/// </summary>
public bool AllowRouting { get; set; }
public bool Disabled { get; set; }
/// <summary>
/// Profile by channel
/// </summary>
public List<string> Profiles { get; set; }
= new List<string>();
public List<RoutingRule> RoutingRules { get; set; }
= new List<RoutingRule>();
2023-08-17 04:04:23 +00:00
public override string ToString()
=> $"{Name} {Id}";
2023-09-02 05:10:46 +00:00
2023-09-07 22:04:34 +00:00
public static Agent Clone(Agent agent)
{
return new Agent
{
Id = agent.Id,
Name = agent.Name,
Description = agent.Description,
Instruction = agent.Instruction,
Functions = agent.Functions,
Responses = agent.Responses,
Samples = agent.Samples,
Knowledges = agent.Knowledges,
IsPublic = agent.IsPublic,
2023-09-18 23:14:24 +00:00
Disabled = agent.Disabled,
AllowRouting = agent.AllowRouting,
Profiles = agent.Profiles,
RoutingRules = agent.RoutingRules,
2023-09-07 22:04:34 +00:00
CreatedDateTime = agent.CreatedDateTime,
UpdatedDateTime = agent.UpdatedDateTime,
};
}
2023-09-02 05:10:46 +00:00
public Agent SetInstruction(string instruction)
{
Instruction = instruction;
return this;
}
2023-09-12 22:08:58 +00:00
public Agent SetTemplates(List<AgentTemplate> templates)
{
2023-09-18 23:14:24 +00:00
Templates = templates ?? new List<AgentTemplate>();
2023-09-12 22:08:58 +00:00
return this;
}
2023-09-02 05:10:46 +00:00
public Agent SetFunctions(List<string> functions)
{
2023-09-03 04:11:53 +00:00
Functions = functions ?? new List<string>();
2023-09-02 05:10:46 +00:00
return this;
}
2023-09-09 21:44:25 +00:00
public Agent SetResponses(List<AgentResponse> responses)
2023-09-02 05:10:46 +00:00
{
2023-09-09 21:44:25 +00:00
Responses = responses ?? new List<AgentResponse>(); ;
2023-09-02 05:10:46 +00:00
return this;
}
2023-09-07 22:04:34 +00:00
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;
}
2023-09-18 23:14:24 +00:00
public Agent SetDisabled(bool disabled)
{
Disabled = disabled;
return this;
}
public Agent SetAllowRouting(bool allowRouting)
{
AllowRouting = allowRouting;
return this;
}
public Agent SetProfiles(List<string> profiles)
{
Profiles = profiles ?? new List<string>();
return this;
}
public Agent SetRoutingRules(List<RoutingRule> rules)
{
RoutingRules = rules ?? new List<RoutingRule>();
return this;
}
2023-06-11 15:22:48 +00:00
}