pyrit.orchestrator.PromptSendingOrchestrator#

class PromptSendingOrchestrator(objective_target: PromptTarget, request_converter_configurations: list[PromptConverterConfiguration] | None = None, response_converter_configurations: list[PromptConverterConfiguration] | None = None, objective_scorer: Scorer | None = None, auxiliary_scorers: list[Scorer] | None = None, should_convert_prepended_conversation: bool = True, batch_size: int = 10, retries_on_objective_failure: int = 0, verbose: bool = False)[source]#

Bases: Orchestrator

This orchestrator takes a set of prompts, converts them using the list of PromptConverters, sends them to a target, and scores the resonses with scorers (if provided).

__init__(objective_target: PromptTarget, request_converter_configurations: list[PromptConverterConfiguration] | None = None, response_converter_configurations: list[PromptConverterConfiguration] | None = None, objective_scorer: Scorer | None = None, auxiliary_scorers: list[Scorer] | None = None, should_convert_prepended_conversation: bool = True, batch_size: int = 10, retries_on_objective_failure: int = 0, verbose: bool = False) None[source]#
Parameters:
  • objective_target (PromptTarget) – The target for sending prompts.

  • prompt_converters (list[PromptConverter], Optional) – List of prompt converters. These are stacked in the order they are provided. E.g. the output of converter1 is the input of converter2.

  • scorers (list[Scorer], Optional) – List of scorers to use for each prompt request response, to be scored immediately after receiving response. Default is None.

  • batch_size (int, Optional) – The (max) batch size for sending prompts. Defaults to 10. Note: If providing max requests per minute on the prompt_target, this should be set to 1 to ensure proper rate limit management.

  • retries_on_objective_failure (int, Optional) – Number of retries to attempt if objective fails. Defaults to 0.

  • verbose (bool, Optional) – Whether to log debug information. Defaults to False.

Methods

__init__(objective_target[, ...])

dispose_db_engine()

Dispose database engine to release database connections and resources.

get_identifier()

get_memory()

Retrieves the memory associated with this orchestrator.

get_score_memory()

Retrieves the scores of the PromptRequestPieces associated with this orchestrator.

run_attack_async(*, objective[, ...])

Runs the attack.

run_attacks_async(*, objectives[, ...])

Runs multiple attacks in parallel using batch_size.

set_skip_criteria(*, skip_criteria[, ...])

Sets the skip criteria for the orchestrator.

async run_attack_async(*, objective: str, seed_prompt: SeedPromptGroup = None, prepended_conversation: list[PromptRequestResponse] | None = None, memory_labels: dict[str, str] | None = None) OrchestratorResult[source]#

Runs the attack.

Parameters:
  • objective (str) – The objective of the attack.

  • seed_prompt (SeedPromptGroup, Optional) – The seed prompt group to start the conversation. By default the objective is used.

  • prepended_conversation (list[PromptRequestResponse], Optional) – The conversation to prepend to the attack. Sent to objective target.

  • memory_labels (dict[str, str], Optional) – The memory labels to use for the attack.

async run_attacks_async(*, objectives: list[str], seed_prompts: list[SeedPromptGroup] | None = None, prepended_conversations: list[list[PromptRequestResponse]] | None = None, memory_labels: dict[str, str] | None = None) list[OrchestratorResult][source]#

Runs multiple attacks in parallel using batch_size.

Parameters:
  • objectives (list[str]) – List of objectives for the attacks.

  • seed_prompts (list[SeedPromptGroup], Optional) – List of seed prompt groups to start the conversations. If not provided, each objective will be used as its own seed prompt.

  • prepended_conversation (list[PromptRequestResponse], Optional) – The conversation to prepend to each attack.

  • memory_labels (dict[str, str], Optional) – The memory labels to use for the attacks.

Returns:

List of results from each attack.

Return type:

list[OrchestratorResult]

set_skip_criteria(*, skip_criteria: PromptFilterCriteria, skip_value_type: Literal['original', 'converted'] = 'original')[source]#

Sets the skip criteria for the orchestrator.

If prompts match this in memory, then they won’t be sent to a target.