@@ -1540,7 +1540,7 @@ def __init__(
15401540 objective_target : PromptTarget = REQUIRED_VALUE , # type: ignore[ty:invalid-parameter-default]
15411541 attack_adversarial_config : AttackAdversarialConfig ,
15421542 attack_converter_config : AttackConverterConfig | None = None ,
1543- attack_scoring_config : AttackScoringConfig | None = None ,
1543+ attack_scoring_config : TAPAttackScoringConfig | None = None ,
15441544 prompt_normalizer : PromptNormalizer | None = None ,
15451545 tree_width : int = 3 ,
15461546 tree_depth : int = 5 ,
@@ -1558,7 +1558,7 @@ def __init__(
15581558 attack_adversarial_config (AttackAdversarialConfig): Configuration for the adversarial chat component.
15591559 attack_converter_config (AttackConverterConfig | None): Configuration for attack converters.
15601560 Defaults to None.
1561- attack_scoring_config (AttackScoringConfig | None): Scoring configuration for TAP.
1561+ attack_scoring_config (TAPAttackScoringConfig | None): Scoring configuration for TAP.
15621562 The objective_scorer must be a FloatScaleThresholdScorer, which provides both
15631563 granular float scores for node comparison and a threshold for determining success.
15641564 Can be either AttackScoringConfig or TAPAttackScoringConfig. If not provided,
@@ -1650,7 +1650,32 @@ def __init__(
16501650 self ._request_converters = attack_converter_config .request_converters
16511651 self ._response_converters = attack_converter_config .response_converters
16521652
1653- # Initialize scoring configuration
1653+ tap_scoring_config = self ._resolve_scoring_config (attack_scoring_config )
1654+ self ._attack_scoring_config = tap_scoring_config
1655+ self ._auxiliary_scorers = tap_scoring_config .auxiliary_scorers
1656+ self ._objective_scorer = tap_scoring_config .objective_scorer
1657+
1658+ # Use the adversarial chat target for scoring, as in CrescendoAttack
1659+ self ._scoring_target = self ._adversarial_chat
1660+
1661+ if self ._configuration .on_topic_checking_enabled and not self ._scoring_target :
1662+ raise ValueError ("On-topic checking is enabled but no scoring target is available." )
1663+
1664+ self ._prompt_normalizer = prompt_normalizer or PromptNormalizer ()
1665+
1666+ def _resolve_scoring_config (self , attack_scoring_config : AttackScoringConfig | None ) -> TAPAttackScoringConfig :
1667+ """
1668+ Normalize runtime inputs while preserving the constructor's factory-facing TAP type contract.
1669+
1670+ Args:
1671+ attack_scoring_config: Optional scoring config, including legacy base configs from direct callers.
1672+
1673+ Returns:
1674+ A TAP scoring config with a float-scale threshold scorer.
1675+
1676+ Raises:
1677+ ValueError: If a base config has no objective scorer or an incompatible scorer.
1678+ """
16541679 # If no scoring config provided, create the default TAP scorer using FloatScaleThresholdScorer
16551680 if attack_scoring_config is None :
16561681 # Determine supported data types based on target's output modalities.
@@ -1701,17 +1726,7 @@ def __init__(
17011726 use_score_as_feedback = attack_scoring_config .use_score_as_feedback ,
17021727 )
17031728
1704- self ._attack_scoring_config = tap_scoring_config
1705- self ._auxiliary_scorers = tap_scoring_config .auxiliary_scorers
1706- self ._objective_scorer = tap_scoring_config .objective_scorer
1707-
1708- # Use the adversarial chat target for scoring, as in CrescendoAttack
1709- self ._scoring_target = self ._adversarial_chat
1710-
1711- if self ._configuration .on_topic_checking_enabled and not self ._scoring_target :
1712- raise ValueError ("On-topic checking is enabled but no scoring target is available." )
1713-
1714- self ._prompt_normalizer = prompt_normalizer or PromptNormalizer ()
1729+ return tap_scoring_config
17151730
17161731 def _load_adversarial_prompts (self ) -> None :
17171732 """Load the adversarial chat prompt template and seed prompt from the default paths."""
0 commit comments