跳到主要内容

chat-agent

<ai.chat-agent>

用于与 AI 机器人进行对话的代理构件,处理通信并整合消息。

Properties

NameDescriptionTypeDefaultRequired
agentIdstring
robotIdstring
conversationIdstring
alwaysUseNewConversationboolean

Events

NameDescriptionEvent Detail
messages.updateMessage[]
busy.changeboolean
conversationId.changestring | null

Methods

NameDescriptionParamsReturns
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

NameTypeRequiredDescription
role"user" | "assistant"
contentstring

MessageChunk

NameTypeRequiredDescription
deltaBaseMessage
conversationIdstring
keynumber
partialboolean

Message

extends BaseMessage
NameTypeRequiredDescription
keynumber
partialboolean
failedboolean