pyrit.models.data_serializer_factory

pyrit.models.data_serializer_factory#

data_serializer_factory(*, data_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'error'], value: str | None = None, extension: str | None = None, category: Literal['seed-prompt-entries', 'prompt-memory-entries'])[source]#

Factory method to create a DataTypeSerializer instance.

Parameters:
  • data_type (str) – The type of the data (e.g., ‘text’, ‘image_path’, ‘audio_path’).

  • value (str) – The data value to be serialized.

  • extension (Optional[str]) – The file extension, if applicable.

  • category (AllowedCategories) – The category or context for the data (e.g., ‘seed-prompt-entries’).

Returns:

An instance of the appropriate serializer.

Return type:

DataTypeSerializer

Raises:

ValueError – If the category is not provided or invalid.