接口文档
更新时间:2024-04-15
接口文档
版本:v1.0.0
流式对话接口
Base URL: https://keyue.cloud.baidu.com/online
接口后缀:/core/v5/stream/query
请求方式:POST
Authentication:token为API Key
Curl 请求示例
# xxxx 替换为实际token
curl --location 'https://keyue.cloud.baidu.com/online/core/v5/stream/query'
--header 'token: xxxx'
--header 'Content-Type: application/json'
--data '{
"queryText": "你好",
"sessionId": "ecb95fcc-0e49-4ab0-b026-c20a8aac1585"
}'
Body 请求参数
{
"queryText": "7fCb",
"sessionId": "phRr",
"variables": {}
}
请求参数
名称 |
位置 |
类型 |
必选 |
中文名 |
说明 |
---|---|---|---|---|---|
Uid | header | string | 否 | none | |
Username | header | string | 否 | none | |
token | header | string | 是 | none | |
body | body | object | 否 | none | |
queryText | body | string | 否 | 用户问题 | none |
sessionId | body | string | 否 | 会话id | 首轮可以为空(如果首轮传了,后续需要使用首轮传的。),首轮会返回sessionId,后续对话需要使用返回的sessionId。 |
variables | body | object | 否 | 变量 | Map格式,key 是变量名称,value是变量值。对话中使用的变量,如果传了会覆盖当前中对话中已有的变量值 |
topicId | body | string | 否 | 主题id | 对话测试时使用,执行指定的topic,和nodeId配合使用 |
engines | body | List<String> | 是 | 使用的对话引擎 | faq、docQa、taskflow ,为null 或taskflow是支持所有引擎 |
startId | body | string | 否 | 节点id | 对话测试时使用,执行指定的节点id。和topicId配合使用 |
返回示例
成功
{
"data": {
"sessionId": "b7e605e4-84fc-41d9-93aa-2dd40d0a8854",
"queryId": null,
"answer": [
{
"chunkId": 1,
"status": "running",
"topicId": "63067e968cbdb692c97b063a",
"blockId": "FhYgt7o-Ow0J_2i_BThpaW5KTwuUJx8K_3sN",
"nodeId": "lsiy2TmjkYAyZZIJKIx71pSRpCbx--n8fR-l",
"reply": {
"type": 1,
"text": "四环路,北至新建宫门路,东邻中关村科技园区,毗邻清华大学、北京大学^[1]^。",
"textList": null,
"clarifyGuide": null,
"replySource": "DOC_QA",
"documents": [
{
"document_id": "68285c8a-25e2-40e3-ae24-acc484c93359",
"document_name": "海淀公园景区介绍.docx",
"data": [
{
"segment_id": "2c585f55-caf5-4de4-a6bb-860105a30b63",
"sentence_id": "1",
"sentence_content": "海淀公园位于北京西北四环万泉河立交桥的西北角,东起万泉河路,西至万柳中路,南到西北四环路,北至新建宫门路,东邻中关村科技园区,毗邻清华大学、北京大学,面积约34公顷,是历史上北京三山五园之一—畅春园的遗址,也是百度与海淀区共建的全球首个AI公园。海淀公园不仅有淀园花谷、仙人承露等景点,也有百度阿波龙无人车、智能步道、小度智能语音亭等AI景点。\r海淀公园始建于2003年,是一座集自然气息、人文底蕴和时尚感于一体的园林。2004 年,海淀公园被确定为北京市首批应急避难场所之一。2018年11月1日,海淀公园宣布正式完成人工智能(AI)改造,成为全球首个AI科技主题公园。\r",
"score": "0.69987035",
"segment_coord": "[{\"pageno\": 0, \"box\": [90, 105, 414, 74]}, {\"pageno\": 0, \"box\": [90, 183, 418, 43]}, {\"pageno\": 0, \"box\": [90, 230, 416, 27]}, {\"pageno\": 0, \"box\": [90, 261, 414, 27]}, {\"pageno\": 0, \"box\": [90, 293, 414, 57]}, {\"pageno\": 0, \"box\": [90, 355, 414, 73]}, {\"pageno\": 0, \"box\": [90, 433, 414, 27]}, {\"pageno\": 0, \"box\": [90, 464, 414, 27]}, {\"pageno\": 0, \"box\": [90, 495, 414, 43]}, {\"pageno\": 0, \"box\": [90, 542, 414, 42]}, {\"pageno\": 0, \"box\": [111, 589, 398, 11]}, {\"pageno\": 0, \"box\": [111, 605, 372, 11]}, {\"pageno\": 0, \"box\": [90, 620, 416, 58]}, {\"pageno\": 0, \"box\": [90, 683, 414, 26]}, {\"pageno\": 0, \"box\": [90, 714, 414, 42]}]"
}
]
}
]
}
}
],
"variables": {
"last_task_prompt": null,
"last_utterance": ""
},
"endTime": null,
"intentRecommendList": null
}
}
返回结果
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | Inline |
返回数据结构
状态码 200
名称 |
类型 |
必选 |
约束 |
中文名 |
说明 |
---|---|---|---|---|---|
variables | object | false | none | none | |
answer | object | true | none | none | |
topicId | string | true | none | none | |
blockId | string | true | none | none | |
nodeId | string | true | none | none | |
reply | object | false | none | none | |
type | integer | true | none | 1 (文本)3(富文本)8(列表) | |
text | string | true | none | 文本/富文本答案 | |
textList | string | true | none | none | |
replySource | string | true | none | 回复来源 | FAQ("faq", "知识库-FAQ"), DOC_QA("docQa", "知识库-文档"), TEXT_REPLY("text", "文本回复"), LARGE_MODEL_REPLY("largeModelReply", "大模型回复"), COLLECT_SLOT_ENTITY("collectSlotEntity", "收集槽位实体"), CHITCHAT("chitchat", "闲聊"), UNMATCHED("unmatch", "未匹配固定话术"), SENSITIVE("sensitive", "敏感拒答话术"), SYSTEM("system", "系统异常"); |
documents | object | true | none | 文档来源; replySource 是DOC_QA 该字段有值。 | |
document_id | string | true | none | 文档id | |
document_name | string | true | none | 文档名 | |
data | object | true | none | 分段知识 | |
segment_id | string | true | none | 分段id | |
sentence_id | string | true | none | 句子id | |
sentence_content | string | true | none | 句子内容 | |
score | string | true | none | 评分 | |
segment_coord | string | true | none | 在原文的坐标 | |
clarifyGuide | string | true | none | 引导话术 | 返回类型是列表,若该字段有值,需展示 |
faqSearch | object | true | none | faq检索结果;replySource 是FAQ 该字段有值。 | |
answer | object | true | none | faq 答案 | |
type | integer | true | none | none | |
text | string | true | none | none | |
score | number | true | none | 置信度 | |
question | string | true | none | 标准问 | |
matchDetail | object | false | none | 匹配详情 | |
matchType | string | true | none | none | |
matchValue | string | true | none | none | |
matchId | string | true | none | none | |
score | number | true | none | none | |
faqId | string | true | none | faqId | |
chunkId | integer | true | none | 流式chunkId | none |
status | string | true | none | 流式状态:running/done | none |
queryId | string | true | none | 本轮对话id | |
sessionId | string | true | none | 会话id | |
intentRecommendList | string | true | none | 意图推荐集合 | |
intent | object | true | none | 意图识别信息,发生意图跳转该字段有值 | |
nameZh | string | true | none | 意图中文名 | |
confidence | number | true | none | 意图识别置信度 |
阻塞式对话接口
Base URL: https://keyue.cloud.baidu.com/online
接口后缀: /core/v5/block/query
请求方式:POST
Authentication:token为API Key
Body 请求参数示例
{
"queryText": "你是谁",
"sessionId": "a562a520-8f52-48e6-9585-87ca3ccd8249"
}
请求参数
名称 |
位置 |
类型 |
必选 |
中文名 |
说明 |
---|---|---|---|---|---|
uid | header | string | 否 | 用户id | |
username | header | string | 否 | 用户名称 | |
token | header | string | 是 | none | |
body | body | object | 否 | none | |
queryText | body | string | 否 | 用户问题 | none |
sessionId | body | string | 否 | 会话id | 首轮可以为空(如果首轮传了,后续需要使用首轮传的。),首轮会返回sessionId,后续对话需要使用返回的sessionId。 |
variables | body | object | 否 | 变量 | Map<String,String>格式,key 是变量名称,value是变量值。对话中使用的变量,如果传了会覆盖当前中对话中已有的变量值 |
topicId | body | string | 否 | 主题id | 对话测试时使用,执行指定的topic,和nodeId配合使用 |
agentId | body | string | 否 | offline使用,online环境再parms中传token | |
strartId | body | string | 否 | 步骤id | none |
返回示例
成功
{
"time": 1704251962164,
"data": {
"sessionId": "e4163e53-3929-4847-9720-9caa559616fe",
"answer": [
{
"topicId": null,
"blockId": null,
"nodeId": "start00000000000000000000",
"reply": null
},
{
"topicId": null,
"blockId": null,
"nodeId": null,
"reply": {
"type": 1,
"text": "你好",
"textList": null,
"replySource": "TEXT_REPLY"
}
},
{
"topicId": null,
"blockId": null,
"nodeId": null,
"reply": {
"type": 1,
"text": "再见",
"textList": null,
"replySource": "TEXT_REPLY"
}
}
],
"recommendList": [
"我想租车"
],
"variables": {}
},
"code": 200,
"msg": "OK"
}
返回结果
状态码 | 状态码含义 | 说明 | 数据模型 |
---|---|---|---|
200 | OK | 成功 | Inline |
返回数据结构
状态码 200
名称 |
类型 |
必选 |
约束 |
中文名 |
说明 |
---|---|---|---|---|---|
variables | object | false | none | none | |
answer | object | true | none | none | |
topicId | string | true | none | none | |
blockId | string | true | none | none | |
nodeId | string | true | none | none | |
reply | object | false | none | none | |
type | integer | true | none | 1 (文本)3(富文本)8(列表) | |
text | string | true | none | 文本/富文本答案 | |
textList | string | true | none | none | |
replySource | string | true | none | 回复来源 | FAQ("faq", "知识库-FAQ"), DOC_QA("docQa", "知识库-文档"), TEXT_REPLY("text", "文本回复"), LARGE_MODEL_REPLY("largeModelReply", "大模型回复"), COLLECT_SLOT_ENTITY("collectSlotEntity", "收集槽位实体"), CHITCHAT("chitchat", "闲聊"), UNMATCHED("unmatch", "未匹配固定话术"), SENSITIVE("sensitive", "敏感拒答话术"), SYSTEM("system", "系统异常"); |
documents | object | true | none | 文档来源; replySource 是DOC_QA 该字段有值。 | |
document_id | string | true | none | 文档id | |
document_name | string | true | none | 文档名 | |
data | object | true | none | 分段知识 | |
segment_id | string | true | none | 分段id | |
sentence_id | string | true | none | 句子id | |
sentence_content | string | true | none | 句子内容 | |
score | string | true | none | 评分 | |
segment_coord | string | true | none | 在原文的坐标 | |
chunkId | integer | true | none | 流式chunkId | none |
status | string | true | none | 流式状态:running/done | none |
queryId | string | true | none | 本轮对话id | |
sessionId | string | true | none | 会话id | |
intentRecommendList | string | true | none | 意图推荐列表 |