@ai-sdk/anthropic 3.0.85 → 3.0.87
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 +15 -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 +4 -4
- package/src/convert-to-anthropic-messages-prompt.ts +32 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -3024,7 +3024,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3024
3024
|
}
|
|
3025
3025
|
}
|
|
3026
3026
|
}
|
|
3027
|
-
messages.push({
|
|
3027
|
+
messages.push({
|
|
3028
|
+
role: "assistant",
|
|
3029
|
+
content: moveToolUseBlocksToEnd(anthropicContent)
|
|
3030
|
+
});
|
|
3028
3031
|
break;
|
|
3029
3032
|
}
|
|
3030
3033
|
default: {
|
|
@@ -3084,6 +3087,27 @@ function groupIntoBlocks(prompt) {
|
|
|
3084
3087
|
}
|
|
3085
3088
|
return blocks;
|
|
3086
3089
|
}
|
|
3090
|
+
function moveToolUseBlocksToEnd(content) {
|
|
3091
|
+
const result = [];
|
|
3092
|
+
let segment = [];
|
|
3093
|
+
function flushSegment() {
|
|
3094
|
+
result.push(
|
|
3095
|
+
...segment.filter((part) => part.type !== "tool_use"),
|
|
3096
|
+
...segment.filter((part) => part.type === "tool_use")
|
|
3097
|
+
);
|
|
3098
|
+
segment = [];
|
|
3099
|
+
}
|
|
3100
|
+
for (const part of content) {
|
|
3101
|
+
if (part.type === "thinking" || part.type === "redacted_thinking") {
|
|
3102
|
+
flushSegment();
|
|
3103
|
+
result.push(part);
|
|
3104
|
+
} else {
|
|
3105
|
+
segment.push(part);
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
flushSegment();
|
|
3109
|
+
return result;
|
|
3110
|
+
}
|
|
3087
3111
|
|
|
3088
3112
|
// src/map-anthropic-stop-reason.ts
|
|
3089
3113
|
function mapAnthropicStopReason({
|