pyrit.models.SeedPromptDataset#
- class SeedPromptDataset(*, prompts: List[Dict[str, Any]] | List[SeedPrompt] = None, data_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'error'] | None = 'text', name: str | None = None, dataset_name: str | None = None, harm_categories: List[str] | None = None, description: str | None = None, authors: List[str] | None = None, groups: List[str] | None = None, source: str | None = None, date_added: datetime | None = None, added_by: str | None = None)[source]#
Bases:
YamlLoadable
SeedPromptDataset manages seed prompts plus optional top-level defaults. Prompts are stored as a List[SeedPrompt], so references to prompt properties are straightforward (e.g. ds.prompts[0].value).
- __init__(*, prompts: List[Dict[str, Any]] | List[SeedPrompt] = None, data_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'error'] | None = 'text', name: str | None = None, dataset_name: str | None = None, harm_categories: List[str] | None = None, description: str | None = None, authors: List[str] | None = None, groups: List[str] | None = None, source: str | None = None, date_added: datetime | None = None, added_by: str | None = None)[source]#
Initialize the dataset. Typically, you’ll call from_dict or from_yaml_file so that top-level defaults are merged into each prompt. If you’re passing prompts directly, they can be either a list of SeedPrompt objects or prompt dictionaries (which then get converted to SeedPrompt objects).
Methods
__init__
(*[, prompts, data_type, name, ...])Initialize the dataset.
from_dict
(data)Builds a SeedPromptDataset by merging top-level defaults into each item in 'prompts'.
from_yaml_file
(file)Creates a new object from a YAML file.
Groups the given list of SeedPrompts by their prompt_group_id and creates SeedPromptGroup instances.
Attributes
- classmethod from_dict(data: Dict[str, Any]) SeedPromptDataset [source]#
Builds a SeedPromptDataset by merging top-level defaults into each item in ‘prompts’.
- static group_seed_prompts_by_prompt_group_id(seed_prompts: List[SeedPrompt]) List[SeedPromptGroup] [source]#
Groups the given list of SeedPrompts by their prompt_group_id and creates SeedPromptGroup instances.
- Parameters:
seed_prompts – A list of SeedPrompt objects.
- Returns:
A list of SeedPromptGroup objects, with prompts grouped by prompt_group_id.
- prompts: List[SeedPrompt]#