BotSharp/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/Conversation.cs

111 lines
3.1 KiB
C#
Raw Normal View History

2023-11-15 13:33:46 +00:00
using BotSharp.Abstraction.Conversations.Enums;
2023-09-08 18:16:23 +00:00
namespace BotSharp.Abstraction.Conversations.Models;
2023-06-27 18:31:13 +00:00
public class Conversation
{
public string Id { get; set; } = string.Empty;
public string AgentId { get; set; } = string.Empty;
public string UserId { get; set; } = string.Empty;
2024-02-12 15:14:33 +00:00
/// <summary>
/// Agent task id
/// </summary>
public string? TaskId { get; set; }
public string Title { get; set; } = string.Empty;
2024-12-12 03:28:00 +00:00
public string TitleAlias { get; set; } = string.Empty;
2023-11-15 13:33:46 +00:00
2023-09-08 18:16:23 +00:00
[JsonIgnore]
public List<DialogElement> Dialogs { get; set; } = [];
2023-11-15 13:33:46 +00:00
2023-09-08 18:16:23 +00:00
[JsonIgnore]
public Dictionary<string, string> States { get; set; } = [];
2023-06-27 18:31:13 +00:00
2023-11-15 13:33:46 +00:00
public string Status { get; set; } = ConversationStatus.Open;
public string Channel { get; set; } = ConversationChannel.OpenAPI;
2024-10-25 02:12:59 +00:00
/// <summary>
/// Channel id, like phone number, email address, etc.
/// </summary>
public string ChannelId { get; set; } = default!;
2024-10-25 02:12:59 +00:00
2024-03-25 22:29:08 +00:00
public int DialogCount { get; set; }
public List<string> Tags { get; set; } = [];
2024-10-18 20:50:39 +00:00
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
}
2023-11-22 00:16:45 +00:00
public class DialogElement
{
2024-05-07 20:31:39 +00:00
[JsonPropertyName("meta_data")]
public DialogMetaData MetaData { get; set; } = new();
2024-05-07 20:31:39 +00:00
[JsonPropertyName("content")]
public string Content { get; set; } = default!;
2024-05-07 20:31:39 +00:00
[JsonPropertyName("secondary_content")]
2024-04-18 21:34:18 +00:00
public string? SecondaryContent { get; set; }
2024-05-07 20:31:39 +00:00
[JsonPropertyName("rich_content")]
2024-02-22 16:02:11 +00:00
public string? RichContent { get; set; }
2024-05-07 20:31:39 +00:00
[JsonPropertyName("secondary_rich_content")]
2024-04-18 21:34:18 +00:00
public string? SecondaryRichContent { get; set; }
2024-05-07 20:31:39 +00:00
[JsonPropertyName("payload")]
2024-05-07 16:55:44 +00:00
public string? Payload { get; set; }
2023-11-22 00:16:45 +00:00
2025-02-17 17:56:53 +00:00
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("data")]
public object? Data { get; set; }
2023-11-22 00:16:45 +00:00
public DialogElement()
{
}
2024-04-18 21:34:18 +00:00
public DialogElement(DialogMetaData meta, string content, string? richContent = null,
2025-02-17 17:56:53 +00:00
string? secondaryContent = null, string? secondaryRichContent = null, string? payload = null, object? data = null)
2023-11-22 00:16:45 +00:00
{
MetaData = meta;
Content = content;
2024-02-22 16:02:11 +00:00
RichContent = richContent;
2024-04-18 21:34:18 +00:00
SecondaryContent = secondaryContent;
SecondaryRichContent = secondaryRichContent;
2024-05-07 16:55:44 +00:00
Payload = payload;
2025-02-17 17:56:53 +00:00
Data = data;
2023-11-22 00:16:45 +00:00
}
2024-03-24 17:33:41 +00:00
public override string ToString()
{
return $"{MetaData.Role}: {Content} [{MetaData?.CreatedTime}]";
2024-03-24 17:33:41 +00:00
}
2023-11-22 00:16:45 +00:00
}
2023-12-28 18:27:09 +00:00
2024-02-22 16:02:11 +00:00
public class DialogMetaData
2023-12-28 18:27:09 +00:00
{
2024-05-07 20:31:39 +00:00
[JsonPropertyName("role")]
public string Role { get; set; } = default!;
2024-05-07 20:31:39 +00:00
[JsonPropertyName("agent_id")]
public string AgentId { get; set; } = default!;
2024-05-07 20:31:39 +00:00
[JsonPropertyName("message_id")]
public string MessageId { get; set; } = default!;
2024-05-07 20:31:39 +00:00
2024-10-07 21:35:39 +00:00
[JsonPropertyName("message_type")]
public string MessageType { get; set; } = default!;
2024-10-07 21:35:39 +00:00
2024-05-07 20:31:39 +00:00
[JsonPropertyName("function_name")]
2023-12-28 18:27:09 +00:00
public string? FunctionName { get; set; }
2024-05-07 20:31:39 +00:00
[JsonPropertyName("sender_id")]
2023-12-28 18:27:09 +00:00
public string? SenderId { get; set; }
2024-05-07 20:31:39 +00:00
[JsonPropertyName("create_at")]
public DateTime CreatedTime { get; set; }
2023-12-28 18:27:09 +00:00
}