@ai-sdk/anthropic 3.0.102 → 3.0.103
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/index.mjs +15 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +14 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +14 -4
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +10 -0
- package/src/anthropic-messages-language-model.ts +3 -0
- package/src/convert-anthropic-messages-usage.ts +8 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
|
|
|
32
32
|
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
|
33
33
|
|
|
34
34
|
// src/version.ts
|
|
35
|
-
var VERSION = true ? "3.0.
|
|
35
|
+
var VERSION = true ? "3.0.103" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -366,6 +366,9 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
366
366
|
usage: import_v42.z.looseObject({
|
|
367
367
|
input_tokens: import_v42.z.number(),
|
|
368
368
|
output_tokens: import_v42.z.number(),
|
|
369
|
+
output_tokens_details: import_v42.z.object({
|
|
370
|
+
thinking_tokens: import_v42.z.number().nullish()
|
|
371
|
+
}).nullish(),
|
|
369
372
|
cache_creation_input_tokens: import_v42.z.number().nullish(),
|
|
370
373
|
cache_read_input_tokens: import_v42.z.number().nullish(),
|
|
371
374
|
iterations: import_v42.z.array(
|
|
@@ -813,6 +816,9 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
813
816
|
usage: import_v42.z.looseObject({
|
|
814
817
|
input_tokens: import_v42.z.number().nullish(),
|
|
815
818
|
output_tokens: import_v42.z.number(),
|
|
819
|
+
output_tokens_details: import_v42.z.object({
|
|
820
|
+
thinking_tokens: import_v42.z.number().nullish()
|
|
821
|
+
}).nullish(),
|
|
816
822
|
cache_creation_input_tokens: import_v42.z.number().nullish(),
|
|
817
823
|
cache_read_input_tokens: import_v42.z.number().nullish(),
|
|
818
824
|
iterations: import_v42.z.array(
|
|
@@ -1844,12 +1850,13 @@ function convertAnthropicMessagesUsage({
|
|
|
1844
1850
|
usage,
|
|
1845
1851
|
rawUsage
|
|
1846
1852
|
}) {
|
|
1847
|
-
var _a, _b, _c;
|
|
1853
|
+
var _a, _b, _c, _d, _e;
|
|
1848
1854
|
const cacheCreationTokens = (_a = usage.cache_creation_input_tokens) != null ? _a : 0;
|
|
1849
1855
|
const cacheReadTokens = (_b = usage.cache_read_input_tokens) != null ? _b : 0;
|
|
1856
|
+
const reasoningTokens = (_d = (_c = usage.output_tokens_details) == null ? void 0 : _c.thinking_tokens) != null ? _d : void 0;
|
|
1850
1857
|
let inputTokens;
|
|
1851
1858
|
let outputTokens;
|
|
1852
|
-
const servedByFallback = (
|
|
1859
|
+
const servedByFallback = (_e = usage.iterations) == null ? void 0 : _e.some(
|
|
1853
1860
|
(iter) => iter.type === "fallback_message"
|
|
1854
1861
|
);
|
|
1855
1862
|
if (usage.iterations && usage.iterations.length > 0 && !servedByFallback) {
|
|
@@ -1883,8 +1890,8 @@ function convertAnthropicMessagesUsage({
|
|
|
1883
1890
|
},
|
|
1884
1891
|
outputTokens: {
|
|
1885
1892
|
total: outputTokens,
|
|
1886
|
-
text: void 0,
|
|
1887
|
-
reasoning:
|
|
1893
|
+
text: reasoningTokens == null ? void 0 : outputTokens - reasoningTokens,
|
|
1894
|
+
reasoning: reasoningTokens
|
|
1888
1895
|
},
|
|
1889
1896
|
raw: rawUsage != null ? rawUsage : usage
|
|
1890
1897
|
};
|
|
@@ -5154,6 +5161,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5154
5161
|
usage.input_tokens = value.usage.input_tokens;
|
|
5155
5162
|
}
|
|
5156
5163
|
usage.output_tokens = value.usage.output_tokens;
|
|
5164
|
+
if (value.usage.output_tokens_details != null) {
|
|
5165
|
+
usage.output_tokens_details = value.usage.output_tokens_details;
|
|
5166
|
+
}
|
|
5157
5167
|
if (value.usage.cache_read_input_tokens != null) {
|
|
5158
5168
|
usage.cache_read_input_tokens = value.usage.cache_read_input_tokens;
|
|
5159
5169
|
}
|