云服务器内容精选

  • 请求示例 请求示例 POST https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/sessions/{session_id}Request Header:Content-Type: application/jsonX-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...Request Body:{ "question": "桌面云打不开了"} Java语言请求代码示例 import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.net.HttpURLConnection;import java.net.URL;public class CBSDemo { public void cbsDemo() { try { //endpoint、projectId、qabot_id等需要替换成实际信息。 URL url = new URL("https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/sessions/{session_id}"); String token = "用户获取得到的实际token值"; HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setDoInput(true); connection.setDoOutput(true); connection.addRequestProperty("Content-Type", "application/json"); connection.addRequestProperty("X-Auth-Token", token); //输入参数 String body = "{\"question\": \"桌面云打不开了\"}"; OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); osw.append(body); osw.flush(); InputStream is = connection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")); while (br.ready()) { System.out.println(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { CBSDemo CBSDemo = new CBSDemo(); CBSDemo.cbsDemo(); }}
  • 响应示例 状态码:200 成功响应示例 { { "answers": [ { "score": 0.949, "answer": "重启电脑", "domain": "桌面云", "qa_pair_id": "888899999", "st_question": "桌面云打不开", "top_score_question": "桌面云打不开" } ], "recommend_answers": [] }, "session_id": "73e84311-32a0-43ff-9735-bb2be1150624"} 状态码:400 失败响应示例 { "error_code":"CBS.0011", "error_msg":"auth failed"}
  • 响应参数 状态码: 200 表5 QaBotAnswers 参数 参数类型 描述 answers Array of QaBotAnswer objects 问答机器人回复。 表6 QaBotAnswer 参数 参数类型 描述 qa_pair_id String 问答对ID,UUID格式,如:305cd440-ab4f-4704-9b30-ffa4e82a5606。 st_question String 标准问题,如:桌面云打不开。 answer String 知识库中的语料答案,包含该字段时,为直接回答;不包含时,为推荐答案。 score Double 相似度得分,精确到小数点后3位。 domain String 问题类别。 top_score_question String 最高评分的扩展问或标准问。 表7 ChatAnswers 参数 参数类型 描述 answer String 答案,如:美好的一天祝您一切顺利。 score Float 闲聊的置信度,范围:[0.0,1.0 ]。0.0表示兜底回复。 表8 TaskBotAnswers 参数 参数类型 描述 answer String 答案, 如:请问您需要查询哪里的天气? skill_id String 技能标识符,UUID格式。如:9eece064-bdb5-43cb-8e0f-8c19a929e25c。 skill_responses Array of SkillResponse objects 技能信息。 表9 SkillResponse 参数 参数类型 描述 skill_id String 输入问题,不能为空,UUID格式,如:9eece064-bdb5-43cb-8e0f-8c19a929e25c。 skill_version String skill的版本。 frame Frame object 命中意图。 candidate object 候选意图,具体参见表15。 locked Boolean 技能是否被锁定,默认是false related_intenions Array of RelatedIntention objects 相关意图信息。 表10 Frame 参数 参数类型 描述 intention String 意图。 confidence Double 命中意图置信度。 current_slots Array of CurrentSlot objects 当前槽位列表。 history_slots Array of HistorySlot objects 历史槽位列表。 reply String 机器人回复。 task_complete Boolean 任务是否完成。 flow_complete Boolean 对话流程是否结束 candidate_words Array of Strings 候选词。 intention_alias String 意图名称。 表11 CurrentSlot 参数 参数类型 描述 slot_id String 槽位ID,UUID格式,如:9eece064-bdb5-43cb-8e0f-8c19a929e25c。 slot_identification String 用户设置的槽位标识 slot_name String 槽位名称。 slot_values Array of SlotValue objects 槽位值。 表12 SlotValue 参数 参数类型 描述 word String 词。 norm_word String 归一化后的标准词。 begin_position Integer 词的起始位置。 end_position Integer 词的结束位置。 表13 HistorySlot 参数 参数类型 描述 slot_identification String 用户设置的槽位标识 slot_name String 槽位名称。 slot_values Array of HistorySlotWord objects 槽信息。 表14 HistorySlotWord 参数 参数类型 描述 word String 词。 norm_word String 归一化后的词。 表15 CandidateIntention 参数 参数类型 描述 candidate_intention String 候选意图。 candidate_confidence Double 候选意图置信度。 表16 RelatedIntention 参数 参数类型 描述 intention String 意图名称。 confidence Double 意图置信度。 状态码: 400 表17 响应Body参数 参数 参数类型 描述 error_code String 调用失败时的错误码。 调用成功时无此字段。 error_msg String 调用失败时的错误信息。 调用成功时无此字段。
  • URI POST https://{endpoint}/v1/{project_id}/qabots/{qabot_id}/sessions/{session_id} 表1 路径参数 参数 是否必选 参数类型 描述 endpoint 是 String 终端节点,即调用API的请求地址。 不同服务不同区域的endpoint不同,您可以从终端节点中获取。 project_id 是 String 项目ID,用于资源隔离。请参见获取项目ID。 qabot_id 是 String 机器人标识符,qabot编号,UUID格式。如:303a0a00-c88a-43e3-aa2f-d5b8b9832b02。 进入问答机器人的Console界面,在“机器人名称/ID”列显示对应的qabot_id。 session_id 是 String 会话标识符,UUID格式。如:c04e6f7b-61d7-4a2d-a0c8-f9ecd2f62359。 具体获取方式请参见开启会话章节。