o
    CjiBX                     @  s0  d dl mZ d dlZd dlZd dlmZmZmZ d dlmZ d dl	Z	ddl
mZmZmZm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	lmZmZ dd
lmZmZ ddl m!Z!m"Z" ddl#m$Z$m%Z%m&Z& ertddl'm(Z(m)Z) ddgZ*G dd deZ+G dd deZ,G dd dZ-G dd dZ.dS )    )annotationsN)TYPE_CHECKINGMappingcast)Literal   )
FileObjectFileDeletedfile_list_paramsfile_create_params)	NOT_GIVENBodyQueryHeadersNotGiven	FileTypes)extract_filesmaybe_transformdeepcopy_minimal)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperasync_to_raw_response_wrapper)SyncPage	AsyncPage)AsyncPaginatorHttpxBinaryResponseContentmake_request_options)OpenAIAsyncOpenAIFiles
AsyncFilesc                         e Zd ZU ded< d5 fddZd	d	d	ed
d6ddZd	d	d	ed
d7ddZed	d	d	edd8d!d"Zd	d	d	ed
d9d$d%Z	d	d	d	ed
d:d'd(Z
ed)d	d	d	ed
d;d*d+Zd,d-d.d<d3d4Z  ZS )=r    FilesWithRawResponsewith_raw_responseclientr   returnNonec                      t  | t| | _d S N)super__init__r#   r$   selfr%   	__class__ m/var/www/html/Resume-Parser/resume-parser-inhouse/venv/lib/python3.10/site-packages/openai/resources/files.pyr+   !      zFiles.__init__Nextra_headersextra_query
extra_bodytimeoutfiler   purpose"Literal['fine-tune', 'assistants']r4   Headers | Noner5   Query | Noner6   Body | Noner7   'float | httpx.Timeout | None | NotGivenr   c          	   
   C  sh   t ||d}tttttf |dggd}|r ddi|pi }| jdt|tj	|t
||||dtdS )	{  Upload a file that can be used across various endpoints/features.

        The size of
        all the files uploaded by one organization can be up to 100 GB.

        The size of individual files for can be a maximum of 512MB. See the
        [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) to
        learn more about the types of files supported. The Fine-tuning API only supports
        `.jsonl` files.

        Please [contact us](https://help.openai.com/) if you need to increase these
        storage limits.

        Args:
          file: The File object (not file name) to be uploaded.

          purpose: The intended purpose of the uploaded file.

              Use "fine-tune" for
              [Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tuning) and
              "assistants" for
              [Assistants](https://platform.openai.com/docs/api-reference/assistants) and
              [Messages](https://platform.openai.com/docs/api-reference/messages). This allows
              us to validate the format of the uploaded file is correct for fine-tuning.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        r8   r9   r8   pathsContent-Typemultipart/form-data/filesr3   bodyfilesoptionscast_tor   r   r   r   strobject_postr   r   FileCreateParamsr   r   	r-   r8   r9   r4   r5   r6   r7   rG   rH   r0   r0   r1   create%   s"   -
zFiles.createfile_idrL   c                C  "   | j d| t||||dtdS )^  
        Returns information about a specific file.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        /files/r3   rI   rJ   _getr   r   r-   rR   r4   r5   r6   r7   r0   r0   r1   retrievei      zFiles.retriever9   r4   r5   r6   r7   str | NotGivenSyncPage[FileObject]c                C  0   | j dtt t||||td|itjdtdS a  
        Returns a list of files that belong to the user's organization.

        Args:
          purpose: Only return files with the given purpose.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rE   r9   )r4   r5   r6   r7   query)pagerI   model)_get_api_listr   r   r   r   r
   FileListParamsr-   r9   r4   r5   r6   r7   r0   r0   r1   list      z
Files.listr	   c                C  rS   )B  
        Delete a file.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rU   r3   rV   _deleter   r	   rY   r0   r0   r1   delete   r[   zFiles.deleter   c                C  s$   | j d| dt||||dtdS )_  
        Returns the contents of the specified file.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rU   /contentr3   rV   rX   r   r   rY   r0   r0   r1   content   s   
