
    i}                       d dl m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mZmZmZmZ ddl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 ddl m!Z!m"Z" ddl#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/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddgZ6 G d de          Z7 G d de          Z8 G d d          Z9 G d d          Z: G d d          Z; G d d           Z<dS )!    )annotations)ListIterable)chainN   )_legacy_response)BodyOmitQueryHeadersNotGivenomit	not_given)is_givenpath_templatemaybe_transformstrip_not_givenasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncPage	AsyncPage)AnthropicError)AsyncPaginatormake_request_options)JSONLDecoderAsyncJSONLDecoder)batch_list_paramsbatch_create_params)AnthropicBetaParam)BetaMessageBatch)BetaDeletedMessageBatch)"BetaMessageBatchIndividualResponseBatchesAsyncBatchesc            	          e Zd Zed&d            Zed'd            Zedddedd(dZedddedd)dZ	eeeedddedd*d Z
edddedd+d"Zedddedd)d#Zedddedd,d%ZdS )-r'   returnBatchesWithRawResponsec                     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
        )r+   selfs    f/root/projects/qq-shell/venv/lib/python3.11/site-packages/anthropic/resources/beta/messages/batches.pywith_raw_responsezBatches.with_raw_response   s     &d+++    BatchesWithStreamingResponsec                     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/anthropics/anthropic-sdk-python#with_streaming_response
        )r3   r.   s    r0   with_streaming_responsezBatches.with_streaming_response(   s     ,D111r2   Nbetasextra_headersextra_query
extra_bodytimeoutrequests%Iterable[batch_create_params.Request]r8   List[AnthropicBetaParam] | Omitr9   Headers | Noner:   Query | Noner;   Body | Noner<   'float | httpx.Timeout | None | NotGivenr$   c          
     V   i t          dt          |          r.d                    t          d |D             dg                    nt          i          |pi }ddi|pi }|                     dt          d|it          j                  t          ||||          t                    S )	  
        Send a batch of Message creation requests.

        The Message Batches API can be used to process multiple Messages API requests at
        once. Once a Message Batch is created, it begins processing immediately. Batches
        can take up to 24 hours to complete.

        Learn more about the Message Batches API in our
        [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

        Args:
          requests: List of requests for prompt completion. Each is an individual request to create
              a Message.

          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              3  4   K   | ]}t          |          V  d S Nstr.0es     r0   	<genexpr>z!Batches.create.<locals>.<genexpr>X   (      5L5Lc!ff5L5L5L5L5L5Lr2   message-batches-2024-09-24/v1/messages/batches?beta=truer=   r9   r:   r;   r<   bodyoptionscast_to)r   r   joinr   r   _postr   r"   BatchCreateParamsr   r$   r/   r=   r8   r9   r:   r;   r<   s          r0   createzBatches.create1   s    H	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_azz, *h!79L9^__(+Q[el   %  
 
 	
r2   message_batch_idrK   c          
     f   |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     t          d|          t          ||||          t          	          S )
  This endpoint is idempotent and can be used to poll for Message Batch
        completion.

        To access the results of a Message Batch, make a request to the
        `results_url` field in the response.

        Learn more about the Message Batches API in our
        [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

        Args:
          message_batch_id: ID of the Message Batch.

          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
        ?Expected a non-empty value for `message_batch_id` but received rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z#Batches.retrieve.<locals>.<genexpr>   rP   r2   rQ   1/v1/messages/batches/{message_batch_id}?beta=truer]   rS   rV   rW   

ValueErrorr   r   rX   r   r   _getr   r   r$   r/   r]   r8   r9   r:   r;   r<   s          r0   retrievezBatches.retrievei   s    D   	us_ossttt	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_ayyM`pqqq(+Q[el   %  
 
 	
r2   after_id	before_idlimitr8   r9   r:   r;   r<   rk   
str | Omitrl   rm   
int | OmitSyncPage[BetaMessageBatch]c               |   i t          dt          |          r.d                    t          d |D             dg                    nt          i          |pi }ddi|pi }|                     dt          t                   t          ||||t          |||dt          j                            t                    S )	4  List all Message Batches within a Workspace.

        Most recently created batches are
        returned first.

        Learn more about the Message Batches API in our
        [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

        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
        rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   zBatches.list.<locals>.<genexpr>   rP   r2   rQ   rR   rk   rl   rm   r9   r:   r;   r<   querypagerV   model)r   r   rX   r   r   _get_api_listr   r$   r   r   r!   BatchListParams	r/   rk   rl   rm   r8   r9   r:   r;   r<   s	            r0   listzBatches.list   s    V	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_a!!,*+(+'%%$,%.!& 
 &5    ## " 
 
 	
r2   r%   c          
     f   |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     t          d|          t          ||||          t          	          S )
  
        Delete a Message Batch.

        Message Batches can only be deleted once they've finished processing. If you'd
        like to delete an in-progress batch, you must first cancel it.

        Learn more about the Message Batches API in our
        [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

        Args:
          message_batch_id: ID of the Message Batch.

          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
        r`   rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z!Batches.delete.<locals>.<genexpr>  rP   r2   rQ   rb   rc   rS   rd   
