bitfab 0.19.0 → 0.19.1
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/dist/{chunk-FA6DBCAT.js → chunk-WZ72P5SX.js} +37 -30
- package/dist/chunk-WZ72P5SX.js.map +1 -0
- package/dist/index.cjs +36 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node.cjs +36 -29
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-FA6DBCAT.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -497,7 +497,7 @@ __export(index_exports, {
|
|
|
497
497
|
module.exports = __toCommonJS(index_exports);
|
|
498
498
|
|
|
499
499
|
// src/version.generated.ts
|
|
500
|
-
var __version__ = "0.19.
|
|
500
|
+
var __version__ = "0.19.1";
|
|
501
501
|
|
|
502
502
|
// src/constants.ts
|
|
503
503
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -918,23 +918,30 @@ function extractContentBlocks(content) {
|
|
|
918
918
|
}
|
|
919
919
|
return content.map((block) => safeSerialize(block));
|
|
920
920
|
}
|
|
921
|
+
function asTokenCount(val) {
|
|
922
|
+
return typeof val === "number" && Number.isFinite(val) ? val : null;
|
|
923
|
+
}
|
|
921
924
|
function extractUsage(message) {
|
|
922
925
|
const usageInfo = {};
|
|
923
926
|
const usage = message.usage;
|
|
924
927
|
if (!usage) {
|
|
925
928
|
return usageInfo;
|
|
926
929
|
}
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
930
|
+
const baseInput = asTokenCount(usage.input_tokens);
|
|
931
|
+
const cacheRead = asTokenCount(usage.cache_read_input_tokens);
|
|
932
|
+
const cacheCreation = asTokenCount(usage.cache_creation_input_tokens);
|
|
933
|
+
if (baseInput !== null || cacheRead !== null || cacheCreation !== null) {
|
|
934
|
+
usageInfo.inputTokens = (baseInput ?? 0) + (cacheRead ?? 0) + (cacheCreation ?? 0);
|
|
935
|
+
}
|
|
936
|
+
const output = asTokenCount(usage.output_tokens);
|
|
937
|
+
if (output !== null) {
|
|
938
|
+
usageInfo.outputTokens = output;
|
|
939
|
+
}
|
|
940
|
+
if (cacheRead !== null) {
|
|
941
|
+
usageInfo.cacheReadTokens = cacheRead;
|
|
942
|
+
}
|
|
943
|
+
if (cacheCreation !== null) {
|
|
944
|
+
usageInfo.cacheCreationTokens = cacheCreation;
|
|
938
945
|
}
|
|
939
946
|
return usageInfo;
|
|
940
947
|
}
|
|
@@ -1728,7 +1735,7 @@ function extractModelName(serialized, metadata) {
|
|
|
1728
1735
|
}
|
|
1729
1736
|
return void 0;
|
|
1730
1737
|
}
|
|
1731
|
-
function
|
|
1738
|
+
function asTokenCount2(value) {
|
|
1732
1739
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1733
1740
|
}
|
|
1734
1741
|
function normalizeTokenUsage(raw) {
|
|
@@ -1737,10 +1744,10 @@ function normalizeTokenUsage(raw) {
|
|
|
1737
1744
|
}
|
|
1738
1745
|
const u = raw;
|
|
1739
1746
|
if ("cache_read_input_tokens" in u || "cache_creation_input_tokens" in u) {
|
|
1740
|
-
const cacheRead =
|
|
1741
|
-
const cacheCreation =
|
|
1742
|
-
const baseInput =
|
|
1743
|
-
const outputTokens =
|
|
1747
|
+
const cacheRead = asTokenCount2(u.cache_read_input_tokens);
|
|
1748
|
+
const cacheCreation = asTokenCount2(u.cache_creation_input_tokens);
|
|
1749
|
+
const baseInput = asTokenCount2(u.input_tokens);
|
|
1750
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1744
1751
|
if (cacheRead === null && cacheCreation === null && baseInput === null && outputTokens === null) {
|
|
1745
1752
|
return null;
|
|
1746
1753
|
}
|
|
@@ -1755,25 +1762,25 @@ function normalizeTokenUsage(raw) {
|
|
|
1755
1762
|
if ("prompt_tokens" in u || "completion_tokens" in u || "promptTokens" in u || "completionTokens" in u) {
|
|
1756
1763
|
const promptDetails = u.prompt_tokens_details ?? {};
|
|
1757
1764
|
return withAnyTokenCount({
|
|
1758
|
-
inputTokens:
|
|
1759
|
-
outputTokens:
|
|
1760
|
-
totalTokens:
|
|
1761
|
-
cachedInputTokens:
|
|
1765
|
+
inputTokens: asTokenCount2(u.prompt_tokens) ?? asTokenCount2(u.promptTokens),
|
|
1766
|
+
outputTokens: asTokenCount2(u.completion_tokens) ?? asTokenCount2(u.completionTokens),
|
|
1767
|
+
totalTokens: asTokenCount2(u.total_tokens) ?? asTokenCount2(u.totalTokens),
|
|
1768
|
+
cachedInputTokens: asTokenCount2(promptDetails.cached_tokens)
|
|
1762
1769
|
});
|
|
1763
1770
|
}
|
|
1764
1771
|
if ("prompt_token_count" in u || "candidates_token_count" in u) {
|
|
1765
1772
|
return withAnyTokenCount({
|
|
1766
|
-
inputTokens:
|
|
1767
|
-
outputTokens:
|
|
1768
|
-
totalTokens:
|
|
1769
|
-
cachedInputTokens:
|
|
1773
|
+
inputTokens: asTokenCount2(u.prompt_token_count),
|
|
1774
|
+
outputTokens: asTokenCount2(u.candidates_token_count),
|
|
1775
|
+
totalTokens: asTokenCount2(u.total_token_count),
|
|
1776
|
+
cachedInputTokens: asTokenCount2(u.cached_content_token_count)
|
|
1770
1777
|
});
|
|
1771
1778
|
}
|
|
1772
1779
|
if ("input_tokens" in u || "output_tokens" in u) {
|
|
1773
1780
|
const inputDetails = u.input_token_details ?? {};
|
|
1774
|
-
const inputTokens =
|
|
1775
|
-
const outputTokens =
|
|
1776
|
-
let totalTokens =
|
|
1781
|
+
const inputTokens = asTokenCount2(u.input_tokens);
|
|
1782
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1783
|
+
let totalTokens = asTokenCount2(u.total_tokens);
|
|
1777
1784
|
if (totalTokens === null && inputTokens !== null && outputTokens !== null) {
|
|
1778
1785
|
totalTokens = inputTokens + outputTokens;
|
|
1779
1786
|
}
|
|
@@ -1781,7 +1788,7 @@ function normalizeTokenUsage(raw) {
|
|
|
1781
1788
|
inputTokens,
|
|
1782
1789
|
outputTokens,
|
|
1783
1790
|
totalTokens,
|
|
1784
|
-
cachedInputTokens:
|
|
1791
|
+
cachedInputTokens: asTokenCount2(inputDetails.cache_read)
|
|
1785
1792
|
});
|
|
1786
1793
|
}
|
|
1787
1794
|
return null;
|