@ai-sdk/anthropic 3.0.85 → 3.0.86
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 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +25 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +25 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/convert-to-anthropic-messages-prompt.ts +32 -1
package/dist/internal/index.js
CHANGED
|
@@ -2983,7 +2983,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2983
2983
|
}
|
|
2984
2984
|
}
|
|
2985
2985
|
}
|
|
2986
|
-
messages.push({
|
|
2986
|
+
messages.push({
|
|
2987
|
+
role: "assistant",
|
|
2988
|
+
content: moveToolUseBlocksToEnd(anthropicContent)
|
|
2989
|
+
});
|
|
2987
2990
|
break;
|
|
2988
2991
|
}
|
|
2989
2992
|
default: {
|
|
@@ -3043,6 +3046,27 @@ function groupIntoBlocks(prompt) {
|
|
|
3043
3046
|
}
|
|
3044
3047
|
return blocks;
|
|
3045
3048
|
}
|
|
3049
|
+
function moveToolUseBlocksToEnd(content) {
|
|
3050
|
+
const result = [];
|
|
3051
|
+
let segment = [];
|
|
3052
|
+
function flushSegment() {
|
|
3053
|
+
result.push(
|
|
3054
|
+
...segment.filter((part) => part.type !== "tool_use"),
|
|
3055
|
+
...segment.filter((part) => part.type === "tool_use")
|
|
3056
|
+
);
|
|
3057
|
+
segment = [];
|
|
3058
|
+
}
|
|
3059
|
+
for (const part of content) {
|
|
3060
|
+
if (part.type === "thinking" || part.type === "redacted_thinking") {
|
|
3061
|
+
flushSegment();
|
|
3062
|
+
result.push(part);
|
|
3063
|
+
} else {
|
|
3064
|
+
segment.push(part);
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
flushSegment();
|
|
3068
|
+
return result;
|
|
3069
|
+
}
|
|
3046
3070
|
|
|
3047
3071
|
// src/map-anthropic-stop-reason.ts
|
|
3048
3072
|
function mapAnthropicStopReason({
|