@ai-sdk/anthropic 4.0.8 → 4.0.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 +6 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +4 -1
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/convert-to-anthropic-prompt.ts +10 -1
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UnsupportedFunctionalityError,
|
|
3
|
+
type JSONObject,
|
|
4
|
+
type JSONValue,
|
|
3
5
|
type SharedV4Warning,
|
|
4
6
|
type LanguageModelV4Message,
|
|
5
7
|
type LanguageModelV4Prompt,
|
|
@@ -801,7 +803,7 @@ export async function convertToAnthropicPrompt({
|
|
|
801
803
|
type: 'tool_use',
|
|
802
804
|
id: part.toolCallId,
|
|
803
805
|
name: part.toolName,
|
|
804
|
-
input: part.input,
|
|
806
|
+
input: toAnthropicToolInput(part.input),
|
|
805
807
|
...(caller && { caller }),
|
|
806
808
|
cache_control: cacheControl,
|
|
807
809
|
});
|
|
@@ -1327,3 +1329,10 @@ function moveToolUseBlocksToEnd(
|
|
|
1327
1329
|
|
|
1328
1330
|
return result;
|
|
1329
1331
|
}
|
|
1332
|
+
|
|
1333
|
+
// wrap invalid tool call input because Anthropic requires it to be an object
|
|
1334
|
+
function toAnthropicToolInput(input: unknown): JSONObject {
|
|
1335
|
+
return typeof input === 'object' && input !== null && !Array.isArray(input)
|
|
1336
|
+
? (input as JSONObject)
|
|
1337
|
+
: { rawInvalidInput: input as JSONValue };
|
|
1338
|
+
}
|