
    g_                       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 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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$ ddl%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+ ddl,m-Z-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)IterableN   )_legacy_response)	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transform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)AnthropicError)AsyncPaginatormake_request_options)MessageBatchIndividualResponsebatch_list_paramsbatch_create_params)JSONLDecoderAsyncJSONLDecoder)MessageBatchBatchesAsyncBatchesc                     e Zd Zedd       Zedd       Z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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    Y/var/www/openai/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_response2   s     ,D11r0   Nextra_headersextra_query
extra_bodytimeoutc          
         | 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.

          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
        /v1/messages/batchesrequestsr5   bodyoptionscast_to)_postr   r"   BatchCreateParamsr   r%   r-   r=   r6   r7   r8   r9   s         r.   createzBatches.create;   sK    < zz" *h!79L9^9^_(+Q[el !  
 	
r0   c          	     r    |st        d|      | j                  d| t        ||||      t              S )0  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.

          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/r5   r@   rA   
ValueError_getr   r%   r-   message_batch_idr6   r7   r8   r9   s         r.   retrievezBatches.retrieveb   sV    8  ^_o^rsttyy#$4#56(+Q[el !  
 	
r0   after_id	before_idlimitr6   r7   r8   r9   c                   | j                  dt        t           t        ||||t	        |||dt
        j                              t              S aP  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`.

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

          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   /cancelr5   rJ   rL   rB   r   r%   rN   s         r.   cancelzBatches.cancel   sY    D  ^_o^rsttzz#$4#5W=(+Q[el !  
 	
r0   c          	        |st        d|      | j                  |      }|j                  st        d|j                         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.

          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   rO   BNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryr5   Tr@   streamrA   )	rL   rP   results_urlr   processing_statusrM   r   r#   r    r-   rO   r6   r7   r8   r9   batchs          r.   resultszBatches.results   s    :  ^_o^rstt/?@   TUZUlUlTmn  "#7QM<ORQyy(+Q[el  !?@  
 	
r0   )returnr+   )rp   r3   r=   z%Iterable[batch_create_params.Request]r6   Headers | Noner7   Query | Noner8   Body | Noner9   'float | httpx.Timeout | None | NotGivenrp   r%   rO   strr6   rr   r7   rs   r8   rt   r9   ru   rp   r%   )rR   str | NotGivenrS   rx   rT   int | NotGivenr6   rr   r7   rs   r8   rt   r9   ru   rp   zSyncPage[MessageBatch])rO   rw   r6   rr   r7   rs   r8   rt   r9   ru   rp   z,JSONLDecoder[MessageBatchIndividualResponse]__name__
__module____qualname__r   r/   r4   r   rE   rP   r]   rb   ro    r0   r.   r&   r&   '   s   , , 2 2 )-$("&;D%
 8%
 &%
 "%
  %
 9%
 
%
Z )-$("&;D$
$
 &$
 "$
  $
 9$
 
$
R $-$- ) )-$("&;D7
 !7
 "	7

 7
 &7
 "7
  7
 97
 
 7
~ )-$("&;D*
*
 &*
 "*
  *
 9*
 
*
d )-$("&;D.
.
 &.
 ".
  .
 9.
 
6.
r0   c                     e Zd Zedd       Zedd       Z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y)r'   c                    t        |       S r*   )AsyncBatchesWithRawResponser,   s    r.   r/   zAsyncBatches.with_raw_response  s     +400r0   c                    t        |       S r2   )!AsyncBatchesWithStreamingResponser,   s    r.   r4   z$AsyncBatches.with_streaming_response)  s     166r0   Nr5   c          
        K   | j                  dt        d|it        j                         d{   t	        ||||      t
               d{   S 7 $7 w)r;   r<   r=   Nr5   r>   )rB   r   r"   rC   r   r%   rD   s         r.   rE   zAsyncBatches.create2  s`     < ZZ",j(-CEXEjEjkk(+Q[el !   
 
 	
k
s!   ,AA
AAAAc          	        K   |st        d|      | j                  d| t        ||||      t               d{   S 7 w)rG   rH   rI   r5   rJ   NrK   rN   s         r.   rP   zAsyncBatches.retrieveY  sd     8  ^_o^rsttYY#$4#56(+Q[el !  
 
 	
 
s   <AAArQ   c                   | j                  dt        t           t        ||||t	        |||dt
        j                              t              S rV   )rZ   r   r%   r   r   r!   r[   r\   s           r.   r]   zAsyncBatches.list  sb    J !!"<((+'%%$,%.!&
 &55 # " 
 	
