U
    ·ÜŸjd  ã                   @  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 ©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'   ú;/tmp/pip-unpacked-wheel-2qj3ofc_/openai/resources/images.pyÚwith_raw_response   s    zImages.with_raw_responseÚImagesWithStreamingResponsec                 C  s   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%   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ú1Optional[Literal[('url', 'b64_json')]] | NotGivenúAOptional[Literal[('256x256', '512x512', '1024x1024')]] | NotGivenústr | NotGivenúHeaders | NoneúQuery | NoneúBody | Noneú'float | httpx.Timeout | None | NotGivenr   ©Úimager.   r/   r0   r1   r2   r3   r4   r5   r6   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
        ©rA   r.   r/   r0   r1   r2   rA   ©ÚpathsúContent-Typeúmultipart/form-dataú/images/variations©r3   r4   r5   r6   ©ÚbodyÚfilesÚoptionsÚcast_to)r   r   r   r   ÚstrÚobjectÚ_postr   r   ÚImageCreateVariationParamsr   r   ©r&   rA   r.   r/   r0   r1   r2   r3   r4   r5   r6   rK   rL   r'   r'   r(   Úcreate_variation1   s.    0úÿ

   ÿùzImages.create_variation©
Úmaskr.   r/   r0   r1   r2   r3   r4   r5   r6   rO   úFileTypes | NotGiven©rA   ÚpromptrV   r.   r/   r0   r1   r2   r3   r4   r5   r6   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
        ©rA   rY   rV   r.   r/   r0   r1   r2   rA   rV   rD   rF   rG   ú/images/editsrI   rJ   )r   r   r   r   rO   rP   rQ   r   r
   ÚImageEditParamsr   r   ©r&   rA   rY   rV   r.   r/   r0   r1   r2   r3   r4   r5   r6   rK   rL   r'   r'   r(   Úeditz   s2    8øÿ"
   ÿùzImages.edit©r.   r/   Úqualityr0   r1   Ústyler2   r3   r4   r5   r6   ú&Literal[('standard', 'hd')] | NotGivenú[Optional[Literal[('256x256', '512x512', '1024x1024', '1792x1024', '1024x1792')]] | NotGivenú2Optional[Literal[('vivid', 'natural')]] | NotGiven©rY   r.   r/   ra   r0   r1   rb   r2   r3   r4   r5   r6   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©rY   r.   r/   ra   r0   r1   rb   r2   rI   ©rK   rM   rN   )rQ   r   r   ÚImageGenerateParamsr   r   ©r&   rY   r.   r/   ra   r0   r1   rb   r2   r3   r4   r5   r6   r'   r'   r(   ÚgenerateÍ   s,    ;ø
õ   ÿîzImages.generate©
Ú__name__Ú
__module__Ú__qualname__r   r)   r,   r   rT   r_   rm   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$   )rr   r%   r'   r'   r(   r)     s    zAsyncImages.with_raw_responseÚ AsyncImagesWithStreamingResponsec                 C  s   t | ƒS r+   )rs   r%   r'   r'   r(   r,   )  s    z#AsyncImages.with_streaming_responseNr-   r   r7   r8   r9   r:   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 )
rB   rC   rA   rD   rF   rG   rH   NrI   rJ   )r   r   r   r   rO   rP   rQ   r   r   rR   r   r   rS   r'   r'   r(   rT   2  s.    0úÿ
   ÿùzAsyncImages.create_variationrU   rO   rW   rX   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 )rZ   r[   rA   rV   rD   rF   rG   r\   NrI   rJ   )r   r   r   r   rO   rP   rQ   r   r
   r]   r   r   r^   r'   r'   r(   r_   {  s2    8øÿ"   ÿùzAsyncImages.editr`   rc   rd   re   rf   c                Ã  sD   | j dt||||||||dœtjƒI dH t|	|
||d�td�I dH S )rg   rh   ri   NrI   rj   )rQ   r   r   rk   r   r   rl   r'   r'   r(   rm   Î  s,    ;ø
õ   ÿîzAsyncImages.generatern   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 ©N)Ú_imagesr	   Zto_raw_response_wrapperrT   r_   rm   ©r&   rv   r'   r'   r(   Ú__init__   s    ÿÿÿzImagesWithRawResponse.__init__N©ro   rp   rq   rz   r'   r'   r'   r(   r!     s   r!   c                   @  s   e Zd Zdddœdd„ZdS )rr   r    rt   ru   c                 C  s4   || _ t |j¡| _t |j¡| _t |j¡| _d S rw   )rx   r	   Zasync_to_raw_response_wrapperrT   r_   rm   ry   r'   r'   r(   rz   /  s    ÿÿÿz#AsyncImagesWithRawResponse.__init__Nr{   r'   r'   r'   r(   rr   .  s   rr   c                   @  s   e Zd Zdddœdd„ZdS )r*   r   rt   ru   c                 C  s.   || _ t|jƒ| _t|jƒ| _t|jƒ| _d S rw   )rx   r   rT   r_   rm   ry   r'   r'   r(   rz   >  s    ÿÿÿz$ImagesWithStreamingResponse.__init__Nr{   r'   r'   r'   r(   r*   =  s   r*   c                   @  s   e Zd Zdddœdd„ZdS )rs   r    rt   ru   c                 C  s.   || _ t|jƒ| _t|jƒ| _t|jƒ| _d S rw   )rx   r   rT   r_   rm   ry   r'   r'   r(   rz   M  s    ÿÿÿz)AsyncImagesWithStreamingResponse.__init__Nr{   r'   r'   r'   r(   rs   L  s   rs   )1Ú
__future__r   Útypingr   r   r   r   Útyping_extensionsr   ZhttpxÚ r	   Útypesr
   r   r   Ú_typesr   r   r   r   r   r   Ú_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!   rr   r*   rs   r'   r'   r'   r(   Ú<module>   s0        