
    4Rj                       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<y)!    )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            	      d   e Zd Zedd       Zedd       Ze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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/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
        )BatchesWithRawResponseselfs    q/var/www/html/meridian/meridian-ai/venv/lib/python3.12/site-packages/anthropic/resources/beta/messages/batches.pywith_raw_responsezBatches.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/anthropics/anthropic-sdk-python#with_streaming_response
        )BatchesWithStreamingResponser-   s    r/   with_streaming_responsezBatches.with_streaming_response(   s     ,D11r1   Nbetasuser_profile_idextra_headersextra_query
extra_bodytimeoutc          
     &   i t        t        |      r#dj                  t        d |D        dg            nt        |d      |xs i }ddi|xs i }| j                  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://platform.claude.com/docs/en/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.

          user_profile_id: The user profile ID to attribute the requests in this batch to. Use when acting
              on behalf of a party other than your organization. Requires the `user-profiles`
              beta header. Applies to every request in the batch; an individual request whose
              `user_profile_id` body field conflicts with this header is errored.

          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
        ,c              3  2   K   | ]  }t        |        y wNstr.0es     r/   	<genexpr>z!Batches.create.<locals>.<genexpr>^        5Lc!f5L   message-batches-2024-09-24anthropic-betazanthropic-user-profile-idrL   /v1/messages/batches?beta=truerequestsr9   r:   r;   r<   bodyoptionscast_to)r   r   joinr   r   _postr   r"   BatchCreateParamsr   r$   r.   rN   r7   r8   r9   r:   r;   r<   s           r/   createzBatches.create1   s    T

   '*hhu5Le5LOkNl/m&n"1@	

 "

 *+GaML_]_azz, *h!79L9^9^_(+Q[el %  
 	
r1   r7   r9   r:   r;   r<   c          
     $   |st        d|      i t        dt        |      r#dj                  t	        d |D        dg            nt
        i      |xs i }ddi|xs i }| j                  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://platform.claude.com/docs/en/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 rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z#Batches.retrieve.<locals>.<genexpr>   rH   rI   rJ   1/v1/messages/batches/{message_batch_id}?beta=truemessage_batch_idrO   rR   rS   

ValueErrorr   r   rT   r   r   _getr   r   r$   r.   r`   r7   r9   r:   r;   r<   s          r/   retrievezBatches.retrievep   s    D  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_ayyM`pq(+Q[el %  
 	
r1   after_id	before_idlimitr7   r9   r:   r;   r<   c               @   i t        dt        |      r#dj                  t        d |D        dg            nt        i      |xs i }ddi|xs i }| j                  dt        t           t        ||||t        |||dt        j                              t              S )	8  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://platform.claude.com/docs/en/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
        rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   zBatches.list.<locals>.<genexpr>   rH   rI   rJ   rM   rh   ri   rj   r9   r:   r;   r<   querypagerR   model)r   r   rT   r   r   _get_api_listr   r$   r   r   r!   BatchListParams	r.   rh   ri   rj   r7   r9   r:   r;   r<   s	            r/   listzBatches.list   s    V	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_a!!,*+(+'%%$,%.!&
 &55 ## " 
 	
r1   c          
     $   |st        d|      i t        dt        |      r#dj                  t	        d |D        dg            nt
        i      |xs i }ddi|xs i }| j                  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://platform.claude.com/docs/en/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\   rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z!Batches.delete.<locals>.<genexpr>  rH   rI   rJ   r^   r_   rO   ra   
rc   r   r   rT   r   r   _deleter   r   r%   re   s          r/   deletezBatches.delete   s    D  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_a||M`pq(+Q[el ,  
 	
r1   c          
     $   |st        d|      i t        dt        |      r#dj                  t	        d |D        dg            nt
        i      |xs i }ddi|xs i }| j                  t        d|      t        ||||      t        	      S )
v  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://platform.claude.com/docs/en/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\   rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z!Batches.cancel.<locals>.<genexpr>U  rH   rI   rJ   8/v1/messages/batches/{message_batch_id}/cancel?beta=truer_   rO   ra   
rc   r   r   rT   r   r   rU   r   r   r$   re   s          r/   cancelzBatches.cancel(  s    P  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_azzJ]m )+Q[el %  
 	
r1   c          
        |st        d|      | j                  |      }|j                  st        d|j                         ddi|xs i }i t        dt        |      r#dj                  t        d |D        d	g            nt        i      |xs i }dd	i|xs i }| j                  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://platform.claude.com/docs/en/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\   r_   BNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryrL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z"Batches.results.<locals>.<genexpr>  rH   rI   rJ   rO   TrR   rS   stream)rc   rf   results_urlr   processing_statusr   r   rT   r   r   rd   r   r   r   r&   r.   r`   r7   r9   r:   r;   r<   batchs           r/   resultszBatches.resultsg  s!   F  ^_o^rstt/?@   TUZUlUlTmn  "#7QM<ORQ	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_ayy%++>NO(+Q[el !!CD  
 	
