a
    !fY                     @  s  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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 dd	lmZmZ dd
lmZm Z  ddl!m"Z" erddl#m$Z$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*dS )    )annotations)TYPE_CHECKINGUnionMappingOptionalcast)LiteralN   )ImagesResponseimage_edit_paramsimage_generate_paramsimage_create_variation_params)	NOT_GIVENBodyQueryHeadersNotGiven	FileTypes)extract_filesmaybe_transformdeepcopy_minimal)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperasync_to_raw_response_wrapper)make_request_options)OpenAIAsyncOpenAIImagesAsyncImagesc                      s   e Zd ZU ded< ddd f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  Z	S )&r   ImagesWithRawResponsewith_raw_responser   Noneclientreturnc                   s   t  | t| | _d S N)super__init__r    r!   selfr$   	__class__ X/var/www/html/python-backend/venv/lib/python3.9/site-packages/openai/resources/images.pyr(      s    zImages.__init__N	modelnresponse_formatsizeuserextra_headersextra_query
extra_bodytimeoutr   0Union[str, Literal['dall-e-2'], 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
   imager0   r1   r2   r3   r4   r5   r6   r7   r8   r%   c       
      
   C  sp   t ||||||d}tttttf |dggd}|rHddi|pDi }| 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`.

          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
        rC   r0   r1   r2   r3   r4   rC   pathsContent-Typemultipart/form-data/images/variationsr5   r6   r7   r8   bodyfilesoptionscast_tor   r   r   r   strobject_postr   r   ZImageCreateVariationParamsr   r
   r*   rC   r0   r1   r2   r3   r4   r5   r6   r7   r8   rM   rN   r-   r-   r.   create_variation#   s*    /

zImages.create_variation
maskr0   r1   r2   r3   r4   r5   r6   r7   r8   rR   FileTypes | NotGivenrC   promptrX   r0   r1   r2   r3   r4   r5   r6   r7   r8   r%   c             
   C  sx   t ||||||||d}tttttf |dgdggd}|rPddi|	pLi }	| jdt|tj	|t
|	|
||dtd	S )
F  
        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`.

          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
        rC   r[   rX   r0   r1   r2   r3   r4   rC   rX   rF   rH   rI   /images/editsrK   rL   r   r   r   r   rR   rS   rT   r   r   ZImageEditParamsr   r
   r*   rC   r[   rX   r0   r1   r2   r3   r4   r5   r6   r7   r8   rM   rN   r-   r-   r.   editm   s.    7"
zImages.editr0   r1   qualityr2   r3   styler4   r5   r6   r7   r8   <Union[str, Literal['dall-e-2', 'dall-e-3'], None] | NotGiven$Literal['standard', 'hd'] | NotGivenYOptional[Literal['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792']] | NotGiven0Optional[Literal['vivid', 'natural']] | NotGivenr[   r0   r1   rc   r2   r3   rd   r4   r5   r6   r7   r8   r%   c                C  s8   | j dt||||||||dtjt|	|
||dtdS )9  
        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`.

          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r[   r0   r1   rc   r2   r3   rd   r4   rK   rM   rO   rP   rT   r   r   ZImageGenerateParamsr   r
   r*   r[   r0   r1   rc   r2   r3   rd   r4   r5   r6   r7   r8   r-   r-   r.   generate   s&    :
zImages.generate
__name__
__module____qualname____annotations__r(   r   rV   ra   rp   __classcell__r-   r-   r+   r.   r      sF   
&O*Xc                      s   e Zd ZU ded< ddd f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  Z	S )&r   AsyncImagesWithRawResponser!   r   r"   r#   c                   s   t  | t| | _d S r&   )r'   r(   rw   r!   r)   r+   r-   r.   r(     s    zAsyncImages.__init__Nr/   r   r9   r:   r;   r<   r=   r>   r?   r@   rA   r
   rB   c       
      
     sv   t ||||||d}tttttf |dggd}|rHddi|pDi }| jdt|tj	|t
|||	|
dtdI d	H S )
rD   rE   rC   rF   rH   rI   rJ   rK   rL   NrQ   rU   r-   r-   r.   rV     s*    /

zAsyncImages.create_variationrW   rR   rY   rZ   c             
     s~   t ||||||||d}tttttf |dgdggd}|rPddi|	pLi }	| jdt|tj	|t
|	|
||dtd	I d
H S )r\   r]   rC   rX   rF   rH   rI   r^   rK   rL   Nr_   r`   r-   r-   r.   ra   b  s.    7"
zAsyncImages.editrb   re   rf   rg   rh   ri   c                  s>   | j dt||||||||dtjt|	|
||dtdI dH S )rj   rk   rl   rK   rm   Nrn   ro   r-   r-   r.   rp     s&    :
zAsyncImages.generaterq   r-   r-   r+   r.   r     sF   
&O*Xc                   @  s   e Zd ZdddddZdS )r    r   r"   imagesr%   c                 C  s(   t |j| _t |j| _t |j| _d S r&   )r   rV   ra   rp   r*   ry   r-   r-   r.   r(     s    zImagesWithRawResponse.__init__Nrr   rs   rt   r(   r-   r-   r-   r.   r      s   r    c                   @  s   e Zd ZdddddZdS )rw   r   r"   rx   c                 C  s(   t |j| _t |j| _t |j| _d S r&   )r   rV   ra   rp   rz   r-   r-   r.   r(     s    z#AsyncImagesWithRawResponse.__init__Nr{   r-   r-   r-   r.   rw     s   rw   )+
__future__r   typingr   r   r   r   r   Ztyping_extensionsr   Zhttpxtypesr
   r   r   r   _typesr   r   r   r   r   r   _utilsr   r   r   Z	_resourcer   r   	_responser   r   Z_base_clientr   Z_clientr   r   __all__r   r   r    rw   r-   r-   r-   r.   <module>   s$     v v