使用接地生成功能回答查询。
HTTP 请求
POST https://developerknowledge.googleapis.com/v1alpha:answerQuery
网址采用 gRPC 转码语法。
请求正文
请求正文中包含结构如下的数据:
| JSON 表示法 |
|---|
{ "query": string } |
| 字段 | |
|---|---|
query |
必需。要回答的查询。 |
响应正文
DeveloperKnowledge.AnswerQuery 的响应消息。
如果成功,响应正文将包含结构如下的数据:
| JSON 表示法 |
|---|
{
"answer": {
object ( |
| 字段 | |
|---|---|
answer |
查询的答案。 |
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/devprofiles.full_controlhttps://www.googleapis.com/auth/cloud-platform
如需了解详情,请参阅 OAuth 2.0 Overview。
答案
对查询的回答。
| JSON 表示法 |
|---|
{ "answerText": string, "citations": [ { object ( |
| 字段 | |
|---|---|
answerText |
包含答案的文本。 |
citations[] |
仅限输出。包含答案的引用。 |
references[] |
仅限输出。包含答案的参考资料。 |
AnswerCitation
片段的引用信息。
| JSON 表示法 |
|---|
{
"startIndex": integer,
"endIndex": integer,
"sources": [
{
object ( |
| 字段 | |
|---|---|
startIndex |
仅限输出。指示片段的起始位置,以字节 (UTF-8 unicode) 为单位,包含在内。如果存在多字节字符(例如非 ASCII 字符),则索引长度会大于字符串长度。 |
endIndex |
仅限输出。指示片段的结束位置,以字节 (UTF-8 unicode) 为单位,不包含在内。如果存在多字节字符(例如非 ASCII 字符),则索引长度会大于字符串长度。 |
sources[] |
仅限输出。包含归因片段的引用来源。 |
CitationSource
引用来源。
| JSON 表示法 |
|---|
{ "referenceIndex": integer } |
| 字段 | |
|---|---|
referenceIndex |
仅限输出。包含 |
AnswerReference
表示对来源的引用。
| JSON 表示法 |
|---|
{ // Union field |
| 字段 | |
|---|---|
联合字段 content。包含引用的内容。content 只能是下列其中一项: |
|
documentReference |
仅限输出。引用文档。 |
DocumentReference
表示对文档的引用。
| JSON 表示法 |
|---|
{
"documentChunk": {
object ( |
| 字段 | |
|---|---|
documentChunk |
仅限输出。包含文档块。未设置 |