o
    î6Wj”  ã                   @  sˆ  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mZmZ ddlmZ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l0m1Z1 ddl2m3Z3 ddl4m5Z5 ddgZ6G dd„ deƒZ7G dd„ deƒZ8G dd„ dƒZ9G dd„ dƒZ:G dd„ dƒZ;G dd „ d ƒZ<dS )!é    )Úannotations)ÚListÚIterable)ÚchainNé   )Ú_legacy_response)ÚBodyÚOmitÚQueryÚHeadersÚNotGivenÚomitÚ	not_given)Úis_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)ÚJSONLDecoderÚAsyncJSONLDecoder)Úbatch_list_paramsÚbatch_create_params)ÚAnthropicBetaParam)ÚBetaMessageBatch)ÚBetaDeletedMessageBatch)Ú"BetaMessageBatchIndividualResponseÚBatchesÚAsyncBatchesc                	   @  óÀ   e Zd Zed0dd„ƒZed1dd„ƒZeeddded	œd2dd„Zedddedœd3dd„Z	eeeeddded œd4d&d'„Z
edddedœd5d)d*„Zedddedœd3d+d,„Zedddedœd6d.d/„ZdS )7r&   Ú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/   úx/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/anthropic/resources/beta/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
        )r3   r-   r/   r/   r0   Úwith_streaming_response(   ó   zBatches.with_streaming_responseN©ÚbetasÚuser_profile_idÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚrequestsú%Iterable[batch_create_params.Request]r8   úList[AnthropicBetaParam] | Omitr9   ú
str | Omitr:   úHeaders | Noner;   úQuery | Noner<   úBody | Noner=   ú'float | httpx.Timeout | None | NotGivenr#   c             	   C  sx   i t t|ƒrd tdd„ |D ƒdgƒ¡nt|dœƒ¥|pi ¥}d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.

          betas: Optional header to specify the beta version(s) you want to use.

          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
        ú,c                 s  ó   � | ]}t |ƒV  qd S ©N©Ústr©Ú.0Úer/   r/   r0   Ú	<genexpr>^   ó   € z!Batches.create.<locals>.<genexpr>úmessage-batches-2024-09-24©úanthropic-betazanthropic-user-profile-idrS   ú/v1/messages/batches?beta=truer>   ©r:   r;   r<   r=   ©ÚbodyÚoptionsÚcast_to)r   r   Újoinr   r   Ú_postr   r!   ÚBatchCreateParamsr   r#   ©r.   r>   r8   r9   r:   r;   r<   r=   r/   r/   r0   Úcreate1   s(   *ÿüÿÿ	÷ÿúzBatches.create©r8   r:   r;   r<   r=   Úmessage_batch_idrK   c                C  ó‚   |s	t d|›�ƒ‚i tdt|ƒrd tdd„ |D ƒdgƒ¡ntiƒ¥|p%i ¥}ddi|p-i ¥}| 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.

          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 rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   —   rP   z#Batches.retrieve.<locals>.<genexpr>rQ   ú1/v1/messages/batches/{message_batch_id}?beta=true©r`   rU   ©rX   rY   ©
Ú
ValueErrorr   r   rZ   r   r   Ú_getr   r   r#   ©r.   r`   r8   r:   r;   r<   r=   r/   r/   r0   Úretrievep   ó*   "ÿýÿÿø

