pyrit.executor.attack.AttackStrategy

pyrit.executor.attack.AttackStrategy#

class AttackStrategy(*, context_type: type[~pyrit.executor.attack.core.attack_strategy.AttackStrategyContextT], logger: ~logging.Logger = <Logger ai-red-team (INFO)>)[source]#

Bases: Strategy[AttackStrategyContextT, AttackStrategyResultT], ABC

Abstract base class for attack strategies. Defines the interface for executing attacks and handling results.

__init__(*, context_type: type[~pyrit.executor.attack.core.attack_strategy.AttackStrategyContextT], logger: ~logging.Logger = <Logger ai-red-team (INFO)>)[source]#

Initialize the attack strategy with a specific context type and logger.

Parameters:
  • context_type (type[AttackStrategyContextT]) – The type of context this strategy operates on.

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

Methods

__init__(*, context_type[, logger])

Initialize the attack strategy with a specific context type and logger.

execute_async()

Execute the attack strategy asynchronously with the provided parameters.

execute_with_context_async(*, context)

Execute strategy with complete lifecycle management.

get_identifier()

async execute_async(*, objective: str, prepended_conversation: list[PromptRequestResponse] | None = None, memory_labels: dict[str, str] | None = None, **kwargs) AttackStrategyResultT[source]#
async execute_async(**kwargs) AttackStrategyResultT

Execute the attack strategy asynchronously with the provided parameters.