Skip to content

TemplateVariablesCollectionsResource

TemplateVariablesCollectionsResource

TemplateVariablesCollectionsResource(client: Union[Client, AsyncClient])

Bases: BaseResource

aupdate async

aupdate(collection_id: int, name: str, description: str | None = None, read_only: bool | None = None, columns: List[str | CollectionColumn] | None = None, collection_type: Literal['STANDARD', 'AGENTIC'] | _Unset = _UNSET, environment_config: dict | None | _Unset = _UNSET) -> TemplateVariablesCollection

Update an existing collection (async).

See update for the parameter contract; collection_type is deprecated.

create

create(name: str, description: str = '', variables: List[Dict[str, Any]] | None = None, columns: List[str | CollectionColumn] | None = None, read_only: bool = False, collection_type: Literal['STANDARD', 'AGENTIC'] = 'STANDARD', environment_config: dict | None = None) -> TemplateVariablesCollectionWithEntries

Creates a new collection.

Parameters:

Name Type Description Default
name str

The name for the new collection.

required
description str

Optional description for the collection.

''
variables list[dict[str, Any]]

Optional list of variables to add to the collection. Values can be strings for TEXT columns, dicts for CONVERSATION columns, or other types.

None
columns list[str | CollectionColumn]

Optional list of column definitions. Can be column names as strings (typed by the server unless you set column_type) or CollectionColumn objects. An AGENTIC collection needs a TEXT column named task holding one unique task name per row, since that is how experiments identify tasks; an instruction column inferred from variables is typed RAW_INPUT.

None
read_only bool

Whether the collection should be read-only.

False
collection_type Literal['STANDARD', 'AGENTIC']

The type of collection ("STANDARD" or "AGENTIC"). Defaults to "STANDARD".

'STANDARD'
environment_config dict | None

Optional environment configuration for agentic collections.

None

Returns:

Type Description
TemplateVariablesCollection

The newly created collection object.

Raises:

Type Description
APIError

If collection with same name already exists (400 BAD REQUEST)

delete

delete(template_variables_collection: TemplateVariablesCollection) -> None

Delete a collection.

get

get(*, name: str | None = None, id: int | None = None) -> TemplateVariablesCollectionWithEntries

Get a collection by name or id.

Parameters:

Name Type Description Default
name str | None

The name of the collection to get.

None
id int | None

The id of the collection to get.

None

Returns:

Name Type Description
TemplateVariablesCollectionWithEntries TemplateVariablesCollectionWithEntries

The collection object.

Raises:

Type Description
ValueError

If neither or both name and id are provided, or if not found.

get_or_create

get_or_create(name: str, description: str = '', variables: List[Dict[str, Any]] | None = None, columns: List[str | CollectionColumn] | None = None, read_only: bool = False, collection_type: Literal['STANDARD', 'AGENTIC'] = 'STANDARD', environment_config: dict | None = None) -> tuple[TemplateVariablesCollectionWithEntries, bool]

Gets an existing collection by name or creates a new one if it doesn't exist.

If a collection with the given name exists: - If columns parameter is provided, validates that the existing collection has matching column types - Returns the existing collection if compatible, otherwise raises ValueError - Other parameters (description, variables, read_only) are ignored with warnings

Parameters:

Name Type Description Default
name str

The name of the collection to get or create.

required
description str

Optional description for the collection if created.

''
variables List[Dict[str, Any]] | None

Optional list of variables to add to the collection if created. Values can be strings for TEXT columns, dicts for CONVERSATION columns, or other types.

None
columns List[str | CollectionColumn] | None

Optional list of column definitions for the collection if created. Can be column names as strings (typed by the server unless you set column_type) or CollectionColumn objects. If provided and collection exists, column types must match existing collection. An AGENTIC collection needs a TEXT column named task holding one unique task name per row, since that is how experiments identify tasks.

None
read_only bool

Whether the collection should be read-only if created.

False
collection_type Literal['STANDARD', 'AGENTIC']

The type of collection ("STANDARD" or "AGENTIC"). Defaults to "STANDARD".

'STANDARD'
environment_config dict | None

Optional environment configuration for agentic collections.

None

Returns:

Type Description
tuple[TemplateVariablesCollectionWithEntries, bool]

tuple[TemplateVariablesCollectionWithEntries, bool]: A tuple containing: - Collection: The retrieved or created collection object - bool: True if a new collection was created, False if existing was found

Raises:

Type Description
ValueError

If collection exists but has incompatible column types

list

list(filters: TemplateVariablesCollectionFilter | None = None, compatible_prompt_template: PromptTemplate | None = None, sort_options: TemplateVariablesCollectionSort | None = None) -> list[TemplateVariablesCollection]

Get a list of template variables collections.

Parameters:

Name Type Description Default
filters TemplateVariablesCollectionFilter | None

Filter for template variables collections.

None
compatible_prompt_template PromptTemplate | None

Filter collections compatible with a specific prompt template.

None
sort_options TemplateVariablesCollectionSort | None

Sort for template variables collections.

None

Returns:

Type Description
list[TemplateVariablesCollection]

list[TemplateVariablesCollection]: A list of template variables collections.

update

update(collection_id: int, name: str, description: str | None = None, read_only: bool | None = None, columns: List[str | CollectionColumn] | None = None, collection_type: Literal['STANDARD', 'AGENTIC'] | _Unset = _UNSET, environment_config: dict | None | _Unset = _UNSET) -> TemplateVariablesCollection

Update an existing collection.

Parameters:

Name Type Description Default
collection_id int

The ID of the collection to update.

required
name str

The new name for the collection.

required
description str | None

Optional new description for the collection.

None
read_only bool | None

Optional new read-only status for the collection.

None
columns List[str | CollectionColumn] | None

Optional list of columns in the desired order. Can be column names as strings (typed by the server unless you set column_type) or CollectionColumn objects. Missing columns are deleted, new columns are created, existing columns are reordered.

None
collection_type Literal['STANDARD', 'AGENTIC'] | _Unset

Deprecated since 1.2.5, removed in 1.4.0 — set the type via create(). A collection's type is fixed at creation, so anything other than its current type is rejected with HTTP 422. Not sent if omitted.

_UNSET
environment_config dict | None | _Unset

Environment configuration for agentic collections. Pass a dict to set, None to clear, or omit to leave unchanged.

_UNSET

Returns:

Name Type Description
TemplateVariablesCollection TemplateVariablesCollection

The updated collection object.

Raises:

Type Description
APIError

If collection doesn't exist or validation fails.