o
    ^۷ii                     @  s  d dl mZ d dlmZ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mZ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 dd
lmZmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* ddl+m,Z,m-Z- ddl.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z6 ddl7m8Z8 ddl9m:Z: ddl;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ZAG dd dZBG dd dZCdS )    )annotations)ListMappingcast)chainN   )_legacy_response)BodyOmitQueryHeadersNotGiven	FileTypesomit	not_given)is_givenextract_filesmaybe_transformstrip_not_givendeepcopy_minimalasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)
BinaryAPIResponseAsyncBinaryAPIResponseStreamedBinaryAPIResponseAsyncStreamedBinaryAPIResponseto_streamed_response_wrapperto_custom_raw_response_wrapper"async_to_streamed_response_wrapper#to_custom_streamed_response_wrapper$async_to_custom_raw_response_wrapper)async_to_custom_streamed_response_wrapper)SyncPage	AsyncPage)file_list_paramsfile_upload_params)AsyncPaginatormake_request_options)!stainless_helper_header_from_file)DeletedFile)FileMetadata)AnthropicBetaParamFiles
AsyncFilesc                	   @     e Zd Zed,ddZed-ddZeeeeddded	d.ddZedddedd/d d!Z	edddedd0d#d$Z
edddedd1d&d'Zedddedd2d*d+ZdS )3r.   returnFilesWithRawResponsec                 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/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
        )r2   self r7   T/home/ubuntu/vllm_env/lib/python3.10/site-packages/anthropic/resources/beta/files.pywith_raw_response'      zFiles.with_raw_responseFilesWithStreamingResponsec                 C  r3   z
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
        )r;   r5   r7   r7   r8   with_streaming_response1      zFiles.with_streaming_responseNafter_id	before_idlimitbetasextra_headersextra_query
extra_bodytimeoutr@   
str | OmitrA   rB   
int | OmitrC   List[AnthropicBetaParam] | OmitrD   Headers | NonerE   Query | NonerF   Body | NonerG   'float | httpx.Timeout | None | NotGivenSyncPage[FileMetadata]c          	      C     i t dt|rdtdd |D dgnti|pi }ddi|p$i }| jdtt t||||t	|||dt
jdtd	S )
F  List Files

        Args:
          after_id: ID of the object to use as a cursor for pagination.

        When provided, returns the
              page of results immediately after this object.

          before_id: ID of the object to use as a cursor for pagination. When provided, returns the
              page of results immediately before this object.

          limit: Number of items to return per page.

              Defaults to `20`. Ranges from `1` to `1000`.

          betas: Optional header to specify the beta version(s) you want to use.

          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
        anthropic-beta,c                 s      | ]}t |V  qd S Nstr.0er7   r7   r8   	<genexpr>d       zFiles.list.<locals>.<genexpr>files-api-2025-04-14/v1/files?beta=truer@   rA   rB   rD   rE   rF   rG   querypageoptionsmodel)r   r   joinr   r   _get_api_listr$   r,   r)   r   r&   FileListParams	r6   r@   rA   rB   rC   rD   rE   rF   rG   r7   r7   r8   list:   <   '
z
Files.listrC   rD   rE   rF   rG   file_idrW   r+   c                C     |s	t d|i tdt|rdtdd |D dgnti|p%i }ddi|p-i }| jd| dt||||d	td
S )  
        Delete File

        Args:
          file_id: ID of the File.

          betas: Optional header to specify the beta version(s) you want to use.

          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 rR   rS   c                 s  rT   rU   rV   rX   r7   r7   r8   r[      r\   zFiles.delete.<locals>.<genexpr>r]   
/v1/files/
?beta=truerD   rE   rF   rG   rd   cast_to	
ValueErrorr   r   rf   r   r   _deleter)   r+   r6   rm   rC   rD   rE   rF   rG   r7   r7   r8   delete   *   