ÿûzBatches.retrieve©Úafter_idÚ	before_idÚlimitr8   r:   r;   r<   r=   rn   ro   rp   ú
int | OmitúSyncPage[BetaMessageBatch]c          	      C  ó€   i t dt|ƒrd tdd„ |D ƒdgƒ¡ntiƒ¥|pi ¥}ddi|p$i ¥}| jdtt t||||t	|||dœt
jƒd�td	�S )
á8  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`.

          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
        rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   Õ   rP   zBatches.list.<locals>.<genexpr>rQ   rT   ©rn   ro   rp   ©r:   r;   r<   r=   Úquery©ÚpagerX   Úmodel)r   r   rZ   r   r   Ú_get_api_listr   r#   r   r   r    ÚBatchListParams©	r.   rn   ro   rp   r8   r:   r;   r<   r=   r/   r/   r0   Úlist§   ó<   +ÿýÿÿø
ýúûïzBatches.listr$   c                C  ra   )á  
        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.

          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
        rc   rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO     rP   z!Batches.delete.<locals>.<genexpr>rQ   rd   re   rU   rf   ©
rh   r   r   rZ   r   r   Ú_deleter   r   r$   rj   r/   r/   r0   Údeleteñ   rl   zBatches.deletec                C  ra   )áv  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.

          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
        rc   rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   U  rP   z!Batches.cancel.<locals>.<genexpr>rQ   ú8/v1/messages/batches/{message_batch_id}/cancel?beta=truere   rU   rf   ©
rh   r   r   rZ   r   r   r[   r   r   r#   rj   r/   r/   r0   Úcancel(  s.   (ÿýÿÿø
ÿÿùzBatches.cancelú0JSONLDecoder[BetaMessageBatchIndividualResponse]c                C  s¼   |s	t d|›�ƒ‚| j|d�}|jstd|j› �ƒ‚ddi|p i ¥}i tdt|ƒr7d tdd	„ |D ƒd
gƒ¡nt	iƒ¥|p>i ¥}dd
i|pFi ¥}| j
t|j|d�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://platform.claude.com/docs/en/build-with-claude/batch-processing)

        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
        rc   re   úBNo `results_url` for the given batch; Has it finished processing? ÚAcceptúapplication/binaryrS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   —  rP   z"Batches.results.<locals>.<genexpr>rQ   rU   T©rX   rY   Ústream)rh   rk   Úresults_urlr   Úprocessing_statusr   r   rZ   r   r   ri   r   r   r   r%   ©r.   r`   r8   r:   r;   r<   r=   Úbatchr/   r/   r0   Úresultsg  s8   #
ÿÿýÿÿø
ÿúzBatches.results)r)   r*   )r)   r3   ©r>   r?   r8   r@   r9   rA   r:   rB   r;   rC   r<   rD   r=   rE   r)   r#   ©r`   rK   r8   r@   r:   rB   r;   rC   r<   rD   r=   rE   r)   r#   )rn   rA   ro   rA   rp   rq   r8   r@   r:   rB   r;   rC   r<   rD   r=   rE   r)   rr   ©r`   rK   r8   r@   r:   rB   r;   rC   r<   rD   r=   rE   r)   r$   )r`   rK   r8   r@   r:   rB   r;   rC   r<   rD   r=   rE   r)   rˆ   ©Ú__name__Ú
__module__Ú__qualname__r   r1   r5   r   r   r^   rk   r~   rƒ   r‡   r“   r/   r/   r/   r0   r&      óZ    	õCö:ôNö;öCöc                	   @  r(   )7r'   r)   ÚAsyncBatchesWithRawResponsec                 C  r+   r,   )rœ   r-   r/   r/   r0   r1   ª  r2   zAsyncBatches.with_raw_responseÚ!AsyncBatchesWithStreamingResponsec                 C  r+   r4   )r�   r-   r/   r/   r0   r5   ´  r6   z$AsyncBatches.with_streaming_responseNr7   r>   r?   r8   r@   r9   rA   r:   rB   r;   rC   r<   rD   r=   rE   r#   c             	   Ã  s†   �i t t|ƒrd tdd„ |D ƒdgƒ¡nt|dœƒ¥|pi ¥}ddi|p&i ¥}| jdtd|itjƒI d	H t	||||d
�t
d�I d	H S )rF   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   ê  rP   z&AsyncBatches.create.<locals>.<genexpr>rQ   rR   rS   rT   r>   NrU   rV   )r   r   rZ   r   r   r[   r   r!   r\   r   r#   r]   r/   r/   r0   r^   ½  s*   €*ÿüÿÿ	÷ÿúzAsyncBatches.creater_   r`   rK   c                Ã  óŠ   �|s
t d|›�ƒ‚i tdt|ƒrd tdd„ |D ƒdgƒ¡ntiƒ¥|p&i ¥}ddi|p.i ¥}| jtd|d�t||||d	�t	d
�I dH S )rb   rc   rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   #  rP   z(AsyncBatches.retrieve.<locals>.<genexpr>rQ   rd   re   rU   rf   Nrg   rj   r/   r/   r0   rk   ü  ó,   €"ÿýÿÿø

