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/__pycache__/_files.cpython-310.pyc
o

���g �@sddlmZddlZddlZddlZddlmZddlmZddl	Z	ddl
mZmZm
Z
mZmZmZmZddlmZmZmZd1dd
�Zd2dd�Zdd�d3dd�Zed4dd��Zed5dd��Zd6dd�Zd7d#d$�Zd8d'd(�Zed4d)d*��Zed5d+d*��Zd6d,d*�Zd7d-d.�Zd8d/d0�ZdS)9�)�annotationsN)�overload)�	TypeGuard�)�	FileTypes�FileContent�RequestFiles�HttpxFileTypes�Base64FileInput�HttpxFileContent�HttpxRequestFiles)�
is_tuple_t�is_mapping_t�
is_sequence_t�obj�object�return�TypeGuard[Base64FileInput]cCst|tj�pt|tj�S�N)�
isinstance�io�IOBase�os�PathLike�r�r�8/usr/local/lib/python3.10/dist-packages/openai/_files.py�is_base64_file_inputsr�TypeGuard[FileContent]cCs,t|t�pt|t�pt|tj�pt|tj�Sr)r�bytes�tuplerrrrrrrr�is_file_contents*�r!)�keyr"�
str | None�NonecCsFt|�s!|durd|�d�nd|�d�}t|�dt|��d��d�dS)NzExpected entry at `�`zExpected file input `zF to be bytes, an io.IOBase instance, PathLike or a tuple but received zL instead. See https://github.com/openai/openai-python/tree/main#file-uploads)r!�RuntimeError�type)rr"�prefixrrr�assert_is_file_content!s ���r)�filescC�dSrr�r*rrr�to_httpx_files)�r-rrcCr+rrr,rrrr--r.�RequestFiles | None�HttpxRequestFiles | NonecCsX|durdSt|�rdd�|��D�}|St|�r"dd�|D�}|Stdt|��d���)NcSsi|]	\}}|t|��qSr��_transform_file��.0r"�filerrr�
<dictcomp>6sz"to_httpx_files.<locals>.<dictcomp>cSsg|]
\}}|t|�f�qSrr1r3rrr�
<listcomp>8sz"to_httpx_files.<locals>.<listcomp>zUnexpected file type input z, expected mapping or sequence)r�itemsr�	TypeErrorr'r,rrrr-1s��r5rr	cCsbt|�rt|tj�rt�|�}|j|��fS|St|�r-|dt	|d�g|dd��RSt
d���Nrr�zCExpected file types input to be a FileContent type or to be a tuple)r!rrr�pathlib�Path�name�
read_bytesr
�_read_file_contentr9�r5�pathrrrr2?s
"r2rrcCst|tj�r
t�|���S|Sr)rrrr<r=r?�r5rrrr@Msr@c���dSrrr,rrr�async_to_httpx_filesS��rEc�rDrrr,rrrrEWrFc�sZ�|durdSt|�rdd�|��D�IdH}|St|�r)dd�|D�IdH}|Std��)Nc�s"�i|]\}}|t|�IdH�qSr��_async_transform_filer3rrrr6`s� z(async_to_httpx_files.<locals>.<dictcomp>c�s$�g|]
\}}|t|�IdHf�qSrrGr3rrrr7bs�"z(async_to_httpx_files.<locals>.<listcomp>zFUnexpected file type input {type(files)}, expected mapping or sequence)rr8rr9r,rrrrE[s���c�sp�t|�rt|tj�rt�|�}|j|��IdHfS|St|�r4|dt	|d�IdHg|dd��RSt
d��r:)r!rrr�anyior=r>r?r
�_async_read_file_contentr9rArrrrHis�
(rHc�s&�t|tj�rt�|���IdHS|Sr)rrrrIr=r?rCrrrrJws�rJ)rrrr)rrrr)rrr"r#rr$)r*r$rr$)r*rrr)r*r/rr0)r5rrr	)r5rrr)�
__future__rrrr<�typingr�typing_extensionsrrI�_typesrrrr	r
rr�_utilsr
rrrr!r)r-r2r@rErHrJrrrr�<module>s4$