zFiles.deleter   c                C  s   |s	t d|ddi|pi }i tdt|r&dtdd |D dgnti|p-i }ddi|p5i }| jd	| d
t||||dtdS )  
        Download File

        Args:
          file_id: ID of the File.

          betas: Optional header to specify the beta version(s) you want to use.

          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
        rp   Acceptapplication/binaryrR   rS   c                 s  rT   rU   rV   rX   r7   r7   r8   r[      r\   z!Files.download.<locals>.<genexpr>r]   rq   /content?beta=truers   rt   )	rw   r   r   rf   r   r   _getr)   r   ry   r7   r7   r8   download   s,   

zFiles.downloadr,   c                C  rn   )  
        Get File Metadata

        Args:
          file_id: ID of the File.

          betas: Optional header to specify the beta version(s) you want to use.

          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
        rp   rR   rS   c                 s  rT   rU   rV   rX   r7   r7   r8   r[     r\   z*Files.retrieve_metadata.<locals>.<genexpr>r]   rq   rr   rs   rt   	rw   r   r   rf   r   r   r   r)   r,   ry   r7   r7   r8   retrieve_metadata   r{   zFiles.retrieve_metadatafiler   c          	   
   C  s   i t dt|rdtdd |D dgnti|pi }ddi|p$i }i t||}td|i}ttt	t
tf |dggd}d|d	< | jd
t|tj|t||||dtdS )  
        Upload File

        Args:
          file: The file to upload

          betas: Optional header to specify the beta version(s) you want to use.

          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   c                 s  rT   rU   rV   rX   r7   r7   r8   r[   3  r\   zFiles.upload.<locals>.<genexpr>r]   r   pathsmultipart/form-dataContent-Typer^   rs   bodyfilesrd   ru   )r   r   rf   r   r   "_stainless_helper_header_from_filer   r   r   r   rW   object_postr   r'   FileUploadParamsr)   r,   	r6   r   rC   rD   rE   rF   rG   r   r   r7   r7   r8   upload  s2   

zFiles.upload)r1   r2   )r1   r;   )r@   rH   rA   rH   rB   rI   rC   rJ   rD   rK   rE   rL   rF   rM   rG   rN   r1   rO   rm   rW   rC   rJ   rD   rK   rE   rL   rF   rM   rG   rN   r1   r+   )rm   rW   rC   rJ   rD   rK   rE   rL   rF   rM   rG   rN   r1   r   rm   rW   rC   rJ   rD   rK   rE   rL   rF   rM   rG   rN   r1   r,   r   r   rC   rJ   rD   rK   rE   rL   rF   rM   rG   rN   r1   r,   __name__
__module____qualname__r   r9   r=   r   r   rj   rz   r   r   r   r7   r7   r7   r8   r.   &   L    	J565c                	   @  r0   )3r/   r1   AsyncFilesWithRawResponsec                 C  r3   r4   )r   r5   r7   r7   r8   r9   N  r:   zAsyncFiles.with_raw_responseAsyncFilesWithStreamingResponsec                 C  r3   r<   )r   r5   r7   r7   r8   r=   X  r>   z"AsyncFiles.with_streaming_responseNr?   r@   rH   rA   rB   rI   rC   rJ   rD   rK   rE   rL   rF   rM   rG   rN   5AsyncPaginator[FileMetadata, AsyncPage[FileMetadata]]c          	      C  rP   )
rQ   rR   rS   c                 s  rT   rU   rV   rX   r7   r7   r8   r[     r\   z"AsyncFiles.list.<locals>.<genexpr>r]   r^   r_   r`   rb   )r   r   rf   r   r   rg   r%   r,   r)   r   r&   rh   ri   r7   r7   r8   rj   a  rk   zAsyncFiles.listrl   rm   rW   r+   c                     |s
t d|i tdt|rdtdd |D dgnti|p&i }ddi|p.i }| jd| dt||||d	td
I dH S )ro   rp   rR   rS   c                 s  rT   rU   rV   rX   r7   r7   r8   r[     r\   z$AsyncFiles.delete.<locals>.<genexpr>r]   rq   rr   rs   rt   Nrv   ry   r7   r7   r8   rz     ,   

