pyrit.models.SeedAttackGroup#
- class SeedAttackGroup(*, seeds: Sequence[Seed | Dict[str, Any]])[source]#
Bases:
SeedGroupA group of seeds for use in attack scenarios.
This class extends SeedGroup with attack-specific validation: - Requires exactly one SeedObjective (not optional like in SeedGroup)
All other functionality (simulated conversation, prepended conversation, next_message, etc.) is inherited from SeedGroup.
- __init__(*, seeds: Sequence[Seed | Dict[str, Any]])[source]#
Initialize a SeedAttackGroup.
- Parameters:
seeds – Sequence of seeds. Must include exactly one SeedObjective.
- Raises:
ValueError – If seeds is empty.
ValueError – If exactly one objective is not provided.
Methods
__init__(*, seeds)Initialize a SeedAttackGroup.
from_yaml_file(file)Create a new object from a YAML file.
is_single_part_single_text_request()Check if this is a single text prompt.
is_single_request()Check if all prompts are in a single sequence.
is_single_turn()Check if this is a single-turn group (single request without objective).
render_template_value(**kwargs)Renders seed values as templates with provided parameters.
validate()Validate the seed attack group state.
Attributes
harm_categoriesReturns a deduplicated list of all harm categories from all seeds.
has_simulated_conversationCheck if this group uses simulated conversation generation.
next_messageReturns a Message containing only the last turn's prompts if it's a user message.
Get the objective for this attack group.
prepended_conversationReturns Messages that should be prepended as conversation history.
promptsGet all SeedPrompt instances from this group.
simulated_conversation_configGet the simulated conversation configuration if set.
user_messagesReturns all prompts as user Messages, one per sequence.
- property objective: SeedObjective#
Get the objective for this attack group.
Unlike SeedGroup.objective which may return None, SeedAttackGroup guarantees exactly one objective exists.
- Returns:
The SeedObjective for this attack group.
- validate() None[source]#
Validate the seed attack group state.
Extends SeedGroup validation to require exactly one objective.
- Raises:
ValueError – If validation fails.