r0   c          	        K   |st        d|      | j                  d| dt        ||||      t               d{   S 7 w)r_   rH   rI   r`   r5   rJ   Nra   rN   s         r.   rb   zAsyncBatches.cancel  sg     D  ^_o^rsttZZ#$4#5W=(+Q[el !   
 
 	
 
s   =AA Ac          	     @  K   |st        d|      | j                  |       d{   }|j                  st        d|j                         ddi|xs i }| j                  |j                  t        ||||      dt        t           	       d{   S 7 q7 w)
rd   rH   re   Nrf   rg   rh   r5   Tri   )	rL   rP   rk   r   rl   rM   r   r$   r    rm   s          r.   ro   zAsyncBatches.results  s     :  ^_o^rsttmm5EmFF   TUZUlUlTmn  "#7QM<ORQYY(+Q[el %&DE  
 
 	
 G
s"   &BBA,BBBB)rp   r   )rp   r   rq   rv   )rR   rx   rS   rx   rT   ry   r6   rr   r7   rs   r8   rt   r9   ru   rp   z5AsyncPaginator[MessageBatch, AsyncPage[MessageBatch]])rO   rw   r6   rr   r7   rs   r8   rt   r9   ru   rp   z1AsyncJSONLDecoder[MessageBatchIndividualResponse]rz   r~   r0   r.   r'   r'     s   1 1 7 7 )-$("&;D%
 8%
 &%
 "%
  %
 9%
 
%
Z )-$("&;D$
$
 &$
 "$
  $
 9$
 
$
R $-$- ) )-$("&;D7
 !7
 "	7

 7
 &7
 "7
  7
 97
 
?7
~ )-$("&;D*
*
 &*
 "*
  *
 9*
 
*
d )-$("&;D.
.
 &.
 ".
  .
 9.
 
;.
r0   c                      e Zd ZddZy)r+   c                p   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        |j                  t              | _        y N)
_batchesr   to_raw_response_wrapperrE   rP   r]   rb   r   ro   r   r-   batchess     r.   __init__zBatchesWithRawResponse.__init__  s    &>>NN
 )@@
 %<<LL
	 '>>NN
 6OO
r0   Nr   r&   rp   Noner{   r|   r}   r   r~   r0   r.   r+   r+         
r0   r+   c                      e Zd ZddZy)r   c                p   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        |j                  t              | _        y r   )
r   r   async_to_raw_response_wrapperrE   rP   r]   rb   r   ro   r   r   s     r.   r   z$AsyncBatchesWithRawResponse.__init__,  s    &DDNN
 )FF
 %BBLL
	 'DDNN
 <OO"
r0   Nr   r'   rp   r   r   r~   r0   r.   r   r   +  r   r0   r   c                      e Zd ZddZy)r3   c                    || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                  t              | _        y r   )	r   r   rE   rP   r]   rb   r   ro   r   r   s     r.   r   z%BatchesWithStreamingResponse.__init__B  su    2NN
 5
 1LL
	 3NN
 ;OO%
r0   Nr   r   r~   r0   r.   r3   r3   A  r   r0   r3   c                      e Zd ZddZy)r   c                    || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                  t              | _        y r   )	r   r   rE   rP   r]   rb   r   ro   r   r   s     r.   r   z*AsyncBatchesWithStreamingResponse.__init__X  sv    8NN
 ;
 7LL
	 9NN
 AOO*
r0   Nr   r   r~   r0   r.   r   r   W  r   r0   r   )8
__future__r   typingr   httpx r   _typesr   r   r	   r
   r   _utilsr   r   _compatr   	_resourcer   r   	_responser   r   r   r   r   r   r   r   r   r   
paginationr   r   _exceptionsr   _base_clientr   r   types.messagesr    r!   r"   _decoders.jsonlr#   r$   types.messages.message_batchr%   __all__r&   r'   r+   r   r3   r   r~   r0   r.   <module>r      s    #     ? ? ' :   . ) @ d d > 8n
%t
o t
nt
# t
n
 
,
 
,
 
,
 
r0   