
    4Rjv                       d dl 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 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l,m-Z- ddl.m/Z/ ddgZ0 G d de      Z1 G d de      Z2 G d d      Z3 G d d      Z4 G d d      Z5 G d d      Z6y)    )annotations)IterableN   )_legacy_response)BodyOmitQueryHeadersNotGivenomit	not_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)batch_list_paramsbatch_create_params)JSONLDecoderAsyncJSONLDecoder)MessageBatch)DeletedMessageBatch)MessageBatchIndividualResponseBatchesAsyncBatchesc                  @   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ddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z
ddded	 	 	 	 	 	 	 	 	 	 	 dd
Zddded	 	 	 	 	 	 	 	 	 	 	 ddZ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    l/var/www/html/meridian/meridian-ai/venv/lib/python3.12/site-packages/anthropic/resources/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1r-   Nuser_profile_idextra_headersextra_query
extra_bodytimeoutc          
         i t        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.

          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
        anthropic-user-profile-id/v1/messages/batchesrequestsr4   r5   r6   r7   bodyoptionscast_to)r   _postr   r   BatchCreateParamsr   r    r*   r<   r3   r4   r5   r6   r7   s          r+   createzBatches.create/   sn    N u?,G+YZt_l_rprtzz" *h!79L9^9^_(+Q[el !  
 	
r-   r=   c          	         |st        d|      | 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.

          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 '/v1/messages/batches/{message_batch_id}message_batch_idr=   r@   rA   
ValueError_getr   r   r    r*   rK   r4   r5   r6   r7   s         r+   retrievezBatches.retrieve`   sV    >  ^_o^rsttyyCVfg(+Q[el !  
 	
r-   after_id	before_idlimitr4   r5   r6   r7   c                   | j                  dt        t           t        ||||t	        |||dt
        j                              t              S a  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`.

          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;   )rS   rT   rU   )r4   r5   r6   r7   query)pager@   model)_get_api_listr   r    r   r   r   BatchListParamsr*   rS   rT   rU   r4   r5   r6   r7   s           r+   listzBatches.list   sb    P !!",'(+'%%$,%.!&
 &55 # " 
 	
r-   c          	         |st        d|      | 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.

          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
        rH   rI   rJ   r=   rL   rN   _deleter   r   r!   rP   s         r+   deletezBatches.delete   sV    >  ^_o^rstt||CVfg(+Q[el (  
 	
r-   c          	         |st        d|      | j                  t        d|      t        ||||      t              S )$  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.

          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
        rH   ./v1/messages/batches/{message_batch_id}/cancelrJ   r=   rL   rN   rB   r   r   r    rP   s         r+   cancelzBatches.cancel   sW    J  ^_o^rsttzzJ]mn(+Q[el !  
 	
r-   c          	     &   |st        d|      | j                  |      }|j                  st        d|j                         ddi|xs i }| j                  t        |j                  |      t        ||||      t        t           d      S )	2  
        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.

          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
        rH   rJ   BNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryr=   Tr@   rA   stream)
rN   rQ   results_urlr   processing_statusrO   r   r   r   r"   r*   rK   r4   r5   r6   r7   batchs          r+   resultszBatches.results  s    @  ^_o^rstt/?@   TUZUlUlTmn  "#7QM<ORQyy%++>NO(+Q[el !!?@  
 	
r-   )returnr(   )ru   r0   r<   z%Iterable[batch_create_params.Request]r3   
str | Omitr4   Headers | Noner5   Query | Noner6   Body | Noner7   'float | httpx.Timeout | None | NotGivenru   r    rK   strr4   rx   r5   ry   r6   rz   r7   r{   ru   r    )rS   rw   rT   rw   rU   
int | Omitr4   rx   r5   ry   r6   rz   r7   r{   ru   zSyncPage[MessageBatch]rK   r}   r4   rx   r5   ry   r6   rz   r7   r{   ru   r!   )rK   r}   r4   rx   r5   ry   r6   rz   r7   r{   ru   z,JSONLDecoder[MessageBatchIndividualResponse]__name__
__module____qualname__r   r,   r1   r   r   rE   rQ   r^   rc   rh   rt    r-   r+   r#   r#      s-   , , 2 2 '+ )-$("&;D/
 8/
 $	/
 &/
 "/
  /
 9/
 
/
n )-$("&;D'
'
 &'
 "'
  '
 9'
 
'
X  $ $  )-$("&;D:
 :
 	:

 :
 &:
 ":
  :
 9:
 
 :
D )-$("&;D'
'
 &'
 "'
  '
 9'
 
'
^ )-$("&;D-
-
 &-
 "-
  -
 9-
 
-
j )-$("&;D1
1
 &1
 "1
  1
 91
 
61
r-   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ddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z
ddded	 	 	 	 	 	 	 	 	 	 	 dd
Zddded	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZy)r$   c                    t        |       S r'   )AsyncBatchesWithRawResponser)   s    r+   r,   zAsyncBatches.with_raw_responseR  s     +400r-   c                    t        |       S r/   )!AsyncBatchesWithStreamingResponser)   s    r+   r1   z$AsyncBatches.with_streaming_response\  s     166r-   Nr2   c          
        K   i t        d|i      |xs i }| j                  dt        d|it        j                         d{   t        ||||      t               d{   S 7 $7 w)r9   r:   r;   r<   Nr=   r>   )r   rB   r   r   rC   r   r    rD   s          r+   rE   zAsyncBatches.createe  s     N u?,G+YZt_l_rprtZZ",j(-CEXEjEjkk(+Q[el !   
 
 	
