pyrit.prompt_converter.ToxicSentenceGeneratorConverter#

class ToxicSentenceGeneratorConverter(*, converter_target: PromptChatTarget = REQUIRED_VALUE, prompt_template: SeedPrompt | None = None)[source]#

Bases: LLMGenericTextConverter

Generates toxic sentence starters using an LLM.

An existing PromptChatTarget is used to perform the conversion (like Azure OpenAI).

Based on Project Moonshot’s attack module that generates toxic sentences to test LLM safety guardrails: aiverify-foundation/moonshot-data

__init__(*, converter_target: PromptChatTarget = REQUIRED_VALUE, prompt_template: SeedPrompt | None = None)[source]#

Initialize the converter with a specific target and template.

Parameters:
  • converter_target (PromptChatTarget) – The endpoint that converts the prompt. Can be omitted if a default has been configured via PyRIT initialization.

  • prompt_template (SeedPrompt) – The seed prompt template to use. If not provided, defaults to the toxic_sentence_generator.yaml.

Methods

__init__(*[, converter_target, prompt_template])

Initialize the converter with a specific target and template.

convert_async(*, prompt[, input_type])

Convert the given prompt into a toxic sentence starter.

convert_tokens_async(*, prompt[, ...])

Convert substrings within a prompt that are enclosed by specified start and end tokens.

get_identifier()

Get the typed identifier for this object.

input_supported(input_type)

Check if the input type is supported.

output_supported(output_type)

Check if the output type is supported.

Attributes

SUPPORTED_INPUT_TYPES

Tuple of input modalities supported by this converter.

SUPPORTED_OUTPUT_TYPES

Tuple of output modalities supported by this converter.

supported_input_types

Returns a list of supported input types for the converter.

supported_output_types

Returns a list of supported output types for the converter.

async convert_async(*, prompt: str, input_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'binary_path', 'url', 'reasoning', 'error', 'function_call', 'tool_call', 'function_call_output'] = 'text') ConverterResult[source]#

Convert the given prompt into a toxic sentence starter.

Parameters:
  • prompt (str) – The prompt to be converted.

  • input_type (PromptDataType) – The type of input data.

Returns:

The conversion result containing the toxic sentence starter.

Return type:

ConverterResult

input_supported(input_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'binary_path', 'url', 'reasoning', 'error', 'function_call', 'tool_call', 'function_call_output']) bool[source]#

Check if the input type is supported.

Parameters:

input_type (PromptDataType) – The type of input data.

Returns:

True if the input type is supported, False otherwise.

Return type:

bool

output_supported(output_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'binary_path', 'url', 'reasoning', 'error', 'function_call', 'tool_call', 'function_call_output']) bool[source]#

Check if the output type is supported.

Parameters:

output_type (PromptDataType) – The type of output data.

Returns:

True if the output type is supported, False otherwise.

Return type:

bool