Skip to content

TemplateVariablesResource

TemplateVariablesResource

TemplateVariablesResource(client: Union[Client, AsyncClient])

Bases: BaseResource

add_many_to_collection

add_many_to_collection(variables: list[dict[str, str]], collection: TemplateVariablesCollection) -> list[TemplateVariables]

Add multiple template variable entries to a collection in one request.

Uses the backend's batch upload endpoint by generating a JSONL payload in memory.

Parameters:

Name Type Description Default
variables list[dict[str, str]]

List of input_values dicts to add.

required
collection TemplateVariablesCollection

Target collection.

required

Returns:

Type Description
list[TemplateVariables]

List[TemplateVariables]: The created template variables.

add_to_collection

add_to_collection(template_variables: dict[str, Any], collection: TemplateVariablesCollection) -> TemplateVariables

Adds a new entry to a collection. If the entry already exists, it will be returned.

Parameters:

Name Type Description Default
template_variables dict[str, Any]

The template variables to add.

required
collection TemplateVariablesCollection

The collection to add the entry to.

required

Returns:

Name Type Description
TemplateVariables TemplateVariables

The retrieved or created template variables object

delete

delete(template_variables: TemplateVariables, collection: TemplateVariablesCollection) -> None

Deletes a template variables.

Parameters:

Name Type Description Default
template_variables TemplateVariables

The template variables to delete.

required
collection TemplateVariablesCollection

The collection containing the template variables.

required

Raises:

Type Description
HTTPStatusError

If the template variables doesn't exist, belongs to a different collection, or belongs to a different project.

delete_all

delete_all(collection: TemplateVariablesCollection) -> None

Deletes all template variables for a collection.

Parameters:

Name Type Description Default
collection TemplateVariablesCollection

The collection to delete all template variables for.

required

Raises:

Type Description
HTTPStatusError

If the collection doesn't exist or belongs to a different project.

generate

generate(collection: TemplateVariablesCollection, prompt_template: PromptTemplate) -> TemplateVariables

Generates a new template variable in a collection using a prompt template.

Parameters:

Name Type Description Default
collection TemplateVariablesCollection

The collection to add the generated template variable to.

required
prompt_template PromptTemplate

The prompt template to use for generation.

required

Returns:

Name Type Description
TemplateVariables TemplateVariables

The newly generated template variables object.

get

get(*, collection_id: int, id: int) -> TemplateVariables

Get a template variable by id.

Parameters:

Name Type Description Default
collection_id int

The id of the collection containing the template variable.

required
id int

The id of the template variable.

required

Returns:

Type Description
TemplateVariables

The requested template variable.

list

list(collection: TemplateVariablesCollection) -> list[TemplateVariables]

Returns all template variables for a collection.

Parameters:

Name Type Description Default
collection TemplateVariablesCollection

The collection to get entries for.

required

Returns:

Type Description
list[TemplateVariables]

list[TemplateVariables]: List of template variables.

Raises:

Type Description
HTTPStatusError

If the collection is not found