braintrust 0.0.80 → 0.0.81
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/.turbo/turbo-build.log +14 -14
- package/dist/browser.js +57 -46
- package/dist/cli.js +122 -89
- package/dist/framework.d.ts +5 -11
- package/dist/index.d.ts +2 -1
- package/dist/index.js +88 -58
- package/dist/logger.d.ts +7 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/util.d.ts +0 -3
- package/package.json +13 -13
- package/dist/merge_row_batch.d.ts +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
|
|
2
|
-
> braintrust@0.0.63 build /
|
|
2
|
+
> braintrust@0.0.63 build /home/ubuntu/braintrust/braintrust/sdk/js
|
|
3
3
|
> run-p build:*
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> braintrust@0.0.63 build:
|
|
7
|
-
> esbuild --bundle src/
|
|
6
|
+
> braintrust@0.0.63 build:node /home/ubuntu/braintrust/braintrust/sdk/js
|
|
7
|
+
> esbuild --platform=node --bundle src/index.ts --outfile=dist/index.js
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> braintrust@0.0.63 build:declarations /
|
|
10
|
+
> braintrust@0.0.63 build:declarations /home/ubuntu/braintrust/braintrust/sdk/js
|
|
11
11
|
> tsc --declaration --emitDeclarationOnly --outDir dist
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
> esbuild --platform=node --bundle src/cli.ts --outfile=dist/cli.js --external:esbuild
|
|
14
|
+
dist/index.js 310.1kb
|
|
16
15
|
|
|
16
|
+
⚡ Done in 197ms
|
|
17
17
|
|
|
18
|
-
> braintrust@0.0.63 build:
|
|
19
|
-
> esbuild --platform=node --bundle src/
|
|
18
|
+
> braintrust@0.0.63 build:cli /home/ubuntu/braintrust/braintrust/sdk/js
|
|
19
|
+
> esbuild --platform=node --bundle src/cli.ts --outfile=dist/cli.js --external:esbuild
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
> braintrust@0.0.63 build:browser /home/ubuntu/braintrust/braintrust/sdk/js
|
|
23
|
+
> esbuild --bundle src/browser.ts --outfile=dist/browser.js --format=esm
|
|
23
24
|
|
|
24
|
-
⚡ Done in 13ms
|
|
25
25
|
|
|
26
|
-
dist/
|
|
26
|
+
dist/browser.js 47.6kb
|
|
27
27
|
|
|
28
|
-
⚡ Done in
|
|
28
|
+
⚡ Done in 36ms
|
|
29
29
|
|
|
30
|
-
dist/cli.js
|
|
30
|
+
dist/cli.js 545.3kb
|
|
31
31
|
|
|
32
|
-
⚡ Done in
|
|
32
|
+
⚡ Done in 62ms
|
package/dist/browser.js
CHANGED
|
@@ -22,7 +22,7 @@ var iso = {
|
|
|
22
22
|
};
|
|
23
23
|
var isomorph_default = iso;
|
|
24
24
|
|
|
25
|
-
// ../../node_modules/.pnpm/uuid@9.0.
|
|
25
|
+
// ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/rng.js
|
|
26
26
|
var getRandomValues;
|
|
27
27
|
var rnds8 = new Uint8Array(16);
|
|
28
28
|
function rng() {
|
|
@@ -35,22 +35,22 @@ function rng() {
|
|
|
35
35
|
return getRandomValues(rnds8);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// ../../node_modules/.pnpm/uuid@9.0.
|
|
38
|
+
// ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/stringify.js
|
|
39
39
|
var byteToHex = [];
|
|
40
40
|
for (let i = 0; i < 256; ++i) {
|
|
41
41
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
42
42
|
}
|
|
43
43
|
function unsafeStringify(arr, offset = 0) {
|
|
44
|
-
return
|
|
44
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// ../../node_modules/.pnpm/uuid@9.0.
|
|
47
|
+
// ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/native.js
|
|
48
48
|
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
49
49
|
var native_default = {
|
|
50
50
|
randomUUID
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
// ../../node_modules/.pnpm/uuid@9.0.
|
|
53
|
+
// ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/v4.js
|
|
54
54
|
function v4(options, buf, offset) {
|
|
55
55
|
if (native_default.randomUUID && !buf && !options) {
|
|
56
56
|
return native_default.randomUUID();
|
|
@@ -70,58 +70,40 @@ function v4(options, buf, offset) {
|
|
|
70
70
|
}
|
|
71
71
|
var v4_default = v4;
|
|
72
72
|
|
|
73
|
-
//
|
|
73
|
+
// ../core/js/dist/index.mjs
|
|
74
74
|
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
75
75
|
var IS_MERGE_FIELD = "_is_merge";
|
|
76
|
-
var GLOBAL_PROJECT = "Global";
|
|
77
|
-
function runFinally(f, finallyF) {
|
|
78
|
-
let runSyncCleanup = true;
|
|
79
|
-
try {
|
|
80
|
-
const ret = f();
|
|
81
|
-
if (ret instanceof Promise) {
|
|
82
|
-
runSyncCleanup = false;
|
|
83
|
-
return ret.finally(finallyF);
|
|
84
|
-
} else {
|
|
85
|
-
return ret;
|
|
86
|
-
}
|
|
87
|
-
} finally {
|
|
88
|
-
if (runSyncCleanup) {
|
|
89
|
-
finallyF();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
76
|
function mergeDicts(mergeInto, mergeFrom) {
|
|
94
77
|
for (const [k, mergeFromV] of Object.entries(mergeFrom)) {
|
|
95
78
|
const mergeIntoV = mergeInto[k];
|
|
96
79
|
if (mergeIntoV instanceof Object && !Array.isArray(mergeIntoV) && mergeFrom instanceof Object && !Array.isArray(mergeFromV)) {
|
|
97
|
-
mergeDicts(
|
|
80
|
+
mergeDicts(
|
|
81
|
+
mergeIntoV,
|
|
82
|
+
mergeFromV
|
|
83
|
+
);
|
|
98
84
|
} else {
|
|
99
85
|
mergeInto[k] = mergeFromV;
|
|
100
86
|
}
|
|
101
87
|
}
|
|
102
88
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
];
|
|
116
|
-
function generateUniqueRowKey(row) {
|
|
117
|
-
const coalesceEmpty = (field) => row[field] ?? "";
|
|
118
|
-
return DATA_OBJECT_KEYS.concat(["id"]).map(coalesceEmpty).join(":");
|
|
89
|
+
function generateMergedRowKey(row) {
|
|
90
|
+
return JSON.stringify(
|
|
91
|
+
[
|
|
92
|
+
"org_id",
|
|
93
|
+
"project_id",
|
|
94
|
+
"experiment_id",
|
|
95
|
+
"dataset_id",
|
|
96
|
+
"prompt_session_id",
|
|
97
|
+
"log_id",
|
|
98
|
+
"id"
|
|
99
|
+
].map((k) => row[k])
|
|
100
|
+
);
|
|
119
101
|
}
|
|
120
102
|
function mergeRowBatch(rows) {
|
|
121
103
|
const out = [];
|
|
122
104
|
const remainingRows = [];
|
|
123
105
|
for (const row of rows) {
|
|
124
|
-
if (row
|
|
106
|
+
if (row.id === void 0) {
|
|
125
107
|
out.push(row);
|
|
126
108
|
} else {
|
|
127
109
|
remainingRows.push(row);
|
|
@@ -129,7 +111,7 @@ function mergeRowBatch(rows) {
|
|
|
129
111
|
}
|
|
130
112
|
const rowGroups = {};
|
|
131
113
|
for (const row of remainingRows) {
|
|
132
|
-
const key =
|
|
114
|
+
const key = generateMergedRowKey(row);
|
|
133
115
|
const existingRow = rowGroups[key];
|
|
134
116
|
if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
|
|
135
117
|
const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
|
|
@@ -145,6 +127,28 @@ function mergeRowBatch(rows) {
|
|
|
145
127
|
return out;
|
|
146
128
|
}
|
|
147
129
|
|
|
130
|
+
// src/util.ts
|
|
131
|
+
var GLOBAL_PROJECT = "Global";
|
|
132
|
+
function runFinally(f, finallyF) {
|
|
133
|
+
let runSyncCleanup = true;
|
|
134
|
+
try {
|
|
135
|
+
const ret = f();
|
|
136
|
+
if (ret instanceof Promise) {
|
|
137
|
+
runSyncCleanup = false;
|
|
138
|
+
return ret.finally(finallyF);
|
|
139
|
+
} else {
|
|
140
|
+
return ret;
|
|
141
|
+
}
|
|
142
|
+
} finally {
|
|
143
|
+
if (runSyncCleanup) {
|
|
144
|
+
finallyF();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function getCurrentUnixTimestamp() {
|
|
149
|
+
return (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
150
|
+
}
|
|
151
|
+
|
|
148
152
|
// src/logger.ts
|
|
149
153
|
var NoopSpan = class {
|
|
150
154
|
constructor() {
|
|
@@ -555,7 +559,8 @@ async function init(project, options = {}) {
|
|
|
555
559
|
apiUrl,
|
|
556
560
|
apiKey,
|
|
557
561
|
orgName,
|
|
558
|
-
disableCache
|
|
562
|
+
disableCache,
|
|
563
|
+
metadata
|
|
559
564
|
} = options || {};
|
|
560
565
|
await login({
|
|
561
566
|
orgName,
|
|
@@ -569,7 +574,8 @@ async function init(project, options = {}) {
|
|
|
569
574
|
dataset,
|
|
570
575
|
update,
|
|
571
576
|
baseExperiment,
|
|
572
|
-
isPublic
|
|
577
|
+
isPublic,
|
|
578
|
+
metadata
|
|
573
579
|
});
|
|
574
580
|
}
|
|
575
581
|
async function withExperiment(project, callback, options = {}) {
|
|
@@ -867,12 +873,14 @@ async function _initExperiment(projectName, {
|
|
|
867
873
|
dataset,
|
|
868
874
|
update,
|
|
869
875
|
baseExperiment,
|
|
870
|
-
isPublic
|
|
876
|
+
isPublic,
|
|
877
|
+
metadata
|
|
871
878
|
} = {
|
|
872
879
|
experimentName: void 0,
|
|
873
880
|
description: void 0,
|
|
874
881
|
baseExperiment: void 0,
|
|
875
|
-
isPublic: false
|
|
882
|
+
isPublic: false,
|
|
883
|
+
metadata: void 0
|
|
876
884
|
}) {
|
|
877
885
|
const args = {
|
|
878
886
|
project_name: projectName,
|
|
@@ -903,6 +911,9 @@ async function _initExperiment(projectName, {
|
|
|
903
911
|
if (isPublic !== void 0) {
|
|
904
912
|
args["public"] = isPublic;
|
|
905
913
|
}
|
|
914
|
+
if (metadata) {
|
|
915
|
+
args["metadata"] = metadata;
|
|
916
|
+
}
|
|
906
917
|
let response = null;
|
|
907
918
|
while (true) {
|
|
908
919
|
try {
|
package/dist/cli.js
CHANGED
|
@@ -9064,7 +9064,7 @@ var require_package = __commonJS({
|
|
|
9064
9064
|
"package.json"(exports2, module2) {
|
|
9065
9065
|
module2.exports = {
|
|
9066
9066
|
name: "braintrust",
|
|
9067
|
-
version: "0.0.
|
|
9067
|
+
version: "0.0.81",
|
|
9068
9068
|
description: "SDK for integrating Braintrust",
|
|
9069
9069
|
main: "./dist/index.js",
|
|
9070
9070
|
browser: {
|
|
@@ -9095,28 +9095,28 @@ var require_package = __commonJS({
|
|
|
9095
9095
|
license: "MIT",
|
|
9096
9096
|
devDependencies: {
|
|
9097
9097
|
"@nodelib/fs.walk": "^1.2.8",
|
|
9098
|
-
"@types/argparse": "^2.0.
|
|
9099
|
-
"@types/cli-progress": "^3.11.
|
|
9100
|
-
"@types/graceful-fs": "^4.1.
|
|
9101
|
-
"@types/node": "^20.
|
|
9098
|
+
"@types/argparse": "^2.0.14",
|
|
9099
|
+
"@types/cli-progress": "^3.11.5",
|
|
9100
|
+
"@types/graceful-fs": "^4.1.9",
|
|
9101
|
+
"@types/node": "^20.10.5",
|
|
9102
9102
|
"@types/pluralize": "^0.0.30",
|
|
9103
|
-
"@types/uuid": "^9.0.
|
|
9103
|
+
"@types/uuid": "^9.0.7",
|
|
9104
9104
|
"npm-run-all": "^4.1.5",
|
|
9105
|
-
typedoc: "^0.
|
|
9106
|
-
"typedoc-plugin-markdown": "^3.
|
|
9107
|
-
typescript: "^5.
|
|
9105
|
+
typedoc: "^0.25.4",
|
|
9106
|
+
"typedoc-plugin-markdown": "^3.17.1",
|
|
9107
|
+
typescript: "^5.3.3"
|
|
9108
9108
|
},
|
|
9109
9109
|
dependencies: {
|
|
9110
|
-
"@braintrust/core": "^0.0.
|
|
9110
|
+
"@braintrust/core": "^0.0.7",
|
|
9111
9111
|
argparse: "^2.0.1",
|
|
9112
9112
|
chalk: "^4.1.2",
|
|
9113
9113
|
"cli-progress": "^3.12.0",
|
|
9114
|
-
esbuild: "^0.18.
|
|
9114
|
+
esbuild: "^0.18.20",
|
|
9115
9115
|
"graceful-fs": "^4.2.11",
|
|
9116
9116
|
minimatch: "^9.0.3",
|
|
9117
9117
|
pluralize: "^8.0.0",
|
|
9118
|
-
"simple-git": "^3.
|
|
9119
|
-
uuid: "^9.0.
|
|
9118
|
+
"simple-git": "^3.21.0",
|
|
9119
|
+
uuid: "^9.0.1"
|
|
9120
9120
|
}
|
|
9121
9121
|
};
|
|
9122
9122
|
}
|
|
@@ -9127,7 +9127,7 @@ var esbuild = __toESM(require("esbuild"));
|
|
|
9127
9127
|
var import_fs = __toESM(require("fs"));
|
|
9128
9128
|
var import_os = __toESM(require("os"));
|
|
9129
9129
|
var import_path = __toESM(require("path"));
|
|
9130
|
-
var
|
|
9130
|
+
var import_util2 = __toESM(require("util"));
|
|
9131
9131
|
var fsWalk = __toESM(require_out3());
|
|
9132
9132
|
|
|
9133
9133
|
// ../../node_modules/.pnpm/minimatch@9.0.3/node_modules/minimatch/dist/mjs/index.js
|
|
@@ -10457,7 +10457,7 @@ minimatch.unescape = unescape;
|
|
|
10457
10457
|
// src/cli.ts
|
|
10458
10458
|
var import_argparse = __toESM(require_argparse());
|
|
10459
10459
|
|
|
10460
|
-
// ../../node_modules/.pnpm/uuid@9.0.
|
|
10460
|
+
// ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-node/rng.js
|
|
10461
10461
|
var import_crypto = __toESM(require("crypto"));
|
|
10462
10462
|
var rnds8Pool = new Uint8Array(256);
|
|
10463
10463
|
var poolPtr = rnds8Pool.length;
|
|
@@ -10469,22 +10469,22 @@ function rng() {
|
|
|
10469
10469
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
10470
10470
|
}
|
|
10471
10471
|
|
|
10472
|
-
// ../../node_modules/.pnpm/uuid@9.0.
|
|
10472
|
+
// ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-node/stringify.js
|
|
10473
10473
|
var byteToHex = [];
|
|
10474
10474
|
for (let i = 0; i < 256; ++i) {
|
|
10475
10475
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
10476
10476
|
}
|
|
10477
10477
|
function unsafeStringify(arr, offset = 0) {
|
|
10478
|
-
return
|
|
10478
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
10479
10479
|
}
|
|
10480
10480
|
|
|
10481
|
-
// ../../node_modules/.pnpm/uuid@9.0.
|
|
10481
|
+
// ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-node/native.js
|
|
10482
10482
|
var import_crypto2 = __toESM(require("crypto"));
|
|
10483
10483
|
var native_default = {
|
|
10484
10484
|
randomUUID: import_crypto2.default.randomUUID
|
|
10485
10485
|
};
|
|
10486
10486
|
|
|
10487
|
-
// ../../node_modules/.pnpm/uuid@9.0.
|
|
10487
|
+
// ../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-node/v4.js
|
|
10488
10488
|
function v4(options, buf, offset) {
|
|
10489
10489
|
if (native_default.randomUUID && !buf && !options) {
|
|
10490
10490
|
return native_default.randomUUID();
|
|
@@ -10507,6 +10507,63 @@ var v4_default = v4;
|
|
|
10507
10507
|
// src/cli.ts
|
|
10508
10508
|
var import_pluralize2 = __toESM(require_pluralize());
|
|
10509
10509
|
|
|
10510
|
+
// ../core/js/dist/index.mjs
|
|
10511
|
+
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
10512
|
+
var IS_MERGE_FIELD = "_is_merge";
|
|
10513
|
+
function mergeDicts(mergeInto, mergeFrom) {
|
|
10514
|
+
for (const [k, mergeFromV] of Object.entries(mergeFrom)) {
|
|
10515
|
+
const mergeIntoV = mergeInto[k];
|
|
10516
|
+
if (mergeIntoV instanceof Object && !Array.isArray(mergeIntoV) && mergeFrom instanceof Object && !Array.isArray(mergeFromV)) {
|
|
10517
|
+
mergeDicts(
|
|
10518
|
+
mergeIntoV,
|
|
10519
|
+
mergeFromV
|
|
10520
|
+
);
|
|
10521
|
+
} else {
|
|
10522
|
+
mergeInto[k] = mergeFromV;
|
|
10523
|
+
}
|
|
10524
|
+
}
|
|
10525
|
+
}
|
|
10526
|
+
function generateMergedRowKey(row) {
|
|
10527
|
+
return JSON.stringify(
|
|
10528
|
+
[
|
|
10529
|
+
"org_id",
|
|
10530
|
+
"project_id",
|
|
10531
|
+
"experiment_id",
|
|
10532
|
+
"dataset_id",
|
|
10533
|
+
"prompt_session_id",
|
|
10534
|
+
"log_id",
|
|
10535
|
+
"id"
|
|
10536
|
+
].map((k) => row[k])
|
|
10537
|
+
);
|
|
10538
|
+
}
|
|
10539
|
+
function mergeRowBatch(rows) {
|
|
10540
|
+
const out = [];
|
|
10541
|
+
const remainingRows = [];
|
|
10542
|
+
for (const row of rows) {
|
|
10543
|
+
if (row.id === void 0) {
|
|
10544
|
+
out.push(row);
|
|
10545
|
+
} else {
|
|
10546
|
+
remainingRows.push(row);
|
|
10547
|
+
}
|
|
10548
|
+
}
|
|
10549
|
+
const rowGroups = {};
|
|
10550
|
+
for (const row of remainingRows) {
|
|
10551
|
+
const key = generateMergedRowKey(row);
|
|
10552
|
+
const existingRow = rowGroups[key];
|
|
10553
|
+
if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
|
|
10554
|
+
const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
|
|
10555
|
+
mergeDicts(existingRow, row);
|
|
10556
|
+
if (preserveNoMerge) {
|
|
10557
|
+
delete existingRow[IS_MERGE_FIELD];
|
|
10558
|
+
}
|
|
10559
|
+
} else {
|
|
10560
|
+
rowGroups[key] = row;
|
|
10561
|
+
}
|
|
10562
|
+
}
|
|
10563
|
+
out.push(...Object.values(rowGroups));
|
|
10564
|
+
return out;
|
|
10565
|
+
}
|
|
10566
|
+
|
|
10510
10567
|
// src/isomorph.ts
|
|
10511
10568
|
var DefaultAsyncLocalStorage = class {
|
|
10512
10569
|
constructor() {
|
|
@@ -10532,8 +10589,6 @@ var iso = {
|
|
|
10532
10589
|
var isomorph_default = iso;
|
|
10533
10590
|
|
|
10534
10591
|
// src/util.ts
|
|
10535
|
-
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
10536
|
-
var IS_MERGE_FIELD = "_is_merge";
|
|
10537
10592
|
function runFinally(f, finallyF) {
|
|
10538
10593
|
let runSyncCleanup = true;
|
|
10539
10594
|
try {
|
|
@@ -10550,61 +10605,10 @@ function runFinally(f, finallyF) {
|
|
|
10550
10605
|
}
|
|
10551
10606
|
}
|
|
10552
10607
|
}
|
|
10553
|
-
function mergeDicts(mergeInto, mergeFrom) {
|
|
10554
|
-
for (const [k, mergeFromV] of Object.entries(mergeFrom)) {
|
|
10555
|
-
const mergeIntoV = mergeInto[k];
|
|
10556
|
-
if (mergeIntoV instanceof Object && !Array.isArray(mergeIntoV) && mergeFrom instanceof Object && !Array.isArray(mergeFromV)) {
|
|
10557
|
-
mergeDicts(mergeIntoV, mergeFromV);
|
|
10558
|
-
} else {
|
|
10559
|
-
mergeInto[k] = mergeFromV;
|
|
10560
|
-
}
|
|
10561
|
-
}
|
|
10562
|
-
}
|
|
10563
10608
|
function getCurrentUnixTimestamp() {
|
|
10564
10609
|
return (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
10565
10610
|
}
|
|
10566
10611
|
|
|
10567
|
-
// src/merge_row_batch.ts
|
|
10568
|
-
var DATA_OBJECT_KEYS = [
|
|
10569
|
-
"org_id",
|
|
10570
|
-
"project_id",
|
|
10571
|
-
"experiment_id",
|
|
10572
|
-
"dataset_id",
|
|
10573
|
-
"prompt_session_id",
|
|
10574
|
-
"log_id"
|
|
10575
|
-
];
|
|
10576
|
-
function generateUniqueRowKey(row) {
|
|
10577
|
-
const coalesceEmpty = (field) => row[field] ?? "";
|
|
10578
|
-
return DATA_OBJECT_KEYS.concat(["id"]).map(coalesceEmpty).join(":");
|
|
10579
|
-
}
|
|
10580
|
-
function mergeRowBatch(rows) {
|
|
10581
|
-
const out = [];
|
|
10582
|
-
const remainingRows = [];
|
|
10583
|
-
for (const row of rows) {
|
|
10584
|
-
if (row["id"] === void 0) {
|
|
10585
|
-
out.push(row);
|
|
10586
|
-
} else {
|
|
10587
|
-
remainingRows.push(row);
|
|
10588
|
-
}
|
|
10589
|
-
}
|
|
10590
|
-
const rowGroups = {};
|
|
10591
|
-
for (const row of remainingRows) {
|
|
10592
|
-
const key = generateUniqueRowKey(row);
|
|
10593
|
-
const existingRow = rowGroups[key];
|
|
10594
|
-
if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
|
|
10595
|
-
const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
|
|
10596
|
-
mergeDicts(existingRow, row);
|
|
10597
|
-
if (preserveNoMerge) {
|
|
10598
|
-
delete existingRow[IS_MERGE_FIELD];
|
|
10599
|
-
}
|
|
10600
|
-
} else {
|
|
10601
|
-
rowGroups[key] = row;
|
|
10602
|
-
}
|
|
10603
|
-
}
|
|
10604
|
-
out.push(...Object.values(rowGroups));
|
|
10605
|
-
return out;
|
|
10606
|
-
}
|
|
10607
|
-
|
|
10608
10612
|
// src/logger.ts
|
|
10609
10613
|
var NoopSpan = class {
|
|
10610
10614
|
constructor() {
|
|
@@ -10914,7 +10918,8 @@ async function init(project, options = {}) {
|
|
|
10914
10918
|
apiUrl,
|
|
10915
10919
|
apiKey,
|
|
10916
10920
|
orgName,
|
|
10917
|
-
disableCache
|
|
10921
|
+
disableCache,
|
|
10922
|
+
metadata
|
|
10918
10923
|
} = options || {};
|
|
10919
10924
|
await login({
|
|
10920
10925
|
orgName,
|
|
@@ -10928,7 +10933,8 @@ async function init(project, options = {}) {
|
|
|
10928
10933
|
dataset,
|
|
10929
10934
|
update,
|
|
10930
10935
|
baseExperiment,
|
|
10931
|
-
isPublic
|
|
10936
|
+
isPublic,
|
|
10937
|
+
metadata
|
|
10932
10938
|
});
|
|
10933
10939
|
}
|
|
10934
10940
|
async function login(options = {}) {
|
|
@@ -11128,12 +11134,14 @@ async function _initExperiment(projectName, {
|
|
|
11128
11134
|
dataset,
|
|
11129
11135
|
update,
|
|
11130
11136
|
baseExperiment,
|
|
11131
|
-
isPublic
|
|
11137
|
+
isPublic,
|
|
11138
|
+
metadata
|
|
11132
11139
|
} = {
|
|
11133
11140
|
experimentName: void 0,
|
|
11134
11141
|
description: void 0,
|
|
11135
11142
|
baseExperiment: void 0,
|
|
11136
|
-
isPublic: false
|
|
11143
|
+
isPublic: false,
|
|
11144
|
+
metadata: void 0
|
|
11137
11145
|
}) {
|
|
11138
11146
|
const args = {
|
|
11139
11147
|
project_name: projectName,
|
|
@@ -11164,6 +11172,9 @@ async function _initExperiment(projectName, {
|
|
|
11164
11172
|
if (isPublic !== void 0) {
|
|
11165
11173
|
args["public"] = isPublic;
|
|
11166
11174
|
}
|
|
11175
|
+
if (metadata) {
|
|
11176
|
+
args["metadata"] = metadata;
|
|
11177
|
+
}
|
|
11167
11178
|
let response = null;
|
|
11168
11179
|
while (true) {
|
|
11169
11180
|
try {
|
|
@@ -11755,9 +11766,6 @@ var GlobalPaths = findGlobalPaths();
|
|
|
11755
11766
|
// src/framework.ts
|
|
11756
11767
|
var import_chalk = __toESM(require_source());
|
|
11757
11768
|
var import_pluralize = __toESM(require_pluralize());
|
|
11758
|
-
function evalMetadataToInitOptions(metadata) {
|
|
11759
|
-
return { experiment: metadata?.experimentName };
|
|
11760
|
-
}
|
|
11761
11769
|
globalThis._evals = {};
|
|
11762
11770
|
function serializeJSONWithPlainString(v) {
|
|
11763
11771
|
if (typeof v === "string") {
|
|
@@ -11971,7 +11979,7 @@ function reportEvaluatorResult(evaluatorName, evaluatorResult, verbose) {
|
|
|
11971
11979
|
// src/node.ts
|
|
11972
11980
|
var import_node_async_hooks = require("node:async_hooks");
|
|
11973
11981
|
|
|
11974
|
-
// ../../node_modules/.pnpm/simple-git@3.
|
|
11982
|
+
// ../../node_modules/.pnpm/simple-git@3.21.0/node_modules/simple-git/dist/esm/index.js
|
|
11975
11983
|
var import_file_exists = __toESM(require_dist(), 1);
|
|
11976
11984
|
var import_debug = __toESM(require_src(), 1);
|
|
11977
11985
|
var import_child_process = require("child_process");
|
|
@@ -12042,6 +12050,11 @@ var __async = (__this, __arguments, generator) => {
|
|
|
12042
12050
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
12043
12051
|
});
|
|
12044
12052
|
};
|
|
12053
|
+
function pathspec(...paths) {
|
|
12054
|
+
const key = new String(paths);
|
|
12055
|
+
cache.set(key, paths);
|
|
12056
|
+
return key;
|
|
12057
|
+
}
|
|
12045
12058
|
function isPathSpec(path5) {
|
|
12046
12059
|
return path5 instanceof String && cache.has(path5);
|
|
12047
12060
|
}
|
|
@@ -13490,6 +13503,19 @@ var init_commit = __esm({
|
|
|
13490
13503
|
init_task();
|
|
13491
13504
|
}
|
|
13492
13505
|
});
|
|
13506
|
+
function first_commit_default() {
|
|
13507
|
+
return {
|
|
13508
|
+
firstCommit() {
|
|
13509
|
+
return this._runTask(straightThroughStringTask(["rev-list", "--max-parents=0", "HEAD"], true), trailingFunctionArgument(arguments));
|
|
13510
|
+
}
|
|
13511
|
+
};
|
|
13512
|
+
}
|
|
13513
|
+
var init_first_commit = __esm({
|
|
13514
|
+
"src/lib/tasks/first-commit.ts"() {
|
|
13515
|
+
init_utils();
|
|
13516
|
+
init_task();
|
|
13517
|
+
}
|
|
13518
|
+
});
|
|
13493
13519
|
function hashObjectTask(filePath, write) {
|
|
13494
13520
|
const commands = ["hash-object", filePath];
|
|
13495
13521
|
if (write) {
|
|
@@ -13823,7 +13849,7 @@ function parseLogOptions(opt = {}, customArgs = []) {
|
|
|
13823
13849
|
suffix.push(`${opt.from || ""}${rangeOperator}${opt.to || ""}`);
|
|
13824
13850
|
}
|
|
13825
13851
|
if (filterString(opt.file)) {
|
|
13826
|
-
|
|
13852
|
+
command.push("--follow", pathspec(opt.file));
|
|
13827
13853
|
}
|
|
13828
13854
|
appendTaskOptions(userOptions(opt), command);
|
|
13829
13855
|
return {
|
|
@@ -13860,6 +13886,7 @@ var excludeOptions;
|
|
|
13860
13886
|
var init_log = __esm({
|
|
13861
13887
|
"src/lib/tasks/log.ts"() {
|
|
13862
13888
|
init_log_format();
|
|
13889
|
+
init_pathspec();
|
|
13863
13890
|
init_parse_list_log_summary();
|
|
13864
13891
|
init_utils();
|
|
13865
13892
|
init_task();
|
|
@@ -14519,6 +14546,7 @@ var init_simple_git_api = __esm({
|
|
|
14519
14546
|
init_checkout();
|
|
14520
14547
|
init_commit();
|
|
14521
14548
|
init_config();
|
|
14549
|
+
init_first_commit();
|
|
14522
14550
|
init_grep();
|
|
14523
14551
|
init_hash_object();
|
|
14524
14552
|
init_init();
|
|
@@ -14592,7 +14620,7 @@ var init_simple_git_api = __esm({
|
|
|
14592
14620
|
return this._runTask(statusTask(getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
|
|
14593
14621
|
}
|
|
14594
14622
|
};
|
|
14595
|
-
Object.assign(SimpleGitApi.prototype, checkout_default(), commit_default(), config_default(), grep_default(), log_default(), show_default(), version_default());
|
|
14623
|
+
Object.assign(SimpleGitApi.prototype, checkout_default(), commit_default(), config_default(), first_commit_default(), grep_default(), log_default(), show_default(), version_default());
|
|
14596
14624
|
}
|
|
14597
14625
|
});
|
|
14598
14626
|
var scheduler_exports = {};
|
|
@@ -16113,11 +16141,11 @@ function evaluateBuildResults(inFile, buildResult) {
|
|
|
16113
16141
|
return { ...globalThis._evals };
|
|
16114
16142
|
});
|
|
16115
16143
|
}
|
|
16116
|
-
async function initLogger(projectName, metadata) {
|
|
16117
|
-
const logger = await init(
|
|
16118
|
-
|
|
16119
|
-
|
|
16120
|
-
);
|
|
16144
|
+
async function initLogger(projectName, experimentName, metadata) {
|
|
16145
|
+
const logger = await init(projectName, {
|
|
16146
|
+
experiment: experimentName,
|
|
16147
|
+
metadata
|
|
16148
|
+
});
|
|
16121
16149
|
const info = await logger.summarize({ summarizeScores: false });
|
|
16122
16150
|
console.log(`Experiment ${logger.name} is running at ${info.experimentUrl}`);
|
|
16123
16151
|
return logger;
|
|
@@ -16142,7 +16170,11 @@ function buildWatchPluginForEvaluator(inFile, opts) {
|
|
|
16142
16170
|
return;
|
|
16143
16171
|
}
|
|
16144
16172
|
for (const evaluator of Object.values(evalResult)) {
|
|
16145
|
-
const logger = opts.noSendLogs ? null : await initLogger(
|
|
16173
|
+
const logger = opts.noSendLogs ? null : await initLogger(
|
|
16174
|
+
evaluator.projectName,
|
|
16175
|
+
evaluator.experimentName,
|
|
16176
|
+
evaluator.metadata
|
|
16177
|
+
);
|
|
16146
16178
|
const evaluatorResult = await runEvaluator(
|
|
16147
16179
|
logger,
|
|
16148
16180
|
evaluator,
|
|
@@ -16244,6 +16276,7 @@ async function runOnce(handles, opts) {
|
|
|
16244
16276
|
const resultPromises = Object.values(evaluators).map(async (evaluator) => {
|
|
16245
16277
|
const logger = opts.noSendLogs ? null : await initLogger(
|
|
16246
16278
|
evaluator.evaluator.projectName,
|
|
16279
|
+
evaluator.evaluator.experimentName,
|
|
16247
16280
|
evaluator.evaluator.metadata
|
|
16248
16281
|
);
|
|
16249
16282
|
try {
|
|
@@ -16314,7 +16347,7 @@ async function collectFiles(inputPath) {
|
|
|
16314
16347
|
files.push(inputPath);
|
|
16315
16348
|
}
|
|
16316
16349
|
} else {
|
|
16317
|
-
const walked = await
|
|
16350
|
+
const walked = await import_util2.default.promisify(fsWalk.walk)(inputPath, {
|
|
16318
16351
|
deepFilter: (entry) => {
|
|
16319
16352
|
return checkMatch(entry.path, null, EXCLUDE);
|
|
16320
16353
|
},
|