pyrit.models.SeedPromptDataset#

class SeedPromptDataset(prompts: List[SeedPrompt] | List[Dict[str, Any]])[source]#

Bases: YamlLoadable

SeedPromptDataset class helps to read a list of seed prompts, which can be loaded from a YAML file. This class manages individual seed prompts, groups them by prompt_group_id if specified, and provides structured access to grouped prompt data.

__init__(prompts: List[SeedPrompt] | List[Dict[str, Any]])[source]#

Methods

__init__(prompts)

from_yaml_file(file)

Creates a new object from a YAML file.

from_yaml_file_with_uniform_metadata(file[, ...])

Creates a new object from a YAML file.

group_seed_prompts_by_prompt_group_id(...)

Groups the given list of SeedPrompts by their prompt_group_id and creates SeedPromptGroup instances.

Attributes

static from_yaml_file_with_uniform_metadata(file: Path, data_type='text') SeedPromptDataset[source]#

Creates a new object from a YAML file.

In the past, PyRIT supported dataset loading from YAML with uniform metadata. That means, every prompt in a dataset had to have the same harm categories, same authors, same groups, etc. This method is a helper to load such datasets.

Parameters:
  • file – The input file path.

  • data_type – The data type of the prompts.

Returns:

A new object of type T.

Raises:
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]#