
    +hg                        d dl mZ d dl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mZ ddlmZ dd	lmZ erd d
lmZ ddZ G d de      Z G d de      Z G d de      Z G d d      Zy)    )annotations)TYPE_CHECKINGAnycast)ArgumentParser   )
get_clientprint_model   )	NOT_GIVENNotGiven
NotGivenOr)	BaseModel)BufferReader)_SubParsersActionc                
   | j                  d      }|j                  ddt        d       |j                  ddt        d	       |j                  d
dt        dd       |j                  dt        d	       |j	                  t
        j                  t               | j                  d      }|j                  ddt        d       |j                  ddt        d	       |j                  ddt        dd       |j                  d
dt        dd       |j                  dt        d	       |j                  ddt        dd       |j	                  t
        j                  t               | j                  d      }|j                  ddt        d	       |j                  ddt        dd       |j                  d
dt        dd       |j                  dt        d	       |j	                  t
        j                  t               y )Nzimages.generatez-pz--promptT)typerequiredz-nz--num-images   )r   defaultz-sz--size	1024x1024zSize of the output image)r   r   helpz--response-formaturl)func
args_modelzimages.editz-Iz--imagez@Image to modify. Should be a local path and a PNG encoded image.)r   r   r   z-Mz--maskFzPath to a mask image. It should be the same size as the image you're editing and a RGBA PNG image. The Alpha channel acts as the mask.zimages.create_variation)
add_parseradd_argumentstrintset_defaultsCLIImagecreateCLIImageCreateArgseditCLIImageEditArgscreate_variationCLIImageCreateVariationArgs)	subparsersubs     H/var/www/html/venv/lib/python3.12/site-packages/openai/cli/_api/image.pyregisterr+      s   


0
1CT:C$?T>Q?T8#{Icd(sEB(//6HI


}
-CT:C$?T>Q?O   T8#{Icd(sEB V   (--4DE


8
9CT>Q?O   T8#{Icd(sEB(33@[\    c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)r#   r   promptr   
num_imagessizeresponse_formatN__name__
__module____qualname____annotations__ r,   r*   r#   r#   :   s    KO
Ir,   r#   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)r'   r   imager   r/   r0   r1   Nr2   r7   r,   r*   r'   r'   A   s    JO
Ir,   r'   c                  N    e Zd ZU ded<   ded<   ded<   ded<   ded<   eZded	<   y
)r%   r   r9   r   r/   r0   r1   r.   zNotGivenOr[str]maskN)r3   r4   r5   r6   r   r;   r7   r,   r*   r%   r%   H   s&    JO
IK%D/%r,   r%   c                  B    e Zd Zedd       Zedd       Zedd       Zy)r!   c           	         t               j                  j                  | j                  | j                  t        t        | j                        t        t        | j                              }t        |       y )N)r.   nr0   r1   )
r	   imagesgenerater.   r/   r   r   r0   r1   r
   )argsr9   s     r*   r"   zCLIImage.createR   sW    ##,,;;oo c499% d&:&:; - 
 	Er,   c           	     l   t        | j                  d      5 }t        |j                         d      }d d d        t	               j
                  j                  df| j                  t        t        | j                        t        t        | j                              }t        |       y # 1 sw Y   xxY w)NrbzUpload progressdescr9   )r9   r>   r0   r1   )openr9   r   readr	   r?   r&   r/   r   r   r0   r1   r
   )rA   file_readerbuffer_readerr9   s       r*   r&   zCLIImage.create_variation^   s    $**d# 	U{()9)9);BSTM	U ##44M*oo c499% d&:&:; 5 
 	E	U 	Us   B**B3c                z   t        | j                  d      5 }t        |j                         d      }d d d        t	        | j
                  t              rt        }n:t        | j
                  d      5 }t        |j                         d      }d d d        t               j                  j                  | j                  df| j                  t	        t              sd|fn|t        t        | j                        t        t        | j                               }t#        |       y # 1 sw Y   xY w# 1 sw Y   xY w)NrC   zImage upload progressrD   zMask progressr9   r;   )r.   r9   r>   r;   r0   r1   )rF   r9   r   rG   
isinstancer;   r   r   r	   r?   r$   r.   r/   r   r   r0   r1   r
   )rA   rH   rI   r;   r9   s        r*   r$   zCLIImage.editm   s   $**d# 	[{()9)9);BYZM	[ dii*-6Ddii& N+#K$4$4$6_MN ##((;;M*oo'1$'A&$t c499% d&:&:; ) 	
 	E'	[ 	[N Ns   D%2D1%D.1D:N)rA   r#   returnNone)rA   r'   rL   rM   )rA   r%   rL   rM   )r3   r4   r5   staticmethodr"   r&   r$   r7   r,   r*   r!   r!   Q   s<    	 	    r,   r!   N)r(   z!_SubParsersAction[ArgumentParser]rL   rM   )
__future__r   typingr   r   r   argparser   _utilsr	   r
   _typesr   r   r   _modelsr   	_progressr   r   r+   r#   r'   r%   r!   r7   r,   r*   <module>rV      s[    " + + # , 5 5  $*(]V ) &y &1 1r,   