
    g.t                       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 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/m0Z0 ddgZ1 G d de      Z2 G d de      Z3 G d d      Z4 G d d      Z5 G d d      Z6 G d d      Z7y)     )annotations)ListIterable)chainN   )_legacy_response)	NOT_GIVENBodyQueryHeadersNotGiven)is_given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)"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y)r#   c                    t        |       S a  
        This property can be used as a prefix for any HTTP method call to return the
        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    ^/var/www/openai/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1r-   Nbetasextra_headersextra_query
extra_bodytimeoutc          
     $   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        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.

        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  2   K   | ]  }t        |        y wNstr.0es     r+   	<genexpr>z!Batches.create.<locals>.<genexpr>Y        5Lec!fe   message-batches-2024-09-24/v1/messages/batches?beta=truerequestsr4   r5   r6   r7   bodyoptionscast_to)r   r   joinr   r	   _postr   r   BatchCreateParamsr   r!   r*   rH   r3   r4   r5   r6   r7   s          r+   createzBatches.create5   s    B	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_azz, *h!79L9^9^_(+Q[el %  
 	
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                  d| 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.

        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 r:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   z#Batches.retrieve.<locals>.<genexpr>   rD   rE   rF   /v1/messages/batches/
?beta=truerI   rL   rM   	
ValueErrorr   r   rN   r   r	   _getr   r!   r*   message_batch_idr3   r4   r5   r6   r7   s          r+   retrievezBatches.retrievej   s    >  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_ayy#$4#5Z@(+Q[el %  
 	
r-   after_id	before_idlimitr3   r4   r5   r6   r7   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 )	  List all Message Batches within a Workspace.

        Most recently created batches are
        returned first.

        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
        r:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   zBatches.list.<locals>.<genexpr>   rD   rE   rF   rG   ra   rb   rc   r4   r5   r6   r7   querypagerL   model)r   r   rN   r   r	   _get_api_listr   r!   r   r   r   BatchListParams	r*   ra   rb   rc   r3   r4   r5   r6   r7   s	            r+   listzBatches.list   s    P	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_a!!,*+(+'%%$,%.!&
 &55 ## " 
 	
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                  d| 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.

        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
        rU   r:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   z!Batches.cancel.<locals>.<genexpr>  rD   rE   rF   rW   /cancel?beta=truerI   rY   	r[   r   r   rN   r   r	   rO   r   r!   r]   s          r+   cancelzBatches.cancel   s    J  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_azz#$4#55FG(+Q[el %  
 	
r-   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                  |j                  t        ||||
      dt        t                 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.

        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
        rU   r^   BNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryr:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   z"Batches.results.<locals>.<genexpr>L  rD   rE   rF   rI   TrL   streamrM   )r[   r_   results_urlr   processing_statusr   r   rN   r   r	   r\   r   r   r"   r*   r^   r3   r4   r5   r6   r7   batchs           r+   resultszBatches.results  s   @  ^_o^rstt/?@   TUZUlUlTmn  "#7QM<ORQ	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_ayy(+Q[el  !CD  
 	
r-   )returnr(   )r   r0   rH   z%Iterable[batch_create_params.Request]r3   #List[AnthropicBetaParam] | NotGivenr4   Headers | Noner5   Query | Noner6   Body | Noner7   'float | httpx.Timeout | None | NotGivenr   r!   r^   r?   r3   r   r4   r   r5   r   r6   r   r7   r   r   r!   )ra   str | NotGivenrb   r   rc   int | NotGivenr3   r   r4   r   r5   r   r6   r   r7   r   r   zSyncPage[BetaMessageBatch])r^   r?   r3   r   r4   r   r5   r   r6   r   r7   r   r   z0JSONLDecoder[BetaMessageBatchIndividualResponse]__name__
__module____qualname__r   r,   r1   r	   rR   r_   rp   rv   r    r-   r+   r#   r#   !   s#   , , 2 2 6? )-$("&;D3
 83
 3	3
 &3
 "3
  3
 93
 
