o
    +ip                     @  s`  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 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Z.G dd deZ/G dd deZ0G dd dZ1G dd dZ2G dd dZ3G dd dZ4dS )    )annotations)IterableN   )_legacy_response)BodyOmitQueryHeadersNotGivenomit	not_given)maybe_transform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dZed-ddZddded	d.ddZddded	d/ddZe	e	e	dddedd0d"d#Z
ddded	d1d%d&Zddded	d/d'd(Zddded	d2d*d+ZdS )3r    returnBatchesWithRawResponsec                 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
        )r$   self r)   a/var/www/html/psymed-ai/venv/lib/python3.10/site-packages/anthropic/resources/messages/batches.pywith_raw_response      zBatches.with_raw_responseBatchesWithStreamingResponsec                 C  r%   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
        )r-   r'   r)   r)   r*   with_streaming_response&      zBatches.with_streaming_responseNextra_headersextra_query
extra_bodytimeoutrequests%Iterable[batch_create_params.Request]r2   Headers | Noner3   Query | Noner4   Body | Noner5   'float | httpx.Timeout | None | NotGivenr   c             	   C  s*   | j dtd|itjt||||dtdS )N  
        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.

          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/batchesr6   r1   bodyoptionscast_to)_postr   r   BatchCreateParamsr   r   r(   r6   r2   r3   r4   r5   r)   r)   r*   create/   s   !zBatches.createmessage_batch_idstrc                C  4   |s	t d|| jd| t||||dtd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.

          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/r1   r@   rA   
ValueError_getr   r   r(   rF   r2   r3   r4   r5   r)   r)   r*   retrieveY      zBatches.retrieveafter_id	before_idlimitr2   r3   r4   r5   rT   
str | OmitrU   rV   
int | OmitSyncPage[MessageBatch]c                C  4   | j dtt t||||t|||dtjdtd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://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`.

          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=   )rT   rU   rV   )r2   r3   r4   r5   query)pager@   model)_get_api_listr   r   r   r   r   BatchListParamsr(   rT   rU   rV   r2   r3   r4   r5   r)   r)   r*   list   $   (zBatches.listr   c                C  rH   )  
        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.

          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
        rJ   rK   r1   rL   rN   _deleter   r   rP   r)   r)   r*   delete   rR   zBatches.deletec                C  s6   |s	t d|| jd| dt||||dtd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://docs.claude.com/en/docs/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
        rJ   rK   /cancelr1   rL   rN   rB   r   r   rP   r)   r)   r*   cancel   s   %
zBatches.cancel,JSONLDecoder[MessageBatchIndividualResponse]c                C  sh   |s	t d|| j|d}|jstd|j ddi|p i }| j|jt||||dtt d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.

          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
        rJ   rF   BNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryr1   Tr@   rA   stream)	rN   rQ   results_urlr   processing_statusrO   r   r   r   r(   rF   r2   r3   r4   r5   batchr)   r)   r*   results  s     
zBatches.results)r#   r$   )r#   r-   r6   r7   r2   r8   r3   r9   r4   r:   r5   r;   r#   r   rF   rG   r2   r8   r3   r9   r4   r:   r5   r;   r#   r   )rT   rW   rU   rW   rV   rX   r2   r8   r3   r9   r4   r:   r5   r;   r#   rY   rF   rG   r2   r8   r3   r9   r4   r:   r5   r;   r#   r   )rF   rG   r2   r8   r3   r9   r4   r:   r5   r;   r#   rl   __name__
__module____qualname__r   r+   r/   r   rE   rQ   r   rb   rg   rk   rx   r)   r)   r)   r*   r       L    	0,B/5c                   @  r"   )3r!   r#   AsyncBatchesWithRawResponsec                 C  r%   r&   )r   r'   r)   r)   r*   r+   K  r,   zAsyncBatches.with_raw_response!AsyncBatchesWithStreamingResponsec                 C  r%   r.   )r   r'   r)   r)   r*   r/   U  r0   z$AsyncBatches.with_streaming_responseNr1   r6   r7   r2   r8   r3   r9   r4   r:   r5   r;   r   c             	     s8   | j dtd|itjI dH t||||dtdI dH S )r<   r=   r6   Nr1   r>   )rB   r   r   rC   r   r   rD   r)   r)   r*   rE   ^  s   !zAsyncBatches.createrF   rG   c                  <   |s
t d|| jd| t||||dtdI dH S )rI   rJ   rK   r1   rL   NrM   rP   r)   r)   r*   rQ        zAsyncBatches.retrieverS   rT   rW   rU   rV   rX   5AsyncPaginator[MessageBatch, AsyncPage[MessageBatch]]c                C  rZ   r[   )r_   r   r   r   r   r   r`   ra   r)   r)   r*   rb     rc   zAsyncBatches.listr   c                  r   )rd   rJ   rK   r1   rL   Nre   rP   r)   r)   r*   rg     r   zAsyncBatches.deletec                  s>   |s
t d|| jd| dt||||dtdI dH S )rh   rJ   rK   ri   r1   rL   Nrj   rP   r)   r)   r*   rk     s   %
zAsyncBatches.cancel1AsyncJSONLDecoder[MessageBatchIndividualResponse]c                  sv   |s
t d|| j|dI dH }|jstd|j ddi|p$i }| j|jt||||dtt dd	I dH S )
rm   rJ   rn   Nro   rp   rq   r1   Trr   )	rN   rQ   rt   r   ru   rO   r   r   r   rv   r)   r)   r*   rx   E  s"    
zAsyncBatches.results)r#   r   )r#   r   ry   rz   )rT   rW   rU   rW   rV   rX   r2   r8   r3   r9   r4   r:   r5   r;   r#   r   r{   )rF   rG   r2   r8   r3   r9   r4   r:   r5   r;   r#   r   r|   r)   r)   r)   r*   r!   J  r   c                   @     e Zd ZdddZdS )	r$   batchesr    r#   Nonec                 C  P   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S N)_batchesr   to_raw_response_wrapperrE   rQ   rb   rg   rk   r(   r   r)   r)   r*   __init__z      
zBatchesWithRawResponse.__init__Nr   r    r#   r   r}   r~   r   r   r)   r)   r)   r*   r$   y      r$   c                   @  r   )	r   r   r!   r#   r   c                 C  r   r   )r   r   async_to_raw_response_wrapperrE   rQ   rb   rg   rk   r   r)   r)   r*   r     r   z$AsyncBatchesWithRawResponse.__init__Nr   r!   r#   r   r   r)   r)   r)   r*   r     r   r   c                   @  r   )	r-   r   r    r#   r   c                 C  F   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r   )r   r   rE   rQ   rb   rg   rk   r   r)   r)   r*   r         
z%BatchesWithStreamingResponse.__init__Nr   r   r)   r)   r)   r*   r-     r   r-   c                   @  r   )	r   r   r!   r#   r   c                 C  r   r   )r   r   rE   rQ   rb   rg   rk   r   r)   r)   r*   r     r   z*AsyncBatchesWithStreamingResponse.__init__Nr   r   r)   r)   r)   r*   r     r   r   )5
__future__r   typingr   httpx r   _typesr   r   r   r	   r
   r   r   _utilsr   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   r-   r   r)   r)   r)   r*   <module>   s8   $  1  1