@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 3.0.87
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1b40ac7: Publish all packages under the `@ai-v6` dist tag.
|
|
8
|
+
- Updated dependencies [1b40ac7]
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.31
|
|
10
|
+
- @ai-sdk/provider@3.0.11
|
|
11
|
+
|
|
12
|
+
## 3.0.86
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 6086c60: fix(anthropic): reorder assistant content b/w client and provider tool use
|
|
17
|
+
|
|
3
18
|
## 3.0.85
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
|
|
|
32
32
|
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
|
33
33
|
|
|
34
34
|
// src/version.ts
|
|
35
|
-
var VERSION = true ? "3.0.
|
|
35
|
+
var VERSION = true ? "3.0.87" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -2991,7 +2991,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2991
2991
|
}
|
|
2992
2992
|
}
|
|
2993
2993
|
}
|
|
2994
|
-
messages.push({
|
|
2994
|
+
messages.push({
|
|
2995
|
+
role: "assistant",
|
|
2996
|
+
content: moveToolUseBlocksToEnd(anthropicContent)
|
|
2997
|
+
});
|
|
2995
2998
|
break;
|
|
2996
2999
|
}
|
|
2997
3000
|
default: {
|
|
@@ -3051,6 +3054,27 @@ function groupIntoBlocks(prompt) {
|
|
|
3051
3054
|
}
|
|
3052
3055
|
return blocks;
|
|
3053
3056
|
}
|
|
3057
|
+
function moveToolUseBlocksToEnd(content) {
|
|
3058
|
+
const result = [];
|
|
3059
|
+
let segment = [];
|
|
3060
|
+
function flushSegment() {
|
|
3061
|
+
result.push(
|
|
3062
|
+
...segment.filter((part) => part.type !== "tool_use"),
|
|
3063
|
+
...segment.filter((part) => part.type === "tool_use")
|
|
3064
|
+
);
|
|
3065
|
+
segment = [];
|
|
3066
|
+
}
|
|
3067
|
+
for (const part of content) {
|
|
3068
|
+
if (part.type === "thinking" || part.type === "redacted_thinking") {
|
|
3069
|
+
flushSegment();
|
|
3070
|
+
result.push(part);
|
|
3071
|
+
} else {
|
|
3072
|
+
segment.push(part);
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
flushSegment();
|
|
3076
|
+
return result;
|
|
3077
|
+
}
|
|
3054
3078
|
|
|
3055
3079
|
// src/map-anthropic-stop-reason.ts
|
|
3056
3080
|
function mapAnthropicStopReason({
|