
    .hZv                       d dl mZ d dlZd dlZd dlmZmZ d dlmZ d dlZddl	m
Z
 ddlmZmZmZ ddlmZmZmZmZmZmZmZmZ dd	lmZmZmZmZ dd
lmZ ddl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+ ddl,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3mZ ddgZ4 G d de       Z5 G d de!      Z6 G d d      Z7 G d d      Z8 G d d      Z9 G d d      Z:y)    )annotationsN)Mappingcast)Literal   )_legacy_response)FilePurposefile_list_paramsfile_create_params)BodyOmitQueryHeadersNotGiven	FileTypesomit	not_given)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            	         e Zd Zedd       Zedd       Zeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZ	eeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z
ddded	 	 	 	 	 	 	 	 	 	 	 dd
Zddded	 	 	 	 	 	 	 	 	 	 	 ddZ ej                  d      ddded	 	 	 	 	 	 	 	 	 	 	 dd       Zddd	 	 	 	 	 	 	 ddZy)r'   c                    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
        )FilesWithRawResponseselfs    W/var/www/html/axiom-chatbot/venv/lib/python3.12/site-packages/openai/resources/files.pywith_raw_responsezFiles.with_raw_response$   s     $D))    c                    t        |       S 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
        )FilesWithStreamingResponser-   s    r/   with_streaming_responsezFiles.with_streaming_response.   s     *$//r1   Nexpires_afterextra_headersextra_query
extra_bodytimeoutc                  t        |||d      }t        t        t        t        t
        f   |      dgg      }	ddi|xs i }| j                  dt        |t        j                        |	t        ||||      t              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 1 TB.

        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. One of: - `assistants`: Used in the
              Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
              fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
              Flexible file type for any purpose - `evals`: Used for eval data sets

          expires_after: The expiration policy for a file. By default, files with `purpose=batch` expire
              after 30 days and all other files are persisted until they are manually deleted.

          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
        filepurposer7   r?   pathsContent-Typemultipart/form-data/filesr8   r9   r:   r;   bodyfilesoptionscast_to)r   r   r   r   strobject_postr   r   FileCreateParamsr$   r%   
r.   r?   r@   r7   r8   r9   r:   r;   rH   rI   s
             r/   createzFiles.create7   s    p  "!.
 d73;#7>xjQ ()>X=CVTVXzz '9'J'JK(+Q[el   
 	
r1   rF   c          	     r    |st        d|      | j                  d| t        ||||      t              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/rF   rJ   rK   
ValueError_getr$   r%   r.   file_idr8   r9   r:   r;   s         r/   retrievezFiles.retrieve   sT    . UV]U`abbyygY(+Q[el   
 	
r1   afterlimitorderr@   r8   r9   r:   r;   c                   | j                  dt        t           t        ||||t	        ||||dt
        j                              t              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
        rE   )r^   r_   r`   r@   )r8   r9   r:   r;   query)pagerJ   model)_get_api_listr!   r%   r$   r   r
   FileListParams	r.   r^   r_   r`   r@   r8   r9   r:   r;   s	            r/   listz
Files.list   se    P !!
+(+'%%!&!&!&#*	 %33 % " 
 	
r1   c          	     r    |st        d|      | j                  d| t        ||||      t              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
        rT   rU   rF   rV   rX   _deleter$   r&   rZ   s         r/   deletezFiles.delete   sT    . UV]U`abb||gY(+Q[el    
 	
r1   c          	         |st        d|      ddi|xs i }| j                  d| dt        ||||      t        j                        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
        rT   Acceptapplication/binaryrU   /contentrF   rV   rX   rY   r$   r   HttpxBinaryResponseContentrZ   s         r/   contentzFiles.content  sq    . UV]U`abb!#7QM<ORQyygYh'(+Q[el %??  
 	
r1   .The `.content()` method should be used insteadc          	     t    |st        d|      | j                  d| dt        ||||      t              S )rp   rT   rU   rs   rF   rV   rX   rY   r$   rL   rZ   s         r/   retrieve_contentzFiles.retrieve_content&  sV    0 UV]U`abbyygYh'(+Q[el   
 	
