单轮问答(即将下线)
功能介绍
问答服务的输入为用户提问,输出是与输入最匹配的Top N(默认为top5)个知识点,知识点按得分从高到低排序。该接口即将下线,请优先使用开启会话、处理会话、关闭会话接口。

返回知识点如果含有答案字段(answer),则表示返回匹配成功结果,如果没有答案字段,则表示推荐结果。
URI
- URI格式
POST /v1/{project_id}/qabots/{qabot_id}/requests
- 参数说明
表1 URI参数说明 名称
是否必选
说明
project_id
是
项目ID,用于资源隔离。请参见获取项目ID。
qabot_id
是
qabot编号,UUID格式,如:303a0a00-c88a-43e3-aa2f-d5b8b9832b02。
进入问答机器人的Console界面,在“机器人名称/ID”列显示对应的qabot_id。
请求消息
请求参数如表2所示。
名称 |
参数类型 |
是否必选 |
说明 |
---|---|---|---|
session_id |
String |
是 |
会话ID,由任意字符串组成,由用户自定义产生,用来区分不同的会话。 具体获取方式请参见开启会话章节。 |
user_id |
String |
否 |
用户ID,用来区分唯一用户信息。 |
question |
String |
是 |
用户问题。 |
extends |
Object |
否 |
扩展参数项,具体参见表3 object。 |
threshold_enable |
Boolean |
否 |
true:启动内部阈值 返回经过阈值处理之后的答案。 false:不启用内部阈值 返回原答案。 |
chat_enable |
Boolean |
否 |
默认true true:使用内部闲聊语料进行兜底。 false:不使用闲聊兜底。 |
operate_type |
Integer |
否 |
调用接口时候传入,用以标记的问答的行为,默认为0,最终会展示在问答日志里。
|
响应消息
名称 |
参数类型 |
说明 |
---|---|---|
qa_pair_id |
String |
问答对ID。 |
st_question |
String |
标准问题。 |
ex_questions |
Array of objects |
扩展问,具体参见表6。 |
answer |
String |
答案。 |
score |
Float |
相似度得分,精确到小数点后3位。 |
domain |
String |
所属领域。 |
示例
- 请求示例
POST https://{endpoint}/v1/1604d8170cd84440a81281e5a3a04f8b/qabots/303a0a00-c88a-43e3-aa2f-d5b8b9832b02/requests Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "user_id": "z00123456", "session_id": "xxxxxxxxxxxxxxxxxx", "operate_type":3, "question": "桌面云无法登录", "extends":{ "domains":["桌面云"], "top":5 }, "threshold_enable":false, "chat_enable":true }
- 响应示例
- 成功响应示例
1. 关闭内置阈值处理(设置threshold_enable = false),按top个数返回结果数量。
{ "request_id": "303a0a00-c88a", "question": "桌面云打不开", "answers": [ { "qa_pair_id":"123", "st_question":"桌面云打开不了", "answer":"用户账号不对", "score":0.952, "domain":"桌面云" }, { "qa_pair_id":"123", "st_question":"桌面云打开不了了", "answer":"用户账号不对", "score":0.901, "domain":"桌面云" }, { "qa_pair_id":"123", "st_question":"桌面云是啥", "answer":"桌面云是可以远程办公的系统", "score":0.352, "domain":"桌面云" }, { "qa_pair_id":"123", "st_question":"电脑桌面打不开", "answer":"请检查下显示器是否开启", "score":0.352, "domain":"桌面云" }, ] }
2. 开启内部阈值处理。表7 内部阈值处理 处理条件
结果
备注
分值>0.85
返回分值与最高分差距在0.05范围内所有命中语料。
如果QaPair对象的answer不为空,则为命中语料,如果answer为空,则为推荐语料。
0.70<分值<0.85
如果存在这个区间的语料,返回最高分值处于这个区间的命中语料。如果不存在这个区间的语料,则返回推荐语料。
0.55<分值<0.70
返回推荐语料。
分值<0.55
不返回语料。
例1:
{ "request_id": "303a0a00-c88a", "question": "桌面云打不开", "answers": [ { "qa_pair_id":"123", "st_question":"桌面云打开不了", "ex_questions": [ { "content": "桌面云" } ], "answer":"用户账号不对", "top_score_question":"桌面云打开不了", "score":0.952, "domain":"桌面云" }, { "qa_pair_id":"123", "st_question":"桌面云打开", "ex_questions": [ { "content": "桌面" } ], "answer":"打开桌面云", "top_score_question":"桌面云打开", "score":0.912, "domain":"桌面云" } ] }
例2:{ "request_id": "303a0a00-c88a", "question": "桌面云打不开", "answers": [ { "qa_pair_id":"123", "st_question":"桌面云打开不了", "top_score_question":"桌面云打开不了", "answer":"用户账号不对", "score":0.752, "domain":"桌面云" } { "qa_pair_id":"123", "st_question":"桌面云打开不了了", "score":0.70, "domain":"桌面云" }, { "qa_pair_id":"123", "st_question":"桌面云是啥", "score":0.54, "domain":"桌面云" } ] }
例3:{ "request_id": "303a0a00-c88a", "question": "桌面云打不开", "answers": [ { "qa_pair_id":"123", "st_question":"桌面云打开不了了", "score":0.291, "domain":"桌面云" }, { "qa_pair_id":"123", "st_question":"桌面云是啥", "score":0.252, "domain":"桌面云" } ] }
3. 闲聊兜底或无答案回复。
{ "request_id": "303a0a00-c88a", "question": "你好", "answers": [ { "answer":"您好,请问有什么可以帮您的吗?" } ] }
- 失败响应示例
{ "error_code": "CBS.0022", "error_msg": "session_id can not be null" }
- 成功响应示例
状态码
状态码请参见状态码。
错误码
错误码请参见错误码。