rf   r   r   rX   r   r   _deleter   r   r%   rh   s          r0   deletezBatches.delete   s    D   	us_ossttt	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_a||M`pqqq(+Q[el   ,  
 
 	
r2   c          
     f   |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     t          d|          t          ||||          t          	          S )
r  Batches may be canceled any time before processing ends.

        Once cancellation is
        initiated, the batch enters a `canceling` state, at which time the system may
        complete any in-progress, non-interruptible requests before finalizing
        cancellation.

        The number of canceled requests is specified in `request_counts`. To determine
        which requests were canceled, check the individual results within the batch.
        Note that cancellation may not result in any canceled requests if they were
        non-interruptible.

        Learn more about the Message Batches API in our
        [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

        Args:
          message_batch_id: ID of the Message Batch.

          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
        r`   rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z!Batches.cancel.<locals>.<genexpr>N  rP   r2   rQ   8/v1/messages/batches/{message_batch_id}/cancel?beta=truerc   rS   rd   
rf   r   r   rX   r   r   rY   r   r   r$   rh   s          r0   cancelzBatches.cancel!  s   P   	us_ossttt	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_azzJ]m   )+Q[el   %  
 
 	
r2   0JSONLDecoder[BetaMessageBatchIndividualResponse]c          
         |st          d|          |                     |          }|j        st          d|j                   ddi|pi }i t          dt          |          r.d                    t          d |D             d	g                    nt          i          |pi }dd	i|pi }| 
                    t          |j        |          t          ||||
          t          t                   d          S )  
        Streams the results of a Message Batch as a `.jsonl` file.

        Each line in the file is a JSON object containing the result of a single request
        in the Message Batch. Results are not guaranteed to be in the same order as
        requests. Use the `custom_id` field to match results to requests.

        Learn more about the Message Batches API in our
        [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

        Args:
          message_batch_id: ID of the Message Batch.

          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
        r`   rc   BNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryrF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z"Batches.results.<locals>.<genexpr>  rP   r2   rQ   rS   TrV   rW   stream)rf   ri   results_urlr   processing_statusr   r   rX   r   r   rg   r   r   r   r&   r/   r]   r8   r9   r:   r;   r<   batchs           r0   resultszBatches.results`  s^   F   	us_ossttt/?@@  	 nUZUlnn   "#7QM<ORQ	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_ayy%+>NOOO(+Q[el   !!CD  
 
 	
r2   )r*   r+   )r*   r3   r=   r>   r8   r?   r9   r@   r:   rA   r;   rB   r<   rC   r*   r$   r]   rK   r8   r?   r9   r@   r:   rA   r;   rB   r<   rC   r*   r$   )rk   rn   rl   rn   rm   ro   r8   r?   r9   r@   r:   rA   r;   rB   r<   rC   r*   rp   r]   rK   r8   r?   r9   r@   r:   rA   r;   rB   r<   rC   r*   r%   )r]   rK   r8   r?   r9   r@   r:   rA   r;   rB   r<   rC   r*   r   __name__
__module____qualname__r   r1   r6   r   r   r\   ri   r}   r   r   r    r2   r0   r'   r'      s       , , , _, 2 2 2 _2 26 )-$("&;D6
 6
 6
 6
 6
 6
x 26 )-$("&;D5
 5
 5
 5
 5
 5
t  $ $ 15 )-$("&;DH
 H
 H
 H
 H
 H
\ 26 )-$("&;D5
 5
 5
 5
 5
 5
v 26 )-$("&;D=
 =
 =
 =
 =
 =
F 26 )-$("&;D?
 ?
 ?
 ?
 ?
 ?
 ?
 ?
r2   c            	          e Zd Zed&d            Zed'd            Zedddedd(dZedddedd)dZ	eeeedddedd*d Z
edddedd+d"Zedddedd)d#Zedddedd,d%ZdS )-r(   r*   AsyncBatchesWithRawResponsec                     t          |           S r-   )r   r.   s    r0   r1   zAsyncBatches.with_raw_response  s     +4000r2   !AsyncBatchesWithStreamingResponsec                     t          |           S r5   )r   r.   s    r0   r6   z$AsyncBatches.with_streaming_response  s     1666r2   Nr7   r=   r>   r8   r?   r9   r@   r:   rA   r;   rB   r<   rC   r$   c          
     r  K   i t          dt          |          r.d                    t          d |D             dg                    nt          i          |pi }ddi|pi }|                     dt          d|it          j                   d{V t          ||||          t          	           d{V S )
rE   rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z&AsyncBatches.create.<locals>.<genexpr>  rP   r2   rQ   rR   r=   NrS   rT   )r   r   rX   r   r   rY   r   r"   rZ   r   r$   r[   s          r0   r\   zAsyncBatches.create  s     H	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_aZZ,,j(-CEXEjkkkkkkkk(+Q[el   %   
 
 
 
 
 
 
 
 	
r2   r]   rK   c          
     v  K   |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     t          d|          t          ||||          t          	           d
{V S )r_   r`   rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z(AsyncBatches.retrieve.<locals>.<genexpr>  rP   r2   rQ   rb   rc   rS   rd   Nre   rh   s          r0   ri   zAsyncBatches.retrieve  s     D   	us_ossttt	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_aYYM`pqqq(+Q[el   %  
 
 
 
 
 
 
 
 	
r2   rj   rk   rn   rl   rm   ro   =AsyncPaginator[BetaMessageBatch, AsyncPage[BetaMessageBatch]]c               |   i t          dt          |          r.d                    t          d |D             dg                    nt          i          |pi }ddi|pi }|                     dt          t                   t          ||||t          |||dt          j                            t                    S )	rr   rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z$AsyncBatches.list.<locals>.<genexpr>S  rP   r2   rQ   rR   rt   ru   rw   )r   r   rX   r   r   rz   r   r$   r   r   r!   r{   r|   s	            r0   r}   zAsyncBatches.list%  s    V	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_a!!,+,(+'%%$,%.!& 
 &5    ## " 
 
 	
r2   r%   c          
     v  K   |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     t          d|          t          ||||          t          	           d
{V S )r   r`   rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z&AsyncBatches.delete.<locals>.<genexpr>  rP   r2   rQ   rb   rc   rS   rd   Nr   rh   s          r0   r   zAsyncBatches.deleteo  s     D   	us_ossttt	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_a\\M`pqqq(+Q[el   , " 
 
 
 
 
 
 
 
 	
r2   c          
     v  K   |st          d|          i t          dt          |          r.d                    t	          d |D             dg                    nt
          i          |pi }ddi|pi }|                     t          d|          t          ||||          t          	           d
{V S )r   r`   rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z&AsyncBatches.cancel.<locals>.<genexpr>  rP   r2   rQ   r   rc   rS   rd   Nr   rh   s          r0   r   zAsyncBatches.cancel  s&     P   	us_ossttt	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_aZZJ]m   )+Q[el   %   
 
 
 
 
 
 
 
 	
r2   5AsyncJSONLDecoder[BetaMessageBatchIndividualResponse]c          
       K   |st          d|          |                     |           d{V }|j        st          d|j                   ddi|pi }i t          dt          |          r.d                    t          d	 |D             d
g                    nt          i          |pi }dd
i|pi }| 
                    t          |j        |          t          ||||          t          t                   d           d{V S )r   r`   rc   Nr   r   r   rF   rG   c              3  4   K   | ]}t          |          V  d S rI   rJ   rL   s     r0   rO   z'AsyncBatches.results.<locals>.<genexpr>  rP   r2   rQ   rS   Tr   )rf   ri   r   r   r   r   r   rX   r   r   rg   r   r   r    r&   r   s           r0   r   zAsyncBatches.results  s     F   	us_osstttmm5EmFFFFFFFF  	 nUZUlnn   "#7QM<ORQ	
