Package google.developers.knowledge.v1alpha

索引

DeveloperKnowledge

Developer Knowledge API 可让您以编程方式访问 Google 的公开开发者文档,从而将此知识库集成到您自己的应用和工作流程中。

该 API 旨在成为以机器可读格式访问 Google 开发者文档的规范来源。

一个典型的使用情形是,先使用 DeveloperKnowledge.SearchDocumentChunks 根据查询内容查找相关网页 URI,然后使用 DeveloperKnowledge.GetDocumentDeveloperKnowledge.BatchGetDocuments 获取热门结果的完整内容。

所有文档内容均以 Markdown 格式提供。

BatchGetDocuments

rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (BatchGetDocumentsResponse)

检索多个文档,每个文档都包含完整的 Markdown 内容。

授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/devprofiles.full_control

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

GetDocument

rpc GetDocument(GetDocumentRequest) returns (Document)

检索包含完整 Markdown 内容的单个文档。

授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/devprofiles.full_control

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

SearchDocumentChunks

rpc SearchDocumentChunks(SearchDocumentChunksRequest) returns (SearchDocumentChunksResponse)

在 Google 的开发者文档中搜索开发者知识。此方法会根据用户的查询返回文档块。同一文档可以有多个块。如需检索完整文档,请使用 DeveloperKnowledge.GetDocumentDeveloperKnowledge.BatchGetDocuments 以及 SearchDocumentChunksResponse.results 中返回的 DocumentChunk.parent

授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/devprofiles.full_control

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

BatchGetDocumentsRequest

DeveloperKnowledge.BatchGetDocuments 的请求消息。

字段
names[]

string

必需。要检索的文档的名称。一个批次最多可以检索 20 个文档。返回的文档与请求中的 names 顺序相同。

格式:documents/{uri_without_scheme} 示例:documents/docs.cloud.google.com/storage/docs/creating-buckets

BatchGetDocumentsResponse

DeveloperKnowledge.BatchGetDocuments 的响应消息。

字段
documents[]

Document

已请求文件。

文档

Document 表示开发者知识语料库中的一段内容。

字段
name

string

标识符。相应文档的资源名称。格式:documents/{uri_without_scheme} 示例:documents/docs.cloud.google.com/storage/docs/creating-buckets

uri

string

仅限输出。内容的 URI,例如 docs.cloud.google.com/storage/docs/creating-buckets

content

string

仅限输出。文档的完整内容(采用 Markdown 格式)。

description

string

仅限输出。文档的说明。

DocumentChunk

DocumentChunk 表示 DeveloperKnowledge 语料库中某个文档的一段内容。如需提取整个文档内容,请将 parent 传递给 DeveloperKnowledge.GetDocumentDeveloperKnowledge.BatchGetDocuments

字段
parent

string

仅限输出。相应块所来自的文档的资源名称。格式:documents/{uri_without_scheme} 示例:documents/docs.cloud.google.com/storage/docs/creating-buckets

id

string

仅限输出。相应块在文档中的 ID。块 ID 在文档中是唯一的,但在不同文档之间并不具有全局唯一性。块 ID 不稳定,可能会随时间而变化。

content

string

仅限输出。文档块的内容。

GetDocumentRequest

DeveloperKnowledge.GetDocument 的请求消息。

字段
name

string

必填。要检索的文档的名称。格式:documents/{uri_without_scheme} 示例:documents/docs.cloud.google.com/storage/docs/creating-buckets

SearchDocumentChunksRequest

DeveloperKnowledge.SearchDocumentChunks 的请求消息。

字段
query

string

必需。用户提供的原始查询字符串,例如“如何创建 Cloud Storage 存储分区?”。

page_size

int32

可选。返回的结果数上限。服务返回的值可能小于此值。

如果未指定,则最多返回 5 个结果。

最大值为 20;大于 20 的值将导致 INVALID_ARGUMENT 错误。

page_token

string

可选。从之前的 SearchDocumentChunks 调用接收的页面令牌。利用其进行后续页面检索。

SearchDocumentChunksResponse

DeveloperKnowledge.SearchDocumentChunks 的响应消息。

字段
results[]

DocumentChunk

给定查询的搜索结果。此列表中的每个 DocumentChunk 都包含与搜索查询相关的内容摘要。将每个结果的 DocumentChunk.parent 字段与 DeveloperKnowledge.GetDocumentDeveloperKnowledge.BatchGetDocuments 搭配使用,即可检索完整的文档内容。

next_page_token

string

可选。可作为 page_token 发送并用于检索下一页的令牌。如果省略此字段,则不存在后续页面。