LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Graphs
  • Functional API
  • Pregel
  • Checkpointing
  • Storage
  • Caching
  • Types
  • Runtime
  • Config
  • Errors
  • Constants
  • Channels
  • Agents
LangGraph CLI
LangGraph SDK
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewGraphsFunctional APIPregelCheckpointingStorageCachingTypesRuntimeConfigErrorsConstantsChannelsAgents
LangGraph CLI
LangGraph SDK
LangGraph Supervisor
LangGraph Swarm
Language
Theme
Pythonlanggraphgraphuipush_ui_message
Function●Since v0.3

push_ui_message

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.

Copy
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
) -> UIMessage

Example:

push_ui_message(
    name="component-name",
    props={"content": "Hello world"},
)

Parameters

NameTypeDescription
name*str

Name of the UI component to render.

props*dict[str, Any]

Properties to pass to the UI component.

idstr | None
Default:None

Optional unique identifier for the UI message. If not provided, a random UUID will be generated.

metadatadict[str, Any] | None
Default:None

Optional additional metadata about the UI message.

messageAnyMessage | None
Default:None

Optional message object to associate with the UI message.

state_keystr | None
Default:'ui'

Key in the graph state where the UI messages are stored.

mergebool
Default:False

Whether to merge props with existing UI message (True) or replace them (False).

View source on GitHub