+21
-30
@@ -645,3 +645,3 @@ "use strict"; | ||
| async function callAnthropic(id, payload, config) { | ||
| var _a; | ||
| var _a, _b, _c; | ||
| const anthropicMessages = jigAnthropicMessages(payload.messages); | ||
@@ -653,15 +653,2 @@ 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; | ||
@@ -676,4 +663,3 @@ if ((config == null ? void 0 : config.service) === "bedrock") { | ||
| messages: anthropicMessages, | ||
| // The pinned Bedrock model predates prompt caching; strip breakpoints | ||
| tools: tools == null ? void 0 : tools.map(({ cache_control, ...t }) => t) | ||
| tools | ||
| }; | ||
@@ -690,2 +676,6 @@ const response = await client.send( | ||
| } else { | ||
| const cachedTools = (tools == null ? void 0 : tools.length) ? [ | ||
| ...tools.slice(0, -1), | ||
| { ...tools[tools.length - 1], cache_control: { type: "ephemeral" } } | ||
| ] : tools; | ||
| const response = await import_axios.default.post( | ||
@@ -696,5 +686,5 @@ "https://api.anthropic.com/v1/messages", | ||
| messages: anthropicMessages, | ||
| tools, | ||
| tools: cachedTools, | ||
| temperature: payload.temperature, | ||
| system, | ||
| system: payload.system, | ||
| max_tokens: 4096 | ||
@@ -753,2 +743,14 @@ }, | ||
| } | ||
| let usage = null; | ||
| if (data.usage) { | ||
| const cacheRead = (_b = data.usage.cache_read_input_tokens) != null ? _b : 0; | ||
| const cacheWrite = (_c = data.usage.cache_creation_input_tokens) != null ? _c : 0; | ||
| const promptTokens = data.usage.input_tokens + cacheRead + cacheWrite; | ||
| usage = { | ||
| prompt_tokens: promptTokens, | ||
| completion_tokens: data.usage.output_tokens, | ||
| total_tokens: promptTokens + data.usage.output_tokens, | ||
| cached_tokens: cacheRead | ||
| }; | ||
| } | ||
| return { | ||
@@ -760,14 +762,3 @@ role: "assistant", | ||
| files: [], | ||
| 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 | ||
| usage | ||
| }; | ||
@@ -774,0 +765,0 @@ } |
+21
-30
@@ -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; | ||
| var _a, _b, _c; | ||
| const anthropicMessages = jigAnthropicMessages(payload.messages); | ||
@@ -622,15 +622,2 @@ 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; | ||
@@ -645,4 +632,3 @@ if ((config == null ? void 0 : config.service) === "bedrock") { | ||
| messages: anthropicMessages, | ||
| // The pinned Bedrock model predates prompt caching; strip breakpoints | ||
| tools: tools == null ? void 0 : tools.map(({ cache_control, ...t }) => t) | ||
| tools | ||
| }; | ||
@@ -659,2 +645,6 @@ const response = await client.send( | ||
| } else { | ||
| const cachedTools = (tools == null ? void 0 : tools.length) ? [ | ||
| ...tools.slice(0, -1), | ||
| { ...tools[tools.length - 1], cache_control: { type: "ephemeral" } } | ||
| ] : tools; | ||
| const response = await axios.post( | ||
@@ -665,5 +655,5 @@ "https://api.anthropic.com/v1/messages", | ||
| messages: anthropicMessages, | ||
| tools, | ||
| tools: cachedTools, | ||
| temperature: payload.temperature, | ||
| system, | ||
| system: payload.system, | ||
| max_tokens: 4096 | ||
@@ -722,2 +712,14 @@ }, | ||
| } | ||
| let usage = null; | ||
| if (data.usage) { | ||
| const cacheRead = (_b = data.usage.cache_read_input_tokens) != null ? _b : 0; | ||
| const cacheWrite = (_c = data.usage.cache_creation_input_tokens) != null ? _c : 0; | ||
| const promptTokens = data.usage.input_tokens + cacheRead + cacheWrite; | ||
| usage = { | ||
| prompt_tokens: promptTokens, | ||
| completion_tokens: data.usage.output_tokens, | ||
| total_tokens: promptTokens + data.usage.output_tokens, | ||
| cached_tokens: cacheRead | ||
| }; | ||
| } | ||
| return { | ||
@@ -729,14 +731,3 @@ role: "assistant", | ||
| files: [], | ||
| 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 | ||
| usage | ||
| }; | ||
@@ -743,0 +734,0 @@ } |
+1
-1
| { | ||
| "name": "190proof", | ||
| "version": "1.0.92", | ||
| "version": "1.0.93", | ||
| "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
268153
-0.42%2549
-0.7%