@bitfab/sdk 0.19.0 → 0.20.0
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-IUZIGC6T.js} +42 -32
- package/dist/chunk-IUZIGC6T.js.map +1 -0
- package/dist/index.cjs +42 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +1 -1
- package/dist/node.cjs +42 -31
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1 -1
- package/dist/{replay-QAWGVRCZ.js → replay-V6RPJYXZ.js} +3 -2
- package/dist/replay-V6RPJYXZ.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-FA6DBCAT.js.map +0 -1
- package/dist/replay-QAWGVRCZ.js.map +0 -1
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-EQI6ZJC3.js";
|
|
11
11
|
|
|
12
12
|
// src/version.generated.ts
|
|
13
|
-
var __version__ = "0.
|
|
13
|
+
var __version__ = "0.20.0";
|
|
14
14
|
|
|
15
15
|
// src/constants.ts
|
|
16
16
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -287,7 +287,7 @@ var HttpClient = class {
|
|
|
287
287
|
* Start a replay session by fetching historical traces.
|
|
288
288
|
* Blocking call — creates a test run and returns lightweight item references.
|
|
289
289
|
*/
|
|
290
|
-
async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId) {
|
|
290
|
+
async startReplay(traceFunctionKey, limit, traceIds, codeChangeDescription, codeChangeFiles, includeDbBranchLease, experimentGroupId, datasetId) {
|
|
291
291
|
const payload = { traceFunctionKey };
|
|
292
292
|
if (limit !== void 0) {
|
|
293
293
|
payload.limit = limit;
|
|
@@ -307,6 +307,9 @@ var HttpClient = class {
|
|
|
307
307
|
if (experimentGroupId !== void 0) {
|
|
308
308
|
payload.experimentGroupId = experimentGroupId;
|
|
309
309
|
}
|
|
310
|
+
if (datasetId !== void 0) {
|
|
311
|
+
payload.datasetId = datasetId;
|
|
312
|
+
}
|
|
310
313
|
const timeout = includeDbBranchLease ? 18e4 : 3e4;
|
|
311
314
|
return this.request("/api/sdk/replay/start", payload, {
|
|
312
315
|
timeout
|
|
@@ -429,23 +432,30 @@ function extractContentBlocks(content) {
|
|
|
429
432
|
}
|
|
430
433
|
return content.map((block) => safeSerialize(block));
|
|
431
434
|
}
|
|
435
|
+
function asTokenCount(val) {
|
|
436
|
+
return typeof val === "number" && Number.isFinite(val) ? val : null;
|
|
437
|
+
}
|
|
432
438
|
function extractUsage(message) {
|
|
433
439
|
const usageInfo = {};
|
|
434
440
|
const usage = message.usage;
|
|
435
441
|
if (!usage) {
|
|
436
442
|
return usageInfo;
|
|
437
443
|
}
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
444
|
+
const baseInput = asTokenCount(usage.input_tokens);
|
|
445
|
+
const cacheRead = asTokenCount(usage.cache_read_input_tokens);
|
|
446
|
+
const cacheCreation = asTokenCount(usage.cache_creation_input_tokens);
|
|
447
|
+
if (baseInput !== null || cacheRead !== null || cacheCreation !== null) {
|
|
448
|
+
usageInfo.inputTokens = (baseInput ?? 0) + (cacheRead ?? 0) + (cacheCreation ?? 0);
|
|
449
|
+
}
|
|
450
|
+
const output = asTokenCount(usage.output_tokens);
|
|
451
|
+
if (output !== null) {
|
|
452
|
+
usageInfo.outputTokens = output;
|
|
453
|
+
}
|
|
454
|
+
if (cacheRead !== null) {
|
|
455
|
+
usageInfo.cacheReadTokens = cacheRead;
|
|
456
|
+
}
|
|
457
|
+
if (cacheCreation !== null) {
|
|
458
|
+
usageInfo.cacheCreationTokens = cacheCreation;
|
|
449
459
|
}
|
|
450
460
|
return usageInfo;
|
|
451
461
|
}
|
|
@@ -1234,7 +1244,7 @@ function extractModelName(serialized, metadata) {
|
|
|
1234
1244
|
}
|
|
1235
1245
|
return void 0;
|
|
1236
1246
|
}
|
|
1237
|
-
function
|
|
1247
|
+
function asTokenCount2(value) {
|
|
1238
1248
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
1239
1249
|
}
|
|
1240
1250
|
function normalizeTokenUsage(raw) {
|
|
@@ -1243,10 +1253,10 @@ function normalizeTokenUsage(raw) {
|
|
|
1243
1253
|
}
|
|
1244
1254
|
const u = raw;
|
|
1245
1255
|
if ("cache_read_input_tokens" in u || "cache_creation_input_tokens" in u) {
|
|
1246
|
-
const cacheRead =
|
|
1247
|
-
const cacheCreation =
|
|
1248
|
-
const baseInput =
|
|
1249
|
-
const outputTokens =
|
|
1256
|
+
const cacheRead = asTokenCount2(u.cache_read_input_tokens);
|
|
1257
|
+
const cacheCreation = asTokenCount2(u.cache_creation_input_tokens);
|
|
1258
|
+
const baseInput = asTokenCount2(u.input_tokens);
|
|
1259
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1250
1260
|
if (cacheRead === null && cacheCreation === null && baseInput === null && outputTokens === null) {
|
|
1251
1261
|
return null;
|
|
1252
1262
|
}
|
|
@@ -1261,25 +1271,25 @@ function normalizeTokenUsage(raw) {
|
|
|
1261
1271
|
if ("prompt_tokens" in u || "completion_tokens" in u || "promptTokens" in u || "completionTokens" in u) {
|
|
1262
1272
|
const promptDetails = u.prompt_tokens_details ?? {};
|
|
1263
1273
|
return withAnyTokenCount({
|
|
1264
|
-
inputTokens:
|
|
1265
|
-
outputTokens:
|
|
1266
|
-
totalTokens:
|
|
1267
|
-
cachedInputTokens:
|
|
1274
|
+
inputTokens: asTokenCount2(u.prompt_tokens) ?? asTokenCount2(u.promptTokens),
|
|
1275
|
+
outputTokens: asTokenCount2(u.completion_tokens) ?? asTokenCount2(u.completionTokens),
|
|
1276
|
+
totalTokens: asTokenCount2(u.total_tokens) ?? asTokenCount2(u.totalTokens),
|
|
1277
|
+
cachedInputTokens: asTokenCount2(promptDetails.cached_tokens)
|
|
1268
1278
|
});
|
|
1269
1279
|
}
|
|
1270
1280
|
if ("prompt_token_count" in u || "candidates_token_count" in u) {
|
|
1271
1281
|
return withAnyTokenCount({
|
|
1272
|
-
inputTokens:
|
|
1273
|
-
outputTokens:
|
|
1274
|
-
totalTokens:
|
|
1275
|
-
cachedInputTokens:
|
|
1282
|
+
inputTokens: asTokenCount2(u.prompt_token_count),
|
|
1283
|
+
outputTokens: asTokenCount2(u.candidates_token_count),
|
|
1284
|
+
totalTokens: asTokenCount2(u.total_token_count),
|
|
1285
|
+
cachedInputTokens: asTokenCount2(u.cached_content_token_count)
|
|
1276
1286
|
});
|
|
1277
1287
|
}
|
|
1278
1288
|
if ("input_tokens" in u || "output_tokens" in u) {
|
|
1279
1289
|
const inputDetails = u.input_token_details ?? {};
|
|
1280
|
-
const inputTokens =
|
|
1281
|
-
const outputTokens =
|
|
1282
|
-
let totalTokens =
|
|
1290
|
+
const inputTokens = asTokenCount2(u.input_tokens);
|
|
1291
|
+
const outputTokens = asTokenCount2(u.output_tokens);
|
|
1292
|
+
let totalTokens = asTokenCount2(u.total_tokens);
|
|
1283
1293
|
if (totalTokens === null && inputTokens !== null && outputTokens !== null) {
|
|
1284
1294
|
totalTokens = inputTokens + outputTokens;
|
|
1285
1295
|
}
|
|
@@ -1287,7 +1297,7 @@ function normalizeTokenUsage(raw) {
|
|
|
1287
1297
|
inputTokens,
|
|
1288
1298
|
outputTokens,
|
|
1289
1299
|
totalTokens,
|
|
1290
|
-
cachedInputTokens:
|
|
1300
|
+
cachedInputTokens: asTokenCount2(inputDetails.cache_read)
|
|
1291
1301
|
});
|
|
1292
1302
|
}
|
|
1293
1303
|
return null;
|
|
@@ -2984,7 +2994,7 @@ var Bitfab = class {
|
|
|
2984
2994
|
`Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
|
|
2985
2995
|
);
|
|
2986
2996
|
}
|
|
2987
|
-
const { replay: doReplay } = await import("./replay-
|
|
2997
|
+
const { replay: doReplay } = await import("./replay-V6RPJYXZ.js");
|
|
2988
2998
|
return doReplay(
|
|
2989
2999
|
this.httpClient,
|
|
2990
3000
|
this.serviceUrl,
|
|
@@ -3063,4 +3073,4 @@ export {
|
|
|
3063
3073
|
Bitfab,
|
|
3064
3074
|
BitfabFunction
|
|
3065
3075
|
};
|
|
3066
|
-
//# sourceMappingURL=chunk-
|
|
3076
|
+
//# sourceMappingURL=chunk-IUZIGC6T.js.map
|