Method: answerQuery

使用接地生成功能回答查询。

HTTP 请求

POST https://developerknowledge.googleapis.com/v1alpha:answerQuery

网址采用 gRPC 转码语法。

请求正文

请求正文中包含结构如下的数据:

JSON 表示法
{
  "query": string
}
字段
query

string

必需。要回答的查询。

响应正文

DeveloperKnowledge.AnswerQuery 的响应消息。

如果成功,响应正文将包含结构如下的数据:

JSON 表示法
{
  "answer": {
    object (Answer)
  }
}
字段
answer

object (Answer)

查询的答案。

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/devprofiles.full_control
  • https://www.googleapis.com/auth/cloud-platform

如需了解详情,请参阅 OAuth 2.0 Overview

答案

对查询的回答。

JSON 表示法
{
  "answerText": string,
  "citations": [
    {
      object (AnswerCitation)
    }
  ],
  "references": [
    {
      object (AnswerReference)
    }
  ]
}
字段
answerText

string

包含答案的文本。

citations[]

object (AnswerCitation)

仅限输出。包含答案的引用。

references[]

object (AnswerReference)

仅限输出。包含答案的参考资料。

AnswerCitation

片段的引用信息。

JSON 表示法
{
  "startIndex": integer,
  "endIndex": integer,
  "sources": [
    {
      object (CitationSource)
    }
  ]
}
字段
startIndex

integer

仅限输出。指示片段的起始位置,以字节 (UTF-8 unicode) 为单位,包含在内。如果存在多字节字符(例如非 ASCII 字符),则索引长度会大于字符串长度。

endIndex

integer

仅限输出。指示片段的结束位置,以字节 (UTF-8 unicode) 为单位,不包含在内。如果存在多字节字符(例如非 ASCII 字符),则索引长度会大于字符串长度。

sources[]

object (CitationSource)

仅限输出。包含归因片段的引用来源。

CitationSource

引用来源。

JSON 表示法
{
  "referenceIndex": integer
}
字段
referenceIndex

integer

仅限输出。包含 references 重复字段中 Answer.AnswerReference 的索引。

AnswerReference

表示对来源的引用。

JSON 表示法
{

  // Union field content can be only one of the following:
  "documentReference": {
    object (DocumentReference)
  }
  // End of list of possible types for union field content.
}
字段
联合字段 content。包含引用的内容。content 只能是下列其中一项:
documentReference

object (DocumentReference)

仅限输出。引用文档。

DocumentReference

表示对文档的引用。

JSON 表示法
{
  "documentChunk": {
    object (DocumentChunk)
  }
}
字段
documentChunk

object (DocumentChunk)

仅限输出。包含文档块。未设置 documentChunk.id 字段,该字段将为空。