pyrit.prompt_converter.ToneConverter#
- class ToneConverter(*, converter_target: PromptChatTarget | None = None, tone: str, prompt_template: SeedPrompt | None = None)[source]#
Bases:
LLMGenericTextConverterConverts a conversation to a different tone using an LLM.
An existing
PromptChatTargetis used to perform the conversion (like Azure OpenAI).- __init__(*, converter_target: PromptChatTarget | None = None, tone: str, prompt_template: SeedPrompt | None = None)[source]#
Initializes the converter with the target chat support, tone, and optional prompt template.
- Parameters:
converter_target (PromptChatTarget) – The target chat support for the conversion which will translate. Can be omitted if a default has been configured via PyRIT initialization.
tone (str) – The tone for the conversation. E.g. upset, sarcastic, indifferent, etc.
prompt_template (SeedPrompt, Optional) – The prompt template for the conversion.
- Raises:
ValueError – If the language is not provided.
Methods
__init__(*[, converter_target, prompt_template])Initializes the converter with the target chat support, tone, and optional prompt template.
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_typesReturns a list of supported input types for the converter.
supported_output_typesReturns a list of supported output types for the converter.