
    U thq                       d dl mZ d dlmZmZmZmZmZ d dlm	Z	 d dl
Z
ddlmZ ddlmZmZmZ ddlmZmZmZmZmZmZ dd	lmZmZmZmZ dd
lmZ ddlm Z m!Z! ddl"m#Z#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z* ddgZ+ G d de           Z, G d de!          Z- G d d          Z. G d d          Z/ G d d          Z0 G d d          Z1dS )    )annotations)List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                      e Zd Zed5d            Zed6d            Zeeeeeddded	d7dZeeeeeeeeeedddedd8d,Zeeeeeeeeeeeddded-d9d4Z	dS ):r!   returnImagesWithRawResponsec                     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%   selfs    k/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/openai/resources/images.pywith_raw_responsezImages.with_raw_response   s     %T***    ImagesWithStreamingResponsec                     t          |           S 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(   s    r*   with_streaming_responsezImages.with_streaming_response#   s     +4000r,   N	modelnresponse_formatsizeuserextra_headersextra_query
extra_bodytimeoutimager   r2   'Union[str, ImageModel, None] | NotGivenr3   Optional[int] | NotGivenr4   /Optional[Literal['url', 'b64_json']] | NotGivenr5   ?Optional[Literal['256x256', '512x512', '1024x1024']] | NotGivenr6   str | NotGivenr7   Headers | Noner8   Query | Noner9   Body | Noner:   'float | httpx.Timeout | None | NotGivenr    c       
        >   t          ||||||d          }t          t          t          t          t
          f         |          dgg          }ddi|pi }|                     dt          |t          j	                  |t          |||	|
          t                    S )	   Creates a variation of a given image.

        This endpoint only supports `dall-e-2`.

        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.

          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;   r2   r3   r4   r5   r6   r;   pathsContent-Typemultipart/form-data/images/variationsr7   r8   r9   r:   bodyfilesoptionscast_to)r   r   r   r   strobject_postr   r   ImageCreateVariationParamsr   r    r)   r;   r2   r3   r4   r5   r6   r7   r8   r9   r:   rO   rP   s                r*   create_variationzImages.create_variation,   s    `  #2 	
 	
 d73;#7>>ykRRR ()>X=CVTVXzz  'D'_``(+Q[el   #  
 
 	
r,   
backgroundmaskr2   r3   output_compressionoutput_formatqualityr4   r5   r6   r7   r8   r9   r:   !Union[FileTypes, List[FileTypes]]promptrS   rZ   =Optional[Literal['transparent', 'opaque', 'auto']] | NotGivenr[   FileTypes | NotGivenr\   r]   3Optional[Literal['png', 'jpeg', 'webp']] | NotGivenr^   IOptional[Literal['standard', 'low', 'medium', 'high', 'auto']] | NotGivenaOptional[Literal['256x256', '512x512', '1024x1024', '1536x1024', '1024x1536', 'auto']] | NotGivenc               T   t          |||||||||	|
||d          }t          t          t          t          t
          f         |          dgddgdgg          }ddi|pi }|                     dt          |t          j	                  |t          ||||	          t          
          S )N  Creates an edited or extended image given one or more source images and a
        prompt.

        This endpoint only supports `gpt-image-1` and `dall-e-2`.

        Args:
          image: The image(s) to edit. Must be a supported image file or an array of images.

              For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
              50MB. You can provide up to 16 images.

              For `dall-e-2`, you can only provide one image, and it should be a square `png`
              file less than 4MB.

          prompt: A text description of the desired image(s). The maximum length is 1000
              characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.

          background: Allows to set transparency for the background of the generated image(s). This
              parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
              `opaque` or `auto` (default value). When `auto` is used, the model will
              automatically determine the best background for the image.

              If `transparent`, the output format needs to support transparency, so it should
              be set to either `png` (default value) or `webp`.

          mask: An additional image whose fully transparent areas (e.g. where alpha is zero)
              indicate where `image` should be edited. If there are multiple images provided,
              the mask will be applied on the first image. 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` and `gpt-image-1` are
              supported. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1`
              is used.

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

          output_compression: The compression level (0-100%) for the generated images. This parameter is only
              supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
              defaults to 100.

          output_format: The format in which the generated images are returned. This parameter is only
              supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
              default value is `png`.

          quality: The quality of the image that will be generated. `high`, `medium` and `low` are
              only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
              Defaults to `auto`.

          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. This parameter is only supported for `dall-e-2`, as `gpt-image-1`
              will always return base64-encoded images.

          size: The size of the generated images. Must be one of `1024x1024`, `1536x1024`
              (landscape), `1024x1536` (portrait), or `auto` (default value) for
              `gpt-image-1`, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.

          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;   r`   rZ   r[   r2   r3   r\   r]   r^   r4   r5   r6   r;   <array>r[   rH   rJ   rK   /images/editsrM   rN   )r   r   r   r   rS   rT   rU   r   r   ImageEditParamsr   r    r)   r;   r`   rZ   r[   r2   r3   r\   r]   r^   r4   r5   r6   r7   r8   r9   r:   rO   rP   s                      r*   editzImages.editu   s    x   (&8!."#2 
 
  d73;#7>>ySZ\eRfiohpFqrrr ()>X=CVTVXzz '8'HII(+Q[el   #  
 
 	
r,   rZ   r2   
moderationr3   r\   r]   r^   r4   r5   styler6   r7   r8   r9   r:   ro   +Optional[Literal['low', 'auto']] | NotGivenOOptional[Literal['standard', 'hd', 'low', 'medium', 'high', 'auto']] | NotGiven{Optional[Literal['auto', '1024x1024', '1536x1024', '1024x1536', '256x256', '512x512', '1792x1024', '1024x1792']] | NotGivenrp   0Optional[Literal['vivid', 'natural']] | NotGivenc                   |                      dt          |||||||||	|
||dt          j                  t	          ||||          t
                    S )  
        Creates an image given a prompt.
        [Learn more](https://platform.openai.com/docs/guides/images).

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

          background: Allows to set transparency for the background of the generated image(s). This
              parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
              `opaque` or `auto` (default value). When `auto` is used, the model will
              automatically determine the best background for the image.

              If `transparent`, the output format needs to support transparency, so it should
              be set to either `png` (default value) or `webp`.

          model: The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or
              `gpt-image-1`. Defaults to `dall-e-2` unless a parameter specific to
              `gpt-image-1` is used.

          moderation: Control the content-moderation level for images generated by `gpt-image-1`. Must
              be either `low` for less restrictive filtering or `auto` (default value).

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

          output_compression: The compression level (0-100%) for the generated images. This parameter is only
              supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
              defaults to 100.

          output_format: The format in which the generated images are returned. This parameter is only
              supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`.

          quality: The quality of the image that will be generated.

              - `auto` (default value) will automatically select the best quality for the
                given model.
              - `high`, `medium` and `low` are supported for `gpt-image-1`.
              - `hd` and `standard` are supported for `dall-e-3`.
              - `standard` is the only option for `dall-e-2`.

          response_format: The format in which generated images with `dall-e-2` and `dall-e-3` are
              returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes
              after the image has been generated. This parameter isn't supported for
              `gpt-image-1` which will always return base64-encoded images.

          size: The size of the generated images. Must be one of `1024x1024`, `1536x1024`
              (landscape), `1024x1536` (portrait), or `auto` (default value) for
              `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and
              one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.

          style: The style of the generated images. This parameter is only supported for
              `dall-e-3`. 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.

          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r`   rZ   r2   ro   r3   r\   r]   r^   r4   r5   rp   r6   rM   rO   rQ   rR   )rU   r   r   ImageGenerateParamsr   r    r)   r`   rZ   r2   ro   r3   r\   r]   r^   r4   r5   rp   r6   r7   r8   r9   r:   s                    r*   generatezImages.generate   s    | zz! $","",*<%2&'6 "   &9 " )+Q[el   #-  
 
 	
r,   )r$   r%   )r$   r-   r;   r   r2   r<   r3   r=   r4   r>   r5   r?   r6   r@   r7   rA   r8   rB   r9   rC   r:   rD   r$   r    "r;   r_   r`   rS   rZ   ra   r[   rb   r2   r<   r3   r=   r\   r=   r]   rc   r^   rd   r4   r>   r5   re   r6   r@   r7   rA   r8   rB   r9   rC   r:   rD   r$   r    "r`   rS   rZ   ra   r2   r<   ro   rq   r3   r=   r\   r=   r]   rc   r^   rr   r4   r>   r5   rs   rp   rt   r6   r@   r7   rA   r8   rB   r9   rC   r:   rD   r$   r    
__name__
__module____qualname__r   r+   r0   r   rX   rm   r|    r,   r*   r!   r!      sG       + + + _+ 1 1 1 _1 :C&/KTPY( )-$("&;DG
 G
 G
 G
 G
 G
\ U^%.9B&/7@MV]fKT( )-$("&;D+y
 y
 y
 y
 y
 y
~ U^9BBK&/7@MVclKT BK( )-$("&;D/u
 u
 u
 u
 u
 u
 u
 u
r,   c                      e Zd Zed5d            Zed6d            Zeeeeeddded	d7dZeeeeeeeeeedddedd8d,Zeeeeeeeeeeeddded-d9d4Z	dS ):r"   r$   AsyncImagesWithRawResponsec                     t          |           S r'   )r   r(   s    r*   r+   zAsyncImages.with_raw_responsei  s     *$///r,    AsyncImagesWithStreamingResponsec                     t          |           S r/   )r   r(   s    r*   r0   z#AsyncImages.with_streaming_responses  s     0555r,   Nr1   r;   r   r2   r<   r3   r=   r4   r>   r5   r?   r6   r@   r7   rA   r8   rB   r9   rC   r:   rD   r    c       
        Z  K   t          ||||||d          }t          t          t          t          t
          f         |          dgg          }ddi|pi }|                     dt          |t          j	                   d{V |t          |||	|
          t          	           d{V S )
rF   rG   r;   rH   rJ   rK   rL   NrM   rN   )r   r   r   r   rS   rT   rU   r   r   rV   r   r    rW   s                r*   rX   zAsyncImages.create_variation|  s      `  #2 	
 	
 d73;#7>>ykRRR ()>X=CVTVXZZ ,T3P3kllllllll(+Q[el   #   
 
 
 
 
 
 
 
 	
r,   rY   r_   r`   rS   rZ   ra   r[   rb   r\   r]   rc   r^   rd   re   c               p  K   t          |||||||||	|
||d          }t          t          t          t          t
          f         |          dgddgdgg          }ddi|pi }|                     dt          |t          j	                   d	{V |t          ||||
          t                     d	{V S )rg   rh   r;   ri   r[   rH   rJ   rK   rj   NrM   rN   )r   r   r   r   rS   rT   rU   r   r   rk   r   r    rl   s                      r*   rm   zAsyncImages.edit  s     x   (&8!."#2 
 
  d73;#7>>ySZ\eRfiohpFqrrr ()>X=CVTVXZZ,T3D3TUUUUUUUU(+Q[el   #   
 
 
 
 
 
 
 
 	
r,   rn   ro   rq   rr   rs   rp   rt   c                  K   |                      dt          |||||||||	|
||dt          j                   d{V t	          ||||          t
                     d{V S )rv   rw   rx   NrM   ry   )rU   r   r   rz   r   r    r{   s                    r*   r|   zAsyncImages.generate@  s      | ZZ!,$","",*<%2&'6 "   &9       " )+Q[el   #-   
 
 
 
 
 
 
 
 	
r,   )r$   r   )r$   r   r}   r~   r   r   r   r,   r*   r"   r"   h  sG       0 0 0 _0 6 6 6 _6 :C&/KTPY( )-$("&;DG
 G
 G
 G
 G
 G
\ U^%.9B&/7@MV]fKT( )-$("&;D+y
 y
 y
 y
 y
 y
~ U^9BBK&/7@MVclKT BK( )-$("&;D/u
 u
 u
 u
 u
 u
 u
 u
r,   c                      e Zd ZddZdS )r%   imagesr!   r$   Nonec                    || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S N)_imagesr   to_raw_response_wrapperrX   rm   r|   r)   r   s     r*   __init__zImagesWithRawResponse.__init__  s^     0 H#!
 !
 %<K
 
	 )@O
 
