chat-agent
<ai.chat-agent>
用于与 AI 机器人进 行对话的代理构件,处理通信并整合消息。
Properties
Name | Description | Type | Default | Required |
---|---|---|---|---|
agentId | string | |||
robotId | string | |||
conversationId | string | |||
alwaysUseNewConversation | boolean |
Events
Name | Description | Event Detail |
---|---|---|
messages.update | Message[] | |
busy.change | boolean | |
conversationId.change | string | null |
Methods
Name | Description | Params | Returns |
---|---|---|---|
postMessage | 发送消息到默认的聊天 API | content: string | |
sendRequest | 发送聊天请求到指定的 URL | leadingMessages: string | BaseMessage[] , url: string , options: Options<MessageChunk> | |
lowLevelSendRequest | 发送底层聊天请求到指定的 URL。接口的请求和响应的数据结构和 OpenAI 聊天接口一致。 | leadingMessages: string | BaseMessage[] , url: string , options: Options<MessageChunk> | |
newConversation |
Type references
BaseMessage
Name | Type | Required | Description |
---|---|---|---|
role | "user" | "assistant" | ✅ | |
content | string | ✅ |
MessageChunk
Name | Type | Required | Description |
---|---|---|---|
delta | BaseMessage | ✅ | |
conversationId | string | ||
key | number | ✅ | |
partial | boolean |
Message
extends BaseMessage
Name | Type | Required | Description |
---|---|---|---|
key | number | ✅ | |
partial | boolean | ||
failed | boolean |