@ai-sdk/anthropic 4.0.50 → 4.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/index.js +66 -17
- package/dist/index.js.map +1 -1
- package/docs/05-anthropic.mdx +4 -53
- package/package.json +3 -3
- package/src/anthropic-batch.ts +80 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.52
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5a7e647: feat(anthropic): add batch cancellation and listing
|
|
8
|
+
- Updated dependencies [9942196]
|
|
9
|
+
- @ai-sdk/provider@4.0.13
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.39
|
|
11
|
+
|
|
12
|
+
## 4.0.51
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [912fb01]
|
|
17
|
+
- @ai-sdk/provider@4.0.12
|
|
18
|
+
- @ai-sdk/provider-utils@5.0.38
|
|
19
|
+
|
|
3
20
|
## 4.0.50
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -6008,25 +6008,33 @@ var anthropicBatchRequestIdPattern = /^[A-Za-z0-9_-]{1,64}$/;
|
|
|
6008
6008
|
var anthropicBatchProviderOptionsSchema = anthropicLanguageModelOptions.pick({
|
|
6009
6009
|
anthropicBeta: true
|
|
6010
6010
|
});
|
|
6011
|
+
var anthropicBatchResponseZodSchema = () => z15.object({
|
|
6012
|
+
id: z15.string(),
|
|
6013
|
+
type: z15.literal("message_batch"),
|
|
6014
|
+
processing_status: z15.string(),
|
|
6015
|
+
request_counts: z15.object({
|
|
6016
|
+
processing: z15.number(),
|
|
6017
|
+
succeeded: z15.number(),
|
|
6018
|
+
errored: z15.number(),
|
|
6019
|
+
canceled: z15.number(),
|
|
6020
|
+
expired: z15.number()
|
|
6021
|
+
}),
|
|
6022
|
+
created_at: z15.string(),
|
|
6023
|
+
expires_at: z15.string(),
|
|
6024
|
+
archived_at: z15.string().nullish(),
|
|
6025
|
+
cancel_initiated_at: z15.string().nullish(),
|
|
6026
|
+
ended_at: z15.string().nullish(),
|
|
6027
|
+
results_url: z15.string().nullish()
|
|
6028
|
+
});
|
|
6011
6029
|
var anthropicBatchResponseSchema = lazySchema14(
|
|
6030
|
+
() => zodSchema14(anthropicBatchResponseZodSchema())
|
|
6031
|
+
);
|
|
6032
|
+
var anthropicBatchListResponseSchema = lazySchema14(
|
|
6012
6033
|
() => zodSchema14(
|
|
6013
6034
|
z15.object({
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
request_counts: z15.object({
|
|
6018
|
-
processing: z15.number(),
|
|
6019
|
-
succeeded: z15.number(),
|
|
6020
|
-
errored: z15.number(),
|
|
6021
|
-
canceled: z15.number(),
|
|
6022
|
-
expired: z15.number()
|
|
6023
|
-
}),
|
|
6024
|
-
created_at: z15.string(),
|
|
6025
|
-
expires_at: z15.string(),
|
|
6026
|
-
archived_at: z15.string().nullish(),
|
|
6027
|
-
cancel_initiated_at: z15.string().nullish(),
|
|
6028
|
-
ended_at: z15.string().nullish(),
|
|
6029
|
-
results_url: z15.string().nullish()
|
|
6035
|
+
data: z15.array(anthropicBatchResponseZodSchema()),
|
|
6036
|
+
has_more: z15.boolean(),
|
|
6037
|
+
last_id: z15.string().nullish()
|
|
6030
6038
|
})
|
|
6031
6039
|
)
|
|
6032
6040
|
);
|
|
@@ -6187,6 +6195,47 @@ var AnthropicBatch = class {
|
|
|
6187
6195
|
async doGetBatchStatus(options) {
|
|
6188
6196
|
return convertAnthropicBatchStatus(await this.retrieveBatch(options));
|
|
6189
6197
|
}
|
|
6198
|
+
async doCancelBatch(options) {
|
|
6199
|
+
await postJsonToApi2({
|
|
6200
|
+
url: this.getBatchUrl(`/${encodeURIComponent(options.batchId)}/cancel`),
|
|
6201
|
+
headers: await this.getBatchHeaders(options.headers),
|
|
6202
|
+
body: {},
|
|
6203
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
6204
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
6205
|
+
anthropicBatchResponseSchema
|
|
6206
|
+
),
|
|
6207
|
+
abortSignal: options.abortSignal,
|
|
6208
|
+
fetch: this.options.config.fetch
|
|
6209
|
+
});
|
|
6210
|
+
return {};
|
|
6211
|
+
}
|
|
6212
|
+
async doListBatches(options) {
|
|
6213
|
+
const url = new URL(this.getBatchUrl(""));
|
|
6214
|
+
if (options.limit != null) {
|
|
6215
|
+
url.searchParams.set("limit", String(options.limit));
|
|
6216
|
+
}
|
|
6217
|
+
if (options.cursor != null) {
|
|
6218
|
+
url.searchParams.set("after_id", options.cursor);
|
|
6219
|
+
}
|
|
6220
|
+
const { value: page } = await getFromApi({
|
|
6221
|
+
url: url.toString(),
|
|
6222
|
+
validateUrl: false,
|
|
6223
|
+
headers: await this.getBatchHeaders(options.headers),
|
|
6224
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
6225
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
6226
|
+
anthropicBatchListResponseSchema
|
|
6227
|
+
),
|
|
6228
|
+
abortSignal: options.abortSignal,
|
|
6229
|
+
fetch: this.options.config.fetch
|
|
6230
|
+
});
|
|
6231
|
+
return {
|
|
6232
|
+
batches: page.data.map((batch) => ({
|
|
6233
|
+
batchId: batch.id,
|
|
6234
|
+
...convertAnthropicBatchStatus(batch)
|
|
6235
|
+
})),
|
|
6236
|
+
...page.has_more && page.last_id != null ? { nextCursor: page.last_id } : {}
|
|
6237
|
+
};
|
|
6238
|
+
}
|
|
6190
6239
|
async doGetBatchResults(options) {
|
|
6191
6240
|
const batch = await this.retrieveBatch(options);
|
|
6192
6241
|
if (convertAnthropicBatchStatus(batch).status === "pending") {
|
|
@@ -7573,7 +7622,7 @@ var AnthropicSkills = class {
|
|
|
7573
7622
|
};
|
|
7574
7623
|
|
|
7575
7624
|
// src/version.ts
|
|
7576
|
-
var VERSION = true ? "4.0.
|
|
7625
|
+
var VERSION = true ? "4.0.52" : "0.0.0-test";
|
|
7577
7626
|
|
|
7578
7627
|
// src/anthropic-provider.ts
|
|
7579
7628
|
var ANTHROPIC_API_URL = "https://api.anthropic.com";
|