HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/openai/resources/__pycache__/images.cpython-310.pyc
o

���gd�@sDddlmZddlmZmZmZmZddlmZddl	Z	ddl
mZddlm
Z
mZmZddlmZmZmZmZmZmZdd	lmZmZmZmZdd
lmZddlmZm Z ddl!m"Z"m#Z#dd
l$m%Z%ddl&m'Z'ddl(m)Z)ddgZ*Gdd�de�Z+Gdd�de �Z,Gdd�d�Z-Gdd�d�Z.Gdd�d�Z/Gdd�d�Z0dS)�)�annotations)�Union�Mapping�Optional�cast)�LiteralN�)�_legacy_response)�image_edit_params�image_generate_params�image_create_variation_params)�	NOT_GIVEN�Body�Query�Headers�NotGiven�	FileTypes)�
extract_files�maybe_transform�deepcopy_minimal�async_maybe_transform)�cached_property)�SyncAPIResource�AsyncAPIResource)�to_streamed_response_wrapper�"async_to_streamed_response_wrapper)�make_request_options)�
ImageModel)�ImagesResponse�Images�AsyncImagesc@�eZdZed0dd��Zed1dd��Zeeeeeddded	�	d2dd �Zeeeeeeddded!�
d3d&d'�Zeeeeeeeddded(�d4d.d/�Z	dS)5r�return�ImagesWithRawResponsecC�t|�S�a
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
        )r#��self�r(�B/usr/local/lib/python3.10/dist-packages/openai/resources/images.py�with_raw_response�zImages.with_raw_response�ImagesWithStreamingResponsecCr$�z�
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
        )r,r&r(r(r)�with_streaming_response(�zImages.with_streaming_responseN�	�model�n�response_format�size�user�
extra_headers�extra_query�
extra_body�timeout�imagerr1�'Union[str, ImageModel, None] | NotGivenr2�Optional[int] | NotGivenr3�/Optional[Literal['url', 'b64_json']] | NotGivenr4�?Optional[Literal['256x256', '512x512', '1024x1024']] | NotGivenr5�str | NotGivenr6�Headers | Noner7�Query | Noner8�Body | Noner9�'float | httpx.Timeout | None | NotGivenrc


Cslt||||||d��}tttttf|�dggd�}ddi|p i�}|jdt|tj	�|t
|||	|
d�td�S)	�
        Creates a variation of a given image.

        Args:
          image: The image to use as the basis for the variation(s). Must be a valid PNG file,
              less than 4MB, and square.

          model: The model to use for image generation. Only `dall-e-2` is supported at this
              time.

          n: The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
              `n=1` is supported.

          response_format: The format in which the generated images are returned. Must be one of `url` or
              `b64_json`. URLs are only valid for 60 minutes after the image has been
              generated.

          size: The size of the generated images. Must be one of `256x256`, `512x512`, or
              `1024x1024`.

          user: A unique identifier representing your end-user, which can help OpenAI to monitor
              and detect abuse.
              [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        �r:r1r2r3r4r5r:��paths�Content-Type�multipart/form-data�/images/variations�r6r7r8r9��body�files�options�cast_to)rrrr�str�object�_postrr�ImageCreateVariationParamsrr�
r'r:r1r2r3r4r5r6r7r8r9rMrNr(r(r)�create_variation1s(0��

