Package com.tnsai.events
Record Class UiComponentEvent
java.lang.Object
java.lang.Record
com.tnsai.events.UiComponentEvent
- Record Components:
eventId- unique identifier for this eventtimestamp- when the event occurredcomponentType- the type of UI component to renderpayload- a map containing data and options specific to the component type
- All Implemented Interfaces:
TnsAIEvent
public record UiComponentEvent(String eventId, Instant timestamp, String componentType, Map<String,Object> payload)
extends Record
implements TnsAIEvent
Event representing a request to render a specific UI component in the frontend.
This allows agents to generate rich, interactive UI elements beyond plain text.
Supports AG-UI Generative UI pattern with streaming and interactive components.
Component Types
chart- Data visualizations (bar, line, pie, etc.)table- Tabular data displaycode- Code blocks with syntax highlightingmarkdown- Formatted text contentform- Interactive forms with inputscard- Card-based layoutslist- List displaysimage- Image contentprogress- Progress indicatorsalert- Notifications and alertscustom- Custom registered components
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UiComponentEventCreates an alert/notification component.static UiComponentEventCreates an alert with title.static UiComponentEventCreates a card component.static UiComponentEventCreates a chart component with specific chart type.static UiComponentEventCreates a chart component.static UiComponentEventCreates a code block component without filename.static UiComponentEventCreates a code block component.Returns the value of thecomponentTyperecord component.static UiComponentEventCreates a custom component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.static UiComponentEventCreates a form component.final inthashCode()Returns a hash code value for this object.static UiComponentEventCreates an image component.static UiComponentEventCreates a list component.static UiComponentEventCreates a markdown component.static UiComponentEventCreates a UI component event with the specified type and payload.payload()Returns the value of thepayloadrecord component.static UiComponentEventCreates a progress indicator component.static UiComponentEventCreates a table component with columns and rows.static UiComponentEventCreates a table component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from interface com.tnsai.events.TnsAIEvent
eventType
-
Field Details
-
TYPE_CHART
- See Also:
-
TYPE_TABLE
- See Also:
-
TYPE_CODE
- See Also:
-
TYPE_MARKDOWN
- See Also:
-
TYPE_FORM
- See Also:
-
TYPE_CARD
- See Also:
-
TYPE_LIST
- See Also:
-
TYPE_IMAGE
- See Also:
-
TYPE_PROGRESS
- See Also:
-
TYPE_ALERT
- See Also:
-
TYPE_CUSTOM
- See Also:
-
-
Constructor Details
-
UiComponentEvent
public UiComponentEvent(String eventId, Instant timestamp, String componentType, Map<String, Object> payload) Creates an instance of aUiComponentEventrecord class.- Parameters:
eventId- the value for theeventIdrecord componenttimestamp- the value for thetimestamprecord componentcomponentType- the value for thecomponentTyperecord componentpayload- the value for thepayloadrecord component
-
-
Method Details
-
of
Creates a UI component event with the specified type and payload.- Parameters:
componentType- the component typepayload- the component data- Returns:
- a new UiComponentEvent
-
chart
Creates a chart component.- Parameters:
chartData- chart configuration and data- Returns:
- a new chart UiComponentEvent
-
chart
public static UiComponentEvent chart(String chartType, List<String> labels, List<Map<String, Object>> datasets) Creates a chart component with specific chart type.- Parameters:
chartType- the chart type (bar, line, pie, area, scatter, etc.)labels- data labelsdatasets- chart datasets- Returns:
- a new chart UiComponentEvent
-
table
Creates a table component.- Parameters:
tableData- table configuration and data- Returns:
- a new table UiComponentEvent
-
table
public static UiComponentEvent table(List<Map<String, Object>> columns, List<Map<String, Object>> rows) Creates a table component with columns and rows.- Parameters:
columns- column definitionsrows- table data rows- Returns:
- a new table UiComponentEvent
-
code
Creates a code block component.- Parameters:
language- programming language for syntax highlightingcontent- the code contentfilename- optional filename to display- Returns:
- a new code UiComponentEvent
-
code
Creates a code block component without filename.- Parameters:
language- programming languagecontent- the code content- Returns:
- a new code UiComponentEvent
-
markdown
Creates a markdown component.- Parameters:
content- markdown text- Returns:
- a new markdown UiComponentEvent
-
form
public static UiComponentEvent form(String formId, List<Map<String, Object>> fields, String submitLabel) Creates a form component.- Parameters:
formId- unique form identifierfields- form field definitionssubmitLabel- submit button label- Returns:
- a new form UiComponentEvent
-
card
Creates a card component.- Parameters:
title- card titlecontent- card contentactions- optional action buttons- Returns:
- a new card UiComponentEvent
-
list
Creates a list component.- Parameters:
items- list itemsordered- whether the list is ordered- Returns:
- a new list UiComponentEvent
-
image
Creates an image component.- Parameters:
src- image source (URL or base64)alt- alternative textcaption- optional caption- Returns:
- a new image UiComponentEvent
-
progress
Creates a progress indicator component.- Parameters:
value- progress value (0-100)label- progress label- Returns:
- a new progress UiComponentEvent
-
alert
Creates an alert/notification component.- Parameters:
type- alert type (info, success, warning, error)message- alert message- Returns:
- a new alert UiComponentEvent
-
alert
Creates an alert with title.- Parameters:
type- alert typetitle- alert titlemessage- alert message- Returns:
- a new alert UiComponentEvent
-
custom
Creates a custom component.- Parameters:
customType- the registered custom component typeprops- component properties- Returns:
- a new custom UiComponentEvent
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
eventId
Returns the value of theeventIdrecord component.- Specified by:
eventIdin interfaceTnsAIEvent- Returns:
- the value of the
eventIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Specified by:
timestampin interfaceTnsAIEvent- Returns:
- the value of the
timestamprecord component
-
componentType
Returns the value of thecomponentTyperecord component.- Returns:
- the value of the
componentTyperecord component
-
payload
Returns the value of thepayloadrecord component.- Returns:
- the value of the
payloadrecord component
-