a
    f(`                     @  sD  d dl mZ d dl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 deZ+G dd de Z,G dd dZ-G dd dZ.G dd dZ/G dd dZ0dS )    )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                   @  s   e Zd ZeddddZeddddZeeeeeddded		d
dddddddddddddZeeeeeeddded
d
dddddddddddddddZeeeeeeedddeddddddd d!ddddddd"d#d$Z	dS )%r   ImagesWithRawResponsereturnc                 C  s   t | S N)r!   self r'   P/var/www/ai-form-bot/venv/lib/python3.9/site-packages/openai/resources/images.pywith_raw_response   s    zImages.with_raw_responseImagesWithStreamingResponsec                 C  s   t | S r$   )r*   r%   r'   r'   r(   with_streaming_response"   s    zImages.with_streaming_responseN	modelnresponse_formatsizeuserextra_headersextra_query
extra_bodytimeoutr   'Union[str, ImageModel, None] | NotGivenOptional[int] | NotGiven/Optional[Literal['url', 'b64_json']] | NotGiven?Optional[Literal['256x256', '512x512', '1024x1024']] | NotGivenstr | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr   imager-   r.   r/   r0   r1   r2   r3   r4   r5   r#   c       
      
   C  sl   t ||||||d}tttttf |dggd}ddi|p@i }| jdt|tj	|t
|||	|
dtd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@   r-   r.   r/   r0   r1   r@   pathsContent-Typemultipart/form-data/images/variationsr2   r3   r4   r5   bodyfilesoptionscast_to)r   r   r   r   strobject_postr   r   ImageCreateVariationParamsr   r   r&   r@   r-   r.   r/   r0   r1   r2   r3   r4   r5   rJ   rK   r'   r'   r(   create_variation&   s(    0

zImages.create_variation
maskr-   r.   r/   r0   r1   r2   r3   r4   r5   rN   FileTypes | NotGivenr@   promptrU   r-   r.   r/   r0   r1   r2   r3   r4   r5   r#   c             
   C  st   t ||||||||d}tttttf |dgdggd}ddi|	pHi }	| jdt|tj	|t
|	|
||dtd	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@   rX   rU   r-   r.   r/   r0   r1   r@   rU   rC   rE   rF   /images/editsrH   rI   )r   r   r   r   rN   rO   rP   r   r
   ImageEditParamsr   r   r&   r@   rX   rU   r-   r.   r/   r0   r1   r2   r3   r4   r5   rJ   rK   r'   r'   r(   edito   s,    8"
zImages.editr-   r.   qualityr/   r0   styler1   r2   r3   r4   r5   $Literal['standard', 'hd'] | NotGivenYOptional[Literal['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792']] | NotGiven0Optional[Literal['vivid', 'natural']] | NotGivenrX   r-   r.   r`   r/   r0   ra   r1   r2   r3   r4   r5   r#   c                C  s8   | j dt||||||||dtjt|	|
||dtd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rX   r-   r.   r`   r/   r0   ra   r1   rH   rJ   rL   rM   )rP   r   r   ImageGenerateParamsr   r   r&   rX   r-   r.   r`   r/   r0   ra   r1   r2   r3   r4   r5   r'   r'   r(   generate   s&    ;
zImages.generate
__name__
__module____qualname__r   r)   r+   r   rS   r^   rl   r'   r'   r'   r(   r      sJ   &N*Wc                   @  s   e Zd ZeddddZeddddZeeeeeddded		d
dddddddddddddZeeeeeeddded
d
dddddddddddddddZeeeeeeedddeddddddd d!ddddddd"d#d$Z	dS )%r    AsyncImagesWithRawResponser"   c                 C  s   t | S r$   )rq   r%   r'   r'   r(   r)     s    zAsyncImages.with_raw_response AsyncImagesWithStreamingResponsec                 C  s   t | S r$   )rr   r%   r'   r'   r(   r+     s    z#AsyncImages.with_streaming_responseNr,   r   r6   r7   r8   r9   r:   r;   r<   r=   r>   r   r?   c       
      
     sx   t ||||||d}tttttf |dggd}ddi|p@i }| jdt|tj	I dH |t
|||	|
dtd	I dH S )
rA   rB   r@   rC   rE   rF   rG   NrH   rI   )r   r   r   r   rN   rO   rP   r   r   rQ   r   r   rR   r'   r'   r(   rS     s(    0
zAsyncImages.create_variationrT   rN   rV   rW   c             
     s   t ||||||||d}tttttf |dgdggd}ddi|	pHi }	| jdt|tj	I dH |t
|	|
||d	td
I dH S )rY   rZ   r@   rU   rC   rE   rF   r[   NrH   rI   )r   r   r   r   rN   rO   rP   r   r
   r\   r   r   r]   r'   r'   r(   r^   e  s,    8"zAsyncImages.editr_   rb   rc   rd   re   c                  sD   | j dt||||||||dtjI dH t|	|
||dtdI dH S )rf   rg   rh   NrH   ri   )rP   r   r   rj   r   r   rk   r'   r'   r(   rl     s&    ;
zAsyncImages.generaterm   r'   r'   r'   r(   r      sJ   &N*Wc                   @  s   e Zd ZdddddZdS )r!   r   Noneimagesr#   c                 C  s4   || _ t|j| _t|j| _t|j| _d S r$   )_imagesr	   Zto_raw_response_wrapperrS   r^   rl   r&   ru   r'   r'   r(   __init__
  s    zImagesWithRawResponse.__init__Nrn   ro   rp   rx   r'   r'   r'   r(   r!   	  s   r!   c                   @  s   e Zd ZdddddZdS )rq   r    rs   rt   c                 C  s4   || _ t|j| _t|j| _t|j| _d S r$   )rv   r	   Zasync_to_raw_response_wrapperrS   r^   rl   rw   r'   r'   r(   rx     s    z#AsyncImagesWithRawResponse.__init__Nry   r'   r'   r'   r(   rq     s   rq   c                   @  s   e Zd ZdddddZdS )r*   r   rs   rt   c                 C  s.   || _ t|j| _t|j| _t|j| _d S r$   )rv   r   rS   r^   rl   rw   r'   r'   r(   rx   (  s    z$ImagesWithStreamingResponse.__init__Nry   r'   r'   r'   r(   r*   '  s   r*   c                   @  s   e Zd ZdddddZdS )rr   r    rs   rt   c                 C  s.   || _ t|j| _t|j| _t|j| _d S r$   )rv   r   rS   r^   rl   rw   r'   r'   r(   rx   7  s    z)AsyncImagesWithStreamingResponse.__init__Nry   r'   r'   r'   r(   rr   6  s   rr   )1
__future__r   typingr   r   r   r   typing_extensionsr   Zhttpx r	   typesr
   r   r   _typesr   r   r   r   r   r   Z_utilsr   r   r   r   _compatr   Z	_resourcer   r   	_responser   r   Z_base_clientr   Ztypes.image_modelr   Ztypes.images_responser   __all__r   r    r!   rq   r*   rr   r'   r'   r'   r(   <module>   s,     w w