$'#chhu5L5Le5L5L5LOkNl/m/m&n&n&n" 	
 "	
 *+GaML_]_aYY%+>NOOO(+Q[el   &&HI  
 
 
 
 
 
 
 
 	
r2   )r*   r   )r*   r   r   r   )rk   rn   rl   rn   rm   ro   r8   r?   r9   r@   r:   rA   r;   rB   r<   rC   r*   r   r   )r]   rK   r8   r?   r9   r@   r:   rA   r;   rB   r<   rC   r*   r   r   r   r2   r0   r(   r(     s       1 1 1 _1 7 7 7 _7 26 )-$("&;D6
 6
 6
 6
 6
 6
x 26 )-$("&;D5
 5
 5
 5
 5
 5
t  $ $ 15 )-$("&;DH
 H
 H
 H
 H
 H
\ 26 )-$("&;D5
 5
 5
 5
 5
 5
v 26 )-$("&;D=
 =
 =
 =
 =
 =
F 26 )-$("&;D?
 ?
 ?
 ?
 ?
 ?
 ?
 ?
r2   c                      e Zd ZddZdS )r+   batchesr'   r*   Nonec                |   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S rI   )	_batchesr   to_raw_response_wrapperr\   ri   r}   r   r   r   r/   r   s     r0   __init__zBatchesWithRawResponse.__init__(  s    &>N
 
 )@
 
 %<L
 
	 '>N
 
 '>N
 
 (?O
 
r2   Nr   r'   r*   r   r   r   r   r   r   r2   r0   r+   r+   '  (        
 
 
 
 
 
r2   r+   c                      e Zd ZddZdS )r   r   r(   r*   r   c                |   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S rI   )	r   r   async_to_raw_response_wrapperr\   ri   r}   r   r   r   r   s     r0   r   z$AsyncBatchesWithRawResponse.__init__@  s    &DN
 
 )F
 
 %BL
 
	 'DN
 
 'DN
 
 (EO
 
r2   Nr   r(   r*   r   r   r   r2   r0   r   r   ?  r   r2   r   c                      e Zd ZddZdS )r3   r   r'   r*   r   c                @   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S rI   )r   r   r\   ri   r}   r   r   r   r   s     r0   r   z%BatchesWithStreamingResponse.__init__X  s    2N
 
 5
 
 1L
 
	 3N
 
 3N
 
 4O
 
r2   Nr   r   r   r2   r0   r3   r3   W  r   r2   r3   c                      e Zd ZddZdS )r   r   r(   r*   r   c                @   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S rI   )r   r   r\   ri   r}   r   r   r   r   s     r0   r   z*AsyncBatchesWithStreamingResponse.__init__p  s    8N
 
 ;
 
 7L
 
	 9N
 
 9N
 
 :O
 
