2023-10-27 20:36:26 +00:00
|
|
|
using BotSharp.Abstraction.Functions.Models;
|
2023-10-27 15:18:48 +00:00
|
|
|
using BotSharp.Abstraction.Models;
|
|
|
|
|
|
2023-06-27 18:31:13 +00:00
|
|
|
namespace BotSharp.Abstraction.Conversations.Models;
|
|
|
|
|
|
2023-10-27 15:18:48 +00:00
|
|
|
public class RoleDialogModel : ITrackableMessage
|
2023-06-27 18:31:13 +00:00
|
|
|
{
|
2023-10-27 15:18:48 +00:00
|
|
|
public string MessageId { get; set; }
|
|
|
|
|
|
2023-06-27 18:31:13 +00:00
|
|
|
/// <summary>
|
2023-07-27 15:07:39 +00:00
|
|
|
/// user, system, assistant, function
|
2023-06-27 18:31:13 +00:00
|
|
|
/// </summary>
|
|
|
|
|
public string Role { get; set; }
|
2023-08-07 20:17:54 +00:00
|
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
2023-07-21 20:15:09 +00:00
|
|
|
public string Content { get; set; }
|
2023-10-18 11:58:36 +00:00
|
|
|
|
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
2023-08-17 04:04:23 +00:00
|
|
|
public string CurrentAgentId { get; set; }
|
2023-06-27 18:31:13 +00:00
|
|
|
|
2023-07-27 15:07:39 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Function name if LLM response function call
|
|
|
|
|
/// </summary>
|
2023-10-18 11:58:36 +00:00
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
2023-07-28 04:27:12 +00:00
|
|
|
public string? FunctionName { get; set; }
|
2023-07-27 21:56:57 +00:00
|
|
|
|
2023-10-18 11:58:36 +00:00
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
2023-08-17 04:04:23 +00:00
|
|
|
public string? FunctionArgs { get; set; }
|
|
|
|
|
|
2023-08-20 20:20:16 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Function execution structured data, this data won't pass to LLM.
|
|
|
|
|
/// It's ideal to render in rich content in UI.
|
|
|
|
|
/// </summary>
|
2023-10-18 11:58:36 +00:00
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
2023-10-23 00:31:49 +00:00
|
|
|
public object Data { get; set; }
|
2023-10-27 19:05:18 +00:00
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
|
|
|
public object? RichContent { get; set; }
|
2023-08-20 20:20:16 +00:00
|
|
|
|
2023-08-31 02:09:38 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Stop conversation completion
|
|
|
|
|
/// </summary>
|
2023-10-18 11:58:36 +00:00
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
2023-08-31 02:09:38 +00:00
|
|
|
public bool StopCompletion { get; set; }
|
|
|
|
|
|
2023-10-27 20:36:26 +00:00
|
|
|
public FunctionCallFromLlm Instruction { get; set; }
|
|
|
|
|
|
2023-10-27 15:18:48 +00:00
|
|
|
private RoleDialogModel()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-21 01:55:40 +00:00
|
|
|
public RoleDialogModel(string role, string text)
|
|
|
|
|
{
|
|
|
|
|
Role = role;
|
2023-07-21 20:15:09 +00:00
|
|
|
Content = text;
|
2023-10-27 15:18:48 +00:00
|
|
|
MessageId = Guid.NewGuid().ToString();
|
2023-07-21 01:55:40 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-27 18:31:13 +00:00
|
|
|
public override string ToString()
|
|
|
|
|
{
|
2023-08-18 04:27:07 +00:00
|
|
|
if (Role == AgentRole.Function)
|
|
|
|
|
{
|
2023-10-23 00:31:49 +00:00
|
|
|
return $"{Role}: {FunctionName}({FunctionArgs}) => {Content}";
|
2023-08-18 04:27:07 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return $"{Role}: {Content}";
|
|
|
|
|
}
|
2023-06-27 18:31:13 +00:00
|
|
|
}
|
|
|
|
|
}
|