pyrit.prompt_converter.NoiseConverter

pyrit.prompt_converter.NoiseConverter#

class NoiseConverter(*, converter_target: PromptChatTarget, noise: str | None = None, number_errors: int = 5, prompt_template: SeedPrompt | None = None)[source]#

Bases: LLMGenericTextConverter

Injects noise errors into a conversation using an LLM.

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

__init__(*, converter_target: PromptChatTarget, noise: str | None = None, number_errors: int = 5, prompt_template: SeedPrompt | None = None)[source]#

Initializes the converter with the specified parameters.

Parameters:
  • converter_target (PromptChatTarget) – The endpoint that converts the prompt.

  • noise (str) – The noise to inject. Grammar error, delete random letter, insert random space, etc.

  • number_errors (int) – The number of errors to inject.

  • prompt_template (SeedPrompt, Optional) – The prompt template for the conversion.

Methods

__init__(*, converter_target[, noise, ...])

Initializes the converter with the specified parameters.

convert_async(*, prompt[, input_type])

Converts the given prompt using an LLM via the specified converter target.

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)

Checks if the input type is supported by the converter.

output_supported(output_type)

Checks if the output type is supported by the converter.

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.