
    Iij                       S SK Jr  S SKrS SKrS SKJrJr  S SKJr  S SKrSSK	J
r
  SSKJrJr  SSKJrJrJrJrJrJr  SS	KJrJrJrJr  SS
KJr  SSKJrJr  SSKJ r J!r!J"r"J#r#J$r$J%r%  SSK&J'r'J(r(  SSK)J*r*J+r+  SSK,J-r-  SSK.J/r/  SS/r0 " S S\5      r1 " S S\5      r2 " S S5      r3 " S S5      r4 " S S5      r5 " S S5      r6g)    )annotationsN)Mappingcast)Literal   )_legacy_response)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)SyncPage	AsyncPage)AsyncPaginatormake_request_options)
FileObject)FileDeletedFiles
AsyncFilesc                     \ rS rSr\SS j5       r\SS j5       rSSS\S.             SS jjrSSS\S.           SS jjr	\SSS\S.           SS	 jjr
SSS\S.           SS
 jjrSSS\S.           SS jjr\R                  " S5      SSS\S.           SS jj5       rSSS.       SS jjrSrg)r$   *   c                    [        U 5      $ N)FilesWithRawResponseselfs    </venv/lib/python3.13/site-packages/openai/resources/files.pywith_raw_responseFiles.with_raw_response+   s    #D))    c                    [        U 5      $ r)   )FilesWithStreamingResponser+   s    r-   with_streaming_responseFiles.with_streaming_response/   s    )$//r0   Nextra_headersextra_query
