@ai-sdk/anthropic 2.0.33 → 2.0.35
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 +12 -0
- package/dist/index.d.mts +41 -2
- package/dist/index.d.ts +41 -2
- package/dist/index.js +58 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +51 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +51 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,12 +5,13 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
generateId as generateId2,
|
|
7
7
|
loadApiKey,
|
|
8
|
+
loadOptionalSetting,
|
|
8
9
|
withoutTrailingSlash,
|
|
9
10
|
withUserAgentSuffix
|
|
10
11
|
} from "@ai-sdk/provider-utils";
|
|
11
12
|
|
|
12
13
|
// src/version.ts
|
|
13
|
-
var VERSION = true ? "2.0.
|
|
14
|
+
var VERSION = true ? "2.0.35" : "0.0.0-test";
|
|
14
15
|
|
|
15
16
|
// src/anthropic-messages-language-model.ts
|
|
16
17
|
import {
|
|
@@ -238,7 +239,18 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
238
239
|
output_tokens: z2.number(),
|
|
239
240
|
cache_creation_input_tokens: z2.number().nullish(),
|
|
240
241
|
cache_read_input_tokens: z2.number().nullish()
|
|
241
|
-
})
|
|
242
|
+
}),
|
|
243
|
+
container: z2.object({
|
|
244
|
+
expires_at: z2.string(),
|
|
245
|
+
id: z2.string(),
|
|
246
|
+
skills: z2.array(
|
|
247
|
+
z2.object({
|
|
248
|
+
type: z2.union([z2.literal("anthropic"), z2.literal("custom")]),
|
|
249
|
+
skill_id: z2.string(),
|
|
250
|
+
version: z2.string()
|
|
251
|
+
})
|
|
252
|
+
).nullish()
|
|
253
|
+
}).nullish()
|
|
242
254
|
})
|
|
243
255
|
)
|
|
244
256
|
);
|
|
@@ -468,7 +480,21 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
468
480
|
type: z2.literal("message_delta"),
|
|
469
481
|
delta: z2.object({
|
|
470
482
|
stop_reason: z2.string().nullish(),
|
|
471
|
-
stop_sequence: z2.string().nullish()
|
|
483
|
+
stop_sequence: z2.string().nullish(),
|
|
484
|
+
container: z2.object({
|
|
485
|
+
expires_at: z2.string(),
|
|
486
|
+
id: z2.string(),
|
|
487
|
+
skills: z2.array(
|
|
488
|
+
z2.object({
|
|
489
|
+
type: z2.union([
|
|
490
|
+
z2.literal("anthropic"),
|
|
491
|
+
z2.literal("custom")
|
|
492
|
+
]),
|
|
493
|
+
skill_id: z2.string(),
|
|
494
|
+
version: z2.string()
|
|
495
|
+
})
|
|
496
|
+
).nullish()
|
|
497
|
+
}).nullish()
|
|
472
498
|
}),
|
|
473
499
|
usage: z2.looseObject({
|
|
474
500
|
output_tokens: z2.number(),
|
|
@@ -1969,7 +1995,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1969
1995
|
});
|
|
1970
1996
|
}
|
|
1971
1997
|
async doGenerate(options) {
|
|
1972
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1998
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1973
1999
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1974
2000
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1975
2001
|
const {
|
|
@@ -2220,7 +2246,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2220
2246
|
anthropic: {
|
|
2221
2247
|
usage: response.usage,
|
|
2222
2248
|
cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
|
|
2223
|
-
stopSequence: (_f = response.stop_sequence) != null ? _f : null
|
|
2249
|
+
stopSequence: (_f = response.stop_sequence) != null ? _f : null,
|
|
2250
|
+
container: response.container ? {
|
|
2251
|
+
expiresAt: response.container.expires_at,
|
|
2252
|
+
id: response.container.id,
|
|
2253
|
+
skills: (_h = (_g = response.container.skills) == null ? void 0 : _g.map((skill) => ({
|
|
2254
|
+
type: skill.type,
|
|
2255
|
+
skillId: skill.skill_id,
|
|
2256
|
+
version: skill.version
|
|
2257
|
+
}))) != null ? _h : null
|
|
2258
|
+
} : null
|
|
2224
2259
|
}
|
|
2225
2260
|
}
|
|
2226
2261
|
};
|
|
@@ -2250,6 +2285,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2250
2285
|
let rawUsage = void 0;
|
|
2251
2286
|
let cacheCreationInputTokens = null;
|
|
2252
2287
|
let stopSequence = null;
|
|
2288
|
+
let container = null;
|
|
2253
2289
|
let blockType = void 0;
|
|
2254
2290
|
const generateId3 = this.generateId;
|
|
2255
2291
|
return {
|
|
@@ -2259,7 +2295,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2259
2295
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2260
2296
|
},
|
|
2261
2297
|
transform(chunk, controller) {
|
|
2262
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2298
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2263
2299
|
if (options.includeRawChunks) {
|
|
2264
2300
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2265
2301
|
}
|
|
@@ -2640,6 +2676,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2640
2676
|
isJsonResponseFromTool: usesJsonResponseTool
|
|
2641
2677
|
});
|
|
2642
2678
|
stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
|
|
2679
|
+
container = value.delta.container != null ? {
|
|
2680
|
+
expiresAt: value.delta.container.expires_at,
|
|
2681
|
+
id: value.delta.container.id,
|
|
2682
|
+
skills: (_j = (_i = value.delta.container.skills) == null ? void 0 : _i.map((skill) => ({
|
|
2683
|
+
type: skill.type,
|
|
2684
|
+
skillId: skill.skill_id,
|
|
2685
|
+
version: skill.version
|
|
2686
|
+
}))) != null ? _j : null
|
|
2687
|
+
} : null;
|
|
2643
2688
|
rawUsage = {
|
|
2644
2689
|
...rawUsage,
|
|
2645
2690
|
...value.usage
|
|
@@ -2655,7 +2700,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2655
2700
|
anthropic: {
|
|
2656
2701
|
usage: rawUsage != null ? rawUsage : null,
|
|
2657
2702
|
cacheCreationInputTokens,
|
|
2658
|
-
stopSequence
|
|
2703
|
+
stopSequence,
|
|
2704
|
+
container
|
|
2659
2705
|
}
|
|
2660
2706
|
}
|
|
2661
2707
|
});
|
|
@@ -3091,7 +3137,12 @@ var anthropicTools = {
|
|
|
3091
3137
|
// src/anthropic-provider.ts
|
|
3092
3138
|
function createAnthropic(options = {}) {
|
|
3093
3139
|
var _a;
|
|
3094
|
-
const baseURL = (_a = withoutTrailingSlash(
|
|
3140
|
+
const baseURL = (_a = withoutTrailingSlash(
|
|
3141
|
+
loadOptionalSetting({
|
|
3142
|
+
settingValue: options.baseURL,
|
|
3143
|
+
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
3144
|
+
})
|
|
3145
|
+
)) != null ? _a : "https://api.anthropic.com/v1";
|
|
3095
3146
|
const getHeaders = () => withUserAgentSuffix(
|
|
3096
3147
|
{
|
|
3097
3148
|
"anthropic-version": "2023-06-01",
|