pyrit.models.SeedGroup#
- class SeedGroup(*, seeds: Sequence[Seed | Dict[str, Any]])[source]#
Bases:
YamlLoadableA group of prompts that need to be sent together, along with an objective. This can include multiturn and multimodal prompts. This class is useful when a target requires multiple message pieces to be grouped and sent together. All prompts in the group should share the same prompt_group_id.
Methods
__init__(*, seeds)from_yaml_file(file)Create a new object from a YAML file.
render_template_value(**kwargs)Renders self.value as a template, applying provided parameters in kwargs.
to_attack_parameters([...])Decomposes this SeedGroup into parts commonly used by attack strategies.
Attributes
Returns a flattened list of all harm categories from all seeds in the group.
- property harm_categories: List[str]#
Returns a flattened list of all harm categories from all seeds in the group.
- Returns:
A list of harm categories from all seeds, with duplicates removed.
- Return type:
List[str]
- property prompts: Sequence[SeedPrompt]#
- render_template_value(**kwargs)[source]#
Renders self.value as a template, applying provided parameters in kwargs.
- Parameters:
kwargs – Key-value pairs to replace in the SeedGroup value.
- Returns:
None
- Raises:
ValueError – If parameters are missing or invalid in the template.
- to_attack_parameters(raise_on_missing_objective: bool = False) DecomposedSeedGroup[source]#
Decomposes this SeedGroup into parts commonly used by attack strategies.
This method extracts: - objective: The string value from SeedObjective (if present) - prepended_conversation: Messages from all sequences except the last turn - current_turn_seed_group: A new SeedGroup containing only the last turn’s prompts
- Parameters:
raise_on_missing_objective – If True, raises ValueError when no objective is present. If False (default), allows None objective.
- Returns:
Object containing the decomposed parts.
- Return type:
DecomposedSeedGroup
- Raises:
ValueError – If conversion to Messages fails or if raise_on_missing_objective is True and no objective is present.