extra_bodytimeoutc                   [        UUS.5      n[        [        [        [        [
        4   U5      S//S9nSS0U=(       d    0 EnU R                  S[        U[        R                  5      U[        X4XVS9[        S9$ )	  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 100 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
filepurposer=   pathsContent-Typemultipart/form-data/filesr5   bodyfilesoptionscast_to)r   r   r   r   strobject_postr   r
   FileCreateParamsr!   r"   	r,   r=   r>   r6   r7   r8   r9   rE   rF   s	            r-   createFiles.create3   s    p  "
 d73;#7>xjQ ()>X=CVTVXzz '9'J'JK(+Q[   
 	
r0   c          
     n    U(       d  [        SU< 35      eU R                  SU 3[        X#XES9[        S9$ )&  
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   rG   rH   
ValueError_getr!   r"   r,   file_idr6   r7   r8   r9   s         r-   retrieveFiles.retrieve   sO    . UV]U`abbyygY(+Q[   
 	
r0   r>   r6   r7   r8   r9   c                   U R                  S[        [           [        UUUU[	        SU0[
        R                  5      S9[        S9$ aq  
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
rC   r>   )r6   r7   r8   r9   query)pagerG   model)_get_api_listr   r"   r!   r   r	   FileListParamsr,   r>   r6   r7   r8   r9   s         r-   list
Files.list   sV    2 !!*%(+'%%y'&:<L<[<[\  " 
 	
r0   c          
     n    U(       d  [        SU< 35      eU R                  SU 3[        X#XES9[        S9$ )
  
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
rR   rS   r5   rT   rV   _deleter!   r#   rX   s         r-   deleteFiles.delete   sO    . UV]U`abb||gY(+Q[    
 	
r0   c          
         U(       d  [        SU< 35      eSS0U=(       d    0 EnU R                  SU S3[        X#XES9[        R                  S9$ )'  
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
rR   Acceptapplication/binaryrS   /contentr5   rT   rV   rW   r!   r   HttpxBinaryResponseContentrX   s         r-   contentFiles.content   sl    . UV]U`abb!#7QM<ORQyygYh'(+Q[ %??  
 	
r0   .The `.content()` method should be used insteadc          
     p    U(       d  [        SU< 35      eU R                  SU S3[        X#XES9[        S9$ )rn   rR   rS   rq   r5   rT   rV   rW   r!   rI   rX   s         r-   retrieve_contentFiles.retrieve_content
  sQ    0 UV]U`abbyygYh'(+Q[   
 	
r0         @  poll_intervalmax_wait_secondsc               >   1 Skn[         R                   " 5       nU R                  U5      nUR                  U;  ab  U R                  U5        U R                  U5      n[         R                   " 5       U-
  U:  a  [	        SU SU S35      eUR                  U;  a  Mb  U$ )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,   idr~   r   TERMINAL_STATESstartr=   s          r-   wait_for_processingFiles.wait_for_processing,  s     <		}}R kk0KK&==$Dyy{U"%55"4RD8TUeTffop  kk0 r0    )returnr*   )r   r2   r=   r   r>   z5Literal['assistants', 'batch', 'fine-tune', 'vision']r6   Headers | Noner7   Query | Noner8   Body | Noner9   'float | httpx.Timeout | None | NotGivenr   r"   rY   rI   r6   r   r7   r   r8   r   r9   r   r   r"   )r>   str | NotGivenr6   r   r7   r   r8   r   r9   r   r   zSyncPage[FileObject]rY   rI   r6   r   r7   r   r8   r   r9   r   r   r#   rY   rI   r6   r   r7   r   r8   r   r9   r   r   z+_legacy_response.HttpxBinaryResponseContentrY   rI   r6   r   r7   r   r8   r   r9   r   r   rI   r   rI   r~   floatr   r   r   r"   __name__
__module____qualname____firstlineno__r   r.   r3   r   rN   rZ   re   rk   rt   typing_extensions
deprecatedry   r   __static_attributes__r   r0   r-   r$   r$   *   sl   * * 0 0 )-$("&;DK
 K
 G	K
 &K
 "K
  K
 9K
 
K
f )-$("&;D

 &
 "
  
 9
 

H #, )-$("&;D$
  $
 &$
 "$
  $
 9$
 
$
X )-$("&;D

 &
 "
  
 9
 

N )-$("&;D 
 
 & 
 " 
   
 9 
 
5 
D !!"RS )-$("&;D

 &
 "
  
 9
 

 T
J  #") 	
   
 r0   c                     \ rS rSr\SS j5       r\SS j5       rSSS\S.             SS jjrSSS\S.           SS jjr	\SSS\S.           SS	 jjr
SSS\S.           SS
 jjrSSS\S.           SS jjr\R                  " S5      SSS\S.           SS jj5       rSSS.       SS jjrSrg)r%   iD  c                    [        U 5      $ r)   )AsyncFilesWithRawResponser+   s    r-   r.   AsyncFiles.with_raw_responseE  s    (..r0   c                    [        U 5      $ r)   )AsyncFilesWithStreamingResponser+   s    r-   r3   "AsyncFiles.with_streaming_responseI  s    .t44r0   Nr5   c               (  #    [        UUS.5      n[        [        [        [        [
        4   U5      S//S9nSS0U=(       d    0 EnU R                  S[        U[        R                  5      I Sh  vN U[        X4XVS9[        S	9I Sh  vN $  N N7f)
r;   r<   r=   r?   rA   rB   rC   Nr5   rD   )r   r   r   r   rI   rJ   rK   r   r
   rL   r!   r"   rM   s	            r-   rN   AsyncFiles.createM  s     p  "
 d73;#7>xjQ ()>X=CVTVXZZ,T3E3V3VWW(+Q[    
 
 	
W
s$   A.B0B
1B	B
BBc          
        #    U(       d  [        SU< 35      eU R                  SU 3[        X#XES9[        S9I Sh  vN $  N7f)rQ   rR   rS   r5   rT   NrU   rX   s         r-   rZ   AsyncFiles.retrieve  s\     . UV]U`abbYYgY(+Q[   
 
 	
 
   :AAAr\   c                   U R                  S[        [           [        UUUU[	        SU0[
        R                  5      S9[        S9$ r^   )rb   r   r"   r!   r   r	   rc   rd   s         r-   re   AsyncFiles.list  sV    2 !!:&(+'%%y'&:<L<[<[\  " 
 	
r0   c          
        #    U(       d  [        SU< 35      eU R                  SU 3[        X#XES9[        S9I Sh  vN $  N7f)rh   rR   rS   r5   rT   Nri   rX   s         r-   rk   AsyncFiles.delete  s\     . UV]U`abb\\gY(+Q[   " 
 
 	
 
r   c          
        #    U(       d  [        SU< 35      eSS0U=(       d    0 EnU R                  SU S3[        X#XES9[        R                  S9I Sh  vN $  N7f)	rn   rR   ro   rp   rS   rq   r5   rT   Nrr   rX   s         r-   rt   AsyncFiles.content  sy     . UV]U`abb!#7QM<ORQYYgYh'(+Q[ %??  
 
 	
 
s   AAAArv   c          
        #    U(       d  [        SU< 35      eU R                  SU S3[        X#XES9[        S9I Sh  vN $  N7f)rn   rR   rS   rq   r5   rT   Nrx   rX   s         r-   ry   AsyncFiles.retrieve_content$  s^     0 UV]U`abbYYgYh'(+Q[   
 
 	
 
s   ;AAAr{   r|   r}   c                 #    1 Skn[         R                   " 5       nU R                  U5      I Sh  vN nUR                  U;  ar  U R                  U5      I Sh  vN   U R                  U5      I Sh  vN n[         R                   " 5       U-
  U:  a  [	        SU SU S35      eUR                  U;  a  Mr  U$  N Na NJ7f)r   >   r   r   r   Nr   r   r   r   r   s          r-   r   AsyncFiles.wait_for_processingF  s      <		]]2&&kk0++m,,,r**Dyy{U"%55"4RD8TUeTffop  kk0  ',*s:   .B?B9(B?B;B?2B=3AB?7B?;B?=B?r   )r   r   )r   r   r   r   )r>   r   r6   r   r7   r   r8   r   r9   r   r   z1AsyncPaginator[FileObject, AsyncPage[FileObject]]r   r   r   r   r   r   r0   r-   r%   r%   D  sl   / / 5 5 )-$("&;DK
 K
 G	K
 &K
 "K
  K
 9K
 
K
f )-$("&;D

 &
 "
  
 9
 

H #, )-$("&;D$
  $
 &$
 "$
  $
 9$
 
;$
X )-$("&;D

 &
 "
  
 9
 

N )-$("&;D 
 
 & 
 " 
   
 9 
 
5 
D !!"RS )-$("&;D

 &
 "
  
 9
 

 T
J  #") 	
   
 r0   c                      \ rS rSrSS jrSrg)r*   i^  c                   Xl         [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR
                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        g r)   )	_filesr   to_raw_response_wrapperrN   rZ   re   rk   rt   ry   r,   rF   s     r-   __init__FilesWithRawResponse.__init___  s    &>>LL
 )@@NN
 %<<JJ
	 '>>LL
 (??MM
 44&& 	r0   r   rt   rN   rk   re   rZ   ry   NrF   r$   r   Noner   r   r   r   r   r   r   r0   r-   r*   r*   ^      
r0   r*   c                      \ rS rSrSS jrSrg)r   ix  c                   Xl         [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR
                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        [        R                  " UR                  5      U l        g r)   )	r   r   async_to_raw_response_wrapperrN   rZ   re   rk   rt   ry   r   s     r-   r   "AsyncFilesWithRawResponse.__init__y  s    &DDLL
 )FFNN
 %BBJJ
	 'DDLL
 (EEMM
 ::&& 	r0   r   NrF   r%   r   r   r   r   r0   r-   r   r   x  r   r0   r   c                      \ rS rSrSS jrSrg)r2   i  c                R   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  [        5      U l        [        UR                  5      U l	        g r)   )
r   r   rN   rZ   re   rk   r   rt   r   ry   r   s     r-   r   #FilesWithStreamingResponse.__init__  s    2LL
 5NN
 1JJ
	 3LL
 ;MM%

 )&& 	r0   r   Nr   r   r   r0   r-   r2   r2         
r0   r2   c                      \ rS rSrSS jrSrg)r   i  c                R   Xl         [        UR                  5      U l        [        UR                  5      U l        [        UR                  5      U l        [        UR
                  5      U l        [        UR                  [        5      U l        [        UR                  5      U l	        g r)   )
r   r   rN   rZ   re   rk   r   rt   r   ry   r   s     r-   r   (AsyncFilesWithStreamingResponse.__init__  s    8LL
 ;NN
 7JJ
	 9LL
 AMM*

 /&& 	r0   r   Nr   r   r   r0   r-   r   r     r   r0   r   )7
__future__r   r   r   typingr   r   r   httpx r   typesr	   r
   _typesr   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#   __all__r$   r%   r*   r   r2   r   r   r0   r-   <module>r      s    #     %   8 I I  & 9  - + ,L
!WO WtW! Wt
 
4
 
4
 
6
 
r0   