@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/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@ai-sdk/provider-utils";
|
|
13
13
|
|
|
14
14
|
// src/version.ts
|
|
15
|
-
var VERSION = true ? "3.0.
|
|
15
|
+
var VERSION = true ? "3.0.103" : "0.0.0-test";
|
|
16
16
|
|
|
17
17
|
// src/anthropic-messages-language-model.ts
|
|
18
18
|
import {
|
|
@@ -365,6 +365,9 @@ var anthropicMessagesResponseSchema = lazySchema2(
|
|
|
365
365
|
usage: z2.looseObject({
|
|
366
366
|
input_tokens: z2.number(),
|
|
367
367
|
output_tokens: z2.number(),
|
|
368
|
+
output_tokens_details: z2.object({
|
|
369
|
+
thinking_tokens: z2.number().nullish()
|
|
370
|
+
}).nullish(),
|
|
368
371
|
cache_creation_input_tokens: z2.number().nullish(),
|
|
369
372
|
cache_read_input_tokens: z2.number().nullish(),
|
|
370
373
|
iterations: z2.array(
|
|
@@ -812,6 +815,9 @@ var anthropicMessagesChunkSchema = lazySchema2(
|
|
|
812
815
|
usage: z2.looseObject({
|
|
813
816
|
input_tokens: z2.number().nullish(),
|
|
814
817
|
output_tokens: z2.number(),
|
|
818
|
+
output_tokens_details: z2.object({
|
|
819
|
+
thinking_tokens: z2.number().nullish()
|
|
820
|
+
}).nullish(),
|
|
815
821
|
cache_creation_input_tokens: z2.number().nullish(),
|
|
816
822
|
cache_read_input_tokens: z2.number().nullish(),
|
|
817
823
|
iterations: z2.array(
|
|
@@ -1869,12 +1875,13 @@ function convertAnthropicMessagesUsage({
|
|
|
1869
1875
|
usage,
|
|
1870
1876
|
rawUsage
|
|
1871
1877
|
}) {
|
|
1872
|
-
var _a, _b, _c;
|
|
1878
|
+
var _a, _b, _c, _d, _e;
|
|
1873
1879
|
const cacheCreationTokens = (_a = usage.cache_creation_input_tokens) != null ? _a : 0;
|
|
1874
1880
|
const cacheReadTokens = (_b = usage.cache_read_input_tokens) != null ? _b : 0;
|
|
1881
|
+
const reasoningTokens = (_d = (_c = usage.output_tokens_details) == null ? void 0 : _c.thinking_tokens) != null ? _d : void 0;
|
|
1875
1882
|
let inputTokens;
|
|
1876
1883
|
let outputTokens;
|
|
1877
|
-
const servedByFallback = (
|
|
1884
|
+
const servedByFallback = (_e = usage.iterations) == null ? void 0 : _e.some(
|
|
1878
1885
|
(iter) => iter.type === "fallback_message"
|
|
1879
1886
|
);
|
|
1880
1887
|
if (usage.iterations && usage.iterations.length > 0 && !servedByFallback) {
|
|
@@ -1908,8 +1915,8 @@ function convertAnthropicMessagesUsage({
|
|
|
1908
1915
|
},
|
|
1909
1916
|
outputTokens: {
|
|
1910
1917
|
total: outputTokens,
|
|
1911
|
-
text: void 0,
|
|
1912
|
-
reasoning:
|
|
1918
|
+
text: reasoningTokens == null ? void 0 : outputTokens - reasoningTokens,
|
|
1919
|
+
reasoning: reasoningTokens
|
|
1913
1920
|
},
|
|
1914
1921
|
raw: rawUsage != null ? rawUsage : usage
|
|
1915
1922
|
};
|
|
@@ -5205,6 +5212,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5205
5212
|
usage.input_tokens = value.usage.input_tokens;
|
|
5206
5213
|
}
|
|
5207
5214
|
usage.output_tokens = value.usage.output_tokens;
|
|
5215
|
+
if (value.usage.output_tokens_details != null) {
|
|
5216
|
+
usage.output_tokens_details = value.usage.output_tokens_details;
|
|
5217
|
+
}
|
|
5208
5218
|
if (value.usage.cache_read_input_tokens != null) {
|
|
5209
5219
|
usage.cache_read_input_tokens = value.usage.cache_read_input_tokens;
|
|
5210
5220
|
}
|