@ai-sdk/anthropic 3.0.128 → 3.0.129
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 +7 -0
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +19 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +19 -2
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/anthropic-messages-api.ts +1 -0
- package/src/anthropic-prepare-tools.ts +6 -2
- package/src/convert-to-anthropic-messages-prompt.ts +24 -0
package/package.json
CHANGED
|
@@ -554,6 +554,7 @@ export type AnthropicSpeed = 'fast' | 'standard';
|
|
|
554
554
|
|
|
555
555
|
export type AnthropicToolChoice =
|
|
556
556
|
| { type: 'auto' | 'any'; disable_parallel_tool_use?: boolean }
|
|
557
|
+
| { type: 'none' }
|
|
557
558
|
| { type: 'tool'; name: string; disable_parallel_tool_use?: boolean };
|
|
558
559
|
|
|
559
560
|
export type AnthropicContainer = {
|
|
@@ -477,8 +477,12 @@ export async function prepareTools({
|
|
|
477
477
|
betas,
|
|
478
478
|
};
|
|
479
479
|
case 'none':
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
return {
|
|
481
|
+
tools: anthropicTools,
|
|
482
|
+
toolChoice: { type: 'none' },
|
|
483
|
+
toolWarnings,
|
|
484
|
+
betas,
|
|
485
|
+
};
|
|
482
486
|
case 'tool':
|
|
483
487
|
if (rejectsForcedToolUse) {
|
|
484
488
|
toolWarnings.push({
|
|
@@ -1207,6 +1207,30 @@ export async function convertToAnthropicMessagesPrompt({
|
|
|
1207
1207
|
) {
|
|
1208
1208
|
const output = part.output;
|
|
1209
1209
|
|
|
1210
|
+
if (
|
|
1211
|
+
output.type === 'error-json' ||
|
|
1212
|
+
(output.type === 'json' &&
|
|
1213
|
+
output.value != null &&
|
|
1214
|
+
typeof output.value === 'object' &&
|
|
1215
|
+
!Array.isArray(output.value) &&
|
|
1216
|
+
'type' in output.value &&
|
|
1217
|
+
output.value.type === 'tool_search_tool_result_error')
|
|
1218
|
+
) {
|
|
1219
|
+
anthropicContent.push({
|
|
1220
|
+
type: 'tool_search_tool_result',
|
|
1221
|
+
tool_use_id: part.toolCallId,
|
|
1222
|
+
content: {
|
|
1223
|
+
type: 'tool_search_tool_result_error',
|
|
1224
|
+
error_code:
|
|
1225
|
+
(await extractErrorValue(output.value)).errorCode ??
|
|
1226
|
+
'unavailable',
|
|
1227
|
+
},
|
|
1228
|
+
cache_control: cacheControl,
|
|
1229
|
+
});
|
|
1230
|
+
|
|
1231
|
+
break;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1210
1234
|
if (output.type !== 'json') {
|
|
1211
1235
|
warnings.push({
|
|
1212
1236
|
type: 'other',
|