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

���g�u�@s|ddlmZddlZddlZddlmZmZddlmZddlZddl	m
Z
ddlmZm
Z
mZddlmZmZmZmZmZmZdd	lmZmZmZmZdd
lmZddlmZmZddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&dd
l'm(Z(m)Z)ddl*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1mZddgZ2Gdd�de�Z3Gdd�de�Z4Gdd�d�Z5Gdd�d�Z6Gdd�d�Z7Gdd�d�Z8dS)�)�annotationsN)�Mapping�cast)�Literal�)�_legacy_response)�FilePurpose�file_list_params�file_create_params)�	NOT_GIVEN�Body�Query�Headers�NotGiven�	FileTypes)�
extract_files�maybe_transform�deepcopy_minimal�async_maybe_transform)�cached_property)�SyncAPIResource�AsyncAPIResource)�StreamedBinaryAPIResponse�AsyncStreamedBinaryAPIResponse�to_streamed_response_wrapper�"async_to_streamed_response_wrapper�#to_custom_streamed_response_wrapper�)async_to_custom_streamed_response_wrapper)�SyncCursorPage�AsyncCursorPage)�AsyncPaginator�make_request_options)�
FileObject)�FileDeleted)r�Files�
AsyncFilesc	@��eZdZed9dd��Zed:dd��Zddded	�d;dd�Zddded	�d<dd�Zeeeeddded�d=d%d&�Z	ddded	�d>d(d)�Z
ddded	�d?d+d,�Ze�
d-�ddded	�d@d.d/��Zd0d1d2�dAd7d8�ZdS)Br$�return�FilesWithRawResponsecC�t|�S�a
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
        )r(��self�r-�A/usr/local/lib/python3.10/dist-packages/openai/resources/files.py�with_raw_response)�zFiles.with_raw_response�FilesWithStreamingResponsecCr)�z�
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
        )r1r+r-r-r.�with_streaming_response3�zFiles.with_streaming_responseN��
