@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4f26d59: feat(provider/anthropic): add disable parallel tool use option
|
|
8
|
+
- a753b3a: feat (provider/anthropic): cache control for tools
|
|
9
|
+
- Updated dependencies [ac34802]
|
|
10
|
+
- @ai-sdk/provider-utils@3.0.0-beta.6
|
|
11
|
+
|
|
3
12
|
## 2.0.0-beta.8
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
10
10
|
type: z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
|
|
11
11
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
12
12
|
}, z.core.$strip>>;
|
|
13
|
+
disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
|
|
13
14
|
}, z.core.$strip>;
|
|
14
15
|
type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
15
16
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
10
10
|
type: z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
|
|
11
11
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
12
12
|
}, z.core.$strip>>;
|
|
13
|
+
disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
|
|
13
14
|
}, z.core.$strip>;
|
|
14
15
|
type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
15
16
|
|
package/dist/index.js
CHANGED
|
@@ -89,12 +89,25 @@ var anthropicProviderOptions = import_v42.z.object({
|
|
|
89
89
|
thinking: import_v42.z.object({
|
|
90
90
|
type: import_v42.z.union([import_v42.z.literal("enabled"), import_v42.z.literal("disabled")]),
|
|
91
91
|
budgetTokens: import_v42.z.number().optional()
|
|
92
|
-
}).optional()
|
|
92
|
+
}).optional(),
|
|
93
|
+
/**
|
|
94
|
+
* Whether to disable parallel function calling during tool use. Default is false.
|
|
95
|
+
* When set to true, Claude will use at most one tool per response.
|
|
96
|
+
*/
|
|
97
|
+
disableParallelToolUse: import_v42.z.boolean().optional()
|
|
93
98
|
});
|
|
94
99
|
|
|
95
100
|
// src/anthropic-prepare-tools.ts
|
|
96
101
|
var import_provider = require("@ai-sdk/provider");
|
|
97
102
|
|
|
103
|
+
// src/get-cache-control.ts
|
|
104
|
+
function getCacheControl(providerMetadata) {
|
|
105
|
+
var _a;
|
|
106
|
+
const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
107
|
+
const cacheControlValue = (_a = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a : anthropic2 == null ? void 0 : anthropic2.cache_control;
|
|
108
|
+
return cacheControlValue;
|
|
109
|
+
}
|
|
110
|
+
|
|
98
111
|
// src/tool/web-search_20250305.ts
|
|
99
112
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
100
113
|
var import_v43 = require("zod/v4");
|
|
@@ -149,7 +162,8 @@ function isWebSearchTool(tool) {
|
|
|
149
162
|
}
|
|
150
163
|
function prepareTools({
|
|
151
164
|
tools,
|
|
152
|
-
toolChoice
|
|
165
|
+
toolChoice,
|
|
166
|
+
disableParallelToolUse
|
|
153
167
|
}) {
|
|
154
168
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
155
169
|
const toolWarnings = [];
|
|
@@ -165,10 +179,12 @@ function prepareTools({
|
|
|
165
179
|
}
|
|
166
180
|
switch (tool.type) {
|
|
167
181
|
case "function":
|
|
182
|
+
const cacheControl = getCacheControl(tool.providerOptions);
|
|
168
183
|
anthropicTools2.push({
|
|
169
184
|
name: tool.name,
|
|
170
185
|
description: tool.description,
|
|
171
|
-
input_schema: tool.inputSchema
|
|
186
|
+
input_schema: tool.inputSchema,
|
|
187
|
+
cache_control: cacheControl
|
|
172
188
|
});
|
|
173
189
|
break;
|
|
174
190
|
case "provider-defined":
|
|
@@ -253,7 +269,7 @@ function prepareTools({
|
|
|
253
269
|
if (toolChoice == null) {
|
|
254
270
|
return {
|
|
255
271
|
tools: anthropicTools2,
|
|
256
|
-
toolChoice: void 0,
|
|
272
|
+
toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
|
|
257
273
|
toolWarnings,
|
|
258
274
|
betas
|
|
259
275
|
};
|
|
@@ -263,14 +279,20 @@ function prepareTools({
|
|
|
263
279
|
case "auto":
|
|
264
280
|
return {
|
|
265
281
|
tools: anthropicTools2,
|
|
266
|
-
toolChoice: {
|
|
282
|
+
toolChoice: {
|
|
283
|
+
type: "auto",
|
|
284
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
285
|
+
},
|
|
267
286
|
toolWarnings,
|
|
268
287
|
betas
|
|
269
288
|
};
|
|
270
289
|
case "required":
|
|
271
290
|
return {
|
|
272
291
|
tools: anthropicTools2,
|
|
273
|
-
toolChoice: {
|
|
292
|
+
toolChoice: {
|
|
293
|
+
type: "any",
|
|
294
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
295
|
+
},
|
|
274
296
|
toolWarnings,
|
|
275
297
|
betas
|
|
276
298
|
};
|
|
@@ -279,7 +301,11 @@ function prepareTools({
|
|
|
279
301
|
case "tool":
|
|
280
302
|
return {
|
|
281
303
|
tools: anthropicTools2,
|
|
282
|
-
toolChoice: {
|
|
304
|
+
toolChoice: {
|
|
305
|
+
type: "tool",
|
|
306
|
+
name: toolChoice.toolName,
|
|
307
|
+
disable_parallel_tool_use: disableParallelToolUse
|
|
308
|
+
},
|
|
283
309
|
toolWarnings,
|
|
284
310
|
betas
|
|
285
311
|
};
|
|
@@ -321,12 +347,6 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
321
347
|
const blocks = groupIntoBlocks(prompt);
|
|
322
348
|
let system = void 0;
|
|
323
349
|
const messages = [];
|
|
324
|
-
function getCacheControl(providerMetadata) {
|
|
325
|
-
var _a2;
|
|
326
|
-
const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
|
|
327
|
-
const cacheControlValue = (_a2 = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a2 : anthropic2 == null ? void 0 : anthropic2.cache_control;
|
|
328
|
-
return cacheControlValue;
|
|
329
|
-
}
|
|
330
350
|
async function shouldEnableCitations(providerMetadata) {
|
|
331
351
|
var _a2, _b2;
|
|
332
352
|
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
@@ -948,8 +968,13 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
948
968
|
} = prepareTools(
|
|
949
969
|
jsonResponseTool != null ? {
|
|
950
970
|
tools: [jsonResponseTool],
|
|
951
|
-
toolChoice: { type: "tool", toolName: jsonResponseTool.name }
|
|
952
|
-
|
|
971
|
+
toolChoice: { type: "tool", toolName: jsonResponseTool.name },
|
|
972
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
973
|
+
} : {
|
|
974
|
+
tools: tools != null ? tools : [],
|
|
975
|
+
toolChoice,
|
|
976
|
+
disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
|
|
977
|
+
}
|
|
953
978
|
);
|
|
954
979
|
return {
|
|
955
980
|
args: {
|