
    g"d                    h   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e      Z+ G d de       Z, G d d      Z- G d d      Z. G d d      Z/ G d d      Z0y)    )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                     e Zd Zed
d       Zedd       Zeeeeeddded		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZeeeeeeddded
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZeeeeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z	y)r    c                    t        |       S a  
        This property can be used as a prefix for any HTTP method call to return the
        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
        )ImagesWithRawResponseselfs    L/var/www/openai/venv/lib/python3.12/site-packages/openai/resources/images.pywith_raw_responsezImages.with_raw_response   s     %T**    c                    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
        )ImagesWithStreamingResponser&   s    r(   with_streaming_responsezImages.with_streaming_response(   s     +400r*   N	modelnresponse_formatsizeuserextra_headersextra_query
extra_bodytimeoutc       
           t        ||||||d      }t        t        t        t        t
        f   |      dgg      }ddi|xs i }| j                  dt        |t        j                        |t        |||	|
      t              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
        imager0   r1   r2   r3   r4   r<   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   ImageCreateVariationParamsr   r   r'   r<   r0   r1   r2   r3   r4   r5   r6   r7   r8   rD   rE   s                r(   create_variationzImages.create_variation1   s    `  #2	
 d73;#7>ykR ()>X=CVTVXzz  'D'_'_`(+Q[el #  
 	
r*   
maskr0   r1   r2   r3   r4   r5   r6   r7   r8   c                  t        ||||||||d      }t        t        t        t        t
        f   |      dgdgg      }ddi|	xs i }	| j                  dt        |t        j                        |t        |	|
||      t        	      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<   promptrO   r0   r1   r2   r3   r4   r<   rO   r=   r?   r@   /images/editsrB   rC   )r   r   r   r   rH   rI   rJ   r   r   ImageEditParamsr   r   r'   r<   rS   rO   r0   r1   r2   r3   r4   r5   r6   r7   r8   rD   rE   s                  r(   editzImages.editz   s    p   #2	
 d73;#7>ySYRZF[\ ()>X=CVTVXzz '8'H'HI(+Q[el #  
 	
r*   r0   r1   qualityr2   r3   styler4   r5   r6   r7   r8   c                   | j                  dt        ||||||||dt        j                        t	        |	|
||      t
              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rS   r0   r1   rY   r2   r3   rZ   r4   rB   rD   rF   rG   )rJ   r   r   ImageGenerateParamsr   r   r'   rS   r0   r1   rY   r2   r3   rZ   r4   r5   r6   r7   r8   s                r(   generatezImages.generate   sh    v zz! $"&'6 " 	 &99 )+Q[el #%  
 	
