namespace AIStudio.Chat.Embedded; /// /// Decides how an embedded chat opens: when it sends the message it opens with, see EmbeddedChat.OpeningMessage, and /// when it offers to let the model begin, see EmbeddedChat.StartRequest. /// public static class EmbeddedChatOpening { /// /// Tells whether an embedded chat sends its opening message now. /// /// /// The message may arrive after the chat loaded, e.g., when the parent learns it only then: it is sent all the /// same, as long as the user wrote nothing in the chat meanwhile. It is sent once per chat, also when sending /// fails and it waits in the field instead. /// /// The message the chat opens with, or null without one. /// The chat shown, or null while it loads. /// Whether the chat sent its opening message already. /// True when the chat sends the message now. public static bool SendsNow(ContentText? openingMessage, EmbeddedConversation? conversation, bool wasSent) => openingMessage is not null && !wasSent && conversation is { IsAvailable: true, IsRunning: false, UserMessageCount: 0 }; /// /// Tells whether an embedded chat offers to let the model open its conversation. /// /// /// Only before anything the user sees: once the model or the user wrote, the conversation has begun. The user may /// always write first instead. /// /// The request which lets the model begin, or null without one. /// The chat shown, or null while it loads. /// True when the chat offers to begin. public static bool OffersStart(string? startRequest, EmbeddedConversation? conversation) => !string.IsNullOrWhiteSpace(startRequest) && conversation is { IsAvailable: true, IsRunning: false, HasVisibleMessages: false }; }