a
    !fBX                     @  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rd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                	      s0  e Zd ZU ded< ddd fddZddded	d
dddddddddZddded	dddddddddZedddeddddddddddZddded	ddddddddd Z	ddded	dddddd!dd"d#Z
ed$ddded	dddddddd%d&Zd'd(d)dd*d*dd+d,d-Z  ZS ).r    FilesWithRawResponsewith_raw_responser   Noneclientreturnc                   s   t  | t| | _d S N)super__init__r"   r#   selfr&   	__class__ W/var/www/html/python-backend/venv/lib/python3.9/site-packages/openai/resources/files.pyr*   !   s    zFiles.__init__Nextra_headersextra_query
extra_bodytimeoutr   "Literal['fine-tune', 'assistants']Headers | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr   filepurposer2   r3   r4   r5   r'   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
        r<   r=   r<   pathsContent-Typemultipart/form-data/filesr1   bodyfilesoptionscast_tor   r   r   r   strobject_postr   r   ZFileCreateParamsr   r   	r,   r<   r=   r2   r3   r4   r5   rF   rG   r/   r/   r0   create%   s"    -
zFiles.createrK   file_idr2   r3   r4   r5   r'   c                C  s"   | 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/r1   rH   rI   _getr   r   r,   rQ   r2   r3   r4   r5   r/   r/   r0   retrievei   s    zFiles.retriever=   r2   r3   r4   r5   str | NotGivenzSyncPage[FileObject]r=   r2   r3   r4   r5   r'   c                C  s0   | 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
        rD   r=   )r2   r3   r4   r5   query)pagerH   model)_get_api_listr   r   r   r   r
   FileListParamsr,   r=   r2   r3   r4   r5   r/   r/   r0   list   s    z
Files.listr	   c                C  s"   | j d| t||||dtdS )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
        rS   r1   rT   _deleter   r	   rW   r/   r/   r0   delete   s    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
        rS   /contentr1   rT   rV   r   r   rW   r/   r/   r0   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 )rh   Acceptapplication/jsonrS   ri   r1   rT   rV   r   rK   rW   r/   r/   r0   retrieve_content   s    
zFiles.retrieve_content      @  poll_intervalmax_wait_secondsfloatidrt   ru   r'   c                C  sd   h d}t   }| |}|j|vr`| | | |}t   | |krtd| d| dq|S )EWaits for the given file to be processed, default timeout is 30 mins.>   deletederror	processedGiving up on waiting for file  to finish processing after 	 seconds.timerX   statusZ_sleepRuntimeErrorr,   rx   rt   ru   ZTERMINAL_STATESstartr<   r/   r/   r0   wait_for_processing  s    



zFiles.wait_for_processing__name__
__module____qualname____annotations__r*   r   rO   rX   rc   rg   rk   typing_extensions
deprecatedrp   r   __classcell__r/   r/   r-   r0   r       sJ   
J",%$c                	      s0  e Zd ZU ded< ddd fddZddded	d
dddddddddZddded	dddddddddZedddeddddddddddZddded	ddddddddd Z	ddded	dddddd!dd"d#Z
ed$ddded	dddddddd%d&Zd'd(d)dd*d*dd+d,d-Z  ZS ).r!   AsyncFilesWithRawResponser#   r   r$   r%   c                   s   t  | t| | _d S r(   )r)   r*   r   r#   r+   r-   r/   r0   r*   (  s    zAsyncFiles.__init__Nr1   r   r6   r7   r8   r9   r:   r   r;   c          	   
     sn   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?   r<   r@   rB   rC   rD   r1   rE   NrJ   rN   r/   r/   r0   rO   ,  s"    -
zAsyncFiles.createrK   rP   c                  s(   | j d| t||||dtdI dH S )rR   rS   r1   rT   NrU   rW   r/   r/   r0   rX   p  s    zAsyncFiles.retrieverY   rZ   z1AsyncPaginator[FileObject, AsyncPage[FileObject]]r[   c                C  s0   | j dtt t||||td|itjdtdS r\   )r`   r   r   r   r   r
   ra   rb   r/   r/   r0   rc     s    zAsyncFiles.listr	   c                  s(   | j d| t||||dtdI dH S )rd   rS   r1   rT   Nre   rW   r/   r/   r0   rg     s    zAsyncFiles.deleter   c                  s*   | j d| dt||||dtdI dH S )rh   rS   ri   r1   rT   Nrj   rW   r/   r/   r0   rk     s    
zAsyncFiles.contentrl   c                  s:   ddi|pi }| j d| dt||||dtdI dH S )rh   rm   rn   rS   ri   r1   rT   Nro   rW   r/   r/   r0   rp     s    
zAsyncFiles.retrieve_contentrq   rr   rs   rv   rw   c                  sv   h d}t   }| |I dH }|j|vrr| |I dH  | |I dH }t   | |kr td| d| dq |S )ry   >   rz   r{   r|   Nr}   r~   r   r   r   r/   r/   r0   r     s    
zAsyncFiles.wait_for_processingr   r/   r/   r-   r0   r!   %  sJ   
J",%$c                   @  s   e Zd ZdddddZdS )r"   r    r$   rG   r'   c                 C  sL   t |j| _t |j| _t |j| _t |j| _t |j| _t |j| _d S r(   )r   rO   rX   rc   rg   rk   rp   r,   rG   r/   r/   r0   r*   -  s$    zFilesWithRawResponse.__init__Nr   r   r   r*   r/   r/   r/   r0   r"   ,  s   r"   c                   @  s   e Zd ZdddddZdS )r   r!   r$   r   c                 C  sL   t |j| _t |j| _t |j| _t |j| _t |j| _t |j| _d S r(   )r   rO   rX   rc   rg   rk   rp   r   r/   r/   r0   r*   C  s$    z"AsyncFilesWithRawResponse.__init__Nr   r/   r/   r/   r0   r   B  s   r   )/
__future__r   r   r   typingr   r   r   r   Zhttpxtypesr   r	   r
   r   _typesr   r   r   r   r   r   _utilsr   r   r   Z	_resourcer   r   	_responser   r   Z
paginationr   r   Z_base_clientr   r   r   Z_clientr   r   __all__r    r!   r"   r   r/   r/   r/   r0   <module>   s.      	  	