@bitfab/sdk 0.39.0 → 0.40.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-SHJ3ABUG.js → chunk-5NT4YDCQ.js} +132 -5
- package/dist/chunk-5NT4YDCQ.js.map +1 -0
- package/dist/{chunk-2JQSYJJR.js → chunk-A22EYRSY.js} +10 -3
- package/dist/{chunk-2JQSYJJR.js.map → chunk-A22EYRSY.js.map} +1 -1
- package/dist/{chunk-RH4K4RSS.js → chunk-E2V4HFSM.js} +10 -3
- package/dist/{chunk-RH4K4RSS.js.map → chunk-E2V4HFSM.js.map} +1 -1
- package/dist/{chunk-FW7PZ3EP.js → chunk-EXT5FK54.js} +2 -2
- package/dist/{http-PRCLI43J.js → http-2OFIGQOK.js} +2 -2
- package/dist/{http-GJZJKNZZ.js → http-OZODCFFA.js} +2 -2
- package/dist/index.cjs +137 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -3
- package/dist/index.d.ts +144 -3
- package/dist/index.js +5 -3
- package/dist/node.cjs +137 -2
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +5 -3
- package/dist/node.js.map +1 -1
- package/dist/{replay-MZYX4IFV.js → replay-352POXG3.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-SHJ3ABUG.js.map +0 -1
- /package/dist/{chunk-FW7PZ3EP.js.map → chunk-EXT5FK54.js.map} +0 -0
- /package/dist/{http-GJZJKNZZ.js.map → http-2OFIGQOK.js.map} +0 -0
- /package/dist/{http-PRCLI43J.js.map → http-OZODCFFA.js.map} +0 -0
- /package/dist/{replay-MZYX4IFV.js.map → replay-352POXG3.js.map} +0 -0
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
replayContextReady,
|
|
6
6
|
runWithReplayContext,
|
|
7
7
|
warnOnce
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-A22EYRSY.js";
|
|
9
9
|
|
|
10
10
|
// src/codeChange.ts
|
|
11
11
|
var MAX_FILES = 60;
|
|
@@ -1147,4 +1147,4 @@ export {
|
|
|
1147
1147
|
sleepForReplayPersistence,
|
|
1148
1148
|
replay
|
|
1149
1149
|
};
|
|
1150
|
-
//# sourceMappingURL=chunk-
|
|
1150
|
+
//# sourceMappingURL=chunk-EXT5FK54.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-A22EYRSY.js";
|
|
10
10
|
import "./chunk-H6LZRFMN.js";
|
|
11
11
|
export {
|
|
12
12
|
BitfabError,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
parseRetryAfterMs,
|
|
18
18
|
serializePayloadBody
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=http-
|
|
20
|
+
//# sourceMappingURL=http-2OFIGQOK.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-E2V4HFSM.js";
|
|
10
10
|
export {
|
|
11
11
|
BitfabError,
|
|
12
12
|
HttpClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
parseRetryAfterMs,
|
|
17
17
|
serializePayloadBody
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=http-
|
|
19
|
+
//# sourceMappingURL=http-OZODCFFA.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var __version__, __packageName__;
|
|
|
42
42
|
var init_version_generated = __esm({
|
|
43
43
|
"src/version.generated.ts"() {
|
|
44
44
|
"use strict";
|
|
45
|
-
__version__ = "0.
|
|
45
|
+
__version__ = "0.40.0";
|
|
46
46
|
__packageName__ = "@bitfab/sdk";
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -1732,6 +1732,10 @@ var init_http = __esm({
|
|
|
1732
1732
|
const response = await this.get(endpoint);
|
|
1733
1733
|
return response.span;
|
|
1734
1734
|
}
|
|
1735
|
+
/**
|
|
1736
|
+
* GET a JSON endpoint on the service with the client's API key. Throws a
|
|
1737
|
+
* `BitfabError` carrying the status text for any non-2xx response.
|
|
1738
|
+
*/
|
|
1735
1739
|
async get(endpoint) {
|
|
1736
1740
|
const url = `${this.serviceUrl}${endpoint}`;
|
|
1737
1741
|
const controller = new AbortController();
|
|
@@ -1745,7 +1749,10 @@ var init_http = __esm({
|
|
|
1745
1749
|
if (!response.ok) {
|
|
1746
1750
|
const errorText = await response.text();
|
|
1747
1751
|
throw new BitfabError(
|
|
1748
|
-
`HTTP ${response.status}: ${errorText.slice(0, 500)}
|
|
1752
|
+
`HTTP ${response.status}: ${errorText.slice(0, 500)}`,
|
|
1753
|
+
void 0,
|
|
1754
|
+
response.status,
|
|
1755
|
+
parseRetryAfterMs(readHeader(response, "retry-after"))
|
|
1749
1756
|
);
|
|
1750
1757
|
}
|
|
1751
1758
|
return await response.json();
|
|
@@ -3197,6 +3204,7 @@ __export(index_exports, {
|
|
|
3197
3204
|
BitfabOpenAITracingProcessor: () => BitfabOpenAITracingProcessor,
|
|
3198
3205
|
BitfabVercelAiHandler: () => BitfabVercelAiHandler,
|
|
3199
3206
|
DEFAULT_SERVICE_URL: () => DEFAULT_SERVICE_URL,
|
|
3207
|
+
DatasetsClient: () => DatasetsClient,
|
|
3200
3208
|
DbBranchReplayError: () => DbBranchReplayError,
|
|
3201
3209
|
HttpClient: () => HttpClient,
|
|
3202
3210
|
NO_MOCK_OVERRIDE: () => NO_MOCK_OVERRIDE,
|
|
@@ -4276,6 +4284,131 @@ async function runFunctionWithBaml(bamlSource, inputs, providers, envVars) {
|
|
|
4276
4284
|
// src/client.ts
|
|
4277
4285
|
init_constants();
|
|
4278
4286
|
|
|
4287
|
+
// src/datasets.ts
|
|
4288
|
+
var DEFAULT_RERUN_TIMEOUT_MS = 9e4;
|
|
4289
|
+
var DEFAULT_RERUN_POLL_INTERVAL_MS = 1e3;
|
|
4290
|
+
var TERMINAL_RERUN_STATUSES = /* @__PURE__ */ new Set([
|
|
4291
|
+
"completed",
|
|
4292
|
+
"errored"
|
|
4293
|
+
]);
|
|
4294
|
+
function sleep(ms) {
|
|
4295
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4296
|
+
}
|
|
4297
|
+
function datasetPath(datasetId, suffix = "") {
|
|
4298
|
+
return `/api/sdk/datasets/${encodeURIComponent(datasetId)}${suffix}`;
|
|
4299
|
+
}
|
|
4300
|
+
var DatasetsClient = class {
|
|
4301
|
+
constructor(httpClient) {
|
|
4302
|
+
this.httpClient = httpClient;
|
|
4303
|
+
}
|
|
4304
|
+
/**
|
|
4305
|
+
* Create a dataset, or update the one already named this way under the same
|
|
4306
|
+
* trace function. `created` reports which happened. An omitted description
|
|
4307
|
+
* leaves an existing one untouched.
|
|
4308
|
+
*/
|
|
4309
|
+
async save(params) {
|
|
4310
|
+
return this.httpClient.request("/api/sdk/datasets", {
|
|
4311
|
+
traceFunctionKey: params.traceFunctionKey,
|
|
4312
|
+
name: params.name,
|
|
4313
|
+
...params.description === void 0 ? {} : { description: params.description }
|
|
4314
|
+
});
|
|
4315
|
+
}
|
|
4316
|
+
/**
|
|
4317
|
+
* List datasets, scoped to one trace function when `traceFunctionKey` is
|
|
4318
|
+
* given and organization-wide otherwise.
|
|
4319
|
+
*/
|
|
4320
|
+
async list(params = {}) {
|
|
4321
|
+
const query = params.traceFunctionKey === void 0 ? "" : `?traceFunctionKey=${encodeURIComponent(params.traceFunctionKey)}`;
|
|
4322
|
+
const response = await this.httpClient.get(
|
|
4323
|
+
`/api/sdk/datasets${query}`
|
|
4324
|
+
);
|
|
4325
|
+
return response.datasets;
|
|
4326
|
+
}
|
|
4327
|
+
/** Fetch one dataset by id. Rejects with a 404 `BitfabError` when it is not in this organization. */
|
|
4328
|
+
async get(datasetId) {
|
|
4329
|
+
const response = await this.httpClient.get(
|
|
4330
|
+
datasetPath(datasetId)
|
|
4331
|
+
);
|
|
4332
|
+
return response.dataset;
|
|
4333
|
+
}
|
|
4334
|
+
/** The ids of every trace in the dataset, the same membership a replay with `datasetId` selects. */
|
|
4335
|
+
async listTraces(datasetId) {
|
|
4336
|
+
return this.httpClient.get(
|
|
4337
|
+
datasetPath(datasetId, "/traces")
|
|
4338
|
+
);
|
|
4339
|
+
}
|
|
4340
|
+
/**
|
|
4341
|
+
* Add traces to the dataset (1 to 100 ids per call). Traces outside the
|
|
4342
|
+
* organization or under another trace function are reported in
|
|
4343
|
+
* `skippedTraceIds` rather than failing the call.
|
|
4344
|
+
*/
|
|
4345
|
+
async addTraces(datasetId, traceIds) {
|
|
4346
|
+
return this.httpClient.request(
|
|
4347
|
+
datasetPath(datasetId, "/traces"),
|
|
4348
|
+
{ traceIds }
|
|
4349
|
+
);
|
|
4350
|
+
}
|
|
4351
|
+
/** Remove traces from the dataset. The traces themselves are never deleted. */
|
|
4352
|
+
async removeTraces(datasetId, traceIds) {
|
|
4353
|
+
return this.httpClient.request(
|
|
4354
|
+
datasetPath(datasetId, "/removeTraces"),
|
|
4355
|
+
{ traceIds }
|
|
4356
|
+
);
|
|
4357
|
+
}
|
|
4358
|
+
/**
|
|
4359
|
+
* Assign graders to the dataset (1 to 100 ids per call). Graders outside the
|
|
4360
|
+
* organization or under another trace function are reported in
|
|
4361
|
+
* `skippedGraderIds` rather than failing the call.
|
|
4362
|
+
*/
|
|
4363
|
+
async addGraders(datasetId, graderIds) {
|
|
4364
|
+
return this.httpClient.request(
|
|
4365
|
+
datasetPath(datasetId, "/graders"),
|
|
4366
|
+
{ graderIds }
|
|
4367
|
+
);
|
|
4368
|
+
}
|
|
4369
|
+
/** Unassign graders from the dataset. */
|
|
4370
|
+
async removeGraders(datasetId, graderIds) {
|
|
4371
|
+
return this.httpClient.request(
|
|
4372
|
+
datasetPath(datasetId, "/removeGraders"),
|
|
4373
|
+
{ graderIds }
|
|
4374
|
+
);
|
|
4375
|
+
}
|
|
4376
|
+
/**
|
|
4377
|
+
* Re-run graders over every trace in the dataset. Defaults to every assigned
|
|
4378
|
+
* grader; an unassigned id is rejected. Waits for the run to finish (up to
|
|
4379
|
+
* `timeoutMs`, default 90s) unless `wait` is `false`, and returns the last
|
|
4380
|
+
* run state seen either way. A request matching an in-flight run joins it.
|
|
4381
|
+
*/
|
|
4382
|
+
async rerunGraders(datasetId, options = {}) {
|
|
4383
|
+
const started = await this.httpClient.request(
|
|
4384
|
+
datasetPath(datasetId, "/rerunGraders"),
|
|
4385
|
+
options.graderIds === void 0 ? {} : { graderIds: options.graderIds }
|
|
4386
|
+
);
|
|
4387
|
+
if (options.wait === false) {
|
|
4388
|
+
return started;
|
|
4389
|
+
}
|
|
4390
|
+
const deadline = Date.now() + (options.timeoutMs ?? DEFAULT_RERUN_TIMEOUT_MS);
|
|
4391
|
+
const interval = options.pollIntervalMs ?? DEFAULT_RERUN_POLL_INTERVAL_MS;
|
|
4392
|
+
let run = started.run;
|
|
4393
|
+
while (!TERMINAL_RERUN_STATUSES.has(run.status) && Date.now() < deadline) {
|
|
4394
|
+
await sleep(interval);
|
|
4395
|
+
run = await this.getGraderRerun(datasetId, run.id) ?? run;
|
|
4396
|
+
}
|
|
4397
|
+
return { run, joinedExisting: started.joinedExisting };
|
|
4398
|
+
}
|
|
4399
|
+
/**
|
|
4400
|
+
* The dataset's active grader re-run, or the run named by `runId`. Returns
|
|
4401
|
+
* `null` when nothing is active or the run does not belong to this dataset.
|
|
4402
|
+
*/
|
|
4403
|
+
async getGraderRerun(datasetId, runId) {
|
|
4404
|
+
const query = runId === void 0 ? "" : `?runId=${encodeURIComponent(runId)}`;
|
|
4405
|
+
const response = await this.httpClient.get(
|
|
4406
|
+
datasetPath(datasetId, `/rerunGraders${query}`)
|
|
4407
|
+
);
|
|
4408
|
+
return response.run;
|
|
4409
|
+
}
|
|
4410
|
+
};
|
|
4411
|
+
|
|
4279
4412
|
// src/dbSnapshot.ts
|
|
4280
4413
|
init_errors();
|
|
4281
4414
|
var SUPPORTED_PROVIDERS = ["neon"];
|
|
@@ -6011,6 +6144,7 @@ var Bitfab = class {
|
|
|
6011
6144
|
serviceUrl: this.serviceUrl,
|
|
6012
6145
|
timeout: this.timeout
|
|
6013
6146
|
});
|
|
6147
|
+
this.datasets = new DatasetsClient(this.httpClient);
|
|
6014
6148
|
}
|
|
6015
6149
|
/**
|
|
6016
6150
|
* Decorate a class method as an automatically expanded trace root.
|
|
@@ -7824,6 +7958,7 @@ function resolveTraceFunctionKey(registration) {
|
|
|
7824
7958
|
BitfabOpenAITracingProcessor,
|
|
7825
7959
|
BitfabVercelAiHandler,
|
|
7826
7960
|
DEFAULT_SERVICE_URL,
|
|
7961
|
+
DatasetsClient,
|
|
7827
7962
|
DbBranchReplayError,
|
|
7828
7963
|
HttpClient,
|
|
7829
7964
|
NO_MOCK_OVERRIDE,
|