@ai-sdk/anthropic 2.0.0-beta.8 → 2.0.0-beta.9
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 +9 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -15
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +40 -15
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +40 -15
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -58,7 +58,12 @@ var anthropicProviderOptions = z2.object({
|
|
|
58
58
|
thinking: z2.object({
|
|
59
59
|
type: z2.union([z2.literal("enabled"), z2.literal("disabled")]),
|
|
60
60
|
budgetTokens: z2.number().optional()
|
|
61
|
-
}).optional()
|
|
61
|
+
}).optional(),
|
|
62
|
+
/**
|
|
63
|
+
* Whether to disable parallel function calling during tool use. Default is false.
|
|
64
|
+
* When set to true, Claude will use at most one tool per response.
|
|
65
|
+
*/
|
|
66
|
+
disableParallelToolUse: z2.boolean().optional()
|
|
62
67
|
});
|
|
63
68
|
|
|
64
69
|
// src/anthropic-prepare-tools.ts
|
|
@@ -66,6 +71,14 @@ import {
|
|
|
66
71
|
UnsupportedFunctionalityError
|
|
67
72
|
} from "@ai-sdk/provider";
|
|
68
73
|
|
|
74
|
+
// src/get-cache-control.ts
|
|
75
|
+
function getCacheControl(providerMetadata) {
|
|
76
|
+
var _a;
|
|
77
|
+
const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
78
|
+
const cacheControlValue = (_a = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a : anthropic == null ? void 0 : anthropic.cache_control;
|
|
79
|
+
return cacheControlValue;
|
|
80
|
+
}
|
|
81
|
+
|
|
69
82
|
// src/tool/web-search_20250305.ts
|
|
70
83
|
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
71
84
|
import { z as z3 } from "zod/v4";
|
|
@@ -120,7 +133,8 @@ function isWebSearchTool(tool) {
|
|
|
120
133
|
}
|
|
121
134
|
function prepareTools({
|
|
122
135
|
tools,
|
|
123
|
-
toolChoice
|
|
136
|
+
toolChoice,
|
|
137
|
+
disableParallelToolUse
|
|
124
138
|
}) {
|
|
125
139
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
126
140
|
const toolWarnings = [];
|
|
@@ -136,10 +150,12 @@ function prepareTools({
|
|
|
136
150
|
}
|
|
137
151
|
switch (tool.type) {
|
|
138
152
|
case "function":
|
|
153
|
+
const cacheControl = getCacheControl(tool.providerOptions);
|
|
139
154
|
anthropicTools2.push({
|
|
140
155
|
name: tool.name,
|
|
141
156
|
description: tool.description,
|
|
142
|
-
input_schema: tool.inputSchema
|
|
157
|
+
input_schema: tool.inputSchema,
|
|
158
|
+
cache_control: cacheControl
|
|
143
159
|
});
|
|
144
160
|
break;
|
|
145
161
|
case "provider-defined":
|
|
@@ -224,7 +240,7 @@ function prepareTools({
|
|
|
224
240
|
if (toolChoice == null) {
|
|
225
241
|
return {
|
|
226
242
|
tools: anthropicTools2,
|
|
227
|
-
toolChoice: void 0,
|
|
243
|
+
toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
|
|
228
244
|
toolWarnings,
|
|
229
245
|
betas
|
|
230
246
|
};
|
|
@@ -234,14 +250,20 @@ function prepareTools({
|
|
|
234
250
|
case "auto":
|
|
235
251
|
return {
|
|
236
252
|
tools: anthropicTools2,
|
|
237
|
-
toolChoice: {
|
|
253
|
+
toolChoice: {
|
|
254
|
+
type: "auto",
|
|
255
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
256
|
+
},
|
|
238
257
|
toolWarnings,
|
|
239
258
|
betas
|
|
240
259
|
};
|
|
241
260
|
case "required":
|
|
242
261
|
return {
|
|
243
262
|
tools: anthropicTools2,
|
|
244
|
-
toolChoice: {
|
|
263
|
+
toolChoice: {
|
|
264
|
+
type: "any",
|
|
265
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
266
|
+
},
|
|
245
267
|
toolWarnings,
|
|
246
268
|
betas
|
|
247
269
|
};
|
|
@@ -250,7 +272,11 @@ function prepareTools({
|
|
|
250
272
|
case "tool":
|
|
251
273
|
return {
|
|
252
274
|
tools: anthropicTools2,
|
|
253
|
-
toolChoice: {
|
|
275
|
+
toolChoice: {
|
|
276
|
+
type: "tool",
|
|
277
|
+
name: toolChoice.toolName,
|
|
278
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
279
|
+
},
|
|
254
280
|
toolWarnings,
|
|
255
281
|
betas
|
|
256
282
|
};
|
|
@@ -294,12 +320,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
294
320
|
const blocks = groupIntoBlocks(prompt);
|
|
295
321
|
let system = void 0;
|
|
296
322
|
const messages = [];
|
|
297
|
-
function getCacheControl(providerMetadata) {
|
|
298
|
-
var _a2;
|
|
299
|
-
const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
300
|
-
const cacheControlValue = (_a2 = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a2 : anthropic == null ? void 0 : anthropic.cache_control;
|
|
301
|
-
return cacheControlValue;
|
|
302
|
-
}
|
|
303
323
|
async function shouldEnableCitations(providerMetadata) {
|
|
304
324
|
var _a2, _b2;
|
|
305
325
|
const anthropicOptions = await parseProviderOptions({
|
|
@@ -921,8 +941,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
921
941
|
} = prepareTools(
|
|
922
942
|
jsonResponseTool != null ? {
|
|
923
943
|
tools: [jsonResponseTool],
|
|
924
|
-
toolChoice: { type: "tool", toolName: jsonResponseTool.name }
|
|
925
|
-
|
|
944
|
+
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
945
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
946
|
+
} : {
|
|
947
|
+
tools: tools != null ? tools : [],
|
|
948
|
+
toolChoice,
|
|
949
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
950
|
+
}
|
|
926
951
|
);
|
|
927
952
|
return {
|
|
928
953
|
args: {
|