r1   )returnr,   )r   r4   rN   z%Iterable[batch_create_params.Request]r7   List[AnthropicBetaParam] | Omitr8   
str | Omitr9   Headers | Noner:   Query | Noner;   Body | Noner<   'float | httpx.Timeout | None | NotGivenr   r$   r`   rC   r7   r   r9   r   r:   r   r;   r   r<   r   r   r$   )rh   r   ri   r   rj   
int | Omitr7   r   r9   r   r:   r   r;   r   r<   r   r   zSyncPage[BetaMessageBatch]r`   rC   r7   r   r9   r   r:   r   r;   r   r<   r   r   r%   )r`   rC   r7   r   r9   r   r:   r   r;   r   r<   r   r   z0JSONLDecoder[BetaMessageBatchIndividualResponse]__name__
__module____qualname__r   r0   r5   r   r   rX   rf   rw   r}   r   r    r1   r/   r'   r'      s   , , 2 2 26&* )-$("&;D=
 8=
 /	=

 $=
 &=
 "=
  =
 9=
 
=
F 26 )-$("&;D5
5
 /	5
 &5
 "5
  5
 95
 
5
t  $ $ 15 )-$("&;DH
 H
 	H

 H
 /H
 &H
 "H
  H
 9H
 
$H
\ 26 )-$("&;D5
5
 /	5
 &5
 "5
  5
 95
 
!5
v 26 )-$("&;D=
=
 /	=
 &=
 "=
  =
 9=
 
=
F 26 )-$("&;D?
?
 /	?
 &?
 "?
  ?
 9?
 
:?
r1   c            	      d   e Zd Zedd       Zedd       Ze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y)r(   c                    t        |       S r+   )AsyncBatchesWithRawResponser-   s    r/   r0   zAsyncBatches.with_raw_response  s     +400r1   c                    t        |       S r3   )!AsyncBatchesWithStreamingResponser-   s    r/   r5   z$AsyncBatches.with_streaming_response  s     166r1   Nr6   c          
     V  K   i t        t        |      r#dj                  t        d |D        dg            nt        |d      |xs i }ddi|xs i }| j                  dt        d|it        j                         d{   t        ||||	      t        
       d{   S 7 $7 w)r>   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z&AsyncBatches.create.<locals>.<genexpr>  rH   rI   rJ   rK   rL   rM   rN   NrO   rP   )r   r   rT   r   r   rU   r   r"   rV   r   r$   rW   s           r/   rX   zAsyncBatches.create  s     T

   '*hhu5Le5LOkNl/m&n"1@	

 "

 *+GaML_]_aZZ,,j(-CEXEjEjkk(+Q[el %   
 
 	
k
s$   A>B) B%
B) B'!B)'B)rY   c          
     @  K   |st        d|      i t        dt        |      r#dj                  t	        d |D        dg            nt
        i      |xs i }ddi|xs i }| j                  t        d|      t        ||||      t        	       d
{   S 7 w)r[   r\   rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z(AsyncBatches.retrieve.<locals>.<genexpr>#  rH   rI   rJ   r^   r_   rO   ra   Nrb   re   s          r/   rf   zAsyncBatches.retrieve  s     D  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_aYYM`pq(+Q[el %  
 
 	
 
   BBBBrg   c               @   i t        dt        |      r#dj                  t        d |D        dg            nt        i      |xs i }ddi|xs i }| j                  dt        t           t        ||||t        |||dt        j                              t              S )	rl   rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z$AsyncBatches.list.<locals>.<genexpr>a  rH   rI   rJ   rM   rn   ro   rq   )r   r   rT   r   r   rt   r   r$   r   r   r!   ru   rv   s	            r/   rw   zAsyncBatches.list3  s    V	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_a!!,+,(+'%%$,%.!&
 &55 ## " 
 	
r1   c          
     @  K   |st        d|      i t        dt        |      r#dj                  t	        d |D        dg            nt
        i      |xs i }ddi|xs i }| j                  t        d|      t        ||||      t        	       d
{   S 7 w)ry   r\   rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z&AsyncBatches.delete.<locals>.<genexpr>  rH   rI   rJ   r^   r_   rO   ra   Nr{   re   s          r/   r}   zAsyncBatches.delete}  s     D  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_a\\M`pq(+Q[el , " 
 
 	
 
r   c          
     @  K   |st        d|      i t        dt        |      r#dj                  t	        d |D        dg            nt
        i      |xs i }ddi|xs i }| j                  t        d|      t        ||||      t        	       d
{   S 7 w)r   r\   rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z&AsyncBatches.cancel.<locals>.<genexpr>  rH   rI   rJ   r   r_   rO   ra   Nr   re   s          r/   r   zAsyncBatches.cancel  s     P  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_aZZJ]m )+Q[el %   
 
 	
 
r   c          
       K   |st        d|      | j                  |       d{   }|j                  st        d|j                         ddi|xs i }i t        dt        |      r#dj                  t        d	 |D        d
g            nt        i      |xs i }dd
i|xs i }| j                  t        |j                  |      t        ||||      t        t           d       d{   S 7 7 w)r   r\   r_   Nr   r   r   rL   r?   c              3  2   K   | ]  }t        |        y wrA   rB   rD   s     r/   rG   z'AsyncBatches.results.<locals>.<genexpr>#  rH   rI   rJ   rO   Tr   )rc   rf   r   r   r   r   r   rT   r   r   rd   r   r   r    r&   r   s           r/   r   zAsyncBatches.results  s9    F  ^_o^rsttmm5EmFF   TUZUlUlTmn  "#7QM<ORQ	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_aYY%++>NO(+Q[el &&HI  
 
 	
% G$
s"   &C:C6CC:1C82C:8C:)r   r   )r   r   r   r   )rh   r   ri   r   rj   r   r7   r   r9   r   r:   r   r;   r   r<   r   r   z=AsyncPaginator[BetaMessageBatch, AsyncPage[BetaMessageBatch]]r   )r`   rC   r7   r   r9   r   r:   r   r;   r   r<   r   r   z5AsyncJSONLDecoder[BetaMessageBatchIndividualResponse]r   r   r1   r/   r(   r(     s   1 1 7 7 26&* )-$("&;D=
 8=
 /	=

 $=
 &=
 "=
  =
 9=
 
=
F 26 )-$("&;D5
5
 /	5
 &5
 "5
  5
 95
 
5
t  $ $ 15 )-$("&;DH
 H
 	H

 H
 /H
 &H
 "H
  H
 9H
 
GH
\ 26 )-$("&;D5
5
 /	5
 &5
 "5
  5
 95
 
!5
v 26 )-$("&;D=
=
 /	=
 &=
 "=
  =
 9=
 
=
F 26 )-$("&;D?
?
 /	?
 &?
 "?
  ?
 9?
 
??
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 rA   )	_batchesr   to_raw_response_wrapperrX   rf   rw   r}   r   r   r.   batchess     r/   __init__zBatchesWithRawResponse.__init__6  s    &>>NN
 )@@
 %<<LL
	 '>>NN
 '>>NN
 (??OO
r1   Nr   r'   r   Noner   r   r   r   r   r1   r/   r,   r,   5      
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 rA   )	r   r   async_to_raw_response_wrapperrX   rf   rw   r}   r   r   r   s     r/   r   z$AsyncBatchesWithRawResponse.__init__N  s    &DDNN
 )FF
 %BBLL
	 'DDNN
 'DDNN
 (EEOO
r1   Nr   r(   r   r   r   r   r1   r/   r   r   M  r   r1   r   c                      e Zd ZddZy)r4   c                J   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        t        |j                        | _        y rA   )r   r   rX   rf   rw   r}   r   r   r   s     r/   r   z%BatchesWithStreamingResponse.__init__f  s    2NN
 5
 1LL
	 3NN
 3NN
 4OO
r1   Nr   r   r   r1   r/   r4   r4   e  r   r1   r4   c                      e Zd ZddZy)r   c                J   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        t        |j                        | _        y rA   )r   r   rX   rf   rw   r}   r   r   r   s     r/   r   z*AsyncBatchesWithStreamingResponse.__init__~  s    8NN
 ;
 7LL
	 9NN
 9NN
 :OO
r1   Nr   r   r   r1   r/   r   r   }  r   r1   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   r4   r   r   r1   r/   <module>r      s    # !   ! L L L g g ' ; Z . * A ? J = G V mn
%I
o I
XI
# I
X
 
0
 
0
 
0
 
r1   