zFiles.content.The `.content()` method should be used insteadc                C  s4   ddi|pi }| j d| dt||||dtdS )rm   Acceptapplication/jsonrU   rn   r3   rV   rX   r   rL   rY   r0   r0   r1   retrieve_content   s   
zFiles.retrieve_content      @  poll_intervalmax_wait_secondsidry   floatrz   c                C  sl   h d}t   }| |}|j|vr4| | | |}t   | |kr/td| d| d|j|vs|S )EWaits for the given file to be processed, default timeout is 30 mins.>   errordeleted	processedGiving up on waiting for file  to finish processing after 	 seconds.timerZ   status_sleepRuntimeErrorr-   r{   ry   rz   TERMINAL_STATESstartr8   r0   r0   r1   wait_for_processing  s   




	zFiles.wait_for_processing)r%   r   r&   r'   r8   r   r9   r:   r4   r;   r5   r<   r6   r=   r7   r>   r&   r   rR   rL   r4   r;   r5   r<   r6   r=   r7   r>   r&   r   )r9   r]   r4   r;   r5   r<   r6   r=   r7   r>   r&   r^   rR   rL   r4   r;   r5   r<   r6   r=   r7   r>   r&   r	   rR   rL   r4   r;   r5   r<   r6   r=   r7   r>   r&   r   rR   rL   r4   r;   r5   r<   r6   r=   r7   r>   r&   rL   r{   rL   ry   r|   rz   r|   r&   r   __name__
__module____qualname____annotations__r+   r   rQ   rZ   rg   rl   rp   typing_extensions
deprecatedru   r   __classcell__r0   r0   r.   r1   r       L   
 J",%$c                      r"   )=r!   AsyncFilesWithRawResponser$   r%   r   r&   r'   c                   r(   r)   )r*   r+   r   r$   r,   r.   r0   r1   r+   (  r2   zAsyncFiles.__init__Nr3   r8   r   r9   r:   r4   r;   r5   r<   r6   r=   r7   r>   r   c          	   
     sp   t ||d}tttttf |dggd}|r!ddi|pi }| jdt|tj	|t
||||dtdI d	H S )
r?   r@   r8   rA   rC   rD   rE   r3   rF   NrK   rP   r0   r0   r1   rQ   ,  s$   -
zAsyncFiles.createrR   rL   c                  *   | j d| t||||dtdI dH S )rT   rU   r3   rV   NrW   rY   r0   r0   r1   rZ   p     zAsyncFiles.retriever\   r]   1AsyncPaginator[FileObject, AsyncPage[FileObject]]c                C  r_   r`   )rd   r   r   r   r   r
   re   rf   r0   r0   r1   rg     rh   zAsyncFiles.listr	   c                  r   )ri   rU   r3   rV   Nrj   rY   r0   r0   r1   rl     r   zAsyncFiles.deleter   c                  s,   | j d| dt||||dtdI dH S )rm   rU   rn   r3   rV   Nro   rY   r0   r0   r1   rp     s   
zAsyncFiles.contentrq   c                  s<   ddi|pi }| j d| dt||||dtdI dH S )rm   rr   rs   rU   rn   r3   rV   Nrt   rY   r0   r0   r1   ru     s   
zAsyncFiles.retrieve_contentrv   rw   rx   r{   ry   r|   rz   c                  s   h d}t   }| |I dH }|j|vr>| |I dH  | |I dH }t   | |kr9td| d| d|j|vs|S )r}   >   r~   r   r   Nr   r   r   r   r   r0   r0   r1   r     s   

	zAsyncFiles.wait_for_processing)r%   r   r&   r'   r   r   )r9   r]   r4   r;   r5   r<   r6   r=   r7   r>   r&   r   r   r   r   r   r   r0   r0   r.   r1   r!   %  r   c                   @     e Zd ZdddZdS )	r#   rH   r    r&   r'   c                 C  L   t |j| _t |j| _t |j| _t |j| _t |j| _t |j| _d S r)   )r   rQ   rZ   rg   rl   rp   ru   r-   rH   r0   r0   r1   r+   -  $   
zFilesWithRawResponse.__init__N)rH   r    r&   r'   r   r   r   r+   r0   r0   r0   r1   r#   ,      r#   c                   @  r   )	r   rH   r!   r&   r'   c                 C  r   r)   )r   rQ   rZ   rg   rl   rp   ru   r   r0   r0   r1   r+   C  r   z"AsyncFilesWithRawResponse.__init__N)rH   r!   r&   r'   r   r0   r0   r0   r1   r   B  r   r   )/
__future__r   r   r   typingr   r   r   r   httpxtypesr   r	   r
   r   _typesr   r   r   r   r   r   _utilsr   r   r   	_resourcer   r   	_responser   r   
paginationr   r   _base_clientr   r   r   _clientr   r   __all__r    r!   r#   r   r0   r0   r0   r1   <module>   s0      	  	