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

Uploads a context file to use as source for the assist calls within the session.

HTTP request

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

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
name

string

Required. The resource name of the Session. Format: projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}

If - is specified as the session ID, a new session is created with an automatically generated ID.

Request body

The request body contains data with the following structure:

JSON representation
{
  "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.
}
Fields
fileName

string

Required. The name of the file.

mimeType

string

Optional. The content type of the file, see https://www.iana.org/assignments/media-types/media-types.xhtml.

This field is required when the data source does not provide the content type.

Union field file. The contents of the file. file can be only one of the following:
fileContents

string (bytes format)

File contents provided inline.

A base64-encoded string.

document

string

Resource name of the Document. The caller needs to have permission to access the Document, otherwise a PERMISSION_DENIED error is returned.

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

Response body

Response for the AssistantService.AddContextFile method.

If successful, the response body contains data with the following structure:

JSON representation
{
  "session": string,
  "fileId": string,
  "tokenCount": string
}
Fields
session

string

The name of the session, either the provided one, or the newly created one.

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

fileId

string

The ID of the uploaded file.

tokenCount
(deprecated)

string (int64 format)

Deprecated: This field will not be set for all file types, and will eventually be removed.

The length of the file measured in tokens.

Authorization scopes

Requires one of the following OAuth scopes:

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

For more information, see the Authentication Overview.

IAM Permissions

Requires the following IAM permission on the name resource:

  • discoveryengine.sessions.addContextFile

For more information, see the IAM documentation.