pyrit.executor.attack.MultiTurnAttackStrategy

pyrit.executor.attack.MultiTurnAttackStrategy#

class MultiTurnAttackStrategy(*, objective_target: ~pyrit.prompt_target.common.prompt_target.PromptTarget, context_type: type[~pyrit.executor.attack.multi_turn.multi_turn_attack_strategy.MultiTurnAttackStrategyContextT], params_type: ~typing.Type[~pyrit.executor.attack.core.attack_parameters.AttackParamsT] = <class 'pyrit.executor.attack.core.attack_parameters.AttackParameters'>, logger: ~logging.Logger = <Logger ai-red-team (INFO)>)[source]#

Bases: AttackStrategy[MultiTurnAttackStrategyContextT, AttackStrategyResultT], ABC

Strategy for executing multi-turn attacks. This strategy is designed to handle attacks that consist of multiple turns of interaction with the target model.

__init__(*, objective_target: ~pyrit.prompt_target.common.prompt_target.PromptTarget, context_type: type[~pyrit.executor.attack.multi_turn.multi_turn_attack_strategy.MultiTurnAttackStrategyContextT], params_type: ~typing.Type[~pyrit.executor.attack.core.attack_parameters.AttackParamsT] = <class 'pyrit.executor.attack.core.attack_parameters.AttackParameters'>, logger: ~logging.Logger = <Logger ai-red-team (INFO)>)[source]#

Implement the base class for multi-turn attack strategies.

Parameters:
  • objective_target (PromptTarget) – The target system to attack.

  • context_type (type[MultiTurnAttackContext]) – The type of context this strategy will use.

  • params_type (Type[AttackParamsT]) – The type of parameters this strategy accepts.

  • logger (logging.Logger) – Logger instance for logging events and messages.

Methods

__init__(*, objective_target, context_type)

Implement the base class for multi-turn attack strategies.

execute_async(**kwargs)

Execute the attack strategy asynchronously with the provided parameters.

execute_with_context_async(*, context)

Execute strategy with complete lifecycle management.

get_attack_scoring_config()

Get the attack scoring configuration used by this strategy.

get_identifier()

Get a serializable identifier for the strategy instance.

get_objective_target()

Get the objective target for this attack strategy.

Attributes

params_type

Get the parameters type for this attack strategy.