pyrit.prompt_converter.RandomCapitalLettersConverter#
- class RandomCapitalLettersConverter(percentage: float = 100.0)[source]#
Bases:
PromptConverter
Takes 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
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'] = '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.
- input_supported(input_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'reasoning', 'error']) bool [source]#
Checks if the input type is supported by the converter.
- Parameters:
input_type (PromptDataType) – The input type to check.
- Returns:
True if the input type is supported, False otherwise.
- Return type:
- is_percentage(input_string)[source]#
Checks if the input string is a valid percentage between 1 and 100.
- output_supported(output_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'reasoning', 'error']) bool [source]#
Checks if the output type is supported by the converter.
- Parameters:
output_type (PromptDataType) – The output type to check.
- Returns:
True if the output type is supported, False otherwise.
- Return type: