Ai · AIChatDialogue
AIChatDialogue
Display AI chat conversation messages to users

When to use

AIChatDialogue can be used together with AIChatInput to build richer, more comprehensive and easier-to-customize AI conversation experiences. The component message format is based on OpenAI's Response Object, and supports the OpenAI community's Response / Chat Completion format standards by default. Responses to GPT-5 and GPT-4o series models are supported out of the box. For details, see Message Data Conversion.

Demos

How to import

Basic Usage

Set chats and onChatsChange to enable basic conversation display and interactions.
Use align to control layout: leftRight (default) and leftAlign.

Message Status

chats is of type Message[]. Each Message contains various fields such as role role, content content, status status, unique identifier id, and creation time createdAt. See Message for details. The status follows the same values as the Response API Status: 6 status values mapping to 3 official styles (success / in progress / failed).

Message Display

The message content uses ContentItem[]. It supports blocks such as text, file, image, code, reasoning, annotation, and tool call. AIChatDialogue.Step is provided for step-by-step displays (e.g., workflows or plans).

References

Use references to define files or text cited by the current message. showReference controls whether a quotable style is shown for the current message. onReferenceClick configures the click handler for the reference button.

Selection

Hints

Use hints to set the hint area content. Clicking a hint populates it as the new user input and triggers onHintClick.

Custom Hint Rendering

Customize the hint area with renderHintBox. Parameters:

Custom Chat Box Rendering

Pass custom rendering configuration via chatBoxRenderConfig. Types:
You can customize the avatar and title via renderChatBoxAvatar and renderChatBoxTitle.

Custom Message Content Rendering

Use renderDialogueContentItem to provide renderers by message type. Example:

Message Data Adapters

The current component's dialogue messages are modeled after OpenAI's Response Object. To better support users in seamlessly integrating the Chat Completion API and Response API, we provide four Adapter transformation functions. Users can directly use these functions to transform the API's return results to obtain data that can be directly used for message display. Two Adapter functions are provided to process the data of the ChatInput component into an input Message format adapted to the Response API or the Input Message format in the Chat Completion API.
For example, when a user returns non-streaming data using the Chat Completion API interface, the chatCompletionToMessage function can be used to convert the Chat Completion Object into a Dialogue Message block format. Note that because the Chat Completion API allows control over the number of results generated for each input message via n, this function returns an array. (Note: If n > 1, the user needs to decide which data to add to the message for display.)
For example, when a user returns streaming data using the Chat Completion API interface, the streamingChatCompletionToMessage function can be used to convert the Chat Completion Chunk Object List into a Dialogue Message format.
When a user returns non-streaming data using the Response API interface, the responseToMessage function can be used to convert the Response Object into a Dialogue Message block format.
When a user returns streaming data using the Response API interface, the streamingResponseToMessage function can be used to convert the Response Chunk Object List into a Dialogue Message format.

API Reference

PropDescriptionTypeDefault
alignConversation layout'leftRight' | 'leftAlign''leftRight'
chatsControlled conversation messagesMessage[]-
classNameCustom class namestring-
disabledFileItemClickDisable file clickbooleanfalse
hintClsHint area outer wrapper class namestring-
hintsHint textsstring[]-
hintStyleHint area outer wrapper styleCSSProperties-
markdownRenderPropsProps passed to the MarkdownRender used by the dialogue. See MarkdownRenderPropsMarkdownRenderProps-
messageEditRenderCustom message edit renderer(props: MessageContent) => React.ReactNode-
modeConversation mode'bubble' | 'noBubble' | 'userBubble''bubble'
onAnnotationClickAnnotation click callback(annotation?: Annotation) => void-
onChatsChangeMessages change callback(chats?: Message[]) => void-
onFileClickAttachment file click callback(file?: InputFile) => void-
onHintClickHint click callback(hint: string) => void-
onImageClickImage click callback(image?: InputImage) => void-
onMessageBadFeedbackNegative feedback callback(message?: Message) => void-
onMessageCopyCopy message callback(message?: Message) => void-
onMessageDeleteDelete message callback(message?: Message) => void-
onMessageEditEdit message callback(message?: Message) => void-
onMessageGoodFeedbackPositive feedback callback(message?: Message) => void-
onMessageResetReset message callback(message?: Message) => void-
onMessageShareShare message callback(message?: Message) => void-
onReferenceClickReference button click callback(message?: Message) => void-
onSelectSelection change callback(selectedIds: string[]) => void-
renderConfigCustom render config for sectionsDialogueRenderConfig-
renderDialogueContentItemRenderer map by message content typeDialogueContentItemRendererMap-
renderHintBoxCustom hint item renderer(props: { content: string; index: number; onHintClick: () => void }) => React.ReactNode-
roleConfigRole metadata config (user/assistant/system, etc.)RoleConfig-
selectingEnable selection modebooleanfalse
showResetShow reset actionbooleantrue
showReferenceShow quotable icon in text or file messages (user messages only)booleanfalse
styleStyleCSSProperties-

RoleConfig

PropDescriptionTypeDefault
useruser infoMetadata | Map<string, Metadata>-
assistantassistant infoMetadata | Map<string, Metadata>-
systemsystem infoMetadata | Map<string, Metadata>-

MetaData

PropDescriptionTypeDefault
nameNamestring-
avatarAvatarstring-
colorAvatar background color, same as Avatar color prop. Supports amber, blue, cyan, green, grey, indigo, light-blue, light-green, lime, orange, pink, purple, red, teal, violet, yellowstringgrey

Message

PropDescriptionTypeDefault
roleRolestring-
nameNamestring-
idUnique IDstring| number-
contentMessage contentstring| ContentItem[]-
createdAtCreated at (timestamp)number-
modelModel namestring-
statusMessage status: queued | in_progress | incomplete | completed | failed | cancelledstringcompleted

Reference

PropDescriptionTypeDefault
idUnique identifierstring| number-
typetypestring-
namenamestring-
urlurlstring-
contenttext contentstring-

Methods

MethodDescription
selectAllSelect all messages
deselectAllDeselect all messages
scrollToBottom(animation: boolean)Scroll to bottom; if true, animate; otherwise no animation

ContentItem

ContentItem supports all OpenAI Response InputItem and OutputItem types. Definitions:

Design Tokens