r*   )returnr%   )rc   r-   r<   r   r0   'Union[str, ImageModel, None] | NotGivenr1   Optional[int] | NotGivenr2   /Optional[Literal['url', 'b64_json']] | NotGivenr3   ?Optional[Literal['256x256', '512x512', '1024x1024']] | NotGivenr4   str | NotGivenr5   Headers | Noner6   Query | Noner7   Body | Noner8   'float | httpx.Timeout | None | NotGivenrc   r   r<   r   rS   rH   rO   zFileTypes | NotGivenr0   re   r1   rf   r2   rg   r3   rh   r4   ri   r5   rj   r6   rk   r7   rl   r8   rm   rc   r   rS   rH   r0   re   r1   rf   rY   z$Literal['standard', 'hd'] | NotGivenr2   rg   r3   zYOptional[Literal['256x256', '512x512', '1024x1024', '1792x1024', '1024x1792']] | NotGivenrZ   z0Optional[Literal['vivid', 'natural']] | NotGivenr4   ri   r5   rj   r6   rk   r7   rl   r8   rm   rc   r   
__name__
__module____qualname__r   r)   r.   r   rM   rW   rb    r*   r(   r    r       sB   + + 1 1 :C&/KTPY( )-$("&;DG
 G
 7	G

 $G
 IG
 NG
 G
 &G
 "G
  G
 9G
 
G
\ &/9B&/KTPY( )-$("&;D!Q
 Q
 	Q

 #Q
 7Q
 $Q
 IQ
 NQ
 Q
 &Q
 "Q
  Q
  9!Q
" 
#Q
n :C&/8AKTjsBK( )-$("&;D!N
 N
 7	N

 $N
 6N
 IN
 hN
 @N
 N
 &N
 "N
  N
  9!N
" 
#N
r*   c                     e Zd Zed
d       Zedd       Zeeeeeddded		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZeeeeeeddded
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZeeeeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z	y)r!   c                    t        |       S r$   )AsyncImagesWithRawResponser&   s    r(   r)   zAsyncImages.with_raw_response  s     *$//r*   c                    t        |       S r,   ) AsyncImagesWithStreamingResponser&   s    r(   r.   z#AsyncImages.with_streaming_response)  s     055r*   Nr/   c       
        <  K   t        ||||||d      }t        t        t        t        t
        f   |      dgg      }ddi|xs i }| j                  dt        |t        j                         d{   |t        |||	|
      t        	       d{   S 7 %7 w)
r:   r;   r<   r=   r?   r@   rA   NrB   rC   )r   r   r   r   rH   rI   rJ   r   r   rK   r   r   rL   s                r(   rM   zAsyncImages.create_variation2  s     `  #2	
 d73;#7>ykR ()>X=CVTVXZZ ,T3P3k3kll(+Q[el #   
 
 	
l
s$   A0B2B
3 BBBBrN   c               D  K   t        ||||||||d      }t        t        t        t        t
        f   |      dgdgg      }ddi|	xs i }	| j                  dt        |t        j                         d{   |t        |	|
||	      t        
       d{   S 7 %7 w)rQ   rR   r<   rO   r=   r?   r@   rT   NrB   rC   )r   r   r   r   rH   rI   rJ   r   r   rU   r   r   rV   s                  r(   rW   zAsyncImages.edit{  s     p   #2	
 d73;#7>ySYRZF[\ ()>X=CVTVXZZ,T3D3T3TUU(+Q[el #   
 
 	
U
s$   A4B 6B
7 B BB B rX   c                  K   | j                  dt        ||||||||dt        j                         d{   t	        |	|
||      t
               d{   S 7 $7 w)r\   r]   r^   NrB   r_   )rJ   r   r   r`   r   r   ra   s                r(   rb   zAsyncImages.generate  s     v ZZ!,$"&'6 " 	 &99  )+Q[el #%   
 
 	

s!   3AA
AAAA)rc   rw   )rc   ry   rd   rn   ro   rp   rt   r*   r(   r!   r!     sB   0 0 6 6 :C&/KTPY( )-$("&;DG
 G
 7	G

 $G
 IG
 NG
 G
 &G
 "G
  G
 9G
 
G
\ &/9B&/KTPY( )-$("&;D!Q
 Q
 	Q

 #Q
 7Q
 $Q
 IQ
 NQ
 Q
 &Q
 "Q
  Q
  9!Q
" 
#Q
n :C&/8AKTjsBK( )-$("&;D!N
 N
 7	N

 $N
 6N
 IN
 hN
 @N
 N
 &N
 "N
  N
  9!N
" 
#N
r*   c                      e Zd ZddZy)r%   c                    || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        y N)_imagesr
   to_raw_response_wrapperrM   rW   rb   r'   imagess     r(   __init__zImagesWithRawResponse.__init__   s[     0 H H##!
 %<<KK
	 )@@OO
r*   Nr   r    rc   Nonerq   rr   rs   r   rt   r*   r(   r%   r%         
r*   r%   c                      e Zd ZddZy)rw   c                    || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        y r   )r   r
   async_to_raw_response_wrapperrM   rW   rb   r   s     r(   r   z#AsyncImagesWithRawResponse.__init__/  s[     0 N N##!
 %BBKK
	 )FFOO
r*   Nr   r!   rc   r   r   rt   r*   r(   rw   rw   .  r   r*   rw   c                      e Zd ZddZy)r-   c                    || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        y r   )r   r   rM   rW   rb   r   s     r(   r   z$ImagesWithStreamingResponse.__init__>  sI     <##!
 1KK
	 5OO
r*   Nr   r   rt   r*   r(   r-   r-   =  r   r*   r-   c                      e Zd ZddZy)ry   c                    || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        y r   )r   r   rM   rW   rb   r   s     r(   r   z)AsyncImagesWithStreamingResponse.__init__M  sI     B##!
 7KK
	 ;OO
r*   Nr   r   rt   r*   r(   ry   ry   L  r   r*   ry   )1
__future__r   typingr   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%   rw   r-   ry   rt   r*   r(   <module>r      s    # 1 1 %   [ [ I I  & 9 X / * 2]
#~
_ ~
B~
" ~
B
 

 

 

 
r*   