��zImages.create_variation�
�maskr1r2r3r4r5r6r7r8r9�promptrQrX�FileTypes | NotGivenc
Cstt||||||||d��}
tttttf|
�dgdggd�}ddi|	p$i�}	|jdt|
tj	�|t
|	|
||d�td	�S)
�
        Creates an edited or extended image given an original image and a prompt.

        Args:
          image: The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask
              is not provided, image must have transparency, which will be used as the mask.

          prompt: A text description of the desired image(s). The maximum length is 1000
              characters.

          mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
              indicate where `image` should be edited. Must be a valid PNG file, less than
              4MB, and have the same dimensions as `image`.

          model: The model to use for image generation. Only `dall-e-2` is supported at this
              time.

          n: The number of images to generate. Must be between 1 and 10.

          response_format: The format in which the generated images are returned. Must be one of `url` or
              `b64_json`. URLs are only valid for 60 minutes after the image has been
              generated.

          size: The size of the generated images. Must be one of `256x256`, `512x512`, or
              `1024x1024`.

          user: A unique identifier representing your end-user, which can help OpenAI to monitor
              and detect abuse.
              [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        �r:rYrXr1r2r3r4r5r:rXrFrHrI�
/images/editsrKrL)rrrrrQrRrSrr
�ImageEditParamsrr�r'r:rYrXr1r2r3r4r5r6r7r8r9rMrNr(r(r)�editzs,8��"
��zImages.edit�r1r2�qualityr3r4�styler5r6r7r8r9rb�$Literal['standard', 'hd'] | NotGiven�YOptional[Literal['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792']] | NotGivenrc�0Optional[Literal['vivid', 'natural']] | NotGivenc
Cs8|jdt||||||||d�tj�t|	|
||d�td�S)�
        Creates an image given a prompt.

        Args:
          prompt: A text description of the desired image(s). The maximum length is 1000
              characters for `dall-e-2` and 4000 characters for `dall-e-3`.

          model: The model to use for image generation.

          n: The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
              `n=1` is supported.

          quality: The quality of the image that will be generated. `hd` creates images with finer
              details and greater consistency across the image. This param is only supported
              for `dall-e-3`.

          response_format: The format in which the generated images are returned. Must be one of `url` or
              `b64_json`. URLs are only valid for 60 minutes after the image has been
              generated.

          size: The size of the generated images. Must be one of `256x256`, `512x512`, or
              `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or
              `1024x1792` for `dall-e-3` models.

          style: The style of the generated images. Must be one of `vivid` or `natural`. Vivid
              causes the model to lean towards generating hyper-real and dramatic images.
              Natural causes the model to produce more natural, less hyper-real looking
              images. This param is only supported for `dall-e-3`.

          user: A unique identifier representing your end-user, which can help OpenAI to monitor
              and detect abuse.
              [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        �/images/generations�rYr1r2rbr3r4rcr5rK�rMrOrP)rSrr�ImageGenerateParamsrr�
r'rYr1r2rbr3r4rcr5r6r7r8r9r(r(r)�generate�s&;�
�
��zImages.generate)r"r#)r"r,�r:rr1r;r2r<r3r=r4r>r5r?r6r@r7rAr8rBr9rCr"r�r:rrYrQrXrZr1r;r2r<r3r=r4r>r5r?r6r@r7rAr8rBr9rCr"r�rYrQr1r;r2r<rbrdr3r=r4rercrfr5r?r6r@r7rAr8rBr9rCr"r�
�__name__�
__module__�__qualname__rr*r.r
rVr`rmr(r(r(r)r�L	�N�W�c@r!)5r r"�AsyncImagesWithRawResponsecCr$r%)rvr&r(r(r)r*r+zAsyncImages.with_raw_response� AsyncImagesWithStreamingResponsecCr$r-)rwr&r(r(r)r.)r/z#AsyncImages.with_streaming_responseNr0r:rr1r;r2r<r3r=r4r>r5r?r6r@r7rAr8rBr9rCrc


�sz�t||||||d��}tttttf|�dggd�}ddi|p!i�}|jdt|tj	�IdH|t
|||	|
d�td	�IdHS)
rDrEr:rFrHrIrJNrKrL)rrrrrQrRrSrrrTrrrUr(r(r)rV2s*�0��
��zAsyncImages.create_variationrWrYrQrXrZc
�s��t||||||||d��}
tttttf|
�dgdggd�}ddi|	p%i�}	|jdt|
tj	�IdH|t
|	|
||d	�td
�IdHS)r[r\r:rXrFrHrIr]NrKrL)rrrrrQrRrSrr
r^rrr_r(r(r)r`{s.�8��"��zAsyncImages.editrarbrdrercrfc
�sF�|jdt||||||||d�tj�IdHt|	|
||d�td�IdHS)rgrhriNrKrj)rSrrrkrrrlr(r(r)rm�s(�;�
�
��zAsyncImages.generate)r"rv)r"rwrnrorprqr(r(r(r)r ruc@�eZdZddd�ZdS)	r#�imagesrr"�NonecC�4||_t�|j�|_t�|j�|_t�|j�|_dS�N)�_imagesr	�to_raw_response_wrapperrVr`rm�r'ryr(r(r)�__init__ ���
�zImagesWithRawResponse.__init__N�ryrr"rz�rrrsrtr�r(r(r(r)r#�r#c@rx)	rvryr r"rzcCr{r|)r}r	�async_to_raw_response_wrapperrVr`rmrr(r(r)r�/r�z#AsyncImagesWithRawResponse.__init__N�ryr r"rzr�r(r(r(r)rv.r�rvc@rx)	r,ryrr"rzcC�.||_t|j�|_t|j�|_t|j�|_dSr|)r}rrVr`rmrr(r(r)r�>���
�z$ImagesWithStreamingResponse.__init__Nr�r�r(r(r(r)r,=r�r,c@rx)	rwryr r"rzcCr�r|)r}rrVr`rmrr(r(r)r�Mr�z)AsyncImagesWithStreamingResponse.__init__Nr�r�r(r(r(r)rwLr�rw)1�
__future__r�typingrrrr�typing_extensionsr�httpx�r	�typesr
rr�_typesr
rrrrr�_utilsrrrr�_compatr�	_resourcerr�	_responserr�_base_clientr�types.image_modelr�types.images_responser�__all__rr r#rvr,rwr(r(r(r)�<module>s2