o
    Cji                     @  s
  d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	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 d.ddZddd/ddZed0ddZed1ddZd2ddZd3d d!Zd4d$d%Zed0d&d'Zed1d(d'Zd2d)d'Zd3d*d+Zd4d,d-ZdS )5    )annotationsN)overload)	TypeGuard   )	FileTypesFileContentRequestFilesHttpxFileTypesHttpxFileContentHttpxRequestFiles)
is_tuple_tis_mapping_tis_sequence_tobjobjectreturnTypeGuard[FileContent]c                 C  s,   t | tpt | tpt | tjpt | tjS N)
isinstancebytestupleioIOBaseosPathLike)r    r   d/var/www/html/Resume-Parser/resume-parser-inhouse/venv/lib/python3.10/site-packages/openai/_files.pyis_file_content   s   *r   )keyr   
str | NoneNonec                C  sF   t | s!|d urd| dnd| d}t| dt|  dd d S )NzExpected entry at ``zExpected 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)r   r   prefixr   r   r   assert_is_file_content   s    r%   filesc                 C     d S r   r   r&   r   r   r   to_httpx_files$      r)   r   r   c                 C  r'   r   r   r(   r   r   r   r)   )   r*   RequestFiles | NoneHttpxRequestFiles | Nonec                 C  sX   | d u rd S t | rdd |  D } | S t| r"dd | D } | S tdt|  d)Nc                 S  s   i | ]	\}}|t |qS r   _transform_file.0r   filer   r   r   
<dictcomp>3   s    z"to_httpx_files.<locals>.<dictcomp>c                 S  s   g | ]
\}}|t |fqS r   r-   r/   r   r   r   
<listcomp>5   s    z"to_httpx_files.<locals>.<listcomp>zUnexpected file type input z, expected mapping or sequence)r   itemsr   	TypeErrorr#   r(   r   r   r   r)   .   s   r1   r   r	   c                 C  sb   t | rt| tjrt| }|j| fS | S t| r-| d t	| d g| dd  R S t
dNr   r      zCExpected file types input to be a FileContent type or to be a tuple)r   r   r   r   pathlibPathname
read_bytesr   _read_file_contentr5   r1   pathr   r   r   r.   <   s   
"r.   r   r
   c                 C  s   t | tjrt|  S | S r   )r   r   r   r8   r9   r;   r1   r   r   r   r<   J   s   r<   c                      d S r   r   r(   r   r   r   async_to_httpx_filesP      rA   c                   r@   r   r   r(   r   r   r   rA   U   rB   c                   sZ   | d u rd S t | rdd |  D I d H } | S t| r)dd | D I d H } | S td)Nc                   s"   i | ]\}}|t |I d H qS r   _async_transform_filer/   r   r   r   r2   _   s     z(async_to_httpx_files.<locals>.<dictcomp>c                   s$   g | ]\}}|t |I d H fqS r   rC   r/   r   r   r   r3   a   s   " z(async_to_httpx_files.<locals>.<listcomp>zFUnexpected file type input {type(files)}, expected mapping or sequence)r   r4   r   r5   r(   r   r   r   rA   Z   s   c                   sp   t | rt| tjrt| }|j| I d H fS | S t| r4| d t	| d I d H g| dd  R S t
dr6   )r   r   r   r   anyior9   r:   r;   r   _async_read_file_contentr5   r=   r   r   r   rD   h   s   
(rD   c                   s&   t | tjrt|  I d H S | S r   )r   r   r   rE   r9   r;   r?   r   r   r   rF   v   s   rF   )r   r   r   r   )r   r   r   r   r   r    )r&   r    r   r    )r&   r   r   r   )r&   r+   r   r,   )r1   r   r   r	   )r1   r   r   r
   )
__future__r   r   r   r8   typingr   typing_extensionsr   rE   _typesr   r   r   r	   r
   r   _utilsr   r   r   r   r%   r)   r.   r<   rA   rD   rF   r   r   r   r   <module>   s2     





