HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/openai/cli/_api/__pycache__/image.cpython-310.pyc
o

���g��@s�ddlmZddlmZmZmZddlmZddlm	Z	m
Z
ddlmZm
Z
mZddlmZdd	lmZer<dd
lmZddd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�d�ZdS)�)�annotations)�
TYPE_CHECKING�Any�cast)�ArgumentParser�)�
get_client�print_model�)�	NOT_GIVEN�NotGiven�
NotGivenOr)�	BaseModel)�BufferReader)�_SubParsersAction�	subparser�!_SubParsersAction[ArgumentParser]�return�NonecCs�|�d�}|jddtd�|jddtdd�|jd	d
tdd�|jd
dtddd�|jdtdd�|jtjtd�|�d�}|jddtd�|jddtdd�|jd	d
tdd�|jddtddd�|jd
dtddd�|jdtdd�|jddtddd�|jtjt	d�|�d�}|jddtd�|jd	d
tdd�|jddtddd�|jd
dtddd�|jdtdd�|jtj
td�dS)Nzimages.generatez-mz--model)�typez-pz--promptT)r�requiredz-nz--num-images�)r�defaultz-sz--size�	1024x1024zSize of the output image)rr�helpz--response-format�url)�func�
args_modelzimages.editz-Iz--imagez@Image to modify. Should be a local path and a PNG encoded image.)rrrz-Mz--maskFz�Path 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.zimages.create_variation)�
add_parser�add_argument�str�int�set_defaults�CLIImage�create�CLIImageCreateArgs�edit�CLIImageEditArgs�create_variation�CLIImageCreateVariationArgs)r�sub�r+�@/usr/local/lib/python3.10/dist-packages/openai/cli/_api/image.py�registersR

��
�r-c@�:eZdZUded<ded<ded<ded<eZded<d	S)
r%r �promptr!�
num_images�size�response_format�NotGivenOr[str]�modelN��__name__�
__module__�__qualname__�__annotations__rr4r+r+r+r,r%=�
r%c@r.)
r)r �imager!r0r1r2r3r4Nr5r+r+r+r,r)Er:r)c@sNeZdZUded<ded<ded<ded<ded<eZded	<eZded
<dS)r'r r;r!r0r1r2r/r3�maskr4N)r6r7r8r9rr<r4r+r+r+r,r'Ms
r'c@s6eZdZeddd��Zeddd	��Zeddd��Zd
S)r#�argsr%rrcCs:t�jj|j|j|jtt|j�tt|j	�d�}t
|�dS)N)r4r/�nr1r2)r�images�generater4r/r0rrr1r2r	)r=r;r+r+r,r$Xs

�	zCLIImage.creater)cCsxt|jd��}t|��dd�}Wd�n1swYt�jj|jd|f|jt	t
|j�t	t
|j�d�}t
|�dS)N�rbzUpload progress��descr;)r4r;r>r1r2)�openr;r�readrr?r(r4r0rrr1r2r	)r=�file_reader�
buffer_readerr;r+r+r,r(es�

�	zCLIImage.create_variationr'c
Cs�t|jd��}t|��dd�}Wd�n1swYt|jt�r't}nt|jd��}t|��dd�}Wd�n1s@wYt�j	j
|j|jd|f|j
t|t�s[d|fn|tt|j�tt|j�d�}t|�dS)NrAzImage upload progressrBz
Mask progressr;r<)r4r/r;r>r<r1r2)rDr;rrE�
isinstancer<rrrr?r&r4r/r0rrr1r2r	)r=rFrGr<r;r+r+r,r&us$��

�z
CLIImage.editN)r=r%rr)r=r)rr)r=r'rr)r6r7r8�staticmethodr$r(r&r+r+r+r,r#Wsr#N)rrrr)�
__future__r�typingrrr�argparser�_utilsrr	�_typesrrr
�_modelsr�	_progressrrr-r%r)r'r#r+r+r+r,�<module>s
.