ÿûzAsyncBatches.retrieverm   rn   ro   rp   rq   ú=AsyncPaginator[BetaMessageBatch, AsyncPage[BetaMessageBatch]]c          	      C  rs   )
rt   rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   a  rP   z$AsyncBatches.list.<locals>.<genexpr>rQ   rT   ru   rv   rx   )r   r   rZ   r   r   r{   r   r#   r   r   r    r|   r}   r/   r/   r0   r~   3  r   zAsyncBatches.listr$   c                Ã  rž   )r€   rc   rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   ¤  rP   z&AsyncBatches.delete.<locals>.<genexpr>rQ   rd   re   rU   rf   Nr�   rj   r/   r/   r0   rƒ   }  rŸ   zAsyncBatches.deletec                Ã  rž   )r„   rc   rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   á  rP   z&AsyncBatches.cancel.<locals>.<genexpr>rQ   r…   re   rU   rf   Nr†   rj   r/   r/   r0   r‡   ´  s0   €(ÿýÿÿø
ÿÿùzAsyncBatches.cancelú5AsyncJSONLDecoder[BetaMessageBatchIndividualResponse]c                Ã  sÊ   �|s
t d|›�ƒ‚| j|d�I dH }|jstd|j› �ƒ‚ddi|p$i ¥}i tdt|ƒr;d td	d
„ |D ƒdgƒ¡nt	iƒ¥|pBi ¥}ddi|pJi ¥}| j
t|j|d�t||||d�tt dd�I dH S )r‰   rc   re   NrŠ   r‹   rŒ   rS   rG   c                 s  rH   rI   rJ   rL   r/   r/   r0   rO   #  rP   z'AsyncBatches.results.<locals>.<genexpr>rQ   rU   Tr�   )rh   rk   r�   r   r�   r   r   rZ   r   r   ri   r   r   r   r%   r‘   r/   r/   r0   r“   ó  s:   €#
ÿÿýÿÿø
ÿúzAsyncBatches.results)r)   rœ   )r)   r�   r”   r•   )rn   rA   ro   rA   rp   rq   r8   r@   r:   rB   r;   rC   r<   rD   r=   rE   r)   r    r–   )r`   rK   r8   r@   r:   rB   r;   rC   r<   rD   r=   rE   r)   r¡   r—   r/   r/   r/   r0   r'   ©  r›   c                   @  ó   e Zd Zddd„ZdS )	r*   Úbatchesr&   r)   ÚNonec                 C  ó^   || _ t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _d S rI   )	Ú_batchesr   Úto_raw_response_wrapperr^   rk   r~   rƒ   r‡   r“   ©r.   r£   r/   r/   r0   Ú__init__6  ó&   ÿÿÿÿÿ
ÿzBatchesWithRawResponse.__init__N©r£   r&   r)   r¤   ©r˜   r™   rš   r©   r/   r/   r/   r0   r*   5  ó    r*   c                   @  r¢   )	rœ   r£   r'   r)   r¤   c                 C  r¥   rI   )	r¦   r   Úasync_to_raw_response_wrapperr^   rk   r~   rƒ   r‡   r“   r¨   r/   r/   r0   r©   N  rª   z$AsyncBatchesWithRawResponse.__init__N©r£   r'   r)   r¤   r¬   r/   r/   r/   r0   rœ   M  r­   rœ   c                   @  r¢   )	r3   r£   r&   r)   r¤   c                 C  óR   || _ t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _d S rI   )r¦   r   r^   rk   r~   rƒ   r‡   r“   r¨   r/   r/   r0   r©   f  ó&   ÿÿÿÿÿ
ÿz%BatchesWithStreamingResponse.__init__Nr«   r¬   r/   r/   r/   r0   r3   e  r­   r3   c                   @  r¢   )	r�   r£   r'   r)   r¤   c                 C  r°   rI   )r¦   r   r^   rk   r~   rƒ   r‡   r“   r¨   r/   r/   r0   r©   ~  r±   z*AsyncBatchesWithStreamingResponse.__init__Nr¯   r¬   r/   r/   r/   r0   r�   }  r­   r�   )=Ú
__future__r   Útypingr   r   Ú	itertoolsr   ÚhttpxÚ r   Ú_typesr   r	   r
   r   r   r   r   Ú_utilsr   r   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_deleted_message_batchr$   Ú:types.beta.messages.beta_message_batch_individual_responser%   Ú__all__r&   r'   r*   rœ   r3   r�   r/   r/   r/   r0   Ú<module>   s@   $      