L iddlmZddlmZmZddlmZddlZddlm Z ddl m Z m Z m Z mZmZmZmZddlmZmZmZmZdd lmZdd lmZmZdd lmZmZdd lm Z m!Z!dd l"m#Z#ddl$m%Z%m&Z&ddl'm(Z(m)Z)ddl*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddgZ5GddeZ6GddeZ7GddZ8GddZ9GddZ:Gdd Z;y)!) annotations)ListIterable)chainN)_legacy_response)BodyOmitQueryHeadersNotGivenomit not_given)is_givenmaybe_transformstrip_not_givenasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncPage AsyncPage)AnthropicError)AsyncPaginatormake_request_options) JSONLDecoderAsyncJSONLDecoder)batch_list_paramsbatch_create_params)AnthropicBetaParam)BetaMessageBatch)BetaDeletedMessageBatch)"BetaMessageBatchIndividualResponseBatches AsyncBatchesc ^eZdZed dZed dZeddded ddZeddded ddZ eeeeddded ddZ eddded dd Z eddded dd Z eddded dd Z y)r&ct|Sa 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 )BatchesWithRawResponseselfs o/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/anthropic/resources/beta/messages/batches.pywith_raw_responsezBatches.with_raw_responses&d++ct|Sz 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_responsezBatches.with_streaming_response(s,D11r0Nbetas extra_headers extra_query extra_bodytimeoutc $itdt|r#djtd|Ddgnti|xsi}ddi|xsi}|j dt d|itjt||||tS)  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. 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,c32K|]}t|ywNstr.0es r. z!Batches.create..X5Lc!f5Lmessage-batches-2024-09-24/v1/messages/batches?beta=truerequestsr7r8r9r:bodyoptionscast_to) rrjoinrr_postrr!BatchCreateParamsrr#r-rKr6r7r8r9r:s r.createzBatches.create1sH  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a zz , *h!79L9^9^_(+Q[el%   r0c |std|itdt|r#djt d|Ddgnt i|xsi}ddi|xsi}|j d|dt||||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. 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. 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>c32K|]}t|ywr@rArCs r.rFz#Batches.retrieve..rGrHrI/v1/messages/batches/ ?beta=truerLrOrP ValueErrorrrrQrr_getrr#r-message_batch_idr6r7r8r9r:s r.retrievezBatches.retrieveisD ^_o^rst t  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a yy#$4#5Z @(+Q[el%   r0after_id before_idlimitr6r7r8r9r:c@itdt|r#djtd|Ddgnti|xsi}ddi|xsi}|j dt tt||||t|||dtjtS) 4List 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`. 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>c32K|]}t|ywr@rArCs r.rFzBatches.list..rGrHrIrJrdrerfr7r8r9r:querypagerOmodel) rrrQrr _get_api_listrr#rrr BatchListParams r-rdrerfr6r7r8r9r:s r.listz Batches.listsV  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a !! ,*+(+'%%$,%.!& &55  ##"  r0c |std|itdt|r#djt d|Ddgnt i|xsi}ddi|xsi}|j d|dt||||t S)  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. 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 rXr=r>c32K|]}t|ywr@rArCs r.rFz!Batches.delete..rGrHrIrZr[rLr\ r^rrrQrr_deleterr$r`s r.deletezBatches.deletesD ^_o^rst t  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a ||#$4#5Z @(+Q[el,   r0c |std|itdt|r#djt d|Ddgnt i|xsi}ddi|xsi}|j d|dt||||t S) rBatches 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. 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 rXr=r>c32K|]}t|ywr@rArCs r.rFz!Batches.cancel..NrGrHrIrZ/cancel?beta=truerLr\ r^rrrQrrrRrr#r`s r.cancelzBatches.cancel!sP ^_o^rst t  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a zz#$4#55F G(+Q[el%   r0c |std||j|}|jstd|jddi|xsi}it dt |r#djtd|Dd gnti|xsi}dd i|xsi}|j|jt|||| ttd 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. 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 rXraBNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryr=r>c32K|]}t|ywr@rArCs r.rFz"Batches.results..rGrHrIrLTrOrPstream)r^rb results_urlrprocessing_statusrrrQrrr_rrr%r-rar6r7r8r9r:batchs r.resultszBatches.results^sF ^_o^rst t /? @   TUZUlUlTmn "#7QMc32K|]}t|ywr@rArCs r.rFz&AsyncBatches.create..rGrHrIrJrKNrLrM) rrrQrrrRrr!rSrr#rTs r.rUzAsyncBatches.createsH  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a ZZ ,,j(-CEXEjEjkk(+Q[el%     k s$A=B(?B$ B(B& B(&B(c 2K|std|itdt|r#djt d|Ddgnt i|xsi}ddi|xsi}|j d|dt||||t d {S7w) rWrXr=r>c32K|]}t|ywr@rArCs r.rFz(AsyncBatches.retrieve..rGrHrIrZr[rLr\Nr]r`s r.rbzAsyncBatches.retrievesD ^_o^rst t  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a YY#$4#5Z @(+Q[el%     BBBBrcc@itdt|r#djtd|Ddgnti|xsi}ddi|xsi}|j dt tt||||t|||dtjtS) rhr=r>c32K|]}t|ywr@rArCs r.rFz$AsyncBatches.list..QrGrHrIrJrjrkrm) rrrQrrrprr#rrr rqrrs r.rszAsyncBatches.list#sV  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a !! ,+,(+'%%$,%.!& &55  ##"  r0c 2K|std|itdt|r#djt d|Ddgnt i|xsi}ddi|xsi}|j d|dt||||t d {S7w) rurXr=r>c32K|]}t|ywr@rArCs r.rFz&AsyncBatches.delete..rGrHrIrZr[rLr\Nrwr`s r.ryzAsyncBatches.deletemsD ^_o^rst t  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a \\#$4#5Z @(+Q[el, "    rc 2K|std|itdt|r#djt d|Ddgnt i|xsi}ddi|xsi}|j d|dt||||t d {S7w) r{rXr=r>c32K|]}t|ywr@rArCs r.rFz&AsyncBatches.cancel..rGrHrIrZr}rLr\Nr~r`s r.rzAsyncBatches.cancelsP ^_o^rst t  $'*hhu5Le5LOkNl/m&n"  "  *+GaML_]_a ZZ#$4#55F G(+Q[el%      rc K|std||j|d{}|jstd|jddi|xsi}it dt |r#djtd |Dd gnti|xsi}dd i|xsi}|j|jt|||| ttd d{S77w)rrXrNrrrr=r>c32K|]}t|ywr@rArCs r.rFz'AsyncBatches.results..rGrHrIrLTr)r^rbrrrrrrQrrr_rrr%rs r.rzAsyncBatches.resultss1F ^_o^rst tmm5EmFF   TUZUlUlTmn "#7QM> NN  )@@     %<< LL  '>> NN  '>> NN  r0Nrr&rNonerrrrrr0r.r+r+# r0r+ceZdZddZy)rcz||_tj|j|_tj|j|_tj|j |_tj|j |_tj|j|_yr@)rrasync_to_raw_response_wrapperrUrbrsryrrs r.rz$AsyncBatchesWithRawResponse.__init__9s &DD NN  )FF     %BB LL  'DD NN  'DD NN  r0Nrr'rrrrr0r.rr8rr0rceZdZddZy)r3c||_t|j|_t|j|_t|j|_t|j |_t|j |_yr@)rrrUrbrsryrrs r.rz%BatchesWithStreamingResponse.__init__Nsr 2 NN  5     1 LL  3 NN  3 NN  r0Nrrrr0r.r3r3Mrr0r3ceZdZddZy)rc||_t|j|_t|j|_t|j|_t|j |_t|j |_yr@)rrrUrbrsryrrs r.rz*AsyncBatchesWithStreamingResponse.__init__csr 8 NN  ;     7 LL  9 NN  9 NN  r0Nrrrr0r.rrbrr0r)< __future__rtypingrr itertoolsrhttpxr_typesr r r r r rr_utilsrrrr_compatr _resourcerr _responserr paginationrr _exceptionsr _base_clientrr_decoders.jsonlrrtypes.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+rr3rrr0r.rs#! !LLLXX';Z.*A?J=GVm n %@ o@ F @ #@ F   *  *  *  r0