@ai-sdk/anthropic 2.0.58 → 2.0.59
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.d.mts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +32 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +31 -11
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +31 -11
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.mjs
CHANGED
|
@@ -562,10 +562,20 @@ var anthropicProviderOptions = z3.object({
|
|
|
562
562
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
563
563
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
564
564
|
*/
|
|
565
|
-
thinking: z3.
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
565
|
+
thinking: z3.discriminatedUnion("type", [
|
|
566
|
+
z3.object({
|
|
567
|
+
/** for Opus 4.6 and newer models */
|
|
568
|
+
type: z3.literal("adaptive")
|
|
569
|
+
}),
|
|
570
|
+
z3.object({
|
|
571
|
+
/** for models before Opus 4.6 */
|
|
572
|
+
type: z3.literal("enabled"),
|
|
573
|
+
budgetTokens: z3.number().optional()
|
|
574
|
+
}),
|
|
575
|
+
z3.object({
|
|
576
|
+
type: z3.literal("disabled")
|
|
577
|
+
})
|
|
578
|
+
]).optional(),
|
|
569
579
|
/**
|
|
570
580
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
571
581
|
* When set to true, Claude will use at most one tool per response.
|
|
@@ -597,7 +607,7 @@ var anthropicProviderOptions = z3.object({
|
|
|
597
607
|
/**
|
|
598
608
|
* @default 'high'
|
|
599
609
|
*/
|
|
600
|
-
effort: z3.enum(["low", "medium", "high"]).optional()
|
|
610
|
+
effort: z3.enum(["low", "medium", "high", "max"]).optional()
|
|
601
611
|
});
|
|
602
612
|
|
|
603
613
|
// src/anthropic-prepare-tools.ts
|
|
@@ -1879,8 +1889,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1879
1889
|
warnings,
|
|
1880
1890
|
cacheControlValidator
|
|
1881
1891
|
});
|
|
1882
|
-
const
|
|
1883
|
-
const
|
|
1892
|
+
const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
|
|
1893
|
+
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
1894
|
+
let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
|
|
1884
1895
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
1885
1896
|
const baseArgs = {
|
|
1886
1897
|
// model id:
|
|
@@ -1893,7 +1904,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1893
1904
|
stop_sequences: stopSequences,
|
|
1894
1905
|
// provider specific settings:
|
|
1895
1906
|
...isThinking && {
|
|
1896
|
-
thinking: {
|
|
1907
|
+
thinking: {
|
|
1908
|
+
type: thinkingType,
|
|
1909
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
1910
|
+
}
|
|
1897
1911
|
},
|
|
1898
1912
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
1899
1913
|
output_config: { effort: anthropicOptions.effort }
|
|
@@ -1921,7 +1935,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1921
1935
|
messages: messagesPrompt.messages
|
|
1922
1936
|
};
|
|
1923
1937
|
if (isThinking) {
|
|
1924
|
-
if (thinkingBudget == null) {
|
|
1938
|
+
if (thinkingType === "enabled" && thinkingBudget == null) {
|
|
1925
1939
|
throw new UnsupportedFunctionalityError3({
|
|
1926
1940
|
functionality: "thinking requires a budget"
|
|
1927
1941
|
});
|
|
@@ -1950,7 +1964,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1950
1964
|
details: "topP is not supported when thinking is enabled"
|
|
1951
1965
|
});
|
|
1952
1966
|
}
|
|
1953
|
-
baseArgs.max_tokens = maxTokens + thinkingBudget;
|
|
1967
|
+
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
1954
1968
|
}
|
|
1955
1969
|
if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
|
|
1956
1970
|
if (maxOutputTokens != null) {
|
|
@@ -2839,7 +2853,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2839
2853
|
}
|
|
2840
2854
|
};
|
|
2841
2855
|
function getModelCapabilities(modelId) {
|
|
2842
|
-
if (modelId.includes("claude-
|
|
2856
|
+
if (modelId.includes("claude-opus-4-6")) {
|
|
2857
|
+
return {
|
|
2858
|
+
maxOutputTokens: 128e3,
|
|
2859
|
+
supportsStructuredOutput: true,
|
|
2860
|
+
isKnownModel: true
|
|
2861
|
+
};
|
|
2862
|
+
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
|
|
2843
2863
|
return {
|
|
2844
2864
|
maxOutputTokens: 64e3,
|
|
2845
2865
|
supportsStructuredOutput: true,
|