3
r 6? )-$("&;D2
2
 3	2
 &2
 "2
  2
 92
 
2
n $-$- )5> )-$("&;DE
 !E
 "	E

 E
 3E
 &E
 "E
  E
 9E
 
$E
V 6? )-$("&;D8
8
 3	8
 &8
 "8
  8
 98
 
8
| 6? )-$("&;D<
<
 3	<
 &<
 "<
  <
 9<
 
:<
r-   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y)r$   c                    t        |       S r'   )AsyncBatchesWithRawResponser)   s    r+   r,   zAsyncBatches.with_raw_response_  s     +400r-   c                    t        |       S r/   )!AsyncBatchesWithStreamingResponser)   s    r+   r1   z$AsyncBatches.with_streaming_responsei  s     166r-   Nr2   c          
     T  K   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        d|it        j                         d{   t        ||||      t        	       d{   S 7 $7 w)
r9   r:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   z&AsyncBatches.create.<locals>.<genexpr>  rD   rE   rF   rG   rH   NrI   rJ   )r   r   rN   r   r	   rO   r   r   rP   r   r!   rQ   s          r+   rR   zAsyncBatches.creater  s     B	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_aZZ,,j(-CEXEjEjkk(+Q[el %   
 
 	
k
s$   A=B(?B$
 B(B& B(&B(c          
     2  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                  d| dt        ||||      t        	       d
{   S 7 w)rT   rU   r:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   z(AsyncBatches.retrieve.<locals>.<genexpr>  rD   rE   rF   rW   rX   rI   rY   NrZ   r]   s          r+   r_   zAsyncBatches.retrieve  s     >  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_aYY#$4#5Z@(+Q[el %  
 
 	
 
   BBBB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 )	re   r:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   z$AsyncBatches.list.<locals>.<genexpr>  rD   rE   rF   rG   rg   rh   rj   )r   r   rN   r   r	   rm   r   r!   r   r   r   rn   ro   s	            r+   rp   zAsyncBatches.list  s    P	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_a!!,+,(+'%%$,%.!&
 &55 ## " 
 	
r-   c          
     2  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                  d| dt        ||||      t        	       d
{   S 7 w)rr   rU   r:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   z&AsyncBatches.cancel.<locals>.<genexpr>L  rD   rE   rF   rW   rt   rI   rY   Nru   r]   s          r+   rv   zAsyncBatches.cancel"  s     J  ^_o^rstt	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_aZZ#$4#55FG(+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                  |j                  t        ||||      dt        t                  d{   S 7 7 w)rx   rU   ry   Nrz   r{   r|   r:   r;   c              3  2   K   | ]  }t        |        y wr=   r>   r@   s     r+   rC   z'AsyncBatches.results.<locals>.<genexpr>  rD   rE   rF   rI   Tr~   )r[   r_   r   r   r   r   r   rN   r   r	   r\   r   r   r"   r   s           r+   r   zAsyncBatches.results\  s1    @  ^_o^rsttmm5EmFF   TUZUlUlTmn  "#7QM<ORQ	
$ '*hhu5Le5LOkNl/m&n"	
 "	
 *+GaML_]_aYY(+Q[el %&HI  
 
 	
% G$
s"   &C/C+B=C/&C-'C/-C/)r   r   )r   r   r   r   )ra   r   rb   r   rc   r   r3   r   r4   r   r5   r   r6   r   r7   r   r   z=AsyncPaginator[BetaMessageBatch, AsyncPage[BetaMessageBatch]])r^   r?   r3   r   r4   r   r5   r   r6   r   r7   r   r   z5AsyncJSONLDecoder[BetaMessageBatchIndividualResponse]r   r   r-   r+   r$   r$   ^  s$   1 1 7 7 6? )-$("&;D3
 83
 3	3
 &3
 "3
  3
 93
 
3
r 6? )-$("&;D2
2
 3	2
 &2
 "2
  2
 92
 
2
n $-$- )5> )-$("&;DE
 !E
 "	E

 E
 3E
 &E
 "E
  E
 9E
 
GE
V 6? )-$("&;D8
8
 3	8
 &8
 "8
  8
 98
 
8
| 6? )-$("&;D<
<
 3	<
 &<
 "<
  <
 9<
 
?<
r-   c                      e Zd ZddZy)r(   c                2   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        y r=   )_batchesr   to_raw_response_wrapperrR   r_   rp   rv   r*   batchess     r+   __init__zBatchesWithRawResponse.__init__  su    &>>NN
 )@@
 %<<LL
	 '>>NN
r-   Nr   r#   r   Noner   r   r   r   r   r-   r+   r(   r(         
r-   r(   c                      e Zd ZddZy)r   c                2   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        y r=   )r   r   async_to_raw_response_wrapperrR   r_   rp   rv   r   s     r+   r   z$AsyncBatchesWithRawResponse.__init__  su    &DDNN
 )FF
 %BBLL
	 'DDNN
r-   Nr   r$   r   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
                        | _        y r=   )r   r   rR   r_   rp   rv   r   s     r+   r   z%BatchesWithStreamingResponse.__init__  s]    2NN
 5
 1LL
	 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
                        | _        y r=   )r   r   rR   r_   rp   rv   r   s     r+   r   z*AsyncBatchesWithStreamingResponse.__init__  s]    8NN
 ;
 7LL
	 9NN
r-   Nr   r   r   r-   r+   r   r     r   r-   r   )8
__future__r   typingr   r   	itertoolsr   httpx r   _typesr	   r
   r   r   r   _utilsr   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_message_batch_individual_responser"   __all__r#   r$   r(   r   r0   r   r   r-   r+   <module>r      s    # !   ! @ @  ( ; Z . * A ? J = G mn
%z
o z
z	z
# z
z	
 
$
 
$
 
$
 
r-   