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.d.cts
CHANGED
|
@@ -1063,7 +1063,7 @@ declare class BitfabFunction {
|
|
|
1063
1063
|
/**
|
|
1064
1064
|
* SDK version from package.json (injected at build time)
|
|
1065
1065
|
*/
|
|
1066
|
-
declare const __version__ = "0.19.
|
|
1066
|
+
declare const __version__ = "0.19.1";
|
|
1067
1067
|
|
|
1068
1068
|
/**
|
|
1069
1069
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -1063,7 +1063,7 @@ declare class BitfabFunction {
|
|
|
1063
1063
|
/**
|
|
1064
1064
|
* SDK version from package.json (injected at build time)
|
|
1065
1065
|
*/
|
|
1066
|
-
declare const __version__ = "0.19.
|
|
1066
|
+
declare const __version__ = "0.19.1";
|
|
1067
1067
|
|
|
1068
1068
|
/**
|
|
1069
1069
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -511,7 +511,7 @@ registerAsyncLocalStorageClass(
|
|
|
511
511
|
);
|
|
512
512
|
|
|
513
513
|
// src/version.generated.ts
|
|
514
|
-
var __version__ = "0.19.
|
|
514
|
+
var __version__ = "0.19.1";
|
|
515
515
|
|
|
516
516
|
// src/constants.ts
|
|
517
517
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -932,23 +932,30 @@ function extractContentBlocks(content) {
|
|
|
932
932
|
}
|
|
933
933
|
return content.map((block) => safeSerialize(block));
|
|
934
934
|
}
|
|
935
|
+
function asTokenCount(val) {
|
|
936
|
+
return typeof val === "number" && Number.isFinite(val) ? val : null;
|
|
937
|
+
}
|
|
935
938
|
function extractUsage(message) {
|
|
936
939
|
const usageInfo = {};
|
|
937
940
|
const usage = message.usage;
|
|
938
941
|
if (!usage) {
|
|
939
942
|
return usageInfo;
|
|
940
943
|
}
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
944
|
+
const baseInput = asTokenCount(usage.input_tokens);
|
|
945
|
+
const cacheRead = asTokenCount(usage.cache_read_input_tokens);
|
|
946
|
+
const cacheCreation = asTokenCount(usage.cache_creation_input_tokens);
|
|
947
|
+
if (baseInput !== null || cacheRead !== null || cacheCreation !== null) {
|
|
948
|
+
usageInfo.inputTokens = (baseInput ?? 0) + (cacheRead ?? 0) + (cacheCreation ?? 0);
|
|
949
|
+
}
|
|
950
|
+
const output = asTokenCount(usage.output_tokens);
|
|
951
|
+
if (output !== null) {
|
|
952
|
+
usageInfo.outputTokens = output;
|
|
953
|
+
}
|
|
954
|
+
if (cacheRead !== null) {
|
|
955
|
+
usageInfo.cacheReadTokens = cacheRead;
|
|
956
|
+
}
|
|
957
|
+
if (cacheCreation !== null) {
|
|
958
|
+
usageInfo.cacheCreationTokens = cacheCreation;
|
|
952
959
|
}
|
|
953
960
|
return usageInfo;
|
|
954
961
|
}
|
|
@@ -1742,7 +1749,7 @@ function extractModelName(serialized, metadata) {
|
|
|
1742
1749
|
}
|
|
1743
1750
|
return void 0;
|
|
1744
1751
|
}
|
|
1745
|
-
function
|
|
1752
|
+
function asTokenCount2(value) {
|
|
1746
1753
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1747
1754
|
}
|
|
1748
1755
|
function normalizeTokenUsage(raw) {
|
|
@@ -1751,10 +1758,10 @@ function normalizeTokenUsage(raw) {
|
|
|
1751
1758
|
}
|
|
1752
1759
|
const u = raw;
|
|
1753
1760
|
if ("cache_read_input_tokens" in u || "cache_creation_input_tokens" in u) {
|
|
1754
|
-
const cacheRead =
|
|
1755
|
-
const cacheCreation =
|
|
1756
|
-
const baseInput =
|
|
1757
|
-
const outputTokens =
|
|
1761
|
+
const cacheRead = asTokenCount2(u.cache_read_input_tokens);
|
|
1762
|
+
const cacheCreation = asTokenCount2(u.cache_creation_input_tokens);
|
|
1763
|
+
const baseInput = asTokenCount2(u.input_tokens);
|
|
1764
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1758
1765
|
if (cacheRead === null && cacheCreation === null && baseInput === null && outputTokens === null) {
|
|
1759
1766
|
return null;
|
|
1760
1767
|
}
|
|
@@ -1769,25 +1776,25 @@ function normalizeTokenUsage(raw) {
|
|
|
1769
1776
|
if ("prompt_tokens" in u || "completion_tokens" in u || "promptTokens" in u || "completionTokens" in u) {
|
|
1770
1777
|
const promptDetails = u.prompt_tokens_details ?? {};
|
|
1771
1778
|
return withAnyTokenCount({
|
|
1772
|
-
inputTokens:
|
|
1773
|
-
outputTokens:
|
|
1774
|
-
totalTokens:
|
|
1775
|
-
cachedInputTokens:
|
|
1779
|
+
inputTokens: asTokenCount2(u.prompt_tokens) ?? asTokenCount2(u.promptTokens),
|
|
1780
|
+
outputTokens: asTokenCount2(u.completion_tokens) ?? asTokenCount2(u.completionTokens),
|
|
1781
|
+
totalTokens: asTokenCount2(u.total_tokens) ?? asTokenCount2(u.totalTokens),
|
|
1782
|
+
cachedInputTokens: asTokenCount2(promptDetails.cached_tokens)
|
|
1776
1783
|
});
|
|
1777
1784
|
}
|
|
1778
1785
|
if ("prompt_token_count" in u || "candidates_token_count" in u) {
|
|
1779
1786
|
return withAnyTokenCount({
|
|
1780
|
-
inputTokens:
|
|
1781
|
-
outputTokens:
|
|
1782
|
-
totalTokens:
|
|
1783
|
-
cachedInputTokens:
|
|
1787
|
+
inputTokens: asTokenCount2(u.prompt_token_count),
|
|
1788
|
+
outputTokens: asTokenCount2(u.candidates_token_count),
|
|
1789
|
+
totalTokens: asTokenCount2(u.total_token_count),
|
|
1790
|
+
cachedInputTokens: asTokenCount2(u.cached_content_token_count)
|
|
1784
1791
|
});
|
|
1785
1792
|
}
|
|
1786
1793
|
if ("input_tokens" in u || "output_tokens" in u) {
|
|
1787
1794
|
const inputDetails = u.input_token_details ?? {};
|
|
1788
|
-
const inputTokens =
|
|
1789
|
-
const outputTokens =
|
|
1790
|
-
let totalTokens =
|
|
1795
|
+
const inputTokens = asTokenCount2(u.input_tokens);
|
|
1796
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1797
|
+
let totalTokens = asTokenCount2(u.total_tokens);
|
|
1791
1798
|
if (totalTokens === null && inputTokens !== null && outputTokens !== null) {
|
|
1792
1799
|
totalTokens = inputTokens + outputTokens;
|
|
1793
1800
|
}
|
|
@@ -1795,7 +1802,7 @@ function normalizeTokenUsage(raw) {
|
|
|
1795
1802
|
inputTokens,
|
|
1796
1803
|
outputTokens,
|
|
1797
1804
|
totalTokens,
|
|
1798
|
-
cachedInputTokens:
|
|
1805
|
+
cachedInputTokens: asTokenCount2(inputDetails.cache_read)
|
|
1799
1806
|
});
|
|
1800
1807
|
}
|
|
1801
1808
|
return null;
|