
    g                        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               |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               |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               |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-mz--model)typez-pz--promptT)r   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     J/var/www/openai/venv/lib/python3.12/site-packages/openai/cli/_api/image.pyregisterr+      s/   


0
1CT93/T:C$?T>Q?T8#{Icd(sEB(//6HI


}
-CT93/T:C$?T>Q?O   T8#{Icd(sEB V   (--4DE


8
9CT93/T>Q?O   T8#{Icd(sEB(33@[\    c                  D    e Zd ZU ded<   ded<   ded<   ded<   eZded<   y	)
r#   r   promptr   
num_imagessizeresponse_formatNotGivenOr[str]modelN__name__
__module____qualname____annotations__r   r3    r,   r*   r#   r#   =   s!    KO
I&E?&r,   r#   c                  D    e Zd ZU ded<   ded<   ded<   ded<   eZded<   y	)
r'   r   imager   r/   r0   r1   r2   r3   Nr4   r9   r,   r*   r'   r'   E   s!    JO
I&E?&r,   r'   c                  \    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	<   eZded
<   y)r%   r   r;   r   r/   r0   r1   r.   r2   maskr3   N)r5   r6   r7   r8   r   r=   r3   r9   r,   r*   r%   r%   M   s0    JO
IK%D/%&E?&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                  | j
                  t        t        | j                        t        t        | j                              }t        |       y )N)r3   r.   nr0   r1   )r	   imagesgenerater3   r.   r/   r   r   r0   r1   r
   )argsr;   s     r*   r"   zCLIImage.createX   s^    ##,,**;;oo c499% d&:&:; - 
 	Er,   c           
        t        | j                  d      5 }t        |j                         d      }d d d        t	               j
                  j                  | j                  df| j                  t        t        | j                        t        t        | j                              }t        |       y # 1 sw Y   xY w)NrbzUpload progressdescr;   )r3   r;   r@   r0   r1   )openr;   r   readr	   rA   r&   r3   r/   r   r   r0   r1   r
   )rC   file_readerbuffer_readerr;   s       r*   r&   zCLIImage.create_variatione   s    $**d#{()9)9);BSTM $ ##44**M*oo c499% d&:&:; 5 
 	E $#s   B55B>c                   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                  | 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)NrE   zImage upload progressrF   zMask progressr;   r=   )r3   r.   r;   r@   r=   r0   r1   )rH   r;   r   rI   
isinstancer=   r   r   r	   rA   r$   r3   r.   r/   r   r   r0   r1   r
   )rC   rJ   rK   r=   r;   s        r*   r$   zCLIImage.editu   s    $**d#{()9)9);BYZM $ dii*-6Ddii&+#K$4$4$6_M ' ##((**;;M*oo'1$'A&$t c499% d&:&:; ) 

 	E) $# '&s   D02D<0D9<EN)rC   r#   returnNone)rC   r'   rN   rO   )rC   r%   rN   rO   )r5   r6   r7   staticmethodr"   r&   r$   r9   r,   r*   r!   r!   W   s<    
 
    r,   r!   N)r(   z!_SubParsersAction[ArgumentParser]rN   rO   )
__future__r   typingr   r   r   argparser   _utilsr	   r
   _typesr   r   r   _modelsr   	_progressr   r   r+   r#   r'   r%   r!   r9   r,   r*   <module>rX      s[    " + + # , 5 5  $*+]\' '') ''y '4 4r,   