88from pyrit .score .scorer_prompt_validator import ScorerPromptValidator
99from pyrit .score .true_false .true_false_score_aggregator import TrueFalseScoreAggregator
1010from pyrit .score .true_false .true_false_scorer import TrueFalseScorer
11- from pyrit .score .video_scorer import _BaseVideoScorer
11+ from pyrit .score .video_scorer import VideoHelper
1212
1313
14- class VideoTrueFalseScorer (TrueFalseScorer , _BaseVideoScorer ):
14+ class VideoTrueFalseScorer (TrueFalseScorer ):
1515 """
1616 A scorer that processes videos by extracting frames and scoring them using a true/false image scorer.
1717
@@ -34,7 +34,7 @@ def __init__(
3434 audio_scorer : Optional [TrueFalseScorer ] = None ,
3535 num_sampled_frames : Optional [int ] = None ,
3636 validator : Optional [ScorerPromptValidator ] = None ,
37- image_objective_template : Optional [str ] = _BaseVideoScorer ._DEFAULT_IMAGE_OBJECTIVE_TEMPLATE ,
37+ image_objective_template : Optional [str ] = VideoHelper ._DEFAULT_IMAGE_OBJECTIVE_TEMPLATE ,
3838 audio_objective_template : Optional [str ] = None ,
3939 ) -> None :
4040 """
@@ -59,18 +59,17 @@ def __init__(
5959 Raises:
6060 ValueError: If audio_scorer is provided and does not support audio_path data type.
6161 """
62- _BaseVideoScorer .__init__ (
63- self ,
62+ super ().__init__ (validator = validator or self ._DEFAULT_VALIDATOR )
63+
64+ self ._video_helper = VideoHelper (
6465 image_capable_scorer = image_capable_scorer ,
6566 num_sampled_frames = num_sampled_frames ,
6667 image_objective_template = image_objective_template ,
6768 audio_objective_template = audio_objective_template ,
6869 )
6970
70- TrueFalseScorer .__init__ (self , validator = validator or self ._DEFAULT_VALIDATOR )
71-
7271 if audio_scorer is not None :
73- self ._validate_audio_scorer (audio_scorer )
72+ VideoHelper ._validate_audio_scorer (audio_scorer )
7473 self .audio_scorer = audio_scorer
7574
7675 def _build_identifier (self ) -> ComponentIdentifier :
@@ -80,16 +79,16 @@ def _build_identifier(self) -> ComponentIdentifier:
8079 Returns:
8180 ComponentIdentifier: The identifier for this scorer.
8281 """
83- sub_scorer_ids = [self .image_scorer .get_identifier ()]
82+ sub_scorer_ids = [self ._video_helper . image_scorer .get_identifier ()]
8483 if self .audio_scorer :
8584 sub_scorer_ids .append (self .audio_scorer .get_identifier ())
8685
8786 return self ._create_identifier (
8887 params = {
89- "num_sampled_frames" : self .num_sampled_frames ,
88+ "num_sampled_frames" : self ._video_helper . num_sampled_frames ,
9089 "has_audio_scorer" : self .audio_scorer is not None ,
91- "image_objective_template" : self .image_objective_template ,
92- "audio_objective_template" : self .audio_objective_template ,
90+ "image_objective_template" : self ._video_helper . image_objective_template ,
91+ "audio_objective_template" : self ._video_helper . audio_objective_template ,
9392 },
9493 children = {
9594 "sub_scorers" : sub_scorer_ids ,
@@ -114,7 +113,7 @@ async def _score_piece_async(self, message_piece: MessagePiece, *, objective: Op
114113 piece_id = message_piece .id if message_piece .id is not None else message_piece .original_prompt_id
115114
116115 # Get scores for all frames and aggregate with OR (True if ANY frame matches)
117- frame_scores = await self ._score_frames_async (message_piece = message_piece , objective = objective )
116+ frame_scores = await self ._video_helper . _score_frames_async (message_piece = message_piece , objective = objective )
118117 frame_result = TrueFalseScoreAggregator .OR (frame_scores )
119118
120119 # Create a Score from the frame aggregation result
@@ -132,7 +131,7 @@ async def _score_piece_async(self, message_piece: MessagePiece, *, objective: Op
132131
133132 # Score audio if audio_scorer is provided
134133 if self .audio_scorer :
135- audio_scores = await self ._score_video_audio_async (
134+ audio_scores = await self ._video_helper . _score_video_audio_async (
136135 message_piece = message_piece , audio_scorer = self .audio_scorer , objective = objective
137136 )
138137 if audio_scores :
0 commit comments