pyrit.executor.attack.AttackParameters#

class AttackParameters(objective: str, next_message: ~pyrit.models.message.Message | None = None, prepended_conversation: ~typing.List[~pyrit.models.message.Message] | None = None, memory_labels: ~typing.Dict[str, str] | None = <factory>)[source]#

Bases: object

Immutable parameters for attack execution.

This class defines the standard contract for attack parameters. All attacks at a given level of the hierarchy share the same parameter signature.

Attacks that don’t accept certain parameters should use the excluding() factory to create a derived params type without those fields. Attacks that need additional parameters should extend this class with new fields.

__init__(objective: str, next_message: ~pyrit.models.message.Message | None = None, prepended_conversation: ~typing.List[~pyrit.models.message.Message] | None = None, memory_labels: ~typing.Dict[str, str] | None = <factory>) None#

Methods

__init__(objective[, next_message, ...])

excluding(*field_names)

Create a new AttackParameters subclass that excludes the specified fields.

from_seed_group(seed_group, **overrides)

Create an AttackParameters instance from a SeedGroup.

Attributes

classmethod excluding(*field_names: str) Type[AttackParameters][source]#

Create a new AttackParameters subclass that excludes the specified fields.

This factory method creates a frozen dataclass without the specified fields. The resulting class inherits the from_seed_group() behavior and will raise if excluded fields are passed as overrides.

Parameters:

*field_names – Names of fields to exclude from the new params type.

Returns:

A new AttackParameters subclass without the specified fields.

Raises:

ValueError – If any field_name is not a valid field of this class.

Example

RolePlayAttackParameters = AttackParameters.excluding(“next_message”, “prepended_conversation”)

classmethod from_seed_group(seed_group: SeedGroup, **overrides: Any) AttackParamsT[source]#

Create an AttackParameters instance from a SeedGroup.

Extracts standard fields from the seed group and applies any overrides. Raises ValueError if overrides contain fields not accepted by this params type.

Parameters:
  • seed_group – The seed group to extract parameters from.

  • **overrides – Field overrides to apply. Must be valid fields for this params type.

Returns:

An instance of this AttackParameters type.

Raises:

ValueError – If seed_group has no objective or if overrides contain invalid fields.

memory_labels: Dict[str, str] | None#
next_message: Message | None = None#
objective: str#
prepended_conversation: List[Message] | None = None#