namespace AIStudio.Chat.Embedded; /// /// An embedded chat as EmbeddedChatService keeps it, with whether the model answers in it right now. /// public sealed class EmbeddedConversation { /// /// The ID of the chat. /// public required Guid ChatId { get; init; } /// /// The assistant which shows the chat. Its requests register in AssistantSessionService under it. /// public required Tools.Components Component { get; init; } /// /// Where the chat lives. /// public required IEmbeddedChatStore Store { get; init; } /// /// The thread of the chat, or null when this version cannot open the stored one. /// public ChatThread? Thread { get; internal set; } /// /// Whether the model answers in the chat right now. /// public bool IsRunning { get; internal set; } /// /// Whether the chat could be opened. /// public bool IsAvailable => this.Thread is not null; /// /// Whether the chat holds any message the user sees. /// public bool HasVisibleMessages => this.Thread?.Blocks.Any(block => !block.HideFromUser) ?? false; /// /// How many messages the user wrote in the chat, those the user does not see left aside. /// public int UserMessageCount => this.Thread?.Blocks.Count(block => block is { Role: ChatRole.USER, HideFromUser: false }) ?? 0; /// /// The first message of the user which the user sees, or null before it. /// public ContentBlock? FirstUserMessage => this.Thread?.Blocks.FirstOrDefault(block => block is { Role: ChatRole.USER, HideFromUser: false }); /// /// Whether the chat holds an answer of the model which the user sees. /// public bool HasAnswer => this.Thread?.Blocks.Any(block => block is { Role: ChatRole.AI, HideFromUser: false }) ?? false; }