@aigne/anthropic 0.14.16-beta.4 → 0.14.16-beta.6
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 +18 -0
- package/lib/cjs/anthropic-chat-model.js +25 -7
- package/lib/esm/anthropic-chat-model.js +25 -7
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.14.16-beta.6](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.14.16-beta.5...anthropic-v0.14.16-beta.6) (2025-12-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **models:** support cache the last message for anthropic chat model ([#853](https://github.com/AIGNE-io/aigne-framework/issues/853)) ([bd08e44](https://github.com/AIGNE-io/aigne-framework/commit/bd08e44b28c46ac9a85234f0100d6dd144703c9d))
|
|
9
|
+
|
|
10
|
+
## [0.14.16-beta.5](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.14.16-beta.4...anthropic-v0.14.16-beta.5) (2025-12-25)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Dependencies
|
|
14
|
+
|
|
15
|
+
* The following workspace dependencies were updated
|
|
16
|
+
* dependencies
|
|
17
|
+
* @aigne/core bumped to 1.72.0-beta.5
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @aigne/test-utils bumped to 0.5.69-beta.5
|
|
20
|
+
|
|
3
21
|
## [0.14.16-beta.4](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.14.16-beta.3...anthropic-v0.14.16-beta.4) (2025-12-24)
|
|
4
22
|
|
|
5
23
|
|
|
@@ -287,7 +287,8 @@ async function convertMessages({ messages, responseFormat, tools, modelOptions,
|
|
|
287
287
|
const systemBlocks = [];
|
|
288
288
|
const msgs = [];
|
|
289
289
|
// Extract cache configuration with defaults
|
|
290
|
-
const { shouldCache,
|
|
290
|
+
const { shouldCache, strategy, autoBreakpoints, ...cacheConfig } = parseCacheConfig(modelOptions);
|
|
291
|
+
const ttl = cacheConfig.ttl === "1h" ? "1h" : undefined;
|
|
291
292
|
for (const msg of messages) {
|
|
292
293
|
if (msg.role === "system") {
|
|
293
294
|
if (typeof msg.content !== "string")
|
|
@@ -348,12 +349,29 @@ async function convertMessages({ messages, responseFormat, tools, modelOptions,
|
|
|
348
349
|
});
|
|
349
350
|
}
|
|
350
351
|
// Apply cache_control to the last system block if auto strategy is enabled
|
|
351
|
-
if (shouldCache && strategy === "auto"
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
lastBlock
|
|
355
|
-
|
|
356
|
-
|
|
352
|
+
if (shouldCache && strategy === "auto") {
|
|
353
|
+
if (autoBreakpoints.system && systemBlocks.length > 0) {
|
|
354
|
+
const lastBlock = systemBlocks[systemBlocks.length - 1];
|
|
355
|
+
if (lastBlock) {
|
|
356
|
+
lastBlock.cache_control = { type: "ephemeral", ttl };
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (autoBreakpoints.lastMessage) {
|
|
360
|
+
const lastMsg = msgs[msgs.length - 1];
|
|
361
|
+
if (lastMsg) {
|
|
362
|
+
if (typeof lastMsg.content === "string") {
|
|
363
|
+
lastMsg.content = [
|
|
364
|
+
{ type: "text", text: lastMsg.content, cache_control: { type: "ephemeral", ttl } },
|
|
365
|
+
];
|
|
366
|
+
}
|
|
367
|
+
else if (Array.isArray(lastMsg.content)) {
|
|
368
|
+
const lastBlock = lastMsg.content[lastMsg.content.length - 1];
|
|
369
|
+
if (lastBlock &&
|
|
370
|
+
lastBlock.type !== "thinking" &&
|
|
371
|
+
lastBlock.type !== "redacted_thinking") {
|
|
372
|
+
lastBlock.cache_control = { type: "ephemeral", ttl };
|
|
373
|
+
}
|
|
374
|
+
}
|
|
357
375
|
}
|
|
358
376
|
}
|
|
359
377
|
}
|
|
@@ -280,7 +280,8 @@ async function convertMessages({ messages, responseFormat, tools, modelOptions,
|
|
|
280
280
|
const systemBlocks = [];
|
|
281
281
|
const msgs = [];
|
|
282
282
|
// Extract cache configuration with defaults
|
|
283
|
-
const { shouldCache,
|
|
283
|
+
const { shouldCache, strategy, autoBreakpoints, ...cacheConfig } = parseCacheConfig(modelOptions);
|
|
284
|
+
const ttl = cacheConfig.ttl === "1h" ? "1h" : undefined;
|
|
284
285
|
for (const msg of messages) {
|
|
285
286
|
if (msg.role === "system") {
|
|
286
287
|
if (typeof msg.content !== "string")
|
|
@@ -341,12 +342,29 @@ async function convertMessages({ messages, responseFormat, tools, modelOptions,
|
|
|
341
342
|
});
|
|
342
343
|
}
|
|
343
344
|
// Apply cache_control to the last system block if auto strategy is enabled
|
|
344
|
-
if (shouldCache && strategy === "auto"
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
lastBlock
|
|
348
|
-
|
|
349
|
-
|
|
345
|
+
if (shouldCache && strategy === "auto") {
|
|
346
|
+
if (autoBreakpoints.system && systemBlocks.length > 0) {
|
|
347
|
+
const lastBlock = systemBlocks[systemBlocks.length - 1];
|
|
348
|
+
if (lastBlock) {
|
|
349
|
+
lastBlock.cache_control = { type: "ephemeral", ttl };
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (autoBreakpoints.lastMessage) {
|
|
353
|
+
const lastMsg = msgs[msgs.length - 1];
|
|
354
|
+
if (lastMsg) {
|
|
355
|
+
if (typeof lastMsg.content === "string") {
|
|
356
|
+
lastMsg.content = [
|
|
357
|
+
{ type: "text", text: lastMsg.content, cache_control: { type: "ephemeral", ttl } },
|
|
358
|
+
];
|
|
359
|
+
}
|
|
360
|
+
else if (Array.isArray(lastMsg.content)) {
|
|
361
|
+
const lastBlock = lastMsg.content[lastMsg.content.length - 1];
|
|
362
|
+
if (lastBlock &&
|
|
363
|
+
lastBlock.type !== "thinking" &&
|
|
364
|
+
lastBlock.type !== "redacted_thinking") {
|
|
365
|
+
lastBlock.cache_control = { type: "ephemeral", ttl };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
350
368
|
}
|
|
351
369
|
}
|
|
352
370
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/anthropic",
|
|
3
|
-
"version": "0.14.16-beta.
|
|
3
|
+
"version": "0.14.16-beta.6",
|
|
4
4
|
"description": "AIGNE Anthropic SDK for integrating with Claude AI models",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@anthropic-ai/sdk": "^0.63.0",
|
|
39
39
|
"zod": "^3.25.67",
|
|
40
|
-
"@aigne/core": "^1.72.0-beta.
|
|
40
|
+
"@aigne/core": "^1.72.0-beta.5",
|
|
41
41
|
"@aigne/platform-helpers": "^0.6.7-beta"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"npm-run-all": "^4.1.5",
|
|
47
47
|
"rimraf": "^6.0.1",
|
|
48
48
|
"typescript": "^5.9.2",
|
|
49
|
-
"@aigne/test-utils": "^0.5.69-beta.
|
|
49
|
+
"@aigne/test-utils": "^0.5.69-beta.5"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"lint": "tsc --noEmit",
|