Skip to content

CriterionSetsResource

CriterionSetsResource

CriterionSetsResource(client: Union[Client, AsyncClient])

Bases: BaseResource

add_prompt_template

add_prompt_template(criterion_set: CriterionSet, prompt_template: PromptTemplate) -> CriterionSet

Add a prompt template to an existing criterion set.

Parameters:

Name Type Description Default
criterion_set CriterionSet

The criterion set.

required
prompt_template PromptTemplate

The prompt template to add.

required

Returns:

Name Type Description
CriterionSet CriterionSet

The updated criterion set.

aremove_prompt_template async

aremove_prompt_template(criterion_set: CriterionSet, prompt_template: PromptTemplate) -> None

Remove a prompt template from a criterion set (async).

create

create(name: str, criteria: List[str | CriterionIn] | None = None) -> CriterionSet

Create a new criterion set.

Parameters:

Name Type Description Default
name str

The name of the criterion set.

required
criteria list[str | CriterionIn]

List of criterion strings or CriterionIn objects.

None

Returns:

Name Type Description
CriterionSet CriterionSet

The created criterion set.

delete

delete(criterion_set: CriterionSet) -> None

Delete a criterion set.

This will also delete all associated criteria.

Parameters:

Name Type Description Default
criterion_set CriterionSet

The criterion set to delete.

required

get

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

Get a specific criterion set by name or id.

Parameters:

Name Type Description Default
name str | None

The name of the criterion set.

None
id int | None

The id of the criterion set.

None

Returns:

Name Type Description
CriterionSet CriterionSet

The requested criterion set.

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, criteria: List[str | CriterionIn] | None = None) -> Tuple[CriterionSet, bool]

Get or create a criterion set.

Attempts to get a criterion set first. If it doesn't exist, creates a new one.

Parameters:

Name Type Description Default
name str

The name of the criterion set.

required
criteria list[str | CriterionIn]

List of criterion strings or CriterionIn objects if creation is needed.

None

Returns:

Type Description
Tuple[CriterionSet, bool]

Tuple[CriterionSet, bool]: A tuple containing: - The criterion set - Boolean indicating if a new criterion set was created (True) or existing one returned (False)

list

list() -> List[CriterionSet]

List all criterion sets in the project.

Returns:

Type Description
List[CriterionSet]

list[CriterionSet]: List of criterion set objects.

remove_prompt_template

remove_prompt_template(criterion_set: CriterionSet, prompt_template: PromptTemplate) -> None

Remove a prompt template from a criterion set.

Parameters:

Name Type Description Default
criterion_set CriterionSet

The criterion set.

required
prompt_template PromptTemplate

The prompt template to remove.

required