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

上傳脈絡資料檔案,做為工作階段內輔助通話的來源。

HTTP 要求

POST https://discoveryengine.googleapis.com/v1beta/{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
  // 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 編碼字串。

回應主體

AssistantService.AddContextFile 方法的回應。

如果成功,回應主體會含有以下結構的資料:

JSON 表示法
{
  "session": string,
  "fileId": string,
  "tokenCount": string,
  "mimeType": string,
  "byteCount": string,
  "fileName": string
}
欄位
session

string

工作階段名稱 (提供的名稱或新建立的名稱)。

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

fileId

string

上傳檔案的 ID。

tokenCount
(deprecated)

string (int64 format)

已淘汰:這個欄位不會針對所有檔案類型設定,且最終會移除。

檔案長度 (以權杖為單位)。

mimeType

string

僅供輸出。上傳檔案的已解析內容類型,請參閱 https://www.iana.org/assignments/media-types/media-types.xhtml

與選用的來電者提供 AddContextFileRequest.mime_type 不同,這是服務實際為檔案解析的內容類型。

byteCount

string (int64 format)

僅供輸出。上傳檔案的大小 (以位元組為單位)。

fileName

string

僅供輸出。上傳檔案的已解析名稱,包括副檔名。

與呼叫端提供的 AddContextFileRequest.file_name 不同,如果呼叫端提供的名稱沒有副檔名,服務會附加與已解析 mimeType 相符的副檔名,因此使用稽核記錄會擷取檔案類型,即使是名稱一般的 AI 生成檔案也一樣。

授權範圍

需要下列其中一種 OAuth 範圍:

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

詳情請參閱Authentication Overview

IAM 權限

需要 name 資源的下列 IAM 權限:

  • discoveryengine.sessions.addContextFile

詳情請參閱 IAM 說明文件