useXChat
useXChat
Work with agent hook for data management.
Importimport{ useXChat }from"@ant-design/x"; |
Sourcecomponents/use-x-chat |
Importimport{ useXChat }from"@ant-design/x"; |
Sourcecomponents/use-x-chat |
Use Agent to manage conversation data and produce data for page rendering.
type useXChat<AgentMessage, ParsedMessage = AgentMessage> = (config: XChatConfig<AgentMessage, ParsedMessage>,) => XChatConfigReturnType;
Property | Description | Type | Default | Version |
---|---|---|---|---|
agent | Agent generated by useXAgent | XAgent | - | |
defaultMessages | default messages | { status, message }[] | - | |
parser | Convert AgentMessage to ParsedMessage for consumption. If not set, AgentMessage will be consumed directly. Supports converting one AgentMessage to multiple ParsedMessages | (message: AgentMessage) => BubbleMessage | BubbleMessage[] | - | |
requestFallback | Fallback when request fails, not provided will not be displayed | AgentMessage | () => AgentMessage | - | |
requestPlaceholder | Show the placeholder information when requesting, not provided will not be displayed | AgentMessage | () => AgentMessage | - |
Property | Description | Type | Version |
---|---|---|---|
messages | Current managed messages content | AgentMessages[] | |
parsedMessages | Parsed messages by parser api | ParsedMessages[] | |
onRequest | Create a message and trigger a request | (message) => void | |
setMessages | Modify messages directly without triggering requests | (messages: { message, status }[]) => void |