@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/internal/index.js
CHANGED
|
@@ -360,6 +360,9 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
360
360
|
usage: import_v42.z.looseObject({
|
|
361
361
|
input_tokens: import_v42.z.number(),
|
|
362
362
|
output_tokens: import_v42.z.number(),
|
|
363
|
+
output_tokens_details: import_v42.z.object({
|
|
364
|
+
thinking_tokens: import_v42.z.number().nullish()
|
|
365
|
+
}).nullish(),
|
|
363
366
|
cache_creation_input_tokens: import_v42.z.number().nullish(),
|
|
364
367
|
cache_read_input_tokens: import_v42.z.number().nullish(),
|
|
365
368
|
iterations: import_v42.z.array(
|
|
@@ -807,6 +810,9 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
807
810
|
usage: import_v42.z.looseObject({
|
|
808
811
|
input_tokens: import_v42.z.number().nullish(),
|
|
809
812
|
output_tokens: import_v42.z.number(),
|
|
813
|
+
output_tokens_details: import_v42.z.object({
|
|
814
|
+
thinking_tokens: import_v42.z.number().nullish()
|
|
815
|
+
}).nullish(),
|
|
810
816
|
cache_creation_input_tokens: import_v42.z.number().nullish(),
|
|
811
817
|
cache_read_input_tokens: import_v42.z.number().nullish(),
|
|
812
818
|
iterations: import_v42.z.array(
|
|
@@ -1838,12 +1844,13 @@ function convertAnthropicMessagesUsage({
|
|
|
1838
1844
|
usage,
|
|
1839
1845
|
rawUsage
|
|
1840
1846
|
}) {
|
|
1841
|
-
var _a, _b, _c;
|
|
1847
|
+
var _a, _b, _c, _d, _e;
|
|
1842
1848
|
const cacheCreationTokens = (_a = usage.cache_creation_input_tokens) != null ? _a : 0;
|
|
1843
1849
|
const cacheReadTokens = (_b = usage.cache_read_input_tokens) != null ? _b : 0;
|
|
1850
|
+
const reasoningTokens = (_d = (_c = usage.output_tokens_details) == null ? void 0 : _c.thinking_tokens) != null ? _d : void 0;
|
|
1844
1851
|
let inputTokens;
|
|
1845
1852
|
let outputTokens;
|
|
1846
|
-
const servedByFallback = (
|
|
1853
|
+
const servedByFallback = (_e = usage.iterations) == null ? void 0 : _e.some(
|
|
1847
1854
|
(iter) => iter.type === "fallback_message"
|
|
1848
1855
|
);
|
|
1849
1856
|
if (usage.iterations && usage.iterations.length > 0 && !servedByFallback) {
|
|
@@ -1877,8 +1884,8 @@ function convertAnthropicMessagesUsage({
|
|
|
1877
1884
|
},
|
|
1878
1885
|
outputTokens: {
|
|
1879
1886
|
total: outputTokens,
|
|
1880
|
-
text: void 0,
|
|
1881
|
-
reasoning:
|
|
1887
|
+
text: reasoningTokens == null ? void 0 : outputTokens - reasoningTokens,
|
|
1888
|
+
reasoning: reasoningTokens
|
|
1882
1889
|
},
|
|
1883
1890
|
raw: rawUsage != null ? rawUsage : usage
|
|
1884
1891
|
};
|
|
@@ -5148,6 +5155,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
5148
5155
|
usage.input_tokens = value.usage.input_tokens;
|
|
5149
5156
|
}
|
|
5150
5157
|
usage.output_tokens = value.usage.output_tokens;
|
|
5158
|
+
if (value.usage.output_tokens_details != null) {
|
|
5159
|
+
usage.output_tokens_details = value.usage.output_tokens_details;
|
|
5160
|
+
}
|
|
5151
5161
|
if (value.usage.cache_read_input_tokens != null) {
|
|
5152
5162
|
usage.cache_read_input_tokens = value.usage.cache_read_input_tokens;
|
|
5153
5163
|
}
|