TemplateVariablesCollectionsResource
TemplateVariablesCollectionsResource ¶
TemplateVariablesCollectionsResource(client: Client)
Bases: BaseResource
create ¶
create(name: str, description: str = '', variables: List[Dict[str, str]] | 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, str]]
|
Optional list of variables to add to the collection. |
None
|
Returns:
Type | Description |
---|---|
TemplateVariablesCollection
|
The newly created collection object. |
Raises:
Type | Description |
---|---|
HTTPStatusError
|
If collection with same name already exists (400 BAD REQUEST) |
get ¶
Get a collection by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the collection to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
TemplateVariablesCollectionWithEntries |
TemplateVariablesCollectionWithEntries
|
The collection object. |
Raises:
Type | Description |
---|---|
ValueError
|
If no collection is found with the given name. |
get_by_id ¶
Get a collection by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
int
|
The id of the collection. |
required |
Returns:
Type | Description |
---|---|
TemplateVariablesCollectionWithEntries
|
The requested collection. |
get_or_create ¶
get_or_create(name: str, description: str = '', variables: List[Dict[str, str]] | None = None) -> tuple[TemplateVariablesCollectionWithEntries, bool]
Gets an existing collection by name or creates a new one if it doesn't exist. The existence check is only based on the name parameter - if a collection with the given name exists, it will be returned regardless of the other parameters.
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, str]] | None
|
Optional list of variables to add to the collection if created. |
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 |
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. |