@bitfab/sdk 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
|
@@ -502,7 +502,7 @@ registerAsyncLocalStorageClass(
|
|
|
502
502
|
);
|
|
503
503
|
|
|
504
504
|
// src/version.generated.ts
|
|
505
|
-
var __version__ = "0.19.
|
|
505
|
+
var __version__ = "0.19.1";
|
|
506
506
|
|
|
507
507
|
// src/constants.ts
|
|
508
508
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -923,23 +923,30 @@ function extractContentBlocks(content) {
|
|
|
923
923
|
}
|
|
924
924
|
return content.map((block) => safeSerialize(block));
|
|
925
925
|
}
|
|
926
|
+
function asTokenCount(val) {
|
|
927
|
+
return typeof val === "number" && Number.isFinite(val) ? val : null;
|
|
928
|
+
}
|
|
926
929
|
function extractUsage(message) {
|
|
927
930
|
const usageInfo = {};
|
|
928
931
|
const usage = message.usage;
|
|
929
932
|
if (!usage) {
|
|
930
933
|
return usageInfo;
|
|
931
934
|
}
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
935
|
+
const baseInput = asTokenCount(usage.input_tokens);
|
|
936
|
+
const cacheRead = asTokenCount(usage.cache_read_input_tokens);
|
|
937
|
+
const cacheCreation = asTokenCount(usage.cache_creation_input_tokens);
|
|
938
|
+
if (baseInput !== null || cacheRead !== null || cacheCreation !== null) {
|
|
939
|
+
usageInfo.inputTokens = (baseInput ?? 0) + (cacheRead ?? 0) + (cacheCreation ?? 0);
|
|
940
|
+
}
|
|
941
|
+
const output = asTokenCount(usage.output_tokens);
|
|
942
|
+
if (output !== null) {
|
|
943
|
+
usageInfo.outputTokens = output;
|
|
944
|
+
}
|
|
945
|
+
if (cacheRead !== null) {
|
|
946
|
+
usageInfo.cacheReadTokens = cacheRead;
|
|
947
|
+
}
|
|
948
|
+
if (cacheCreation !== null) {
|
|
949
|
+
usageInfo.cacheCreationTokens = cacheCreation;
|
|
943
950
|
}
|
|
944
951
|
return usageInfo;
|
|
945
952
|
}
|
|
@@ -1733,7 +1740,7 @@ function extractModelName(serialized, metadata) {
|
|
|
1733
1740
|
}
|
|
1734
1741
|
return void 0;
|
|
1735
1742
|
}
|
|
1736
|
-
function
|
|
1743
|
+
function asTokenCount2(value) {
|
|
1737
1744
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1738
1745
|
}
|
|
1739
1746
|
function normalizeTokenUsage(raw) {
|
|
@@ -1742,10 +1749,10 @@ function normalizeTokenUsage(raw) {
|
|
|
1742
1749
|
}
|
|
1743
1750
|
const u = raw;
|
|
1744
1751
|
if ("cache_read_input_tokens" in u || "cache_creation_input_tokens" in u) {
|
|
1745
|
-
const cacheRead =
|
|
1746
|
-
const cacheCreation =
|
|
1747
|
-
const baseInput =
|
|
1748
|
-
const outputTokens =
|
|
1752
|
+
const cacheRead = asTokenCount2(u.cache_read_input_tokens);
|
|
1753
|
+
const cacheCreation = asTokenCount2(u.cache_creation_input_tokens);
|
|
1754
|
+
const baseInput = asTokenCount2(u.input_tokens);
|
|
1755
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1749
1756
|
if (cacheRead === null && cacheCreation === null && baseInput === null && outputTokens === null) {
|
|
1750
1757
|
return null;
|
|
1751
1758
|
}
|
|
@@ -1760,25 +1767,25 @@ function normalizeTokenUsage(raw) {
|
|
|
1760
1767
|
if ("prompt_tokens" in u || "completion_tokens" in u || "promptTokens" in u || "completionTokens" in u) {
|
|
1761
1768
|
const promptDetails = u.prompt_tokens_details ?? {};
|
|
1762
1769
|
return withAnyTokenCount({
|
|
1763
|
-
inputTokens:
|
|
1764
|
-
outputTokens:
|
|
1765
|
-
totalTokens:
|
|
1766
|
-
cachedInputTokens:
|
|
1770
|
+
inputTokens: asTokenCount2(u.prompt_tokens) ?? asTokenCount2(u.promptTokens),
|
|
1771
|
+
outputTokens: asTokenCount2(u.completion_tokens) ?? asTokenCount2(u.completionTokens),
|
|
1772
|
+
totalTokens: asTokenCount2(u.total_tokens) ?? asTokenCount2(u.totalTokens),
|
|
1773
|
+
cachedInputTokens: asTokenCount2(promptDetails.cached_tokens)
|
|
1767
1774
|
});
|
|
1768
1775
|
}
|
|
1769
1776
|
if ("prompt_token_count" in u || "candidates_token_count" in u) {
|
|
1770
1777
|
return withAnyTokenCount({
|
|
1771
|
-
inputTokens:
|
|
1772
|
-
outputTokens:
|
|
1773
|
-
totalTokens:
|
|
1774
|
-
cachedInputTokens:
|
|
1778
|
+
inputTokens: asTokenCount2(u.prompt_token_count),
|
|
1779
|
+
outputTokens: asTokenCount2(u.candidates_token_count),
|
|
1780
|
+
totalTokens: asTokenCount2(u.total_token_count),
|
|
1781
|
+
cachedInputTokens: asTokenCount2(u.cached_content_token_count)
|
|
1775
1782
|
});
|
|
1776
1783
|
}
|
|
1777
1784
|
if ("input_tokens" in u || "output_tokens" in u) {
|
|
1778
1785
|
const inputDetails = u.input_token_details ?? {};
|
|
1779
|
-
const inputTokens =
|
|
1780
|
-
const outputTokens =
|
|
1781
|
-
let totalTokens =
|
|
1786
|
+
const inputTokens = asTokenCount2(u.input_tokens);
|
|
1787
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1788
|
+
let totalTokens = asTokenCount2(u.total_tokens);
|
|
1782
1789
|
if (totalTokens === null && inputTokens !== null && outputTokens !== null) {
|
|
1783
1790
|
totalTokens = inputTokens + outputTokens;
|
|
1784
1791
|
}
|
|
@@ -1786,7 +1793,7 @@ function normalizeTokenUsage(raw) {
|
|
|
1786
1793
|
inputTokens,
|
|
1787
1794
|
outputTokens,
|
|
1788
1795
|
totalTokens,
|
|
1789
|
-
cachedInputTokens:
|
|
1796
|
+
cachedInputTokens: asTokenCount2(inputDetails.cache_read)
|
|
1790
1797
|
});
|
|
1791
1798
|
}
|
|
1792
1799
|
return null;
|