zAsyncFiles.deleter   c                  s   |s
t d|ddi|pi }i tdt|r'dtdd |D dgnti|p.i }ddi|p6i }| jd	| d
t||||dtdI dH S )r|   rp   r}   r~   rR   rS   c                 s  rT   rU   rV   rX   r7   r7   r8   r[     r\   z&AsyncFiles.download.<locals>.<genexpr>r]   rq   r   rs   rt   N)	rw   r   r   rf   r   r   r   r)   r   ry   r7   r7   r8   r     s.   

zAsyncFiles.downloadr,   c                  r   )r   rp   rR   rS   c                 s  rT   rU   rV   rX   r7   r7   r8   r[   +  r\   z/AsyncFiles.retrieve_metadata.<locals>.<genexpr>r]   rq   rr   rs   rt   Nr   ry   r7   r7   r8   r   
  r   zAsyncFiles.retrieve_metadatar   r   c          	   
     s   i t dt|rdtdd |D dgnti|pi }ddi|p%i }i t||}td|i}ttt	t
tf |dggd}d|d	< | jd
t|tjI dH |t||||dtdI dH S )r   rR   rS   c                 s  rT   rU   rV   rX   r7   r7   r8   r[   Z  r\   z$AsyncFiles.upload.<locals>.<genexpr>r]   r   r   r   r   r^   Nrs   r   )r   r   rf   r   r   r   r   r   r   r   rW   r   r   r   r'   r   r)   r,   r   r7   r7   r8   r   ;  s4   
zAsyncFiles.upload)r1   r   )r1   r   )r@   rH   rA   rH   rB   rI   rC   rJ   rD   rK   rE   rL   rF   rM   rG   rN   r1   r   r   )rm   rW   rC   rJ   rD   rK   rE   rL   rF   rM   rG   rN   r1   r   r   r   r   r7   r7   r7   r8   r/   M  r   c                   @     e Zd ZdddZdS )	r2   r   r.   r1   Nonec                 C  P   || _ t|j| _t|j| _t|jt| _t|j| _t|j	| _	d S rU   )
_filesr   to_raw_response_wrapperrj   rz   r   r   r   r   r   r6   r   r7   r7   r8   __init__u  "   
zFilesWithRawResponse.__init__Nr   r.   r1   r   r   r   r   r   r7   r7   r7   r8   r2   t      r2   c                   @  r   )	r   r   r/   r1   r   c                 C  r   rU   )
r   r   async_to_raw_response_wrapperrj   rz   r"   r   r   r   r   r   r7   r7   r8   r     r   z"AsyncFilesWithRawResponse.__init__Nr   r/   r1   r   r   r7   r7   r7   r8   r     r   r   c                   @  r   )	r;   r   r.   r1   r   c                 C  H   || _ t|j| _t|j| _t|jt| _t|j| _t|j| _d S rU   )	r   r   rj   rz   r!   r   r   r   r   r   r7   r7   r8   r     "   
z#FilesWithStreamingResponse.__init__Nr   r   r7   r7   r7   r8   r;     r   r;   c                   @  r   )	r   r   r/   r1   r   c                 C  r   rU   )	r   r    rj   rz   r#   r   r   r   r   r   r7   r7   r8   r     r   z(AsyncFilesWithStreamingResponse.__init__Nr   r   r7   r7   r7   r8   r     r   r   )D
__future__r   typingr   r   r   	itertoolsr   httpx r   _typesr	   r
   r   r   r   r   r   r   _utilsr   r   r   r   r   r   _compatr   	_resourcer   r   	_responser   r   r   r   r   r   r    r!   r"   r#   
paginationr$   r%   
types.betar&   r'   _base_clientr(   r)   lib._stainless_helpersr*   r   types.beta.deleted_filer+   types.beta.file_metadatar,   types.anthropic_beta_paramr-   __all__r.   r/   r2   r   r;   r   r7   r7   r7   r8   <module>   s8   ( 0  )  )