@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/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "@ai-sdk/provider-utils";
|
|
12
12
|
|
|
13
13
|
// src/version.ts
|
|
14
|
-
var VERSION = true ? "2.0.
|
|
14
|
+
var VERSION = true ? "2.0.59" : "0.0.0-test";
|
|
15
15
|
|
|
16
16
|
// src/anthropic-messages-language-model.ts
|
|
17
17
|
import {
|
|
@@ -577,10 +577,20 @@ var anthropicProviderOptions = z3.object({
|
|
|
577
577
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
578
578
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
579
579
|
*/
|
|
580
|
-
thinking: z3.
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
580
|
+
thinking: z3.discriminatedUnion("type", [
|
|
581
|
+
z3.object({
|
|
582
|
+
/** for Opus 4.6 and newer models */
|
|
583
|
+
type: z3.literal("adaptive")
|
|
584
|
+
}),
|
|
585
|
+
z3.object({
|
|
586
|
+
/** for models before Opus 4.6 */
|
|
587
|
+
type: z3.literal("enabled"),
|
|
588
|
+
budgetTokens: z3.number().optional()
|
|
589
|
+
}),
|
|
590
|
+
z3.object({
|
|
591
|
+
type: z3.literal("disabled")
|
|
592
|
+
})
|
|
593
|
+
]).optional(),
|
|
584
594
|
/**
|
|
585
595
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
586
596
|
* When set to true, Claude will use at most one tool per response.
|
|
@@ -612,7 +622,7 @@ var anthropicProviderOptions = z3.object({
|
|
|
612
622
|
/**
|
|
613
623
|
* @default 'high'
|
|
614
624
|
*/
|
|
615
|
-
effort: z3.enum(["low", "medium", "high"]).optional()
|
|
625
|
+
effort: z3.enum(["low", "medium", "high", "max"]).optional()
|
|
616
626
|
});
|
|
617
627
|
|
|
618
628
|
// src/anthropic-prepare-tools.ts
|
|
@@ -1894,8 +1904,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1894
1904
|
warnings,
|
|
1895
1905
|
cacheControlValidator
|
|
1896
1906
|
});
|
|
1897
|
-
const
|
|
1898
|
-
const
|
|
1907
|
+
const thinkingType = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type;
|
|
1908
|
+
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
1909
|
+
let thinkingBudget = thinkingType === "enabled" ? (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.budgetTokens : void 0;
|
|
1899
1910
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
1900
1911
|
const baseArgs = {
|
|
1901
1912
|
// model id:
|
|
@@ -1908,7 +1919,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1908
1919
|
stop_sequences: stopSequences,
|
|
1909
1920
|
// provider specific settings:
|
|
1910
1921
|
...isThinking && {
|
|
1911
|
-
thinking: {
|
|
1922
|
+
thinking: {
|
|
1923
|
+
type: thinkingType,
|
|
1924
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
1925
|
+
}
|
|
1912
1926
|
},
|
|
1913
1927
|
...(anthropicOptions == null ? void 0 : anthropicOptions.effort) && {
|
|
1914
1928
|
output_config: { effort: anthropicOptions.effort }
|
|
@@ -1936,7 +1950,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1936
1950
|
messages: messagesPrompt.messages
|
|
1937
1951
|
};
|
|
1938
1952
|
if (isThinking) {
|
|
1939
|
-
if (thinkingBudget == null) {
|
|
1953
|
+
if (thinkingType === "enabled" && thinkingBudget == null) {
|
|
1940
1954
|
throw new UnsupportedFunctionalityError3({
|
|
1941
1955
|
functionality: "thinking requires a budget"
|
|
1942
1956
|
});
|
|
@@ -1965,7 +1979,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1965
1979
|
details: "topP is not supported when thinking is enabled"
|
|
1966
1980
|
});
|
|
1967
1981
|
}
|
|
1968
|
-
baseArgs.max_tokens = maxTokens + thinkingBudget;
|
|
1982
|
+
baseArgs.max_tokens = maxTokens + (thinkingBudget != null ? thinkingBudget : 0);
|
|
1969
1983
|
}
|
|
1970
1984
|
if (isKnownModel && baseArgs.max_tokens > maxOutputTokensForModel) {
|
|
1971
1985
|
if (maxOutputTokens != null) {
|
|
@@ -2854,7 +2868,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2854
2868
|
}
|
|
2855
2869
|
};
|
|
2856
2870
|
function getModelCapabilities(modelId) {
|
|
2857
|
-
if (modelId.includes("claude-
|
|
2871
|
+
if (modelId.includes("claude-opus-4-6")) {
|
|
2872
|
+
return {
|
|
2873
|
+
maxOutputTokens: 128e3,
|
|
2874
|
+
supportsStructuredOutput: true,
|
|
2875
|
+
isKnownModel: true
|
|
2876
|
+
};
|
|
2877
|
+
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
|
|
2858
2878
|
return {
|
|
2859
2879
|
maxOutputTokens: 64e3,
|
|
2860
2880
|
supportsStructuredOutput: true,
|