@ai-sdk/anthropic 4.0.60 → 4.0.61
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 +9 -0
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +13 -5
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/anthropic-api.ts +1 -1
- package/src/anthropic-batch.ts +4 -0
- package/src/anthropic-language-model.ts +4 -0
- package/src/convert-to-anthropic-prompt.ts +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.61
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3733d6e: fix(anthropic): omit empty compaction blocks from replay
|
|
8
|
+
- Updated dependencies [ffb0e76]
|
|
9
|
+
- @ai-sdk/provider@4.0.18
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.46
|
|
11
|
+
|
|
3
12
|
## 4.0.60
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -272,7 +272,7 @@ var anthropicResponseSchema = lazySchema3(
|
|
|
272
272
|
}),
|
|
273
273
|
z3.object({
|
|
274
274
|
type: z3.literal("compaction"),
|
|
275
|
-
content: z3.string()
|
|
275
|
+
content: z3.string().nullish()
|
|
276
276
|
}),
|
|
277
277
|
z3.object({
|
|
278
278
|
type: z3.literal("tool_use"),
|
|
@@ -3243,6 +3243,9 @@ async function convertToAnthropicPrompt({
|
|
|
3243
3243
|
case "text": {
|
|
3244
3244
|
const textMetadata = (_k = part.providerOptions) == null ? void 0 : _k.anthropic;
|
|
3245
3245
|
if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
|
|
3246
|
+
if (part.text === "") {
|
|
3247
|
+
break;
|
|
3248
|
+
}
|
|
3246
3249
|
anthropicContent.push({
|
|
3247
3250
|
type: "compaction",
|
|
3248
3251
|
content: part.text,
|
|
@@ -3769,10 +3772,12 @@ async function convertToAnthropicPrompt({
|
|
|
3769
3772
|
}
|
|
3770
3773
|
}
|
|
3771
3774
|
}
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3775
|
+
if (anthropicContent.length > 0) {
|
|
3776
|
+
messages.push({
|
|
3777
|
+
role: "assistant",
|
|
3778
|
+
content: moveToolUseBlocksToEnd(anthropicContent)
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3776
3781
|
break;
|
|
3777
3782
|
}
|
|
3778
3783
|
default: {
|
|
@@ -4893,6 +4898,9 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
4893
4898
|
break;
|
|
4894
4899
|
}
|
|
4895
4900
|
case "compaction": {
|
|
4901
|
+
if (!part.content) {
|
|
4902
|
+
break;
|
|
4903
|
+
}
|
|
4896
4904
|
content.push({
|
|
4897
4905
|
type: "text",
|
|
4898
4906
|
text: part.content,
|
|
@@ -7160,6 +7168,9 @@ function convertAnthropicBatchResponse(response, generateId4) {
|
|
|
7160
7168
|
});
|
|
7161
7169
|
break;
|
|
7162
7170
|
case "compaction":
|
|
7171
|
+
if (!part.content) {
|
|
7172
|
+
break;
|
|
7173
|
+
}
|
|
7163
7174
|
content.push({
|
|
7164
7175
|
type: "text",
|
|
7165
7176
|
text: part.content,
|
|
@@ -8275,7 +8286,7 @@ var AnthropicSkills = class {
|
|
|
8275
8286
|
};
|
|
8276
8287
|
|
|
8277
8288
|
// src/version.ts
|
|
8278
|
-
var VERSION = true ? "4.0.
|
|
8289
|
+
var VERSION = true ? "4.0.61" : "0.0.0-test";
|
|
8279
8290
|
|
|
8280
8291
|
// src/anthropic-provider.ts
|
|
8281
8292
|
var ANTHROPIC_API_URL = "https://api.anthropic.com";
|