r,   Nr   r!   r$   r   r   r   r   r   r   r,   r*   r%   r%     (        
 
 
 
 
 
r,   r%   c                      e Zd ZddZdS )r   r   r"   r$   r   c                    || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S r   )r   r   async_to_raw_response_wrapperrX   rm   r|   r   s     r*   r   z#AsyncImagesWithRawResponse.__init__  s^     0 N#!
 !
 %BK
 
	 )FO
 
r,   Nr   r"   r$   r   r   r   r,   r*   r   r     r   r,   r   c                      e Zd ZddZdS )r-   r   r!   r$   r   c                    || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r   )r   r   rX   rm   r|   r   s     r*   r   z$ImagesWithStreamingResponse.__init__  sU     <#!
 !
 1K
 
	 5O
 
r,   Nr   r   r   r,   r*   r-   r-     r   r,   r-   c                      e Zd ZddZdS )r   r   r"   r$   r   c                    || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r   )r   r   rX   rm   r|   r   s     r*   r   z)AsyncImagesWithStreamingResponse.__init__  sU     B#!
 !
 7K
 
	 ;O
 
r,   Nr   r   r   r,   r*   r   r     r   r,   r   )2
__future__r   typingr   r   r   r   r   typing_extensionsr	   httpx r   typesr   r   r   _typesr   r   r   r   r   r   _utilsr   r   r   r   _compatr   	_resourcer   r   	_responser   r   _base_clientr   types.image_modelr   types.images_responser    __all__r!   r"   r%   r   r-   r   r   r,   r*   <module>r      su   # " " " " " 7 7 7 7 7 7 7 7 7 7 7 7 7 7 % % % % % %        [ [ [ [ [ [ [ [ [ [ I I I I I I I I I I I I I I I I \ \ \ \ \ \ \ \ \ \ \ \ % % % % % % 9 9 9 9 9 9 9 9 X X X X X X X X / / / / / / * * * * * * 2 2 2 2 2 2]
#M
 M
 M
 M
 M
_ M
 M
 M
`
M
 M
 M
 M
 M
" M
 M
 M
`

 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
r,   