Package io.jmix.aichat.data
Interface AiChatItems<T extends AiChatMessage>
- Type Parameters:
T- the application's message type
- All Superinterfaces:
DataUnit
- All Known Implementing Classes:
AbstractAiChatItems,ContainerAiChatItems,ListAiChatItems
Source of conversation messages for
AiChat: the component reads the
rendered history from it and appends generated messages to it.
Messages are read through the AiChatMessage contract, so no
property mapping is involved. Creating a message instance is not this unit's
job — AiChatMessageFactory mints it, and the unit only stores it.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAiChatItems.ItemsChangeEvent<T extends AiChatMessage>Event fired when the message collection changes.static enumKind of message collection change.Nested classes/interfaces inherited from interface io.jmix.flowui.data.DataUnit
DataUnit.StateChangeEvent -
Method Summary
Modifier and TypeMethodDescriptionvoidAppends a message to the end of the conversation.com.vaadin.flow.shared.RegistrationaddItemsChangeListener(Consumer<AiChatItems.ItemsChangeEvent<T>> listener) Adds a listener notified when the messages or one of their properties change.getItems()Returns the messages in render order.voidremoveItem(T item) Removes a message from the conversation.Methods inherited from interface io.jmix.flowui.data.DataUnit
addStateChangeListener, getState
-
Method Details
-
getItems
Returns the messages in render order. The returned list is not modifiable; useaddItem(AiChatMessage)andremoveItem(AiChatMessage)instead.- Returns:
- the messages in render order
-
addItem
Appends a message to the end of the conversation. Implementations must fire anAiChatItems.ItemsChangeEventof typeAiChatItems.ItemsChangeType.ADD—AiChatre-renders on that notification alone, so a silent mutation leaves the message unrendered.- Parameters:
item- the message to append
-
removeItem
Removes a message from the conversation. Does nothing when the message is not present. Implementations must fire anAiChatItems.ItemsChangeEventof typeAiChatItems.ItemsChangeType.REMOVEfor an actual removal —AiChatre-renders on that notification alone, so a silent mutation leaves the message rendered.- Parameters:
item- the message to remove
-
addItemsChangeListener
com.vaadin.flow.shared.Registration addItemsChangeListener(Consumer<AiChatItems.ItemsChangeEvent<T>> listener) Adds a listener notified when the messages or one of their properties change.- Parameters:
listener- the listener to add- Returns:
- a registration for removing the listener
-