pyrit.score.ScorerIdentifier#
- class ScorerIdentifier(type: str, system_prompt_template: str | None = None, user_prompt_template: str | None = None, sub_identifier: List[ScorerIdentifier] | None = None, target_info: Dict[str, Any] | None = None, score_aggregator: str | None = None, scorer_specific_params: Dict[str, Any] | None = None, pyrit_version: str = '0.10.1.dev0')[source]#
Bases:
objectConfiguration class for Scorers.
This class encapsulates the modifiable parameters that can be used to create a complete scoring configuration. These parameters can be modified, and configurations can be compared to each other via scorer evaluations.
- __init__(type: str, system_prompt_template: str | None = None, user_prompt_template: str | None = None, sub_identifier: List[ScorerIdentifier] | None = None, target_info: Dict[str, Any] | None = None, score_aggregator: str | None = None, scorer_specific_params: Dict[str, Any] | None = None, pyrit_version: str = '0.10.1.dev0') None#
Methods
__init__(type[, system_prompt_template, ...])compute_hash([hashable_dict])Compute a hash representing the current configuration.
Convert the ScorerIdentifier to a compact dictionary for storage.
Attributes
- compute_hash(hashable_dict: Dict[str, Any] | None = None) str[source]#
Compute a hash representing the current configuration.
- Parameters:
hashable_dict – Pre-computed hashable dict to avoid recomputation. If None, _to_hashable_dict() will be called.
- Returns:
A hash string representing the configuration.
- Return type:
- sub_identifier: List[ScorerIdentifier] | None = None#
- to_compact_dict() Dict[str, Any][source]#
Convert the ScorerIdentifier to a compact dictionary for storage.
Long prompts (>100 characters) are hashed to sha256:{hash[:16]} format. Nested sub_identifiers are recursively compacted. Includes the computed hash of the configuration.
- Returns:
A compact dictionary representation with hash.
- Return type:
Dict[str, Any]