pyrit.models.Score#

class Score(*, id: UUID | str | None = None, score_value: str, score_value_description: str, score_type: Literal['true_false', 'float_scale'], score_category: str, score_rationale: str, score_metadata: str, scorer_class_identifier: Dict[str, str] = None, prompt_request_response_id: str | UUID, timestamp: datetime | None = None, task: str | None = None)[source]#

Bases: object

__init__(*, id: UUID | str | None = None, score_value: str, score_value_description: str, score_type: Literal['true_false', 'float_scale'], score_category: str, score_rationale: str, score_metadata: str, scorer_class_identifier: Dict[str, str] = None, prompt_request_response_id: str | UUID, timestamp: datetime | None = None, task: str | None = None)[source]#

Methods

__init__(*[, id, scorer_class_identifier, ...])

get_value()

Returns the value of the score based on its type.

to_dict()

validate(scorer_type, score_value)

Attributes

get_value()[source]#

Returns the value of the score based on its type.

If the score type is “true_false”, it returns True if the score value is “true” (case-insensitive), otherwise it returns False.

If the score type is “float_scale”, it returns the score value as a float.

Raises:

ValueError – If the score type is unknown.

Returns:

The value of the score based on its type.

id: UUID | str#
prompt_request_response_id: UUID | str#
score_category: str#
score_metadata: str#
score_rationale: str#
score_type: Literal['true_false', 'float_scale']#
score_value: str#
score_value_description: str#
scorer_class_identifier: Dict[str, str]#
task: str#
timestamp: datetime#
to_dict()[source]#
validate(scorer_type, score_value)[source]#