IBot
函数型智能体框架提供了 IBot
接口,开发者只要实现一个满足 IBot
的类,就可以部署起相应的服务。
IBot
完整的方法定义及对应的服务如下:
提供的服务 | IBot 方法名 | 描述 |
---|---|---|
POST /v1/aibot/bots/:botId/send-message | sendMessage | 与智能体进行对话 |
GET /v1/aibot/bots/:botId/records | getChatRecords | 查询智能体历史对话信息 |
POST /v1/aibot/bots/:botId/recommend-questions | getRecommendQuestions | 获取推荐问题 |
POST /v1/aibot/bots/:botId/feedback | sendFeedback | 提交用户反馈 |
GET /v1/aibot/bots/:botId/feedback | getFeedback | 查询用户反馈 |
使用 BotCore
基类 能够更加快速地实现 IBot
接口。
方法
sendMessage()
sendMessage(
input
):Promise
\<void
>
sendMessage - POST /v1/aibot/bots/:botId/send-message
与 Agent 问答对话接口实现,该接口无返回值,接口内需要通过 this.sseSender 发送 Server-Sent Events 给客户端
微信基础库 wx.cloud.extend.AI.bot.sendMessage API对应接口 https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/reference-sdk-api/extend/ai.html#AI-bot-sendMessage
参数
input
发送消息的输入
返回
Promise
\<void
>
对应 HTTP API
https://docs.cloudbase.net/http-api/ai-bot/send-message
getChatRecords()?
optional
getChatRecords(input
):Promise
\<GetChatRecordOutput
>
getChatRecords - GET /v1/aibot/bots/:botId/records
查询 Agent 历史对话信息接口实现,返回历史对话记录。
注意:需在 sendMessage 接口中实现记录对话信息,并在此接口查询对话信息并中返回
微信基础库 wx.cloud.extend.AI.bot.getChatRecords API对应接口 https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/reference-sdk-api/extend/ai.html#AI-bot-getChatRecords
参数
input
返回
Promise
\<GetChatRecordOutput
>
对应 HTTP API
https://docs.cloudbase.net/http-api/ai-bot/get-chat-history
getFeedback()?
optional
getFeedback(input
):Promise
\<GetFeedbackOutput
>
getFeedback - GET /v1/aibot/bots/:botId/feedback
获取用户反馈接口实现,返回用户反馈列表
微信基础库 wx.cloud.extend.AI.bot.getFeedBack API对应接口 https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/reference-sdk-api/extend/ai.html#AI-bot-getFeedBack
参数
input
返回
Promise
\<GetFeedbackOutput
>
对应 HTTP API
https://docs.cloudbase.net/http-api/ai-bot/get-feedback
getRecommendQuestions()?
optional
getRecommendQuestions(input
):Promise
\<void
>
getRecommendQuestions - POST /v1/aibot/bots/:botId/recommend-questions
获取推荐问题接口实现,返回推荐问题列表
微信基础库 wx.cloud.extend.AI.bot.getRecommendQuestions API对应接口 https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/reference-sdk-api/extend/ai.html#AI-bot-getRecommendQuestions
参数
input
返回
Promise
\<void
>
对应 HTTP API
https://docs.cloudbase.net/http-api/ai-bot/get-recommend-questions
sendFeedback()?
optional
sendFeedback(input
):Promise
\<SendFeedbackOutput
>
sendFeedback - POST /v1/aibot/bots/:botId/feedback
发送用户反馈接口实现,返回发送用户反馈结果
微信基础库 wx.cloud.extend.AI.bot.sendFeedback API对应接口 https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloud/reference-sdk-api/extend/ai.html#AI-bot-sendFeedback
参数
input
返回
Promise
\<SendFeedbackOutput
>
对应 HTTP API
https://docs.cloudbase.net/http-api/ai-bot/send-feedback
类型
GetChatRecordInput
属性
pageNumber
pageNumber:
number
pageSize
pageSize:
number
sort
sort:
string
GetChatRecordOutput
属性
recordList
recordList:
object
[]
botId?
optional
botId:string
content?
optional
content:string
conversation?
optional
conversation:string
createTime?
optional
createTime:string
image?
optional
image:string
recordId?
optional
recordId:string
reply?
optional
reply:string
replyTo?
optional
replyTo:string
role?
optional
role:string
triggerSrc?
optional
triggerSrc:string
type?
optional
type:string
total
total:
number
GetFeedbackInput
属性
from
from:
number
maxRating
maxRating:
number
minRating
minRating:
number
pageNumber
pageNumber:
number
pageSize
pageSize:
number
sender
sender:
string
senderFilter
senderFilter:
string
to
to:
number
type
type:
string
GetFeedbackOutput
属性
feedbackList
feedbackList:
object
[]
aiAnswer
aiAnswer:
string
botId
botId:
string
comment
comment:
string
createTime
createTime:
string
input
input:
string
rating
rating:
number
sender
sender:
string
tags
tags:
string
[]
type
type:
string
total
total:
number
GetRecommendQuestionsInput
属性
agentSetting
agentSetting:
string
history
history:
object
[]
content
content:
string
role
role:
string
introduction
introduction:
string
msg
msg:
string
name
name:
string
SendFeedbackInput
属性
aiAnswer
aiAnswer:
string
comment
comment:
string
input
input:
string
rating
rating:
number
recordId
recordId:
string
tags
tags:
string
[]
type
type:
string
SendFeedbackOutput
属性
status
status:
"success"
SendMessageInput
属性
history?
optional
history:object
[]
content
content:
string
role
role:
"user"
|"assistant"
msg
msg:
string