pyrit.prompt_converter.TranslationConverter#
- class TranslationConverter(*, converter_target: PromptChatTarget, language: str, prompt_template: SeedPrompt = None)[source]#
Bases:
PromptConverter
- __init__(*, converter_target: PromptChatTarget, language: str, prompt_template: SeedPrompt = None)[source]#
Initializes a TranslationConverter object.
- Parameters:
converter_target (PromptChatTarget) – The target chat support for the conversion which will translate
language (str) – The language for the conversion. E.g. Spanish, French, leetspeak, etc.
prompt_template (SeedPrompt, Optional) – The prompt template for the conversion.
- Raises:
ValueError – If the language is not provided.
Methods
__init__
(*, converter_target, language[, ...])Initializes a TranslationConverter object.
convert_async
(*, prompt[, input_type])Generates variations of the input prompt using the converter target.
convert_tokens_async
(*, prompt[, ...])Converts substrings within a prompt that are enclosed by specified start and end tokens.
get_identifier
()input_supported
(input_type)Checks if the input type is supported by the converter
send_translation_prompt_async
(request)- async convert_async(*, prompt: str, input_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'text') ConverterResult [source]#
Generates variations of the input prompt using the converter target. :param prompt: prompt to convert :type prompt: str
- Returns:
result generated by the converter target
- Return type: