pyrit.executor.attack.AttackContext#
- class AttackContext(params: ~pyrit.executor.attack.core.attack_parameters.AttackParamsT, start_time: float = 0.0, related_conversations: set[~pyrit.models.conversation_reference.ConversationReference] = <factory>, _next_message_override: ~pyrit.models.message.Message | None = None, _prepended_conversation_override: ~typing.List[~pyrit.models.message.Message] | None = None, _memory_labels_override: ~typing.Dict[str, str] | None = None)[source]#
Bases:
StrategyContext,ABC,Generic[AttackParamsT]Base class for all attack contexts.
This class holds both the immutable attack parameters and the mutable execution state. The params field contains caller-provided inputs, while other fields track execution progress.
Attacks that generate certain values internally (e.g., RolePlayAttack generates next_message and prepended_conversation) can set the mutable override fields (_next_message_override, _prepended_conversation_override) during _setup_async.
- __init__(params: ~pyrit.executor.attack.core.attack_parameters.AttackParamsT, start_time: float = 0.0, related_conversations: set[~pyrit.models.conversation_reference.ConversationReference] = <factory>, _next_message_override: ~pyrit.models.message.Message | None = None, _prepended_conversation_override: ~typing.List[~pyrit.models.message.Message] | None = None, _memory_labels_override: ~typing.Dict[str, str] | None = None) None#
Methods
__init__(params[, start_time, ...])duplicate()Create a deep copy of the context.
Attributes
Additional labels that can be applied to the prompts throughout the attack.
Optional message to send to the objective target.
Natural-language description of what the attack tries to achieve.
Conversation that is automatically prepended to the target model.
- property memory_labels: Dict[str, str]#
Additional labels that can be applied to the prompts throughout the attack.
- params: AttackParamsT#
- property prepended_conversation: List[Message]#
Conversation that is automatically prepended to the target model.