L ipddlmZddlmZddlZddlmZddlmZm Z m Z m Z m Z m Z mZddlmZmZddlmZdd lmZmZdd lmZmZdd lmZmZdd lmZdd lm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddgZ.GddeZ/GddeZ0GddZ1GddZ2GddZ3GddZ4y)) annotations)IterableN)_legacy_response)BodyOmitQueryHeadersNotGivenomit not_given)maybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncPage AsyncPage)AnthropicError)AsyncPaginatormake_request_options)batch_list_paramsbatch_create_params) JSONLDecoderAsyncJSONLDecoder) MessageBatch)DeletedMessageBatch)MessageBatchIndividualResponseBatches AsyncBatchesc:eZdZed dZed dZddded ddZddded ddZe e e ddded ddZ ddded dd Z ddded dd Z ddded 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 j/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/anthropic/resources/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,D11r+N extra_headers extra_query extra_bodytimeoutc |jdtd|itjt ||||t 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/batchesrequestsr0bodyoptionscast_to)_postrrBatchCreateParamsrrr(r8r1r2r3r4s r)createzBatches.create/sLBzz " *h!79L9^9^_(+Q[el!   r+c r|std||jd|t||||tS)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/r0r;r< ValueError_getrrr(message_batch_idr1r2r3r4s r)retrievezBatches.retrieveYsV> ^_o^rst tyy#$4#5 6(+Q[el!   r+after_id before_idlimitr1r2r3r4c|jdttt||||t |||dt j tSaList 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 r7)rMrNrO)r1r2r3r4query)pager;model) _get_api_listrrrrrBatchListParamsr(rMrNrOr1r2r3r4s r)listz Batches.listsbP!! ",'(+'%%$,%.!& &55  #"  r+c r|std||jd|t||||tS) 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 rCrDr0rErG_deleterrrIs r)deletezBatches.deletesV> ^_o^rst t||#$4#5 6(+Q[el(   r+c t|std||jd|dt||||tS) 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 rCrD/cancelr0rErGr=rrrIs r)cancelzBatches.cancelsYJ ^_o^rst tzz#$4#5W =(+Q[el!   r+c |std||j|}|jstd|jddi|xsi}|j |jt ||||ttdS) . 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 rCrJBNo `results_url` for the given batch; Has it finished processing? Acceptapplication/binaryr0Tr;r<stream) rGrK results_urlrprocessing_statusrHrrr r(rJr1r2r3r4batchs r)resultszBatches.resultss@ ^_o^rst t /? @   TUZUlUlTmn "#7QMrrr?s r)r@zAsyncBatches.create^saBZZ ",j(-CEXEjEjkk(+Q[el!     k s!,AA AAAAc K|std||jd|t||||td{S7w)rBrCrDr0rENrFrIs r)rKzAsyncBatches.retrievesd> ^_o^rst tYY#$4#5 6(+Q[el!      ^_o^rst t\\#$4#5 6(+Q[el( "    rc K|std||jd|dt||||td{S7w)r_rCrDr`r0rENrarIs r)rbzAsyncBatches.cancelsgJ ^_o^rst tZZ#$4#5W =(+Q[el!      s=AAAc @K|std||j|d{}|jstd|jddi|xsi}|j |jt ||||ttd d{S7q7w) rdrCreNrfrgrhr0Tri) rGrKrkrrlrHrrr rms r)rozAsyncBatches.resultsEs@ ^_o^rst tmm5EmFF   TUZUlUlTmn "#7QM> NN  )@@     %<< LL  '>> NN  '>> NN  r+Nrr!rpNoner|r}r~rrr+r)r&r&y r+r&ceZdZddZy)rcz||_tj|j|_tj|j|_tj|j |_tj|j |_tj|j|_yr)rrasync_to_raw_response_wrapperr@rKrXr]rbrs r)rz$AsyncBatchesWithRawResponse.__init__s &DD NN  )FF     %BB LL  'DD NN  'DD NN  r+Nrr"rprrrr+r)rrrr+rceZdZddZy)r.c||_t|j|_t|j|_t|j|_t|j |_t|j |_yr)rrr@rKrXr]rbrs r)rz%BatchesWithStreamingResponse.__init__sr 2 NN  5     1 LL  3 NN  3 NN  r+Nrrrr+r)r.r.rr+r.ceZdZddZy)rc||_t|j|_t|j|_t|j|_t|j |_t|j |_yr)rrr@rKrXr]rbrs r)rz*AsyncBatchesWithStreamingResponse.__init__sr 8 NN  ;     7 LL  9 NN  9 NN  r+Nrrrr+r)rrrr+r)5 __future__rtypingrhttpxr_typesrrr r r r r _utilsrr_compatr _resourcerr _responserr paginationrr _exceptionsr _base_clientrrtypes.messagesrr_decoders.jsonlrrtypes.messages.message_batchr$types.messages.deleted_message_batchr0types.messages.message_batch_individual_responser __all__r!r"r&rr.rrr+r)rs# KKK<&:Y-)@D>8G^ n %l ol ^ l #l ^   *  *  *  r+