extra_headers�extra_query�
extra_body�timeout�filer�purposerr6�Headers | Noner7�Query | Noner8�Body | Noner9�'float | httpx.Timeout | None | NotGivenr"c	
Csdt||d��}tttttf|�dggd�}ddi|pi�}|jdt|tj	�|t
||||d�td�S)	�Upload a file that can be used across various endpoints.

        Individual files can be
        up to 512 MB, and the size of all files uploaded by one organization can be up
        to 100 GB.

        The Assistants API supports files up to 2 million tokens and of specific file
        types. See the
        [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
        details.

        The Fine-tuning API only supports `.jsonl` files. The input also has certain
        required formats for fine-tuning
        [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
        [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
        models.

        The Batch API only supports `.jsonl` files up to 200 MB in size. The input also
        has a specific required
        [format](https://platform.openai.com/docs/api-reference/batch/request-input).

        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 "assistants" for
              [Assistants](https://platform.openai.com/docs/api-reference/assistants) and
              [Message](https://platform.openai.com/docs/api-reference/messages) files,
              "vision" for Assistants image file inputs, "batch" for
              [Batch API](https://platform.openai.com/docs/guides/batch), and "fine-tune" for
              [Fine-tuning](https://platform.openai.com/docs/api-reference/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�/filesr5��body�files�options�cast_to)rrrr�str�object�_postrr
�FileCreateParamsr!r"�	r,r:r;r6r7r8r9rHrIr-r-r.�create<s 8��
��zFiles.create�file_idrLcC�4|s	td|����|jd|��t||||d�td�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
        �6Expected a non-empty value for `file_id` but received �/files/r5�rJrK��
ValueError�_getr!r"�r,rRr6r7r8r9r-r-r.�retrieve����zFiles.retrieve��after�limit�orderr;r6r7r8r9r_�str | NotGivenr`�int | NotGivenra�!Literal['asc', 'desc'] | NotGiven�SyncCursorPage[FileObject]c	C�6|jdttt||||t||||d�tj�d�td�S�a�Returns a list of files.

        Args:
          after: A cursor for use in pagination.

        `after` is an object ID that defines your place
              in the list. For instance, if you make a list request and receive 100 objects,
              ending with obj_foo, your subsequent call can include after=obj_foo in order to
              fetch the next page of the list.

          limit: A limit on the number of objects to be returned. Limit can range between 1 and
              10,000, and the default is 10,000.

          order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
              order and `desc` for descending order.

          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
        rF)r_r`rar;)r6r7r8r9�query)�pagerJ�model)�
_get_api_listrr"r!rr	�FileListParams�	r,r_r`rar;r6r7r8r9r-r-r.�list��&(����z
Files.listr#cCrS)�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
        rUrVr5rW�rY�_deleter!r#r[r-r-r.�delete�r]zFiles.delete�+_legacy_response.HttpxBinaryResponseContentcCsH|s	td|����ddi|pi�}|jd|�d�t||||d�tjd�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�Accept�application/binaryrV�/contentr5rW�rYrZr!r�HttpxBinaryResponseContentr[r-r-r.�contents
��z
Files.content�.The `.content()` method should be used insteadcCs6|s	td|����|jd|�d�t||||d�td�S)rurUrVrxr5rW�rYrZr!rLr[r-r-r.�retrieve_content*s
��zFiles.retrieve_content�@���
poll_interval�max_wait_seconds�idr��floatr�cCslhd�}t��}|�|�}|j|vr4|�|�|�|�}t��||kr/td|�d|�d���|j|vs|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.��timer\�status�_sleep�RuntimeError�r,r�r�r��TERMINAL_STATES�startr:r-r-r.�wait_for_processingLs



�
�	zFiles.wait_for_processing)r'r()r'r1�r:rr;rr6r<r7r=r8r>r9r?r'r"�rRrLr6r<r7r=r8r>r9r?r'r")r_rbr`rcrardr;rbr6r<r7r=r8r>r9r?r're�rRrLr6r<r7r=r8r>r9r?r'r#�rRrLr6r<r7r=r8r>r9r?r'rt�rRrLr6r<r7r=r8r>r9r?r'rL�r�rLr�r�r�r�r'r"��__name__�
__module__�__qualname__rr/r3rrQr\rnrsr{�typing_extensions�
deprecatedr~r�r-r-r-r.r$(�V	�S�$�C�'�"�%�c	@r&)Br%r'�AsyncFilesWithRawResponsecCr)r*)r�r+r-r-r.r/er0zAsyncFiles.with_raw_response�AsyncFilesWithStreamingResponsecCr)r2)r�r+r-r-r.r3or4z"AsyncFiles.with_streaming_responseNr5r:rr;rr6r<r7r=r8r>r9r?r"c	
�sr�t||d��}tttttf|�dggd�}ddi|pi�}|jdt|tj	�IdH|t
||||d�td	�IdHS)
r@rAr:rBrDrErFNr5rG)rrrrrLrMrNrr
rOr!r"rPr-r-r.rQxs"�8����zAsyncFiles.createrRrLc��<�|s
td|����|jd|��t||||d�td�IdHS)rTrUrVr5rWNrXr[r-r-r.r\�����zAsyncFiles.retriever^r_rbr`rcrard�7AsyncPaginator[FileObject, AsyncCursorPage[FileObject]]c	Crfrg)rkrr"r!rr	rlrmr-r-r.rn�rozAsyncFiles.listr#c�r�)rprUrVr5rWNrqr[r-r-r.rs#r�zAsyncFiles.deletertc�sP�|s
td|����ddi|pi�}|jd|�d�t||||d�tjd�IdHS)	rurUrvrwrVrxr5rWNryr[r-r-r.r{Ds�
��zAsyncFiles.contentr|c�s>�|s
td|����|jd|�d�t||||d�td�IdHS)rurUrVrxr5rWNr}r[r-r-r.r~fs�
��zAsyncFiles.retrieve_contentrr�r�r�r�r�r�c�s��hd�}t��}|�|�IdH}|j|vr>|�|�IdH|�|�IdH}t��||kr9td|�d|�d���|j|vs|S)r�>r�r�r�Nr�r�r�r�r�r-r-r.r��s�
�
�	zAsyncFiles.wait_for_processing)r'r�)r'r�r�r�)r_rbr`rcrardr;rbr6r<r7r=r8r>r9r?r'r�r�r�r�r�r�r-r-r-r.r%dr�c@�eZdZddd�ZdS)	r(rIr$r'�NonecC�^||_t�|j�|_t�|j�|_t�|j�|_t�|j�|_t�|j�|_t�|j�|_dS�N)	�_filesr�to_raw_response_wrapperrQr\rnrsr{r~�r,rIr-r-r.�__init__��(�������zFilesWithRawResponse.__init__N�rIr$r'r��r�r�r�r�r-r-r-r.r(��r(c@r�)	r�rIr%r'r�cCr�r�)	r�r�async_to_raw_response_wrapperrQr\rnrsr{r~r�r-r-r.r��r�z"AsyncFilesWithRawResponse.__init__N�rIr%r'r�r�r-r-r-r.r��r�r�c@r�)	r1rIr$r'r�cC�T||_t|j�|_t|j�|_t|j�|_t|j�|_t|jt�|_t|j	�|_	dSr�)
r�rrQr\rnrsrr{rr~r�r-r-r.r���*�������z#FilesWithStreamingResponse.__init__Nr�r�r-r-r-r.r1�r�r1c@r�)	r�rIr%r'r�cCr�r�)
r�rrQr\rnrsrr{rr~r�r-r-r.r��r�z(AsyncFilesWithStreamingResponse.__init__Nr�r�r-r-r-r.r��r�r�)9�
__future__rr�r��typingrrr�httpx�r�typesrr	r
�_typesrrr
rrr�_utilsrrrr�_compatr�	_resourcerr�	_responserrrrrr�
paginationrr�_base_clientr r!�types.file_objectr"�types.file_deletedr#�types.file_purpose�__all__r$r%r(r�r1r�r-r-r-r.�<module>s:  >>