pyrit.prompt_target.OpenAIDALLETarget#

class OpenAIDALLETarget(image_size: Literal['256x256', '512x512', '1024x1024'] = '1024x1024', num_images: int = 1, dalle_version: Literal['dall-e-2', 'dall-e-3'] = 'dall-e-2', quality: Literal['standard', 'hd'] = 'standard', style: Literal['natural', 'vivid'] = 'natural', *args, **kwargs)[source]#

Bases: OpenAITarget

The Dalle3Target takes a prompt and generates images This class initializes a DALL-E image target

__init__(image_size: Literal['256x256', '512x512', '1024x1024'] = '1024x1024', num_images: int = 1, dalle_version: Literal['dall-e-2', 'dall-e-3'] = 'dall-e-2', quality: Literal['standard', 'hd'] = 'standard', style: Literal['natural', 'vivid'] = 'natural', *args, **kwargs)[source]#

Initialize the DALL-E target with specified parameters.

Parameters:
  • image_size (Literal["256x256", "512x512", "1024x1024"], Optional) – The size of the generated images. Defaults to “1024x1024”.

  • num_images (int, Optional) – The number of images to generate. Defaults to 1. For DALL-E-2, this can be between 1 and 10. For DALL-E-3, this must be 1.

  • dalle_version (Literal["dall-e-2", "dall-e-3"], Optional) – The version of DALL-E to use. Defaults to “dall-e-2”.

  • quality (Literal["standard", "hd"], Optional) – The quality of the generated images. Only applicable for DALL-E-3. Defaults to “standard”.

  • style (Literal["natural", "vivid"], Optional) – The style of the generated images. Only applicable for DALL-E-3. Defaults to “natural”.

  • *args – Additional positional arguments to be passed to AzureOpenAITarget.

  • **kwargs – Additional keyword arguments to be passed to AzureOpenAITarget.

Raises:
  • ValueError – If num_images is not 1 for DALL-E-3.

  • ValueError – If num_images is less than 1 or greater than 10 for DALL-E-2.

Methods

__init__([image_size, num_images, ...])

Initialize the DALL-E target with specified parameters.

dispose_db_engine()

Dispose DuckDB database engine to release database connections and resources.

get_identifier()

send_chat_prompt_async(*, prompt, ...[, ...])

Sends a text prompt to the target without having to build the prompt request.

send_prompt_async(**kwargs)

Sends a normalized prompt async to the prompt target.

set_system_prompt(*, system_prompt, ...[, ...])

Sets the system prompt for the prompt target.

Attributes

ADDITIONAL_REQUEST_HEADERS

deployment_environment_variable

endpoint_uri_environment_variable

api_key_environment_variable

supported_converters

async send_prompt_async(**kwargs)#

Sends a normalized prompt async to the prompt target.