using Microsoft.SemanticKernel.ChatCompletion; namespace AI.Models.Store { /// /// 会话存储条目的抽象基类。每条为 TextEntry(角色+文本)或 SpecialEntry(类型+YAML 载荷)。 /// 存储由 ChatSession 持有,作为 UI 与 Prompt 构建的唯一事实来源。 /// public abstract class ConversationEntry { /// /// 条目种类:Text 或 Special,用于序列化/反序列化与类型判别。 /// public abstract string Kind { get; } } /// /// 纯文本消息条目:角色(User/Assistant/System)+ 文本内容。 /// public sealed class TextConversationEntry : ConversationEntry { public override string Kind => "Text"; /// 角色 public AuthorRole Role { get; set; } /// 文本内容 public string Content { get; set; } = string.Empty; public TextConversationEntry() { } public TextConversationEntry(AuthorRole role, string content) { Role = role; Content = content ?? string.Empty; } } /// /// 特殊消息条目:类型(Form/ParameterSet/Table/ColumnMatch/WorkflowStatus)+ YAML 载荷。 /// public sealed class SpecialConversationEntry : ConversationEntry { public override string Kind => "Special"; /// 特殊消息类型名 public string Type { get; set; } = string.Empty; /// YAML 载荷(与 ISpecialMessage 可序列化/反序列化对应) public string Payload { get; set; } = string.Empty; public SpecialConversationEntry() { } public SpecialConversationEntry(string type, string payload) { Type = type ?? string.Empty; Payload = payload ?? string.Empty; } } }