Method: projects.locations.collections.engines.sessions.addContextFile

上传上下文文件,以用作会话中辅助调用的来源。

HTTP 请求

POST https://discoveryengine.googleapis.com/v1alpha/{name=projects/*/locations/*/collections/*/engines/*/sessions/*}:addContextFile

网址采用 gRPC 转码语法。

路径参数

参数
name

string

必需。会话的资源名称。格式:projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}

如果将 - 指定为会话 ID,系统会创建一个具有自动生成的 ID 的新会话。

请求正文

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

JSON 表示法
{
  "fileName": string,
  "mimeType": string,

  // Union field file can be only one of the following:
  "fileContents": string,
  "document": string
  // End of list of possible types for union field file.
}
字段
fileName

string

必需。文件的名称。

mimeType

string

可选。文件的内容类型,请参阅 https://www.iana.org/assignments/media-types/media-types.xhtml

如果数据源未提供内容类型,则此字段为必需字段。

联合字段 file。文件的内容。file 只能是下列其中一项:
fileContents

string (bytes format)

内嵌提供文件内容。

使用 base64 编码的字符串。

document

string

Document 的资源名称。调用者需要有权访问 Document,否则会返回 PERMISSION_DENIED 错误。

格式:projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}/branches/{branch}/documents/{document}

响应正文

AssistantService.AddContextFile 方法的响应。

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

JSON 表示法
{
  "session": string,
  "fileId": string,
  "tokenCount": string
}
字段
session

string

会话的名称,可以是提供的名称,也可以是新创建的名称。

格式:projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}

fileId

string

上传文件的 ID。

tokenCount
(deprecated)

string (int64 format)

已弃用:此字段不会针对所有文件类型进行设置,最终将被移除。

文件长度(以 token 为单位)。

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/cloud-platform
  • https://www.googleapis.com/auth/discoveryengine.readwrite
  • https://www.googleapis.com/auth/discoveryengine.assist.readwrite

如需了解详情,请参阅 Authentication Overview

IAM 权限

需要拥有 name 资源的以下 IAM 权限:

  • discoveryengine.sessions.addContextFile

如需了解详情,请参阅 IAM 文档