pyrit.orchestrator.PromptSendingOrchestrator#

class PromptSendingOrchestrator(prompt_target: PromptTarget, prompt_converters: list[PromptConverter] | None = None, scorers: list[Scorer] | None = None, batch_size: int = 10, 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__(prompt_target: PromptTarget, prompt_converters: list[PromptConverter] | None = None, scorers: list[Scorer] | None = None, batch_size: int = 10, verbose: bool = False) None[source]#
Parameters:
  • prompt_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.

Methods

__init__(prompt_target[, prompt_converters, ...])

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.

print_conversations()

Prints the conversation between the prompt target and the red teaming bot.

send_normalizer_requests_async(*, ...[, ...])

Sends the normalized prompts to the prompt target.

send_prompts_async(*, prompt_list[, ...])

Sends the prompts to the prompt target.

set_prepended_conversation(*, ...)

Prepends a conversation to the prompt target.

async print_conversations()[source]#

Prints the conversation between the prompt target and the red teaming bot.

async send_normalizer_requests_async(*, prompt_request_list: list[NormalizerRequest], memory_labels: dict[str, str] | None = None) list[PromptRequestResponse][source]#

Sends the normalized prompts to the prompt target.

async send_prompts_async(*, prompt_list: list[str], prompt_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'text', memory_labels: dict[str, str] | None = None, metadata: str | None = None) list[PromptRequestResponse][source]#

Sends the prompts to the prompt target.

Parameters:
  • prompt_list (list[str]) – The list of prompts to be sent.

  • prompt_type (PromptDataType) – The type of prompt data. Defaults to “text”.

  • memory_labels (dict[str, str], Optional) – A free-form dictionary of additional labels to apply to the prompts. Any labels passed in will be combined with self._global_memory_labels (from the GLOBAL_MEMORY_LABELS environment variable) into one dictionary. In the case of collisions, the passed-in labels take precedence. Defaults to None.

  • metadata – Any additional information to be added to the memory entry corresponding to the prompts sent.

Returns:

The responses from sending the prompts.

Return type:

list[PromptRequestResponse]

set_prepended_conversation(*, prepended_conversation: list[PromptRequestResponse])[source]#

Prepends a conversation to the prompt target.