r1         @  poll_intervalmax_wait_secondsc               .   h d}t        j                          }| j                  |      }|j                  |vr]| j                  |       | j                  |      }t        j                          |z
  |kD  rt	        d| d| d      |j                  |vr]|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.   idr~   r   TERMINAL_STATESstartr?   s          r/   wait_for_processingzFiles.wait_for_processingH  s     <		}}R kk0KK&==$Dyy{U"%55"4RD8TUeTffop  kk0 r1   )returnr,   )r   r4   r?   r   r@   r	   r7   z&file_create_params.ExpiresAfter | Omitr8   Headers | Noner9   Query | Noner:   Body | Noner;   'float | httpx.Timeout | None | NotGivenr   r%   r[   rL   r8   r   r9   r   r:   r   r;   r   r   r%   )r^   
str | Omitr_   
int | Omitr`   Literal['asc', 'desc'] | Omitr@   r   r8   r   r9   r   r:   r   r;   r   r   zSyncCursorPage[FileObject]r[   rL   r8   r   r9   r   r:   r   r;   r   r   r&   r[   rL   r8   r   r9   r   r:   r   r;   r   r   z+_legacy_response.HttpxBinaryResponseContentr[   rL   r8   r   r9   r   r:   r   r;   r   r   rL   r   rL   r~   floatr   r   r   r%   __name__
__module____qualname__r   r0   r5   r   r   rQ   r\   ri   rn   rv   typing_extensions
deprecatedrz   r    r1   r/   r'   r'   #   s   * * 0 0 AE )-$("&;DL
 L
 	L

 >L
 &L
 "L
  L
 9L
 
L
h )-$("&;D

 &
 "
  
 9
 

H ! /3" )-$("&;D;
 ;
 	;

 -;
 ;
 &;
 ";
  ;
 9;
 
$;
F )-$("&;D

 &
 "
  
 9
 

N )-$("&;D 
 
 & 
 " 
   
 9 
 
5 
D "!!"RS )-$("&;D

 &
 "
  
 9
 

 T
J  #") 	
   
r1   c            	         e Zd Zedd       Zedd       Zeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZ	eeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z
ddded	 	 	 	 	 	 	 	 	 	 	 dd
Zddded	 	 	 	 	 	 	 	 	 	 	 ddZ ej                  d      ddded	 	 	 	 	 	 	 	 	 	 	 dd       Zddd	 	 	 	 	 	 	 ddZy)r(   c                    t        |       S r+   )AsyncFilesWithRawResponser-   s    r/   r0   zAsyncFiles.with_raw_responsea  s     )..r1   c                    t        |       S r3   )AsyncFilesWithStreamingResponser-   s    r/   r5   z"AsyncFiles.with_streaming_responsek  s     /t44r1   Nr6   c               6  K   t        |||d      }t        t        t        t        t
        f   |      dgg      }	ddi|xs i }| j                  dt        |t        j                         d{   |	t        ||||      t        	       d{   S 7 %7 w)
r=   r>   r?   rA   rC   rD   rE   NrF   rG   )r   r   r   r   rL   rM   rN   r   r   rO   r$   r%   rP   s
             r/   rQ   zAsyncFiles.createt  s     p  "!.
 d73;#7>xjQ ()>X=CVTVXZZ,T3E3V3VWW(+Q[el    
 
 	
W
s$   A-B/B
0 BBBBrF   c          	        K   |st        d|      | j                  d| t        ||||      t               d{   S 7 w)rS   rT   rU   rF   rV   NrW   rZ   s         r/   r\   zAsyncFiles.retrieve  sb     . UV]U`abbYYgY(+Q[el   
 
 	
 
   <AAAr]   c                   | j                  dt        t           t        ||||t	        ||||dt
        j                              t              S rb   )rf   r"   r%   r$   r   r
   rg   rh   s	            r/   ri   zAsyncFiles.list  se    P !! ,(+'%%!&!&!&#*	 %33 % " 
 	
r1   c          	        K   |st        d|      | j                  d| t        ||||      t               d{   S 7 w)rk   rT   rU   rF   rV   Nrl   rZ   s         r/   rn   zAsyncFiles.delete   sb     . UV]U`abb\\gY(+Q[el   " 
 
 	
 
r   c          	        K   |st        d|      ddi|xs i }| j                  d| dt        ||||      t        j                         d{   S 7 w)	rp   rT   rq   rr   rU   rs   rF   rV   Nrt   rZ   s         r/   rv   zAsyncFiles.contentA  s     . UV]U`abb!#7QM<ORQYYgYh'(+Q[el %??  
 
 	
 
