@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/dist/internal/index.d.ts
CHANGED
package/dist/internal/index.js
CHANGED
|
@@ -257,7 +257,7 @@ var anthropicResponseSchema = lazySchema3(
|
|
|
257
257
|
}),
|
|
258
258
|
z3.object({
|
|
259
259
|
type: z3.literal("compaction"),
|
|
260
|
-
content: z3.string()
|
|
260
|
+
content: z3.string().nullish()
|
|
261
261
|
}),
|
|
262
262
|
z3.object({
|
|
263
263
|
type: z3.literal("tool_use"),
|
|
@@ -3228,6 +3228,9 @@ async function convertToAnthropicPrompt({
|
|
|
3228
3228
|
case "text": {
|
|
3229
3229
|
const textMetadata = (_k = part.providerOptions) == null ? void 0 : _k.anthropic;
|
|
3230
3230
|
if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
|
|
3231
|
+
if (part.text === "") {
|
|
3232
|
+
break;
|
|
3233
|
+
}
|
|
3231
3234
|
anthropicContent.push({
|
|
3232
3235
|
type: "compaction",
|
|
3233
3236
|
content: part.text,
|
|
@@ -3754,10 +3757,12 @@ async function convertToAnthropicPrompt({
|
|
|
3754
3757
|
}
|
|
3755
3758
|
}
|
|
3756
3759
|
}
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3760
|
+
if (anthropicContent.length > 0) {
|
|
3761
|
+
messages.push({
|
|
3762
|
+
role: "assistant",
|
|
3763
|
+
content: moveToolUseBlocksToEnd(anthropicContent)
|
|
3764
|
+
});
|
|
3765
|
+
}
|
|
3761
3766
|
break;
|
|
3762
3767
|
}
|
|
3763
3768
|
default: {
|
|
@@ -4878,6 +4883,9 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
4878
4883
|
break;
|
|
4879
4884
|
}
|
|
4880
4885
|
case "compaction": {
|
|
4886
|
+
if (!part.content) {
|
|
4887
|
+
break;
|
|
4888
|
+
}
|
|
4881
4889
|
content.push({
|
|
4882
4890
|
type: "text",
|
|
4883
4891
|
text: part.content,
|