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.
set_objective(value)Set or update the objective for this SeedGroup.
Attributes
Returns a flattened list of all harm categories from all seeds in the group.
Returns a Message containing only the last turn's prompts if it's a user message.
Returns Messages that should be prepended as conversation history.
Returns all prompts as user Messages, one per sequence.
- 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 next_message: Message | None#
Returns a Message containing only the last turn’s prompts if it’s a user message.
If the last message in the sequence is a user message, returns that message. If the last message is not a user message, returns None.
- Returns:
Message for the current/last turn if user role, or None otherwise.
- Return type:
Optional[Message]
- property objective: SeedObjective | None#
- property prepended_conversation: List[Message] | None#
Returns Messages that should be prepended as conversation history.
If the last message in the sequence is a user message, returns all messages except the last one. If the last message is not a user message, returns the entire sequence as conversation history.
- Returns:
Messages for conversation history, or None if empty.
- Return type:
Optional[List[Message]]
- 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.
- set_objective(value: str) None[source]#
Set or update the objective for this SeedGroup.
If an objective already exists, updates its value. If not, creates a new SeedObjective and inserts it at the beginning.
- Parameters:
value (str) – The objective value to set.
- property user_messages: List[Message]#
Returns all prompts as user Messages, one per sequence.
This is used by MultiPromptSendingAttack to get user messages for multi-turn attacks. Only returns messages from prompts (not objectives).
- Returns:
All user messages in sequence order, or empty list if no prompts.
- Return type:
List[Message]