s   AAAArw   c          	        K   |st        d|      | j                  d| dt        ||||      t               d{   S 7 w)rp   rT   rU   rs   rF   rV   Nry   rZ   s         r/   rz   zAsyncFiles.retrieve_contentc  sd     0 UV]U`abbYYgYh'(+Q[el   
 
 	
 
s   =AA Ar{   r|   r}   c               r  K   h d}t        j                          }| j                  |       d{   }|j                  |vrm| j                  |       d{    | j                  |       d{   }t        j                          |z
  |kD  rt	        d| d| d      |j                  |vrm|S 7 7 \7 Ew)r   >   r   r   r   Nr   r   r   r   r   s          r/   r   zAsyncFiles.wait_for_processing  s      <		]]2&&kk0++m,,,r**Dyy{U"%55"4RD8TUeTffop  kk0  ',*s9   -B7B1&B7B3B7/B50>B7/B73B75B7)r   r   )r   r   r   r   )r^   r   r_   r   r`   r   r@   r   r8   r   r9   r   r:   r   r;   r   r   z7AsyncPaginator[FileObject, AsyncCursorPage[FileObject]]r   r   r   r   r   r   r1   r/   r(   r(   `  s   / / 5 5 AE )-$("&;DL
 L
 	L

 >L
 &L
 "L
  L
 9L
 
L
h )-$("&;D

 &
 "
  
 9
 

H ! /3" )-$("&;D;
 ;
 	;

 -;
 ;
 &;
 ";
  ;
 9;
 
A;
F )-$("&;D

 &
 "
  
 9
 

N )-$("&;D 
 
 & 
 " 
   
 9 
 
5 
D "!!"RS )-$("&;D

 &
 "
  
 9
 

 T
J  #") 	
   
r1   c                      e Zd ZddZy)r,   c                   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y N)	_filesr   to_raw_response_wrapperrQ   r\   ri   rn   rv   rz   r.   rI   s     r/   __init__zFilesWithRawResponse.__init__  s    &>>LL
 )@@NN
 %<<JJ
	 '>>LL
 (??MM
 44&& 	r1   NrI   r'   r   Noner   r   r   r   r   r1   r/   r,   r,         
r1   r,   c                      e Zd ZddZy)r   c                   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y r   )	r   r   async_to_raw_response_wrapperrQ   r\   ri   rn   rv   rz   r   s     r/   r   z"AsyncFilesWithRawResponse.__init__  s    &DDLL
 )FFNN
 %BBJJ
	 'DDLL
 (EEMM
 ::&& 	r1   NrI   r(   r   r   r   r   r1   r/   r   r     r   r1   r   c                      e Zd ZddZy)r4   c                T   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                  t              | _        t        |j                        | _	        y r   )
r   r   rQ   r\   ri   rn   r   rv   r   rz   r   s     r/   r   z#FilesWithStreamingResponse.__init__  s    2LL
 5NN
 1JJ
	 3LL
 ;MM%

 )&& 	r1   Nr   r   r   r1   r/   r4   r4         
r1   r4   c                      e Zd ZddZy)r   c                T   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                  t              | _        t        |j                        | _	        y r   )
r   r   rQ   r\   ri   rn   r    rv   r   rz   r   s     r/   r   z(AsyncFilesWithStreamingResponse.__init__  s    8LL
 ;NN
 7JJ
	 9LL
 AMM*

 /&& 	r1   Nr   r   r   r1   r/   r   r     r   r1   r   );
__future__r   r   r   typingr   r   r   httpx r   typesr	   r
   r   _typesr   r   r   r   r   r   r   r   _utilsr   r   r   r   _compatr   	_resourcer   r   	_responser   r   r   r   r   r    
paginationr!   r"   _base_clientr#   r$   types.file_objectr%   types.file_deletedr&   types.file_purpose__all__r'   r(   r,   r   r4   r   r   r1   r/   <module>r      s    #     %   E E U U U \ \ % 9  9 ? * , ,L
!zO zz	z! zz	
 
4
 
4
 
6
 
r1   