更新时间:2023-12-18 GMT+08:00
分享

新问答接口

功能介绍

支持多轮流程问答接口

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

URI

POST /v2/irobot/ask

请求参数

表1 请求Body参数

参数

是否必选

参数类型

描述

question

String

用户输入问题

最小长度:1

最大长度:1000

top

Integer

最大返回数据条数

最小值:1

最大值:10

themes

Array of RelationTheme objects

主题列表

数组长度:0 - 10

source

String

  • PORTAL:

  • INCIDENT:

最小长度:0

最大长度:64

枚举值:

  • PORTAL

  • INCIDENT

session_id

String

会话ID

最小长度:0

最大长度:64

source_qa_pair_id

String

语料ID

最小长度:0

最大长度:64

alternative_answer_enable

Boolean

是否需要备选答案

product_type_id

String

产品类型Id

最小长度:0

最大长度:64

specify_node_id

String

指定的节点ID

最小长度:0

最大长度:64

表2 RelationTheme

参数

是否必选

参数类型

描述

theme_name

String

主题

最小长度:0

最大长度:65535

relation_type

String

  • NON_PRIMARY: 主主题

  • PRIMARY:

枚举值:

  • NON_PRIMARY

  • PRIMARY

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

error_code

String

错误码

最小长度:0

最大长度:32

error_msg

String

错误描述

最小长度:0

最大长度:32

lang_result

LangResult object

语种检测结果

reply_type

String

  • QA_BOT:

  • TASK_BOT:

  • CHAT_BOT:

  • GRAPH_BOT:

  • HW_CLOUD:

枚举值:

  • QA_BOT

  • TASK_BOT

  • CHAT_BOT

  • GRAPH_BOT

  • HW_CLOUD

session_id

String

会话ID

最小长度:0

最大长度:64

request_id

String

请求ID

最小长度:0

最大长度:64

answers_detail

AnswerDetail object

答案

表4 LangResult

参数

参数类型

描述

language

String

语言

最小长度:0

最大长度:64

is_en

Boolean

是否英语

表5 AnswerDetail

参数

参数类型

描述

qabot_answers

Array of QabotAnswer objects

答案列表

数组长度:0 - 65535

qa_flow_answers

QaFlowHitResult object

多轮问答答案列表

chat_answer

String

问题

最小长度:0

最大长度:65535

graph_answer

QaGraphAnswer object

图谱答案列表

表6 QabotAnswer

参数

参数类型

描述

question

String

问题

最小长度:0

最大长度:65535

answer

String

答案

最小长度:0

最大长度:65535

score

Double

评分

最小值:0

最大值:1

domain

String

主题

最小长度:0

最大长度:200

link

String

链接地址

最小长度:0

最大长度:1024

qa_pair_id

String

语料id

最小长度:0

最大长度:64

domain_id

String

主题id

最小长度:0

最大长度:64

top_score_question

String

推荐答案

最小长度:0

最大长度:65535

relevance_details

Array of RelevanceQapair objects

相关问题列表

数组长度:0 - 65535

表7 RelevanceQapair

参数

参数类型

描述

link

String

链接

最小长度:0

最大长度:65535

question

String

标准问题

最小长度:0

最大长度:9223372036854775807

qa_pair_id

String

标准问题Id

最小长度:0

最大长度:64

表8 QaFlowHitResult

参数

参数类型

描述

session_id

String

seesionID

最小长度:0

最大长度:64

current_node

QaFlowHitNodeVo object

当前节点

candidate_nodes

Array of QaFlowHitNodeVo objects

备用节点

数组长度:0 - 65535

is_completed

Boolean

是否完整

表9 QaFlowHitNodeVo

参数

参数类型

描述

id

String

ID

最小长度:0

最大长度:64

name

String

名称

最小长度:0

最大长度:255

content

String

内容

最小长度:0

最大长度:65535

answer_type

String

  • TEXT:

  • RICH_TEXT:

  • FLOW:

  • QA_PAIR:

枚举值:

  • TEXT

  • RICH_TEXT

  • FLOW

  • QA_PAIR

表10 QaGraphAnswer

参数

参数类型

描述

answer

String

答案

最小长度:0

最大长度:65535

score

Double

评分

最小值:0

最大值:1

type

Integer

类型

最小值:0

最大值:2147483647

options

Array of strings

列表

最小长度:0

最大长度:65535

数组长度:0 - 65535

请求示例

POST https://{endpoint}/v2/irobot/ask

{
  "question" : "ECS如何购买"
}

响应示例

状态码: 200

成功返回200

{
  "lang_result" : null,
  "reply_type" : "QA_BOT",
  "session_id" : "session-id",
  "request_id" : "request-id",
  "answers_detail" : {
    "qabot_answers" : [ {
      "question" : "问题",
      "answer" : "答案",
      "score" : 0.85,
      "domain" : "ECS",
      "link" : "link",
      "qa_pair_id" : "语料id",
      "domain_id" : "主题id",
      "top_score_question" : "推荐答案",
      "relevance_details" : [ {
        "link" : "link",
        "question" : "标准问题",
        "qa_pair_id" : "标准问题Id"
      } ]
    } ],
    "qa_flow_answers" : [ {
      "session_id" : "seesionID",
      "is_completed" : true,
      "current_node" : [ {
        "id" : "node-id",
        "name" : "node-name",
        "content" : "内容",
        "answer_type" : "TEXT"
      } ],
      "candidate_nodes" : [ {
        "id" : "node-id",
        "name" : "node-name",
        "content" : "内容",
        "answer_type" : "TEXT"
      } ]
    } ],
    "chat_answer" : "问题",
    "graph_answer" : [ {
      "answer" : "答案",
      "score" : 0.85,
      "type" : 1,
      "options" : [ "option" ]
    } ]
  }
}

状态码

状态码

描述

200

成功返回200

错误码

请参见错误码

分享:

    相关文档

    相关产品