r2   Nr   r   r   r2   r0   r   r   o  r   r2   r   )=
__future__r   typingr   r   	itertoolsr   httpx r   _typesr	   r
   r   r   r   r   r   _utilsr   r   r   r   r   _compatr   	_resourcer   r   	_responser   r   
paginationr   r   _exceptionsr   _base_clientr   r   _decoders.jsonlr   r    types.beta.messagesr!   r"   types.anthropic_beta_paramr#   &types.beta.messages.beta_message_batchr$   .types.beta.messages.beta_deleted_message_batchr%   :types.beta.messages.beta_message_batch_individual_responser&   __all__r'   r(   r+   r   r3   r   r   r2   r0   <module>r      s   # " " " " " ! ! ! ! ! ! ! !        ! ! ! ! ! ! L L L L L L L L L L L L L L L L L L g g g g g g g g g g g g g g ' ' ' ' ' ' ; ; ; ; ; ; ; ; Z Z Z Z Z Z Z Z . . . . . . . . * * * * * * A A A A A A A A ? ? ? ? ? ? ? ? J J J J J J J J = = = = = = G G G G G G V V V V V V m m m m m mn
%B
 B
 B
 B
 B
o B
 B
 B
JB
 B
 B
 B
 B
# B
 B
 B
J
 
 
 
 
 
 
 
0
 
 
 
 
 
 
 
0
 
 
 
 
 
 
 
0
 
 
 
 
 
 
 
 
 
r2   