pyrit.prompt_converter.RandomCapitalLettersConverter#
- class RandomCapitalLettersConverter(percentage: float = 100.0)[source]#
Bases:
PromptConverterTakes a prompt and randomly capitalizes it by a percentage of the total characters.
- __init__(percentage: float = 100.0) None[source]#
Initializes the converter with the specified percentage of randomization.
- Parameters:
percentage (float) – The percentage of characters to capitalize in the prompt. Must be between 1 and 100. Defaults to 100.0. This includes decimal points in that range.
Methods
__init__([percentage])Initializes the converter with the specified percentage of randomization.
convert_async(*, prompt[, input_type])Converts the given prompt by randomly capitalizing a percentage of its characters.
convert_tokens_async(*, prompt[, ...])Converts substrings within a prompt that are enclosed by specified start and end tokens.
generate_random_positions(total_length, ...)Generates a list of unique random positions within the range of total_length.
get_identifier()Returns an identifier dictionary for the converter.
input_supported(input_type)Checks if the input type is supported by the converter.
is_lowercase_letter(char)Checks if the given character is a lowercase letter.
is_percentage(input_string)Checks if the input string is a valid percentage between 1 and 100.
output_supported(output_type)Checks if the output type is supported by the converter.
Converts a string by randomly capitalizing a percentage of its characters.
Attributes
Tuple of input modalities supported by this converter.
Tuple of output modalities supported by this converter.
supported_input_typesReturns a list of supported input types for the converter.
supported_output_typesReturns a list of supported output types for the converter.
- SUPPORTED_INPUT_TYPES: tuple[Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'reasoning', 'error', 'function_call', 'tool_call', 'function_call_output'], ...] = ('text',)#
Tuple of input modalities supported by this converter. Subclasses must override this.
- SUPPORTED_OUTPUT_TYPES: tuple[Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'reasoning', 'error', 'function_call', 'tool_call', 'function_call_output'], ...] = ('text',)#
Tuple of output modalities supported by this converter. Subclasses must override this.
- 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]#
Converts the given prompt by randomly capitalizing a percentage of its characters.
- generate_random_positions(total_length, set_number)[source]#
Generates a list of unique random positions within the range of total_length.