pyrit.executor.promptgen.fuzzer.FuzzerConverter#

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

Bases: PromptConverter

Base class for GPTFUZZER converters.

Adapted from GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Prompts. Paper: https://arxiv.org/pdf/2309.10253 by Jiahao Yu, Xingwei Lin, Zheng Yu, Xinyu Xing. GitHub: sherdencooper/GPTFuzz

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

Initialize the converter with the specified chat target and prompt template.

Parameters:
  • converter_target (PromptChatTarget) – Chat target used to perform fuzzing on user prompt. Can be omitted if a default has been configured via PyRIT initialization.

  • prompt_template (SeedPrompt) – Template to be used instead of the default system prompt with instructions for the chat target.

Raises:

ValueError – If converter_target is not provided and no default has been configured.

Methods

__init__(*[, converter_target])

Initialize the converter with the specified chat target and prompt template.

convert_async(*, prompt[, input_type])

Convert the given prompt into the target format supported by the converter.

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

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

get_identifier()

Returns an identifier dictionary for the converter.

input_supported(input_type)

Check if the input type is supported.

output_supported(output_type)

Check if the output type is supported.

send_prompt_async(request)

Send the message to the converter target and process the response.

update(**kwargs)

Update the converter with new parameters.

Attributes

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', 'url', 'reasoning', 'error', 'function_call', 'tool_call', 'function_call_output'] = 'text') ConverterResult[source]#

Convert the given prompt into the target format supported by the converter.

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

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

Returns:

The result containing the modified prompt.

Return type:

ConverterResult

Raises:

ValueError – If the input type is not supported.

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

Check if the input type is supported.

Returns:

True if input type is text, False otherwise.

Return type:

bool

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

Check if the output type is supported.

Returns:

True if output type is text, False otherwise.

Return type:

bool

async send_prompt_async(request)[source]#

Send the message to the converter target and process the response.

Parameters:

request – The message request to send.

Returns:

The output from the parsed JSON response.

Return type:

str

Raises:

InvalidJsonException – If the response is not valid JSON or missing required keys.

update(**kwargs) None[source]#

Update the converter with new parameters.