Chat
Introduction
The chat component is a visual building block designed for conversational AI scenarios. It consists of a highly customizable session list and an input area, offering developers an out-of-the-box solution for AI chat interfaces. The component provides an intuitive user view and integrates seamlessly with Alibaba Cloud Model Studio applications or model services. This integration simplifies and accelerates the process of building and testing conversational AI systems for various scenarios.
Configuration items
Category |
Configuration |
Example |
Description |
Content |
Information |
|
Session information data. Use this to control the display of the chat list. This configuration accepts an array of objects with the following format. The chat component renders the session content from top to bottom according to the array order:
|
Welcome message |
Welcome message configuration. Use this to configure the content and style of the chat component's welcome message. The main configuration items are as follows:
|
||
User content configuration |
User content configuration. Use this to configure the content and style of the user role's chat bubbles in the session stream. The main configuration items are as follows:
|
||
Assistant content configuration |
Assistant content configuration. Use this to configure the content and style of the assistant role's chat bubbles in the session stream. The configuration items are the same as those for the user content configuration. |
||
Action bar |
Action bar. Use this to configure the content and trigger behavior of the interactive toolbar that appears when you hover over a chat bubble. The action bar configuration consists of the following properties:
|
||
Hide input area |
Hide input area. Specifies whether to hide the input area of the chat component. |
||
Input area configuration |
Input area configuration. Defines the style and content of the chat component's input area. The specific configuration items are as follows:
|
||
Display name |
Display name. Specifies whether to display the name of the user or assistant role in the chat bubble. |
||
Enable MagicPen enhanced rendering |
If you enable this option, the chat bubble content will support HTML tag rendering. However, this may cause rendering conflicts with other components. |
||
Enable profile picture and content on separate lines |
If you enable this option, the profile picture and chat content are displayed on separate lines. |
||
Enable TOC |
If you enable this option, you can use `## Contents` in Markdown to generate a table of contents. |
||
Custom Tags |
|
Lets you customize the rendering mode for non-standard HTML tags, such as <tag> and <ref>. |
|
Interaction |
Hide |
Hide. For more information, see Common properties. |
|
Keep layout when hidden |
Keep layout when hidden. For more information, see Common properties. |
||
Loading |
Loading. Specifies whether the chat component shows a loading state. |
||
AI integration operation |
AI integration operation. Use this to associate the chat component with an `Alibaba Cloud Model Studio agent application integration operation` or an `Alibaba Cloud Model Studio model ensemble operation`. For more information, see Integrate with Alibaba Cloud Model Studio applications and Integrate with Alibaba Cloud Model Studio models. |
||
Advanced options |
Advanced options. You can configure the following properties:
Note
On some older Android models, streaming responses may jitter when the scroll behavior is set to `Smooth`. To support older Android devices, consider switching the scroll behavior to `No animation`. |
||
Style |
Margin |
Margin. For more information, see Common properties. |
|
Mode |
Mode. The arrangement of user and assistant roles in the chat component. Options are `Document` or `Chat`. In `Document` mode, the session content for both assistant and user roles is left-aligned. |
||
Background image |
|
Sets one or more background images, corresponding to the CSS property: background-image. For more information, see the MDN documentation. |
|
Background color |
Sets the background color. Corresponding CSS property: background-color. See the MDN documentation |
||
Border radius |
Sets the corner radius of the outer border, corresponding to the CSS property: border-radius. For more information, see the MDN documentation |
||
Border |
Sets the border property, which corresponds to the CSS border property. For more information, see MDN Web Docs. |
||
Top border |
Sets the top border properties, corresponding to the CSS `border-top` property. See the MDN documentation for details. |
||
Bottom border |
Sets the properties for the bottom border. This corresponds to the CSS property: border-bottom. For more information, see the MDN documentation. |
||
Left border |
Sets the left border properties, which correspond to the CSS property: border-left. See MDN documentation for details. |
||
Right border |
Sets the right border properties. This corresponds to the CSS property: border-right. See details on MDN. |
Properties and methods
Name |
Type |
Example |
Description |
chats |
Array<{ id: string createAt: number; updateAt: number; role: user | assistant; content: string; parentId?: string; }> |
|
The session data of the chat component. |
loading |
boolean |
|
The current loading state of the chat component. |
setChats |
func |
|
Sets the session data for the chat component. |
clearChats |
func |
|
Clears the session data of the chat component. |
setLoading |
func |
|
Sets the loading state of the chat component. |
clearLoading |
func |
|
Clears the loading state of the chat component. |
sendMessage |
func |
|
Sends a message as the user role in the chat component. |
clearMessage |
func |
|
Clears the current session stream of the chat component. |
stopGenerateMessage |
func |
|
Stops the process of the current streaming response in the chat component. |
setMessageContent |
func |
|
Changes the content of the session data for a specified ID. |
scrollToBottom |
func |
|
Scrolls the chat component's session stream to the bottom. |
Event callbacks
Configuration |
Description |
The event triggered when content is sent. |
|
The event triggered when a response is complete. |
|
The event triggered when an image is uploaded successfully. (This takes effect only when image input is enabled). |
|
The event triggered when an image fails to upload. (This takes effect only when image input is enabled). |
|
The event triggered when an image is deleted. (This takes effect only when image input is enabled). |
|
The event triggered when a file is uploaded successfully. (This takes effect only when file input is enabled). |
|
The event triggered when a file fails to upload. (This takes effect only when file input is enabled). |
|
The event triggered when a file is deleted. (This takes effect only when file input is enabled). |


