@ai-sdk/anthropic 4.0.0-beta.3 → 4.0.0-beta.4
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 +26 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +11 -2
- package/dist/internal/index.d.ts +11 -2
- package/dist/internal/index.js +25 -14
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +22 -11
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/anthropic-messages-language-model.ts +12 -0
- package/src/anthropic-prepare-tools.ts +16 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,21 +18,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
VERSION: () => VERSION,
|
|
24
24
|
anthropic: () => anthropic,
|
|
25
25
|
createAnthropic: () => createAnthropic,
|
|
26
26
|
forwardAnthropicContainerIdFromLastStep: () => forwardAnthropicContainerIdFromLastStep
|
|
27
27
|
});
|
|
28
|
-
module.exports = __toCommonJS(
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
29
|
|
|
30
30
|
// src/anthropic-provider.ts
|
|
31
31
|
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 ? "4.0.0-beta.
|
|
35
|
+
var VERSION = true ? "4.0.0-beta.4" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -1269,7 +1269,8 @@ async function prepareTools({
|
|
|
1269
1269
|
toolChoice,
|
|
1270
1270
|
disableParallelToolUse,
|
|
1271
1271
|
cacheControlValidator,
|
|
1272
|
-
supportsStructuredOutput
|
|
1272
|
+
supportsStructuredOutput,
|
|
1273
|
+
supportsStrictTools
|
|
1273
1274
|
}) {
|
|
1274
1275
|
var _a;
|
|
1275
1276
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -1291,13 +1292,20 @@ async function prepareTools({
|
|
|
1291
1292
|
const eagerInputStreaming = anthropicOptions == null ? void 0 : anthropicOptions.eagerInputStreaming;
|
|
1292
1293
|
const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
|
|
1293
1294
|
const allowedCallers = anthropicOptions == null ? void 0 : anthropicOptions.allowedCallers;
|
|
1295
|
+
if (!supportsStrictTools && tool.strict != null) {
|
|
1296
|
+
toolWarnings.push({
|
|
1297
|
+
type: "unsupported",
|
|
1298
|
+
feature: "strict",
|
|
1299
|
+
details: `Tool '${tool.name}' has strict: ${tool.strict}, but strict mode is not supported by this provider. The strict property will be ignored.`
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1294
1302
|
anthropicTools2.push({
|
|
1295
1303
|
name: tool.name,
|
|
1296
1304
|
description: tool.description,
|
|
1297
1305
|
input_schema: tool.inputSchema,
|
|
1298
1306
|
cache_control: cacheControl,
|
|
1299
1307
|
...eagerInputStreaming ? { eager_input_streaming: true } : {},
|
|
1300
|
-
...
|
|
1308
|
+
...supportsStrictTools === true && tool.strict != null ? { strict: tool.strict } : {},
|
|
1301
1309
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
1302
1310
|
...allowedCallers != null ? { allowed_callers: allowedCallers } : {},
|
|
1303
1311
|
...tool.inputExamples != null ? {
|
|
@@ -2872,7 +2880,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2872
2880
|
providerOptions,
|
|
2873
2881
|
stream
|
|
2874
2882
|
}) {
|
|
2875
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2883
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2876
2884
|
const warnings = [];
|
|
2877
2885
|
if (frequencyPenalty != null) {
|
|
2878
2886
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -2930,7 +2938,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2930
2938
|
isKnownModel
|
|
2931
2939
|
} = getModelCapabilities(this.modelId);
|
|
2932
2940
|
const supportsStructuredOutput = ((_a = this.config.supportsNativeStructuredOutput) != null ? _a : true) && modelSupportsStructuredOutput;
|
|
2933
|
-
const
|
|
2941
|
+
const supportsStrictTools = ((_b = this.config.supportsStrictTools) != null ? _b : true) && modelSupportsStructuredOutput;
|
|
2942
|
+
const structureOutputMode = (_c = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _c : "auto";
|
|
2934
2943
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2935
2944
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
2936
2945
|
type: "function",
|
|
@@ -2965,14 +2974,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2965
2974
|
});
|
|
2966
2975
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
2967
2976
|
prompt,
|
|
2968
|
-
sendReasoning: (
|
|
2977
|
+
sendReasoning: (_d = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _d : true,
|
|
2969
2978
|
warnings,
|
|
2970
2979
|
cacheControlValidator,
|
|
2971
2980
|
toolNameMapping
|
|
2972
2981
|
});
|
|
2973
|
-
const thinkingType = (
|
|
2982
|
+
const thinkingType = (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.type;
|
|
2974
2983
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2975
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
2984
|
+
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.budgetTokens : void 0;
|
|
2976
2985
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2977
2986
|
const baseArgs = {
|
|
2978
2987
|
// model id:
|
|
@@ -3179,7 +3188,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3179
3188
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3180
3189
|
betas.add("fast-mode-2026-02-01");
|
|
3181
3190
|
}
|
|
3182
|
-
if (stream && ((
|
|
3191
|
+
if (stream && ((_g = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _g : true)) {
|
|
3183
3192
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3184
3193
|
}
|
|
3185
3194
|
const {
|
|
@@ -3193,13 +3202,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3193
3202
|
toolChoice: { type: "required" },
|
|
3194
3203
|
disableParallelToolUse: true,
|
|
3195
3204
|
cacheControlValidator,
|
|
3196
|
-
supportsStructuredOutput: false
|
|
3205
|
+
supportsStructuredOutput: false,
|
|
3206
|
+
supportsStrictTools
|
|
3197
3207
|
} : {
|
|
3198
3208
|
tools: tools != null ? tools : [],
|
|
3199
3209
|
toolChoice,
|
|
3200
3210
|
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
|
|
3201
3211
|
cacheControlValidator,
|
|
3202
|
-
supportsStructuredOutput
|
|
3212
|
+
supportsStructuredOutput,
|
|
3213
|
+
supportsStrictTools
|
|
3203
3214
|
}
|
|
3204
3215
|
);
|
|
3205
3216
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
@@ -3216,7 +3227,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3216
3227
|
...betas,
|
|
3217
3228
|
...toolsBetas,
|
|
3218
3229
|
...userSuppliedBetas,
|
|
3219
|
-
...(
|
|
3230
|
+
...(_h = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _h : []
|
|
3220
3231
|
]),
|
|
3221
3232
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3222
3233
|
toolNameMapping,
|