pyrit.prompt_converter.SuperscriptConverter#

class SuperscriptConverter(*, word_selection_strategy: WordSelectionStrategy | None = None, word_split_separator: str | None = ' ')[source]#

Bases: WordLevelConverter

Converts text to superscript.

This converter leaves characters that do not have a superscript equivalent unchanged.

__init__(*, word_selection_strategy: WordSelectionStrategy | None = None, word_split_separator: str | None = ' ')#

Initializes the converter with the specified selection strategy.

Parameters:
  • word_selection_strategy (Optional[WordSelectionStrategy]) – The strategy for selecting which words to convert. If None, all words will be converted. Defaults to None.

  • word_split_separator (Optional[str]) – Separator used to split words in the input text. If None, splits by any whitespace. Defaults to “ “.

Methods

__init__(*[, word_selection_strategy, ...])

Initializes the converter with the specified selection strategy.

convert_async(*, prompt[, input_type])

Converts 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.

convert_word_async(word)

Converts a single word into the target format supported by the converter.

get_identifier()

Returns an identifier dictionary for the converter.

input_supported(input_type)

Checks if the input type is supported by the converter.

join_words(words)

Provides a way for subclasses to override the default behavior of joining words.

output_supported(output_type)

Checks if the output type is supported by the converter.

validate_input(prompt)

Validates the input before processing (can be overridden by subclasses).

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_word_async(word: str) str[source]#

Converts a single word into the target format supported by the converter.

Parameters:

word (str) – The word to be converted.

Returns:

The converted word.

Return type:

str