+29
-9
@@ -645,3 +645,3 @@ "use strict"; | ||
| async function callAnthropic(id, payload, config) { | ||
| var _a, _b; | ||
| var _a; | ||
| const anthropicMessages = jigAnthropicMessages(payload.messages); | ||
@@ -653,2 +653,15 @@ const tools = (_a = payload.functions) == null ? void 0 : _a.map((f) => ({ | ||
| })); | ||
| if (tools == null ? void 0 : tools.length) { | ||
| tools[tools.length - 1] = { | ||
| ...tools[tools.length - 1], | ||
| cache_control: { type: "ephemeral" } | ||
| }; | ||
| } | ||
| const system = payload.system ? [ | ||
| { | ||
| type: "text", | ||
| text: payload.system, | ||
| cache_control: { type: "ephemeral" } | ||
| } | ||
| ] : void 0; | ||
| let data; | ||
@@ -663,3 +676,4 @@ if ((config == null ? void 0 : config.service) === "bedrock") { | ||
| messages: anthropicMessages, | ||
| tools | ||
| // The pinned Bedrock model predates prompt caching; strip breakpoints | ||
| tools: tools == null ? void 0 : tools.map(({ cache_control, ...t }) => t) | ||
| }; | ||
@@ -683,3 +697,3 @@ const response = await client.send( | ||
| temperature: payload.temperature, | ||
| system: payload.system, | ||
| system, | ||
| max_tokens: 4096 | ||
@@ -744,8 +758,14 @@ }, | ||
| files: [], | ||
| usage: data.usage ? { | ||
| prompt_tokens: data.usage.input_tokens, | ||
| completion_tokens: data.usage.output_tokens, | ||
| total_tokens: data.usage.input_tokens + data.usage.output_tokens, | ||
| cached_tokens: (_b = data.usage.cache_read_input_tokens) != null ? _b : 0 | ||
| } : null | ||
| usage: data.usage ? (() => { | ||
| var _a2, _b; | ||
| const cacheRead = (_a2 = data.usage.cache_read_input_tokens) != null ? _a2 : 0; | ||
| const cacheWrite = (_b = data.usage.cache_creation_input_tokens) != null ? _b : 0; | ||
| const promptTokens = data.usage.input_tokens + cacheRead + cacheWrite; | ||
| return { | ||
| prompt_tokens: promptTokens, | ||
| completion_tokens: data.usage.output_tokens, | ||
| total_tokens: promptTokens + data.usage.output_tokens, | ||
| cached_tokens: cacheRead | ||
| }; | ||
| })() : null | ||
| }; | ||
@@ -752,0 +772,0 @@ } |
+29
-9
@@ -614,3 +614,3 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { | ||
| async function callAnthropic(id, payload, config) { | ||
| var _a, _b; | ||
| var _a; | ||
| const anthropicMessages = jigAnthropicMessages(payload.messages); | ||
@@ -622,2 +622,15 @@ const tools = (_a = payload.functions) == null ? void 0 : _a.map((f) => ({ | ||
| })); | ||
| if (tools == null ? void 0 : tools.length) { | ||
| tools[tools.length - 1] = { | ||
| ...tools[tools.length - 1], | ||
| cache_control: { type: "ephemeral" } | ||
| }; | ||
| } | ||
| const system = payload.system ? [ | ||
| { | ||
| type: "text", | ||
| text: payload.system, | ||
| cache_control: { type: "ephemeral" } | ||
| } | ||
| ] : void 0; | ||
| let data; | ||
@@ -632,3 +645,4 @@ if ((config == null ? void 0 : config.service) === "bedrock") { | ||
| messages: anthropicMessages, | ||
| tools | ||
| // The pinned Bedrock model predates prompt caching; strip breakpoints | ||
| tools: tools == null ? void 0 : tools.map(({ cache_control, ...t }) => t) | ||
| }; | ||
@@ -652,3 +666,3 @@ const response = await client.send( | ||
| temperature: payload.temperature, | ||
| system: payload.system, | ||
| system, | ||
| max_tokens: 4096 | ||
@@ -713,8 +727,14 @@ }, | ||
| files: [], | ||
| usage: data.usage ? { | ||
| prompt_tokens: data.usage.input_tokens, | ||
| completion_tokens: data.usage.output_tokens, | ||
| total_tokens: data.usage.input_tokens + data.usage.output_tokens, | ||
| cached_tokens: (_b = data.usage.cache_read_input_tokens) != null ? _b : 0 | ||
| } : null | ||
| usage: data.usage ? (() => { | ||
| var _a2, _b; | ||
| const cacheRead = (_a2 = data.usage.cache_read_input_tokens) != null ? _a2 : 0; | ||
| const cacheWrite = (_b = data.usage.cache_creation_input_tokens) != null ? _b : 0; | ||
| const promptTokens = data.usage.input_tokens + cacheRead + cacheWrite; | ||
| return { | ||
| prompt_tokens: promptTokens, | ||
| completion_tokens: data.usage.output_tokens, | ||
| total_tokens: promptTokens + data.usage.output_tokens, | ||
| cached_tokens: cacheRead | ||
| }; | ||
| })() : null | ||
| }; | ||
@@ -721,0 +741,0 @@ } |
+1
-1
| { | ||
| "name": "190proof", | ||
| "version": "1.0.91", | ||
| "version": "1.0.92", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
269285
1.77%2567
1.58%