@ai-sdk/anthropic 4.0.20 → 4.0.21
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 +6 -0
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +14 -4
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/anthropic-api.ts +10 -0
- package/src/anthropic-language-model.ts +3 -0
- package/src/convert-anthropic-usage.ts +8 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -447,6 +447,9 @@ var anthropicResponseSchema = lazySchema3(
|
|
|
447
447
|
usage: z3.looseObject({
|
|
448
448
|
input_tokens: z3.number(),
|
|
449
449
|
output_tokens: z3.number(),
|
|
450
|
+
output_tokens_details: z3.object({
|
|
451
|
+
thinking_tokens: z3.number().nullish()
|
|
452
|
+
}).nullish(),
|
|
450
453
|
cache_creation_input_tokens: z3.number().nullish(),
|
|
451
454
|
cache_read_input_tokens: z3.number().nullish(),
|
|
452
455
|
iterations: z3.array(
|
|
@@ -894,6 +897,9 @@ var anthropicChunkSchema = lazySchema3(
|
|
|
894
897
|
usage: z3.looseObject({
|
|
895
898
|
input_tokens: z3.number().nullish(),
|
|
896
899
|
output_tokens: z3.number(),
|
|
900
|
+
output_tokens_details: z3.object({
|
|
901
|
+
thinking_tokens: z3.number().nullish()
|
|
902
|
+
}).nullish(),
|
|
897
903
|
cache_creation_input_tokens: z3.number().nullish(),
|
|
898
904
|
cache_read_input_tokens: z3.number().nullish(),
|
|
899
905
|
iterations: z3.array(
|
|
@@ -1963,12 +1969,13 @@ function convertAnthropicUsage({
|
|
|
1963
1969
|
usage,
|
|
1964
1970
|
rawUsage
|
|
1965
1971
|
}) {
|
|
1966
|
-
var _a, _b, _c;
|
|
1972
|
+
var _a, _b, _c, _d, _e;
|
|
1967
1973
|
const cacheCreationTokens = (_a = usage.cache_creation_input_tokens) != null ? _a : 0;
|
|
1968
1974
|
const cacheReadTokens = (_b = usage.cache_read_input_tokens) != null ? _b : 0;
|
|
1975
|
+
const reasoningTokens = (_d = (_c = usage.output_tokens_details) == null ? void 0 : _c.thinking_tokens) != null ? _d : void 0;
|
|
1969
1976
|
let inputTokens;
|
|
1970
1977
|
let outputTokens;
|
|
1971
|
-
const servedByFallback = (
|
|
1978
|
+
const servedByFallback = (_e = usage.iterations) == null ? void 0 : _e.some(
|
|
1972
1979
|
(iter) => iter.type === "fallback_message"
|
|
1973
1980
|
);
|
|
1974
1981
|
if (usage.iterations && usage.iterations.length > 0 && !servedByFallback) {
|
|
@@ -2002,8 +2009,8 @@ function convertAnthropicUsage({
|
|
|
2002
2009
|
},
|
|
2003
2010
|
outputTokens: {
|
|
2004
2011
|
total: outputTokens,
|
|
2005
|
-
text: void 0,
|
|
2006
|
-
reasoning:
|
|
2012
|
+
text: reasoningTokens == null ? void 0 : outputTokens - reasoningTokens,
|
|
2013
|
+
reasoning: reasoningTokens
|
|
2007
2014
|
},
|
|
2008
2015
|
raw: rawUsage != null ? rawUsage : usage
|
|
2009
2016
|
};
|
|
@@ -5402,6 +5409,9 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
5402
5409
|
usage.input_tokens = value.usage.input_tokens;
|
|
5403
5410
|
}
|
|
5404
5411
|
usage.output_tokens = value.usage.output_tokens;
|
|
5412
|
+
if (value.usage.output_tokens_details != null) {
|
|
5413
|
+
usage.output_tokens_details = value.usage.output_tokens_details;
|
|
5414
|
+
}
|
|
5405
5415
|
if (value.usage.cache_read_input_tokens != null) {
|
|
5406
5416
|
usage.cache_read_input_tokens = value.usage.cache_read_input_tokens;
|
|
5407
5417
|
}
|
|
@@ -6462,7 +6472,7 @@ var AnthropicSkills = class {
|
|
|
6462
6472
|
};
|
|
6463
6473
|
|
|
6464
6474
|
// src/version.ts
|
|
6465
|
-
var VERSION = true ? "4.0.
|
|
6475
|
+
var VERSION = true ? "4.0.21" : "0.0.0-test";
|
|
6466
6476
|
|
|
6467
6477
|
// src/anthropic-provider.ts
|
|
6468
6478
|
var ANTHROPIC_API_URL = "https://api.anthropic.com";
|