o
    î6Wj¨v  ã                   @  sh  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Z0G dd„ deƒZ1G dd„ deƒZ2G dd„ dƒZ3G dd„ dƒZ4G dd„ dƒZ5G dd„ dƒZ6dS )é    )Ú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d„ƒZed/dd„ƒZeddded	œd0dd„Zdddedœd1dd„Z	eeedddedœd2d$d%„Z
dddedœd3d'd(„Zdddedœd1d)d*„Zdddedœd4d,d-„ZdS )5r"   Ú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+   ús/home/esfera/Documents/content_generation/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©Úuser_profile_idÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚrequestsú%Iterable[batch_create_params.Request]r4   ú
str | Omitr5   úHeaders | Noner6   úQuery | Noner7   úBody | Noner8   ú'float | httpx.Timeout | None | NotGivenr   c             	   C  sB   i t d|iƒ¥|p
i ¥}| jdtd|itjƒt||||d�td�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/batchesr9   ©r5   r6   r7   r8   ©ÚbodyÚoptionsÚcast_to)r   Ú_postr   r   ÚBatchCreateParamsr   r   ©r*   r9   r4   r5   r6   r7   r8   r+   r+   r,   Úcreate/   s   'ÿúzBatches.createrC   Úmessage_batch_idÚstrc                C  ó6   |s	t d|›�ƒ‚| jtd|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://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}©rL   rC   ©rF   rG   ©Ú
ValueErrorÚ_getr   r   r   ©r*   rL   r5   r6   r7   r8   r+   r+   r,   Úretrieve`   ó   
ÿûzBatches.retrieve©Úafter_idÚ	before_idÚlimitr5   r6   r7   r8   r[   r\   r]   ú
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://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
        rB   )r[   r\   r]   )r5   r6   r7   r8   Úquery)ÚpagerF   Úmodel)Ú_get_api_listr   r   r   r   r   ÚBatchListParams©r*   r[   r\   r]   r5   r6   r7   r8   r+   r+   r,   Úlist‰   ó$   (ýúûïzBatches.listr    c                C  rN   )á¶  
        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
        rP   rQ   rR   rC   rS   ©rU   Ú_deleter   r   r    rW   r+   r+   r,   ÚdeleteÅ   rY   zBatches.deletec                C  rN   )á$  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
        rP   ú./v1/messages/batches/{message_batch_id}/cancelrR   rC   rS   ©rU   rH   r   r   r   rW   r+   r+   r,   Úcancelî   s   %
ÿûzBatches.cancelú,JSONLDecoder[MessageBatchIndividualResponse]c                C  sp   |s	t d|›�ƒ‚| j|d�}|jstd|j› �ƒ‚ddi|p i ¥}| jt|j|d�t||||d�tt	 d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
        rP   rR   úBNo `results_url` for the given batch; Has it finished processing? ÚAcceptúapplication/binaryrC   T©rF   rG   Ústream)
rU   rX   Úresults_urlr   Úprocessing_statusrV   r   r   r   r!   ©r*   rL   r5   r6   r7   r8   Úbatchr+   r+   r,   Úresults  s     
ÿÿúzBatches.results)r%   r&   )r%   r/   ©r9   r:   r4   r;   r5   r<   r6   r=   r7   r>   r8   r?   r%   r   ©rL   rM   r5   r<   r6   r=   r7   r>   r8   r?   r%   r   )r[   r;   r\   r;   r]   r^   r5   r<   r6   r=   r7   r>   r8   r?   r%   r_   ©rL   rM   r5   r<   r6   r=   r7   r>   r8   r?   r%   r    )rL   rM   r5   r<   r6   r=   r7   r>   r8   r?   r%   rr   ©Ú__name__Ú
__module__Ú__qualname__r   r-   r1   r   r   rK   rX   rh   rm   rq   r}   r+   r+   r+   r,   r"      óN    	ö7÷,õB÷/÷5÷c                   @  r$   )5r#   r%   ÚAsyncBatchesWithRawResponsec                 C  r'   r(   )r†   r)   r+   r+   r,   r-   R  r.   zAsyncBatches.with_raw_responseÚ!AsyncBatchesWithStreamingResponsec                 C  r'   r0   )r‡   r)   r+   r+   r,   r1   \  r2   z$AsyncBatches.with_streaming_responseNr3   r9   r:   r4   r;   r5   r<   r6   r=   r7   r>   r8   r?   r   c             	   Ã  sP   �i t d|iƒ¥|pi ¥}| jdtd|itjƒI dH t||||d�td�I dH S )r@   rA   rB   r9   NrC   rD   )r   rH   r   r   rI   r   r   rJ   r+   r+   r,   rK   e  s   €'ÿúzAsyncBatches.createrC   rL   rM   c                Ã  ó>   �|s
t d|›�ƒ‚| jtd|d�t||||d�td�I dH S )rO   rP   rQ   rR   rC   rS   NrT   rW   r+   r+   r,   rX   –  ó   €
ÿûzAsyncBatches.retrieverZ   r[   r\   r]   r^   ú5AsyncPaginator[MessageBatch, AsyncPage[MessageBatch]]c                C  r`   ra   )re   r   r   r   r   r   rf   rg   r+   r+   r,   rh   ¿  ri   zAsyncBatches.listr    c                Ã  rˆ   )rj   rP   rQ   rR   rC   rS   Nrk   rW   r+   r+   r,   rm   û  r‰   zAsyncBatches.deletec                Ã  rˆ   )rn   rP   ro   rR   rC   rS   Nrp   rW   r+   r+   r,   rq   $  s   €%
ÿûzAsyncBatches.cancelú1AsyncJSONLDecoder[MessageBatchIndividualResponse]c                Ã  s~   �|s
t d|›�ƒ‚| j|d�I dH }|jstd|j› �ƒ‚ddi|p$i ¥}| jt|j|d�t||||d�tt	 dd	�I dH S )
rs   rP   rR   Nrt   ru   rv   rC   Trw   )
rU   rX   ry   r   rz   rV   r   r   r   r!   r{   r+   r+   r,   r}   S  s"   € 
ÿÿúzAsyncBatches.results)r%   r†   )r%   r‡   r~   r   )r[   r;   r\   r;   r]   r^   r5   r<   r6   r=   r7   r>   r8   r?   r%   rŠ   r€   )rL   rM   r5   r<   r6   r=   r7   r>   r8   r?   r%   r‹   r�   r+   r+   r+   r,   r#   Q  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_wrapperrK   rX   rh   rm   rq   ©r*   r�   r+   r+   r,   Ú__init__ˆ  ó    ÿÿÿÿ
ÿzBatchesWithRawResponse.__init__N©r�   r"   r%   rŽ   ©r‚   rƒ   r„   r”   r+   r+   r+   r,   r&   ‡  ó    r&   c                   @  rŒ   )	r†   r�   r#   r%   rŽ   c                 C  r�   r�   )r‘   r   Úasync_to_raw_response_wrapperrK   rX   rh   rm   rq   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   rK   rX   rh   rm   rq   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   rK   rX   rh   rm   rq   r“   r+   r+   r,   r”   Ç  rœ   z*AsyncBatchesWithStreamingResponse.__init__Nrš   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†   r/   r‡   r+   r+   r+   r,   Ú<module>   s8   $  8  8