pyrit.prompt_converter.ToneConverter#
- class ToneConverter(*, converter_target: PromptChatTarget, tone: str, prompt_template: SeedPrompt = None)[source]#
Bases:
LLMGenericTextConverter
Converts a conversation to a different tone using an LLM.
An existing
PromptChatTarget
is used to perform the conversion (like Azure OpenAI).- __init__(*, converter_target: PromptChatTarget, tone: str, prompt_template: SeedPrompt = 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.
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, tone[, ...])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_types
Returns a list of supported input types for the converter.
supported_output_types
Returns a list of supported output types for the converter.