@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/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@ai-sdk/provider-utils";
|
|
13
13
|
|
|
14
14
|
// src/version.ts
|
|
15
|
-
var VERSION = true ? "3.0.
|
|
15
|
+
var VERSION = true ? "3.0.86" : "0.0.0-test";
|
|
16
16
|
|
|
17
17
|
// src/anthropic-messages-language-model.ts
|
|
18
18
|
import {
|
|
@@ -3040,7 +3040,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
3040
3040
|
}
|
|
3041
3041
|
}
|
|
3042
3042
|
}
|
|
3043
|
-
messages.push({
|
|
3043
|
+
messages.push({
|
|
3044
|
+
role: "assistant",
|
|
3045
|
+
content: moveToolUseBlocksToEnd(anthropicContent)
|
|
3046
|
+
});
|
|
3044
3047
|
break;
|
|
3045
3048
|
}
|
|
3046
3049
|
default: {
|
|
@@ -3100,6 +3103,27 @@ function groupIntoBlocks(prompt) {
|
|
|
3100
3103
|
}
|
|
3101
3104
|
return blocks;
|
|
3102
3105
|
}
|
|
3106
|
+
function moveToolUseBlocksToEnd(content) {
|
|
3107
|
+
const result = [];
|
|
3108
|
+
let segment = [];
|
|
3109
|
+
function flushSegment() {
|
|
3110
|
+
result.push(
|
|
3111
|
+
...segment.filter((part) => part.type !== "tool_use"),
|
|
3112
|
+
...segment.filter((part) => part.type === "tool_use")
|
|
3113
|
+
);
|
|
3114
|
+
segment = [];
|
|
3115
|
+
}
|
|
3116
|
+
for (const part of content) {
|
|
3117
|
+
if (part.type === "thinking" || part.type === "redacted_thinking") {
|
|
3118
|
+
flushSegment();
|
|
3119
|
+
result.push(part);
|
|
3120
|
+
} else {
|
|
3121
|
+
segment.push(part);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
flushSegment();
|
|
3125
|
+
return result;
|
|
3126
|
+
}
|
|
3103
3127
|
|
|
3104
3128
|
// src/map-anthropic-stop-reason.ts
|
|
3105
3129
|
function mapAnthropicStopReason({
|