mirror of
https://github.com/Onewon/claude-code.git
synced 2026-04-26 23:01:23 +03:00
Add all the original files from the deleted 0.2.8 npm package
This commit is contained in:
112
vendor/sdk/resources/beta/messages/batches.js
vendored
Normal file
112
vendor/sdk/resources/beta/messages/batches.js
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BetaMessageBatchesPage = exports.Batches = void 0;
|
||||
const resource_1 = require("../../../resource.js");
|
||||
const core_1 = require("../../../core.js");
|
||||
const pagination_1 = require("../../../pagination.js");
|
||||
const jsonl_1 = require("../../../internal/decoders/jsonl.js");
|
||||
const error_1 = require("../../../error.js");
|
||||
class Batches extends resource_1.APIResource {
|
||||
/**
|
||||
* 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](/en/docs/build-with-claude/batch-processing)
|
||||
*/
|
||||
create(params, options) {
|
||||
const { betas, ...body } = params;
|
||||
return this._client.post('/v1/messages/batches?beta=true', {
|
||||
body,
|
||||
...options,
|
||||
headers: {
|
||||
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
}
|
||||
retrieve(messageBatchId, params = {}, options) {
|
||||
if ((0, core_1.isRequestOptions)(params)) {
|
||||
return this.retrieve(messageBatchId, {}, params);
|
||||
}
|
||||
const { betas } = params;
|
||||
return this._client.get(`/v1/messages/batches/${messageBatchId}?beta=true`, {
|
||||
...options,
|
||||
headers: {
|
||||
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
}
|
||||
list(params = {}, options) {
|
||||
if ((0, core_1.isRequestOptions)(params)) {
|
||||
return this.list({}, params);
|
||||
}
|
||||
const { betas, ...query } = params;
|
||||
return this._client.getAPIList('/v1/messages/batches?beta=true', BetaMessageBatchesPage, {
|
||||
query,
|
||||
...options,
|
||||
headers: {
|
||||
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
}
|
||||
delete(messageBatchId, params = {}, options) {
|
||||
if ((0, core_1.isRequestOptions)(params)) {
|
||||
return this.delete(messageBatchId, {}, params);
|
||||
}
|
||||
const { betas } = params;
|
||||
return this._client.delete(`/v1/messages/batches/${messageBatchId}?beta=true`, {
|
||||
...options,
|
||||
headers: {
|
||||
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
}
|
||||
cancel(messageBatchId, params = {}, options) {
|
||||
if ((0, core_1.isRequestOptions)(params)) {
|
||||
return this.cancel(messageBatchId, {}, params);
|
||||
}
|
||||
const { betas } = params;
|
||||
return this._client.post(`/v1/messages/batches/${messageBatchId}/cancel?beta=true`, {
|
||||
...options,
|
||||
headers: {
|
||||
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
}
|
||||
async results(messageBatchId, params = {}, options) {
|
||||
if ((0, core_1.isRequestOptions)(params)) {
|
||||
return this.results(messageBatchId, {}, params);
|
||||
}
|
||||
const batch = await this.retrieve(messageBatchId);
|
||||
if (!batch.results_url) {
|
||||
throw new error_1.AnthropicError(`No batch \`results_url\`; Has it finished processing? ${batch.processing_status} - ${batch.id}`);
|
||||
}
|
||||
const { betas } = params;
|
||||
return this._client
|
||||
.get(batch.results_url, {
|
||||
...options,
|
||||
headers: {
|
||||
'anthropic-beta': [...(betas ?? []), 'message-batches-2024-09-24'].toString(),
|
||||
Accept: 'application/binary',
|
||||
...options?.headers,
|
||||
},
|
||||
__binaryResponse: true,
|
||||
})
|
||||
._thenUnwrap((_, props) => jsonl_1.JSONLDecoder.fromResponse(props.response, props.controller));
|
||||
}
|
||||
}
|
||||
exports.Batches = Batches;
|
||||
class BetaMessageBatchesPage extends pagination_1.Page {
|
||||
}
|
||||
exports.BetaMessageBatchesPage = BetaMessageBatchesPage;
|
||||
Batches.BetaMessageBatchesPage = BetaMessageBatchesPage;
|
||||
//# sourceMappingURL=batches.js.map
|
||||
Reference in New Issue
Block a user