k
s$   AA,A(
A,#A*$A,*A,r=   c          	        K   |st        d|      | j                  t        d|      t        ||||      t               d{   S 7 w)rG   rH   rI   rJ   r=   rL   NrM   rP   s         r+   rQ   zAsyncBatches.retrieve  sd     >  ^_o^rsttYYCVfg(+Q[el !  
 
 	
 
   AAAArR   c                   | j                  dt        t           t        ||||t	        |||dt
        j                              t              S rW   )r[   r   r    r   r   r   r\   r]   s           r+   r^   zAsyncBatches.list  sb    P !!"<((+'%%$,%.!&
 &55 # " 
 	
r-   c          	        K   |st        d|      | j                  t        d|      t        ||||      t               d{   S 7 w)r`   rH   rI   rJ   r=   rL   Nra   rP   s         r+   rc   zAsyncBatches.delete  sd     >  ^_o^rstt\\CVfg(+Q[el ( " 
 
 	
 
r   c          	        K   |st        d|      | j                  t        d|      t        ||||      t               d{   S 7 w)re   rH   rf   rJ   r=   rL   Nrg   rP   s         r+   rh   zAsyncBatches.cancel$  se     J  ^_o^rsttZZJ]mn(+Q[el !   
 
 	
 
r   c          	     V  K   |st        d|      | j                  |       d{   }|j                  st        d|j                         ddi|xs i }| j                  t        |j                  |      t        ||||      t        t           d	       d{   S 7 |7 w)
rj   rH   rJ   Nrk   rl   rm   r=   Trn   )
rN   rQ   rp   r   rq   rO   r   r   r   r"   rr   s          r+   rt   zAsyncBatches.resultsS  s     @  ^_o^rsttmm5EmFF   TUZUlUlTmn  "#7QM<ORQYY%++>NO(+Q[el &&DE  
 
 	
 G
s"   &B)B%A7B) B'!B)'B))ru   r   )ru   r   rv   r|   )rS   rw   rT   rw   rU   r~   r4   rx   r5   ry   r6   rz   r7   r{   ru   z5AsyncPaginator[MessageBatch, AsyncPage[MessageBatch]]r   )rK   r}   r4   rx   r5   ry   r6   rz   r7   r{   ru   z1AsyncJSONLDecoder[MessageBatchIndividualResponse]r   r   r-   r+   r$   r$   Q  s-   1 1 7 7 '+ )-$("&;D/
 8/
 $	/
 &/
 "/
  /
 9/
 
/
n )-$("&;D'
'
 &'
 "'
  '
 9'
 
'
X  $ $  )-$("&;D:
 :
 	:

 :
 &:
 ":
  :
 9:
 
?:
D )-$("&;D'
'
 &'
 "'
  '
 9'
 
'
^ )-$("&;D-
-
 &-
 "-
  -
 9-
 
-
j )-$("&;D1
1
 &1
 "1
  1
 91
 
;1
r-   c                      e Zd ZddZy)r(   c                z   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y N)_batchesr   to_raw_response_wrapperrE   rQ   r^   rc   rh   r*   batchess     r+   __init__zBatchesWithRawResponse.__init__  s    &>>NN
 )@@
 %<<LL
	 '>>NN
 '>>NN
r-   Nr   r#   ru   Noner   r   r   r   r   r-   r+   r(   r(         
r-   r(   c                      e Zd ZddZy)r   c                z   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y r   )r   r   async_to_raw_response_wrapperrE   rQ   r^   rc   rh   r   s     r+   r   z$AsyncBatchesWithRawResponse.__init__  s    &DDNN
 )FF
 %BBLL
	 'DDNN
 'DDNN
r-   Nr   r$   ru   r   r   r   r-   r+   r   r     r   r-   r   c                      e Zd ZddZy)r0   c                   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        y r   )r   r   rE   rQ   r^   rc   rh   r   s     r+   r   z%BatchesWithStreamingResponse.__init__  sr    2NN
 5
 1LL
	 3NN
 3NN
r-   Nr   r   r   r-   r+   r0   r0     r   r-   r0   c                      e Zd ZddZy)r   c                   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        y r   )r   r   rE   rQ   r^   rc   rh   r   s     r+   r   z*AsyncBatchesWithStreamingResponse.__init__  sr    8NN
 ;
 7LL
	 9NN
 9NN
r-   Nr   r   r   r-   r+   r   r     r   r-   r   )7
__future__r   typingr   httpx r   _typesr   r   r	   r
   r   r   r   _utilsr   r   r   r   _compatr   	_resourcer   r   	_responser   r   
paginationr   r   _exceptionsr   _base_clientr   r   types.messagesr   r   _decoders.jsonlr   r   types.messages.message_batchr    $types.messages.deleted_message_batchr!   0types.messages.message_batch_individual_responser"   __all__r#   r$   r(   r   r0   r   r   r-   r+   <module>r      s    #     K K K \ \ & : Y - ) @ D > 8 G ^n
%s
o s
l	s
# s
l	
 
*
 
*
 
*
 
r-   