pyrit.prompt_normalizer.NormalizerRequestPiece#
- class NormalizerRequestPiece(*, prompt_value: str, prompt_data_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'], request_converters: list[PromptConverter] = [], metadata: str = None)[source]#
Bases:
ABC
- __init__(*, prompt_value: str, prompt_data_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'], request_converters: list[PromptConverter] = [], metadata: str = None) None [source]#
Represents a piece of a normalizer request.
It represents the minimum unit of data that must be converted before sending to a target. A piece of text, with a type, that is run through a series of converters and may contain metadata.
- Parameters:
request_converters (list[PromptConverter]) – A list of PromptConverter objects.
prompt_value (str) – The prompt value.
prompt_data_type (PromptDataType) – The data type of the prompt.
metadata (str, Optional) – Additional metadata. Defaults to None.
- Raises:
ValueError – If prompt_converters is not a non-empty list of PromptConverter objects.
ValueError – If prompt_text is not a string.
Methods
__init__
(*, prompt_value, prompt_data_type)Represents a piece of a normalizer request.
validate
()Validates the NormalizerRequestPiece.
- validate()[source]#
Validates the NormalizerRequestPiece.
- Raises:
ValueError – If doesn’t validate