Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This refactor is a part of #755 .
进行了以下修改:
新 HTTP API
Endpoint
请求体
"wav"
(默认),"mp3"
,"silk"
,"amr"
。Message 对象
"text"
,"image"
, 和"voice"
。Message 类型
当前支持的消息类型如下:
"text"
:文本消息,内容为纯文本。"image"
:图片消息,内容为图片的 BASE64 编码字符串。"voice"
:语音消息,内容为语音的 BASE64 编码字符串以及音频格式和文本转语音的结果(可选)。对于
"image"
类型的消息,值应该是图片的 BASE64 编码字符串,例如:对于
"voice"
类型的消息,值应该是语音的 base64 编码字符串、音频格式以及文本转语音的结果(可选),例如:其中,
"value"
字段的值是语音的 BASE64 编码字符串,"format"
字段的值是音频格式,例如"wav"
,而"text"
字段的值是文本转语音的结果(可选)。请求示例:
响应
服务器会以 Server-Sent Event(SSE)流的形式返回 JSON 对象,代表机器人的响应。每个响应对象可能包含一个或多个消息对象,具体取决于机器人的输出。
响应示例:
响应包含一个 JSON 对象,其中包含一个
"messages"
字段,它是一个消息对象数组。每个消息对象都有"type"
、"value"
和"format"
字段(如果适用)。"value"
字段包含以 Base64 格式编码的消息内容。请注意,响应可能包含多个消息对象,具体取决于机器人的输出。客户端示例代码
Python
JavaScript