Push a new UI message to update the UI state.
This function creates and sends a UI message that will be rendered in the UI. It also updates the graph state with the new UI message.
push_ui_message(
name: str,
props: dict[str, Any],
*,
id: str | None = None,
metadata: dict[str, Any] | None = None,
message: AnyMessage | None = None,
state_key: str | None = 'ui',
merge: bool = False
) -> UIMessageExample:
push_ui_message(
name="component-name",
props={"content": "Hello world"},
)| Name | Type | Description |
|---|---|---|
name* | str | Name of the UI component to render. |
props* | dict[str, Any] | Properties to pass to the UI component. |
id | str | None | Default: NoneOptional unique identifier for the UI message. If not provided, a random UUID will be generated. |
metadata | dict[str, Any] | None | Default: NoneOptional additional metadata about the UI message. |
message | AnyMessage | None | Default: NoneOptional message object to associate with the UI message. |
state_key | str | None | Default: 'ui'Key in the graph state where the UI messages are stored. |
merge | bool | Default: FalseWhether to merge props with existing UI message (True) or replace them (False). |