Skip to main content

contexts

Creates, updates, deletes, gets or lists a contexts resource.

Overview

Namecontexts
TypeResource
Idgoogle.aiplatform.contexts

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringImmutable. The resource name of the Context.
createTimestring (google-datetime)Output only. Timestamp when this Context was created.
descriptionstringDescription of the Context
displayNamestringUser provided display name of the Context. May be up to 128 Unicode characters.
etagstringAn eTag used to perform consistent read-modify-write updates. If not set, a blind "overwrite" update happens.
labelsobjectThe labels with user-defined metadata to organize your Contexts. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. No more than 64 user labels can be associated with one Context (System labels are excluded).
metadataobjectProperties of the Context. Top level metadata keys' heading and trailing spaces will be trimmed. The size of this field should not exceed 200KB.
parentContextsarrayOutput only. A list of resource names of Contexts that are parents of this Context. A Context may have at most 10 parent_contexts.
schemaTitlestringThe title of the schema describing the metadata. Schema title and version is expected to be registered in earlier Create Schema calls. And both are used together as unique identifiers to identify schemas within the local metadata store.
schemaVersionstringThe version of the schema in schema_name to use. Schema title and version is expected to be registered in earlier Create Schema calls. And both are used together as unique identifiers to identify schemas within the local metadata store.
updateTimestring (google-datetime)Output only. Timestamp when this Context was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, metadataStoresId, contextsIdRetrieves a specific Context.
listselectprojectsId, locationsId, metadataStoresIdpageSize, pageToken, filter, orderByLists Contexts on the MetadataStore.
createinsertprojectsId, locationsId, metadataStoresIdcontextIdCreates a Context associated with a MetadataStore.
patchupdateprojectsId, locationsId, metadataStoresId, contextsIdupdateMask, allowMissingUpdates a stored Context.
deletedeleteprojectsId, locationsId, metadataStoresId, contextsIdforce, etagDeletes a stored Context.
retrieve_contextsexecprojectsId, locationsIdRetrieves relevant contexts for a query.
purgeexecprojectsId, locationsId, metadataStoresIdPurges Contexts.
add_context_artifacts_and_executionsexecprojectsId, locationsId, metadataStoresId, contextsIdAdds a set of Artifacts and Executions to a Context. If any of the Artifacts or Executions have already been added to a Context, they are simply skipped.
add_context_childrenexecprojectsId, locationsId, metadataStoresId, contextsIdAdds a set of Contexts as children to a parent Context. If any of the child Contexts have already been added to the parent Context, they are simply skipped. If this call would create a cycle or cause any Context to have more than 10 parents, the request will fail with an INVALID_ARGUMENT error.
remove_context_childrenexecprojectsId, locationsId, metadataStoresId, contextsIdRemove a set of children contexts from a parent Context. If any of the child Contexts were NOT added to the parent Context, they are simply skipped.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
contextsIdstring
locationsIdstring
metadataStoresIdstring
projectsIdstring
allowMissingboolean
contextIdstring
etagstring
filterstring
forceboolean
orderBystring
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)

SELECT examples

Retrieves a specific Context.

SELECT
name,
createTime,
description,
displayName,
etag,
labels,
metadata,
parentContexts,
schemaTitle,
schemaVersion,
updateTime
FROM google.aiplatform.contexts
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND metadataStoresId = '{{ metadataStoresId }}' -- required
AND contextsId = '{{ contextsId }}' -- required;

INSERT examples

Creates a Context associated with a MetadataStore.

INSERT INTO google.aiplatform.contexts (
data__name,
data__displayName,
data__etag,
data__labels,
data__schemaTitle,
data__schemaVersion,
data__metadata,
data__description,
projectsId,
locationsId,
metadataStoresId,
contextId
)
SELECT
'{{ name }}',
'{{ displayName }}',
'{{ etag }}',
'{{ labels }}',
'{{ schemaTitle }}',
'{{ schemaVersion }}',
'{{ metadata }}',
'{{ description }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ metadataStoresId }}',
'{{ contextId }}'
RETURNING
name,
createTime,
description,
displayName,
etag,
labels,
metadata,
parentContexts,
schemaTitle,
schemaVersion,
updateTime
;

UPDATE examples

Updates a stored Context.

UPDATE google.aiplatform.contexts
SET
data__name = '{{ name }}',
data__displayName = '{{ displayName }}',
data__etag = '{{ etag }}',
data__labels = '{{ labels }}',
data__schemaTitle = '{{ schemaTitle }}',
data__schemaVersion = '{{ schemaVersion }}',
data__metadata = '{{ metadata }}',
data__description = '{{ description }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND metadataStoresId = '{{ metadataStoresId }}' --required
AND contextsId = '{{ contextsId }}' --required
AND updateMask = '{{ updateMask}}'
AND allowMissing = {{ allowMissing}}
RETURNING
name,
createTime,
description,
displayName,
etag,
labels,
metadata,
parentContexts,
schemaTitle,
schemaVersion,
updateTime;

DELETE examples

Deletes a stored Context.

DELETE FROM google.aiplatform.contexts
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND metadataStoresId = '{{ metadataStoresId }}' --required
AND contextsId = '{{ contextsId }}' --required
AND force = '{{ force }}'
AND etag = '{{ etag }}';

Lifecycle Methods

Retrieves relevant contexts for a query.

EXEC google.aiplatform.contexts.retrieve_contexts 
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required
@@json=
'{
"vertexRagStore": "{{ vertexRagStore }}",
"query": "{{ query }}"
}';