pyrit.models.Seed#
- class Seed(value: str, value_sha256: str | None = None, id: ~uuid.UUID | None = <factory>, name: str | None = None, dataset_name: str | None = None, harm_categories: ~typing.Sequence[str] | None = <factory>, description: str | None = None, authors: ~typing.Sequence[str] | None = <factory>, groups: ~typing.Sequence[str] | None = <factory>, source: str | None = None, date_added: ~datetime.datetime | None = <factory>, added_by: str | None = None, metadata: ~typing.Dict[str, str | int] | None = <factory>, prompt_group_id: ~uuid.UUID | None = None, prompt_group_alias: str | None = None)[source]#
Bases:
YamlLoadableRepresents seed data with various attributes and metadata.
- __init__(value: str, value_sha256: str | None = None, id: ~uuid.UUID | None = <factory>, name: str | None = None, dataset_name: str | None = None, harm_categories: ~typing.Sequence[str] | None = <factory>, description: str | None = None, authors: ~typing.Sequence[str] | None = <factory>, groups: ~typing.Sequence[str] | None = <factory>, source: str | None = None, date_added: ~datetime.datetime | None = <factory>, added_by: str | None = None, metadata: ~typing.Dict[str, str | int] | None = <factory>, prompt_group_id: ~uuid.UUID | None = None, prompt_group_alias: str | None = None) None#
Methods
__init__(value[, value_sha256, id, name, ...])from_yaml_file(file)Create a new object from a YAML file.
from_yaml_with_required_parameters(...[, ...])Load a Seed from a YAML file and validate that it contains specific parameters.
render_template_value(**kwargs)Renders self.value as a template, applying provided parameters in kwargs.
render_template_value_silent(**kwargs)Renders self.value as a template, applying provided parameters in kwargs.
This method computes the SHA256 hash value asynchronously.
Attributes
Return the data type for this seed.
- property data_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'binary_path', 'url', 'reasoning', 'error', 'function_call', 'tool_call', 'function_call_output']#
Return the data type for this seed.
Base implementation returns ‘text’. SeedPrompt overrides this to support multiple data types (image_path, audio_path, etc.).
- abstract classmethod from_yaml_with_required_parameters(template_path: str | Path, required_parameters: list[str], error_message: str | None = None) Seed[source]#
Load a Seed from a YAML file and validate that it contains specific parameters.
- Parameters:
template_path – Path to the YAML file containing the template.
required_parameters – List of parameter names that must exist in the template.
error_message – Custom error message if validation fails. If None, a default message is used.
- Returns:
The loaded and validated seed of the specific subclass type.
- Return type:
- render_template_value(**kwargs: Any) str[source]#
Renders self.value as a template, applying provided parameters in kwargs.
- Parameters:
kwargs – Key-value pairs to replace in the SeedPrompt value.
- Returns:
A new prompt with the parameters applied.
- Raises:
ValueError – If parameters are missing or invalid in the template.
- render_template_value_silent(**kwargs: Any) str[source]#
Renders self.value as a template, applying provided parameters in kwargs. For parameters in the template that are not provided as kwargs here, this function will leave them as is instead of raising an error.
- Parameters:
kwargs – Key-value pairs to replace in the SeedPrompt value.
- Returns:
A new prompt with the parameters applied.
- Raises:
ValueError – If parameters are missing or invalid in the template.
- async set_sha256_value_async() None[source]#
This method computes the SHA256 hash value asynchronously. It should be called after prompt value is serialized to text, as file paths used in the value may have changed from local to memory storage paths.
Note, this method is async due to the blob retrieval. And because of that, we opted to take it out of main and setter functions. The disadvantage is that it must be explicitly called.