pyrit.models.SeedSimulatedConversation#
- class SeedSimulatedConversation(*, adversarial_chat_system_prompt_path: str | Path, simulated_target_system_prompt_path: str | Path | None = None, next_message_system_prompt_path: str | Path | None = None, num_turns: int = 3, sequence: int = 0, pyrit_version: str | None = None, **kwargs: Any)[source]#
Bases:
SeedConfiguration for generating a simulated conversation dynamically.
This class holds the paths and parameters needed to generate prepended conversation content by running an adversarial chat against a simulated (compliant) target.
This is a pure configuration class. The actual generation is performed by generate_simulated_conversation_async in the executor layer, which accepts this config along with runtime dependencies (adversarial_chat target, scorer).
The value property returns a JSON serialization of the config for database storage and deduplication.
- num_turns#
Number of conversation turns to generate.
- adversarial_chat_system_prompt_path#
Path to the adversarial chat system prompt YAML.
- simulated_target_system_prompt_path#
Path to the simulated target system prompt YAML. Defaults to the compliant prompt if not specified.
- next_message_system_prompt_path#
Optional path to the system prompt for generating an additional user message after the simulated conversation. If provided, a single LLM call generates a final user message that attempts to get the target to fulfill the objective in their next response.
- __init__(*, adversarial_chat_system_prompt_path: str | Path, simulated_target_system_prompt_path: str | Path | None = None, next_message_system_prompt_path: str | Path | None = None, num_turns: int = 3, sequence: int = 0, pyrit_version: str | None = None, **kwargs: Any) None[source]#
Initialize a SeedSimulatedConversation.
- Parameters:
adversarial_chat_system_prompt_path – Path to YAML file containing the adversarial chat system prompt.
simulated_target_system_prompt_path – Optional path to YAML file containing the simulated target system prompt. Defaults to the compliant prompt.
next_message_system_prompt_path – Optional path to YAML file containing the system prompt for generating a final user message. If provided, after the simulated conversation is generated, a single LLM call generates a user message that attempts to get the target to fulfill the objective. Defaults to None (no next message generation).
num_turns – Number of conversation turns to generate. Defaults to 3.
sequence – The starting sequence number for generated turns. When combined with static SeedPrompts, this determines where the simulated turns are inserted. Defaults to 0.
pyrit_version – PyRIT version for reproducibility tracking. Defaults to current version.
**kwargs – Additional arguments passed to the Seed base class.
Methods
__init__(*, adversarial_chat_system_prompt_path)Initialize a SeedSimulatedConversation.
Compute a deterministic hash of this configuration.
from_dict(data)Create a SeedSimulatedConversation from a dictionary, typically from YAML.
from_yaml_file(file)Create a new object from a YAML file.
from_yaml_with_required_parameters(...[, ...])Load a SeedSimulatedConversation from a YAML file and validate required parameters.
Get an identifier dict capturing this configuration for comparison/storage.
Load and render the simulated target system prompt.
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.
set_sha256_value_async()This method computes the SHA256 hash value asynchronously.
Attributes
added_bydata_typeReturn the data type for this seed.
dataset_namedescriptionnameprompt_group_aliasprompt_group_idGet the range of sequence numbers this simulated conversation will occupy.
sourcevalue_sha256- compute_hash() str[source]#
Compute a deterministic hash of this configuration.
- Returns:
A SHA256 hash string representing the configuration.
- classmethod from_dict(data: Dict[str, Any]) SeedSimulatedConversation[source]#
Create a SeedSimulatedConversation from a dictionary, typically from YAML.
- Expected format:
num_turns: 3 adversarial_chat_system_prompt_path: path/to/adversarial.yaml simulated_target_system_prompt_path: path/to/simulated.yaml # optional
- Parameters:
data – Dictionary containing the configuration.
- Returns:
A new SeedSimulatedConversation instance.
- classmethod from_yaml_with_required_parameters(template_path: str | Path, required_parameters: list[str], error_message: str | None = None) SeedSimulatedConversation[source]#
Load a SeedSimulatedConversation from a YAML file and validate required parameters.
- Parameters:
template_path – Path to the YAML file containing the config.
required_parameters – List of parameter names that must exist.
error_message – Custom error message if validation fails.
- Returns:
The loaded and validated SeedSimulatedConversation.
- Raises:
ValueError – If required parameters are missing.
- get_identifier() Dict[str, Any][source]#
Get an identifier dict capturing this configuration for comparison/storage.
- Returns:
Dictionary with configuration details.
- static load_simulated_target_system_prompt(*, objective: str, num_turns: int, simulated_target_system_prompt_path: str | Path | None = None) str | None[source]#
Load and render the simulated target system prompt.
If no path is provided, returns None (no system prompt). Validates that the template has required objective and num_turns parameters.
- Parameters:
objective – The objective to render into the template.
num_turns – The number of turns to render into the template.
simulated_target_system_prompt_path – Optional path to the prompt YAML file. If None, no system prompt is used.
- Returns:
The rendered system prompt string, or None if no path is provided.
- Raises:
ValueError – If the template doesn’t have required parameters.
- property sequence_range: range#
Get the range of sequence numbers this simulated conversation will occupy.
Each turn generates 2 messages (user + assistant), so num_turns generates num_turns * 2 messages. If next_message_system_prompt_path is set, an additional user message is added at the end.
- Returns:
A range object representing the sequence numbers.