braintrust 0.3.6 → 0.3.7
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/dev/dist/index.d.mts +228 -16
- package/dev/dist/index.d.ts +228 -16
- package/dev/dist/index.js +2121 -1133
- package/dev/dist/index.mjs +2077 -1089
- package/dist/browser.d.mts +331 -39
- package/dist/browser.d.ts +331 -39
- package/dist/browser.js +2065 -1110
- package/dist/browser.mjs +2001 -1046
- package/dist/cli.js +2191 -1159
- package/dist/index.d.mts +356 -28
- package/dist/index.d.ts +356 -28
- package/dist/index.js +2550 -1227
- package/dist/index.mjs +2464 -1141
- package/package.json +13 -8
- package/util/dist/index.d.mts +5229 -0
- package/util/dist/index.d.ts +5229 -0
- package/util/dist/index.js +1264 -0
- package/util/dist/index.mjs +1264 -0
package/dist/browser.mjs
CHANGED
|
@@ -87,33 +87,990 @@ var Queue = class {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
90
|
+
// util/db_fields.ts
|
|
91
|
+
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
92
|
+
var IS_MERGE_FIELD = "_is_merge";
|
|
93
|
+
var AUDIT_SOURCE_FIELD = "_audit_source";
|
|
94
|
+
var AUDIT_METADATA_FIELD = "_audit_metadata";
|
|
95
|
+
var VALID_SOURCES = ["app", "api", "external"];
|
|
96
|
+
var PARENT_ID_FIELD = "_parent_id";
|
|
97
|
+
|
|
98
|
+
// util/span_identifier_v3.ts
|
|
99
|
+
import * as uuid3 from "uuid";
|
|
100
|
+
|
|
101
|
+
// util/span_identifier_v2.ts
|
|
102
|
+
import * as uuid2 from "uuid";
|
|
103
|
+
|
|
104
|
+
// util/span_identifier_v1.ts
|
|
105
|
+
import * as uuid from "uuid";
|
|
106
|
+
import { z } from "zod/v3";
|
|
107
|
+
function tryMakeUuid(s) {
|
|
108
|
+
try {
|
|
109
|
+
const ret = uuid.parse(s);
|
|
110
|
+
if (ret.length !== 16) {
|
|
111
|
+
throw new Error();
|
|
112
|
+
}
|
|
113
|
+
return { bytes: Buffer.from(ret), isUUID: true };
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var ENCODING_VERSION_NUMBER = 1;
|
|
119
|
+
var INVALID_ENCODING_ERRMSG = "SpanComponents string is not properly encoded. This may be due to a version mismatch between the SDK library used to export the span and the library used to decode it. Please make sure you are using the same SDK version across the board";
|
|
120
|
+
var SpanObjectTypeV1 = /* @__PURE__ */ ((SpanObjectTypeV12) => {
|
|
121
|
+
SpanObjectTypeV12[SpanObjectTypeV12["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
122
|
+
SpanObjectTypeV12[SpanObjectTypeV12["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
123
|
+
return SpanObjectTypeV12;
|
|
124
|
+
})(SpanObjectTypeV1 || {});
|
|
125
|
+
var SpanObjectTypeV1EnumSchema = z.nativeEnum(SpanObjectTypeV1);
|
|
126
|
+
var SpanRowIdsV1 = class {
|
|
127
|
+
rowId;
|
|
128
|
+
spanId;
|
|
129
|
+
rootSpanId;
|
|
130
|
+
constructor(args) {
|
|
131
|
+
this.rowId = args.rowId;
|
|
132
|
+
this.spanId = args.spanId;
|
|
133
|
+
this.rootSpanId = args.rootSpanId;
|
|
134
|
+
if (!this.rowId) {
|
|
135
|
+
throw new Error("rowId must be nonempty string");
|
|
136
|
+
}
|
|
137
|
+
if (!this.spanId) {
|
|
138
|
+
throw new Error("spanId must be nonempty string");
|
|
139
|
+
}
|
|
140
|
+
if (!this.rootSpanId) {
|
|
141
|
+
throw new Error("rootSpanId must be nonempty string");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
toObject() {
|
|
145
|
+
return {
|
|
146
|
+
rowId: this.rowId,
|
|
147
|
+
spanId: this.spanId,
|
|
148
|
+
rootSpanId: this.rootSpanId
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var SpanComponentsV1 = class _SpanComponentsV1 {
|
|
153
|
+
objectType;
|
|
154
|
+
objectId;
|
|
155
|
+
rowIds;
|
|
156
|
+
constructor(args) {
|
|
157
|
+
this.objectType = args.objectType;
|
|
158
|
+
this.objectId = args.objectId;
|
|
159
|
+
this.rowIds = args.rowIds;
|
|
160
|
+
}
|
|
161
|
+
toStr() {
|
|
162
|
+
const allBuffers = [];
|
|
163
|
+
const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
|
|
164
|
+
allBuffers.push(
|
|
165
|
+
Buffer.from([
|
|
166
|
+
ENCODING_VERSION_NUMBER,
|
|
167
|
+
this.objectType,
|
|
168
|
+
this.rowIds ? 1 : 0,
|
|
169
|
+
rowIdIsUUID ? 1 : 0
|
|
170
|
+
])
|
|
171
|
+
);
|
|
172
|
+
const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid(
|
|
173
|
+
this.objectId
|
|
174
|
+
);
|
|
175
|
+
if (!objectIdIsUUID) {
|
|
176
|
+
throw new Error("object_id component must be a valid UUID");
|
|
177
|
+
}
|
|
178
|
+
allBuffers.push(objectIdBytes);
|
|
179
|
+
if (this.rowIds) {
|
|
180
|
+
const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid(
|
|
181
|
+
this.rowIds.spanId
|
|
182
|
+
);
|
|
183
|
+
if (!spanIdIsUUID) {
|
|
184
|
+
throw new Error("span_id component must be a valid UUID");
|
|
185
|
+
}
|
|
186
|
+
const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid(
|
|
187
|
+
this.rowIds.rootSpanId
|
|
188
|
+
);
|
|
189
|
+
if (!rootSpanIdIsUUID) {
|
|
190
|
+
throw new Error("root_span_id component must be a valid UUID");
|
|
191
|
+
}
|
|
192
|
+
allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
|
|
193
|
+
}
|
|
194
|
+
return Buffer.concat(allBuffers).toString("base64");
|
|
195
|
+
}
|
|
196
|
+
static fromStr(s) {
|
|
197
|
+
try {
|
|
198
|
+
const rawBytes = Buffer.from(s, "base64");
|
|
199
|
+
if (rawBytes[0] !== ENCODING_VERSION_NUMBER) {
|
|
200
|
+
throw new Error();
|
|
201
|
+
}
|
|
202
|
+
const objectType = SpanObjectTypeV1EnumSchema.parse(rawBytes[1]);
|
|
203
|
+
if (![0, 1].includes(rawBytes[2])) {
|
|
204
|
+
throw new Error();
|
|
205
|
+
}
|
|
206
|
+
if (![0, 1].includes(rawBytes[3])) {
|
|
207
|
+
throw new Error();
|
|
208
|
+
}
|
|
209
|
+
const hasRowId = rawBytes[2] == 1;
|
|
210
|
+
const rowIdIsUUID = rawBytes[3] == 1;
|
|
211
|
+
const objectId = uuid.stringify(rawBytes.subarray(4, 20));
|
|
212
|
+
const rowIds = (() => {
|
|
213
|
+
if (!hasRowId) {
|
|
214
|
+
return void 0;
|
|
215
|
+
}
|
|
216
|
+
const spanId = uuid.stringify(rawBytes.subarray(20, 36));
|
|
217
|
+
const rootSpanId = uuid.stringify(rawBytes.subarray(36, 52));
|
|
218
|
+
const rowId = rowIdIsUUID ? uuid.stringify(rawBytes.subarray(52)) : rawBytes.subarray(52).toString("utf-8");
|
|
219
|
+
return new SpanRowIdsV1({ rowId, spanId, rootSpanId });
|
|
220
|
+
})();
|
|
221
|
+
return new _SpanComponentsV1({ objectType, objectId, rowIds });
|
|
222
|
+
} catch (e) {
|
|
223
|
+
throw new Error(INVALID_ENCODING_ERRMSG);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
objectIdFields() {
|
|
227
|
+
switch (this.objectType) {
|
|
228
|
+
case 1 /* EXPERIMENT */:
|
|
229
|
+
return { experiment_id: this.objectId };
|
|
230
|
+
case 2 /* PROJECT_LOGS */:
|
|
231
|
+
return { project_id: this.objectId, log_id: "g" };
|
|
232
|
+
default:
|
|
233
|
+
throw new Error("Impossible");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
toObject() {
|
|
237
|
+
return {
|
|
238
|
+
objectType: this.objectType,
|
|
239
|
+
objectId: this.objectId,
|
|
240
|
+
rowIds: this.rowIds?.toObject()
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// util/span_identifier_v2.ts
|
|
246
|
+
import { z as z2 } from "zod/v3";
|
|
247
|
+
function tryMakeUuid2(s) {
|
|
248
|
+
try {
|
|
249
|
+
const ret = uuid2.parse(s);
|
|
250
|
+
if (ret.length !== 16) {
|
|
251
|
+
throw new Error();
|
|
252
|
+
}
|
|
253
|
+
return { bytes: Buffer.from(ret), isUUID: true };
|
|
254
|
+
} catch (e) {
|
|
255
|
+
return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
var ENCODING_VERSION_NUMBER2 = 2;
|
|
259
|
+
var INVALID_ENCODING_ERRMSG2 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER2}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
|
|
260
|
+
var INTEGER_ENCODING_NUM_BYTES = 4;
|
|
261
|
+
var SpanObjectTypeV2 = /* @__PURE__ */ ((SpanObjectTypeV22) => {
|
|
262
|
+
SpanObjectTypeV22[SpanObjectTypeV22["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
263
|
+
SpanObjectTypeV22[SpanObjectTypeV22["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
264
|
+
return SpanObjectTypeV22;
|
|
265
|
+
})(SpanObjectTypeV2 || {});
|
|
266
|
+
var SpanObjectTypeV2EnumSchema = z2.nativeEnum(SpanObjectTypeV2);
|
|
267
|
+
var SpanRowIdsV2 = class {
|
|
268
|
+
rowId;
|
|
269
|
+
spanId;
|
|
270
|
+
rootSpanId;
|
|
271
|
+
constructor(args) {
|
|
272
|
+
this.rowId = args.rowId;
|
|
273
|
+
this.spanId = args.spanId;
|
|
274
|
+
this.rootSpanId = args.rootSpanId;
|
|
275
|
+
if (!this.rowId) {
|
|
276
|
+
throw new Error("rowId must be nonempty string");
|
|
277
|
+
}
|
|
278
|
+
if (!this.spanId) {
|
|
279
|
+
throw new Error("spanId must be nonempty string");
|
|
280
|
+
}
|
|
281
|
+
if (!this.rootSpanId) {
|
|
282
|
+
throw new Error("rootSpanId must be nonempty string");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
toObject() {
|
|
286
|
+
return {
|
|
287
|
+
rowId: this.rowId,
|
|
288
|
+
spanId: this.spanId,
|
|
289
|
+
rootSpanId: this.rootSpanId
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
var SpanComponentsV2 = class _SpanComponentsV2 {
|
|
294
|
+
objectType;
|
|
295
|
+
objectId;
|
|
296
|
+
computeObjectMetadataArgs;
|
|
297
|
+
rowIds;
|
|
298
|
+
constructor(args) {
|
|
299
|
+
this.objectType = args.objectType;
|
|
300
|
+
this.objectId = args.objectId;
|
|
301
|
+
this.computeObjectMetadataArgs = args.computeObjectMetadataArgs;
|
|
302
|
+
this.rowIds = args.rowIds;
|
|
303
|
+
if (!(this.objectId || this.computeObjectMetadataArgs)) {
|
|
304
|
+
throw new Error(
|
|
305
|
+
"Must provide either objectId or computeObjectMetadataArgs"
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
toStr() {
|
|
310
|
+
const allBuffers = [];
|
|
311
|
+
const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid2(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
|
|
312
|
+
allBuffers.push(
|
|
313
|
+
Buffer.from([
|
|
314
|
+
ENCODING_VERSION_NUMBER2,
|
|
315
|
+
this.objectType,
|
|
316
|
+
this.objectId ? 1 : 0,
|
|
317
|
+
this.computeObjectMetadataArgs ? 1 : 0,
|
|
318
|
+
this.rowIds ? 1 : 0,
|
|
319
|
+
rowIdIsUUID ? 1 : 0
|
|
320
|
+
])
|
|
321
|
+
);
|
|
322
|
+
if (this.objectId) {
|
|
323
|
+
const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid2(
|
|
324
|
+
this.objectId
|
|
325
|
+
);
|
|
326
|
+
if (!objectIdIsUUID) {
|
|
327
|
+
throw new Error("object_id component must be a valid UUID");
|
|
328
|
+
}
|
|
329
|
+
allBuffers.push(objectIdBytes);
|
|
330
|
+
}
|
|
331
|
+
if (this.computeObjectMetadataArgs) {
|
|
332
|
+
const computeObjectMetadataBytes = Buffer.from(
|
|
333
|
+
JSON.stringify(this.computeObjectMetadataArgs),
|
|
334
|
+
"utf-8"
|
|
335
|
+
);
|
|
336
|
+
const serializedLenBytes = Buffer.alloc(INTEGER_ENCODING_NUM_BYTES);
|
|
337
|
+
serializedLenBytes.writeInt32BE(computeObjectMetadataBytes.length);
|
|
338
|
+
allBuffers.push(serializedLenBytes, computeObjectMetadataBytes);
|
|
339
|
+
}
|
|
340
|
+
if (this.rowIds) {
|
|
341
|
+
const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid2(
|
|
342
|
+
this.rowIds.spanId
|
|
343
|
+
);
|
|
344
|
+
if (!spanIdIsUUID) {
|
|
345
|
+
throw new Error("span_id component must be a valid UUID");
|
|
346
|
+
}
|
|
347
|
+
const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid2(
|
|
348
|
+
this.rowIds.rootSpanId
|
|
349
|
+
);
|
|
350
|
+
if (!rootSpanIdIsUUID) {
|
|
351
|
+
throw new Error("root_span_id component must be a valid UUID");
|
|
352
|
+
}
|
|
353
|
+
allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
|
|
354
|
+
}
|
|
355
|
+
return Buffer.concat(allBuffers).toString("base64");
|
|
356
|
+
}
|
|
357
|
+
static fromStr(s) {
|
|
358
|
+
try {
|
|
359
|
+
const rawBytes = Buffer.from(s, "base64");
|
|
360
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER2) {
|
|
361
|
+
const spanComponentsOld = SpanComponentsV1.fromStr(s);
|
|
362
|
+
return new _SpanComponentsV2({
|
|
363
|
+
objectType: SpanObjectTypeV2EnumSchema.parse(
|
|
364
|
+
spanComponentsOld.objectType
|
|
365
|
+
),
|
|
366
|
+
objectId: spanComponentsOld.objectId,
|
|
367
|
+
rowIds: spanComponentsOld.rowIds ? new SpanRowIdsV2({
|
|
368
|
+
rowId: spanComponentsOld.rowIds.rowId,
|
|
369
|
+
spanId: spanComponentsOld.rowIds.spanId,
|
|
370
|
+
rootSpanId: spanComponentsOld.rowIds.rootSpanId
|
|
371
|
+
}) : void 0
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
if (rawBytes[0] !== ENCODING_VERSION_NUMBER2) {
|
|
375
|
+
throw new Error();
|
|
376
|
+
}
|
|
377
|
+
const objectType = SpanObjectTypeV2EnumSchema.parse(rawBytes[1]);
|
|
378
|
+
for (let i = 2; i < 6; ++i) {
|
|
379
|
+
if (![0, 1].includes(rawBytes[i])) {
|
|
380
|
+
throw new Error();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const hasObjectId = rawBytes[2] == 1;
|
|
384
|
+
const hasComputeObjectMetadataArgs = rawBytes[3] == 1;
|
|
385
|
+
const hasRowId = rawBytes[4] == 1;
|
|
386
|
+
const rowIdIsUUID = rawBytes[5] == 1;
|
|
387
|
+
let byteCursor = 6;
|
|
388
|
+
let objectId = void 0;
|
|
389
|
+
if (hasObjectId) {
|
|
390
|
+
const nextByteCursor = byteCursor + 16;
|
|
391
|
+
objectId = uuid2.stringify(
|
|
392
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
393
|
+
);
|
|
394
|
+
byteCursor = nextByteCursor;
|
|
395
|
+
}
|
|
396
|
+
let computeObjectMetadataArgs;
|
|
397
|
+
if (hasComputeObjectMetadataArgs) {
|
|
398
|
+
let nextByteCursor = byteCursor + INTEGER_ENCODING_NUM_BYTES;
|
|
399
|
+
const serializedLenBytes = rawBytes.readInt32BE(byteCursor);
|
|
400
|
+
byteCursor = nextByteCursor;
|
|
401
|
+
nextByteCursor = byteCursor + serializedLenBytes;
|
|
402
|
+
computeObjectMetadataArgs = JSON.parse(
|
|
403
|
+
rawBytes.subarray(byteCursor, nextByteCursor).toString("utf-8")
|
|
404
|
+
);
|
|
405
|
+
byteCursor = nextByteCursor;
|
|
406
|
+
}
|
|
407
|
+
const rowIds = (() => {
|
|
408
|
+
if (!hasRowId) {
|
|
409
|
+
return void 0;
|
|
410
|
+
}
|
|
411
|
+
let nextByteCursor = byteCursor + 16;
|
|
412
|
+
const spanId = uuid2.stringify(
|
|
413
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
414
|
+
);
|
|
415
|
+
byteCursor = nextByteCursor;
|
|
416
|
+
nextByteCursor = byteCursor + 16;
|
|
417
|
+
const rootSpanId = uuid2.stringify(
|
|
418
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
419
|
+
);
|
|
420
|
+
byteCursor = nextByteCursor;
|
|
421
|
+
const rowId = rowIdIsUUID ? uuid2.stringify(rawBytes.subarray(byteCursor)) : rawBytes.subarray(byteCursor).toString("utf-8");
|
|
422
|
+
return new SpanRowIdsV2({ rowId, spanId, rootSpanId });
|
|
423
|
+
})();
|
|
424
|
+
return new _SpanComponentsV2({
|
|
425
|
+
objectType,
|
|
426
|
+
objectId,
|
|
427
|
+
computeObjectMetadataArgs,
|
|
428
|
+
rowIds
|
|
429
|
+
});
|
|
430
|
+
} catch (e) {
|
|
431
|
+
throw new Error(INVALID_ENCODING_ERRMSG2);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
objectIdFields() {
|
|
435
|
+
if (!this.objectId) {
|
|
436
|
+
throw new Error(
|
|
437
|
+
"Impossible: cannot invoke `object_id_fields` unless SpanComponentsV2 is initialized with an `object_id`"
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
switch (this.objectType) {
|
|
441
|
+
case 1 /* EXPERIMENT */:
|
|
442
|
+
return { experiment_id: this.objectId };
|
|
443
|
+
case 2 /* PROJECT_LOGS */:
|
|
444
|
+
return { project_id: this.objectId, log_id: "g" };
|
|
445
|
+
default:
|
|
446
|
+
throw new Error("Impossible");
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
toObject() {
|
|
450
|
+
return {
|
|
451
|
+
objectType: this.objectType,
|
|
452
|
+
objectId: this.objectId,
|
|
453
|
+
computeObjectMetadataArgs: this.computeObjectMetadataArgs,
|
|
454
|
+
rowIds: this.rowIds?.toObject()
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// util/span_identifier_v3.ts
|
|
460
|
+
import { z as z3 } from "zod/v3";
|
|
461
|
+
|
|
462
|
+
// util/bytes.ts
|
|
463
|
+
function concatUint8Arrays(...arrays) {
|
|
464
|
+
const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
|
|
465
|
+
const result = new Uint8Array(totalLength);
|
|
466
|
+
let offset = 0;
|
|
467
|
+
for (const arr of arrays) {
|
|
468
|
+
result.set(arr, offset);
|
|
469
|
+
offset += arr.length;
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
}
|
|
473
|
+
function uint8ArrayToBase64(uint8Array) {
|
|
474
|
+
let binary = "";
|
|
475
|
+
for (let i = 0; i < uint8Array.length; i++) {
|
|
476
|
+
binary += String.fromCharCode(uint8Array[i]);
|
|
477
|
+
}
|
|
478
|
+
return btoa(binary);
|
|
479
|
+
}
|
|
480
|
+
function base64ToUint8Array(base64) {
|
|
481
|
+
const binary = atob(base64);
|
|
482
|
+
const uint8Array = new Uint8Array(binary.length);
|
|
483
|
+
for (let i = 0; i < binary.length; i++) {
|
|
484
|
+
uint8Array[i] = binary.charCodeAt(i);
|
|
485
|
+
}
|
|
486
|
+
return uint8Array;
|
|
487
|
+
}
|
|
488
|
+
function uint8ArrayToString(uint8Array) {
|
|
489
|
+
const decoder = new TextDecoder("utf-8");
|
|
490
|
+
return decoder.decode(uint8Array);
|
|
491
|
+
}
|
|
492
|
+
function stringToUint8Array(str) {
|
|
493
|
+
const encoder = new TextEncoder();
|
|
494
|
+
return encoder.encode(str);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// util/span_identifier_v3.ts
|
|
498
|
+
function tryMakeUuid3(s) {
|
|
499
|
+
try {
|
|
500
|
+
const ret = uuid3.parse(s);
|
|
501
|
+
if (ret.length !== 16) {
|
|
502
|
+
throw new Error();
|
|
503
|
+
}
|
|
504
|
+
return { bytes: new Uint8Array(ret), isUUID: true };
|
|
505
|
+
} catch {
|
|
506
|
+
return { bytes: void 0, isUUID: false };
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
var ENCODING_VERSION_NUMBER3 = 3;
|
|
510
|
+
var INVALID_ENCODING_ERRMSG3 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER3}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
|
|
511
|
+
var SpanObjectTypeV3 = /* @__PURE__ */ ((SpanObjectTypeV32) => {
|
|
512
|
+
SpanObjectTypeV32[SpanObjectTypeV32["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
513
|
+
SpanObjectTypeV32[SpanObjectTypeV32["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
514
|
+
SpanObjectTypeV32[SpanObjectTypeV32["PLAYGROUND_LOGS"] = 3] = "PLAYGROUND_LOGS";
|
|
515
|
+
return SpanObjectTypeV32;
|
|
516
|
+
})(SpanObjectTypeV3 || {});
|
|
517
|
+
var spanObjectTypeV3EnumSchema = z3.nativeEnum(SpanObjectTypeV3);
|
|
518
|
+
function spanObjectTypeV3ToString(objectType) {
|
|
519
|
+
switch (objectType) {
|
|
520
|
+
case 1 /* EXPERIMENT */:
|
|
521
|
+
return "experiment";
|
|
522
|
+
case 2 /* PROJECT_LOGS */:
|
|
523
|
+
return "project_logs";
|
|
524
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
525
|
+
return "playground_logs";
|
|
526
|
+
default:
|
|
527
|
+
const x = objectType;
|
|
528
|
+
throw new Error(`Unknown SpanObjectTypeV3: ${x}`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
var InternalSpanComponentUUIDFields = /* @__PURE__ */ ((InternalSpanComponentUUIDFields2) => {
|
|
532
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["OBJECT_ID"] = 1] = "OBJECT_ID";
|
|
533
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROW_ID"] = 2] = "ROW_ID";
|
|
534
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["SPAN_ID"] = 3] = "SPAN_ID";
|
|
535
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROOT_SPAN_ID"] = 4] = "ROOT_SPAN_ID";
|
|
536
|
+
return InternalSpanComponentUUIDFields2;
|
|
537
|
+
})(InternalSpanComponentUUIDFields || {});
|
|
538
|
+
var internalSpanComponentUUIDFieldsEnumSchema = z3.nativeEnum(
|
|
539
|
+
InternalSpanComponentUUIDFields
|
|
540
|
+
);
|
|
541
|
+
var _INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME = {
|
|
542
|
+
[1 /* OBJECT_ID */]: "object_id",
|
|
543
|
+
[2 /* ROW_ID */]: "row_id",
|
|
544
|
+
[3 /* SPAN_ID */]: "span_id",
|
|
545
|
+
[4 /* ROOT_SPAN_ID */]: "root_span_id"
|
|
546
|
+
};
|
|
547
|
+
var spanComponentsV3Schema = z3.object({
|
|
548
|
+
object_type: spanObjectTypeV3EnumSchema,
|
|
549
|
+
// TODO(manu): We should have a more elaborate zod schema for
|
|
550
|
+
// `propagated_event`. This will required zod-ifying the contents of
|
|
551
|
+
// sdk/js/util/object.ts.
|
|
552
|
+
propagated_event: z3.record(z3.unknown()).nullish()
|
|
553
|
+
}).and(
|
|
554
|
+
z3.union([
|
|
555
|
+
// Must provide one or the other.
|
|
556
|
+
z3.object({
|
|
557
|
+
object_id: z3.string().nullish(),
|
|
558
|
+
compute_object_metadata_args: z3.optional(z3.null())
|
|
559
|
+
}),
|
|
560
|
+
z3.object({
|
|
561
|
+
object_id: z3.optional(z3.null()),
|
|
562
|
+
compute_object_metadata_args: z3.record(z3.unknown())
|
|
563
|
+
})
|
|
564
|
+
])
|
|
565
|
+
).and(
|
|
566
|
+
z3.union([
|
|
567
|
+
// Either all of these must be provided or none.
|
|
568
|
+
z3.object({
|
|
569
|
+
row_id: z3.string(),
|
|
570
|
+
span_id: z3.string(),
|
|
571
|
+
root_span_id: z3.string()
|
|
572
|
+
}),
|
|
573
|
+
z3.object({
|
|
574
|
+
row_id: z3.optional(z3.null()),
|
|
575
|
+
span_id: z3.optional(z3.null()),
|
|
576
|
+
root_span_id: z3.optional(z3.null())
|
|
577
|
+
})
|
|
578
|
+
])
|
|
579
|
+
);
|
|
580
|
+
var SpanComponentsV3 = class _SpanComponentsV3 {
|
|
581
|
+
constructor(data) {
|
|
582
|
+
this.data = data;
|
|
583
|
+
}
|
|
584
|
+
toStr() {
|
|
585
|
+
const jsonObj = {
|
|
586
|
+
compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
|
|
587
|
+
propagated_event: this.data.propagated_event || void 0
|
|
588
|
+
};
|
|
589
|
+
const allBuffers = [];
|
|
590
|
+
allBuffers.push(
|
|
591
|
+
new Uint8Array([ENCODING_VERSION_NUMBER3, this.data.object_type])
|
|
592
|
+
);
|
|
593
|
+
const uuidEntries = [];
|
|
594
|
+
function addUuidField(origVal, fieldId) {
|
|
595
|
+
const ret = tryMakeUuid3(origVal);
|
|
596
|
+
if (ret.isUUID) {
|
|
597
|
+
uuidEntries.push(
|
|
598
|
+
concatUint8Arrays(new Uint8Array([fieldId]), ret.bytes)
|
|
599
|
+
);
|
|
600
|
+
} else {
|
|
601
|
+
jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = origVal;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (this.data.object_id) {
|
|
605
|
+
addUuidField(
|
|
606
|
+
this.data.object_id,
|
|
607
|
+
1 /* OBJECT_ID */
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
if (this.data.row_id) {
|
|
611
|
+
addUuidField(this.data.row_id, 2 /* ROW_ID */);
|
|
612
|
+
}
|
|
613
|
+
if (this.data.span_id) {
|
|
614
|
+
addUuidField(this.data.span_id, 3 /* SPAN_ID */);
|
|
615
|
+
}
|
|
616
|
+
if (this.data.root_span_id) {
|
|
617
|
+
addUuidField(
|
|
618
|
+
this.data.root_span_id,
|
|
619
|
+
4 /* ROOT_SPAN_ID */
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
if (uuidEntries.length > 255) {
|
|
623
|
+
throw new Error("Impossible: too many UUID entries to encode");
|
|
624
|
+
}
|
|
625
|
+
allBuffers.push(new Uint8Array([uuidEntries.length]));
|
|
626
|
+
allBuffers.push(...uuidEntries);
|
|
627
|
+
if (Object.keys(jsonObj).length > 0) {
|
|
628
|
+
allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
|
|
629
|
+
}
|
|
630
|
+
return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
|
|
631
|
+
}
|
|
632
|
+
static fromStr(s) {
|
|
633
|
+
try {
|
|
634
|
+
const rawBytes = base64ToUint8Array(s);
|
|
635
|
+
const jsonObj = {};
|
|
636
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER3) {
|
|
637
|
+
const spanComponentsOld = SpanComponentsV2.fromStr(s);
|
|
638
|
+
jsonObj["object_type"] = spanComponentsOld.objectType;
|
|
639
|
+
jsonObj["object_id"] = spanComponentsOld.objectId;
|
|
640
|
+
jsonObj["compute_object_metadata_args"] = spanComponentsOld.computeObjectMetadataArgs;
|
|
641
|
+
if (spanComponentsOld.rowIds) {
|
|
642
|
+
jsonObj["row_id"] = spanComponentsOld.rowIds.rowId;
|
|
643
|
+
jsonObj["span_id"] = spanComponentsOld.rowIds.spanId;
|
|
644
|
+
jsonObj["root_span_id"] = spanComponentsOld.rowIds.rootSpanId;
|
|
645
|
+
}
|
|
646
|
+
} else {
|
|
647
|
+
jsonObj["object_type"] = rawBytes[1];
|
|
648
|
+
const numUuidEntries = rawBytes[2];
|
|
649
|
+
let byteOffset = 3;
|
|
650
|
+
for (let i = 0; i < numUuidEntries; ++i) {
|
|
651
|
+
const fieldId = internalSpanComponentUUIDFieldsEnumSchema.parse(
|
|
652
|
+
rawBytes[byteOffset]
|
|
653
|
+
);
|
|
654
|
+
const fieldBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
|
|
655
|
+
byteOffset += 17;
|
|
656
|
+
jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = uuid3.stringify(fieldBytes);
|
|
657
|
+
}
|
|
658
|
+
if (byteOffset < rawBytes.length) {
|
|
659
|
+
const remainingJsonObj = JSON.parse(
|
|
660
|
+
uint8ArrayToString(rawBytes.subarray(byteOffset))
|
|
661
|
+
);
|
|
662
|
+
Object.assign(jsonObj, remainingJsonObj);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
return _SpanComponentsV3.fromJsonObj(jsonObj);
|
|
666
|
+
} catch {
|
|
667
|
+
throw new Error(INVALID_ENCODING_ERRMSG3);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
objectIdFields() {
|
|
671
|
+
if (!this.data.object_id) {
|
|
672
|
+
throw new Error(
|
|
673
|
+
"Impossible: cannot invoke `objectIdFields` unless SpanComponentsV3 is initialized with an `object_id`"
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
switch (this.data.object_type) {
|
|
677
|
+
case 1 /* EXPERIMENT */:
|
|
678
|
+
return { experiment_id: this.data.object_id };
|
|
679
|
+
case 2 /* PROJECT_LOGS */:
|
|
680
|
+
return { project_id: this.data.object_id, log_id: "g" };
|
|
681
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
682
|
+
return { prompt_session_id: this.data.object_id, log_id: "x" };
|
|
683
|
+
default:
|
|
684
|
+
const _ = this.data.object_type;
|
|
685
|
+
throw new Error("Impossible");
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
async export() {
|
|
689
|
+
return this.toStr();
|
|
690
|
+
}
|
|
691
|
+
static fromJsonObj(jsonObj) {
|
|
692
|
+
return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
// util/type_util.ts
|
|
697
|
+
function isObject(value) {
|
|
698
|
+
return value instanceof Object && !(value instanceof Array);
|
|
699
|
+
}
|
|
700
|
+
function isArray(value) {
|
|
701
|
+
return value instanceof Array;
|
|
702
|
+
}
|
|
703
|
+
function isObjectOrArray(value) {
|
|
704
|
+
return value instanceof Object;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// util/object_util.ts
|
|
708
|
+
function mergeDictsWithPaths({
|
|
709
|
+
mergeInto,
|
|
710
|
+
mergeFrom,
|
|
711
|
+
mergePaths
|
|
712
|
+
}) {
|
|
713
|
+
const mergePathsSerialized = new Set(
|
|
714
|
+
mergePaths.map((p) => JSON.stringify(p))
|
|
715
|
+
);
|
|
716
|
+
return mergeDictsWithPathsHelper({
|
|
717
|
+
mergeInto,
|
|
718
|
+
mergeFrom,
|
|
719
|
+
path: [],
|
|
720
|
+
mergePaths: mergePathsSerialized
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
function mergeDictsWithPathsHelper({
|
|
724
|
+
mergeInto,
|
|
725
|
+
mergeFrom,
|
|
726
|
+
path,
|
|
727
|
+
mergePaths
|
|
728
|
+
}) {
|
|
729
|
+
Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
|
|
730
|
+
const fullPath = path.concat([k]);
|
|
731
|
+
const fullPathSerialized = JSON.stringify(fullPath);
|
|
732
|
+
const mergeIntoV = recordFind(mergeInto, k);
|
|
733
|
+
if (isObject(mergeIntoV) && isObject(mergeFromV) && !mergePaths.has(fullPathSerialized)) {
|
|
734
|
+
mergeDictsWithPathsHelper({
|
|
735
|
+
mergeInto: mergeIntoV,
|
|
736
|
+
mergeFrom: mergeFromV,
|
|
737
|
+
path: fullPath,
|
|
738
|
+
mergePaths
|
|
739
|
+
});
|
|
740
|
+
} else {
|
|
741
|
+
mergeInto[k] = mergeFromV;
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
return mergeInto;
|
|
745
|
+
}
|
|
746
|
+
function mergeDicts(mergeInto, mergeFrom) {
|
|
747
|
+
return mergeDictsWithPaths({ mergeInto, mergeFrom, mergePaths: [] });
|
|
748
|
+
}
|
|
749
|
+
function mapAt(m, k) {
|
|
750
|
+
const ret = m.get(k);
|
|
751
|
+
if (ret === void 0) {
|
|
752
|
+
throw new Error(`Map does not contain key ${k}`);
|
|
753
|
+
}
|
|
754
|
+
return ret;
|
|
755
|
+
}
|
|
756
|
+
function recordFind(m, k) {
|
|
757
|
+
return m[k];
|
|
758
|
+
}
|
|
759
|
+
function getObjValueByPath(row, path) {
|
|
760
|
+
let curr = row;
|
|
761
|
+
for (const p of path) {
|
|
762
|
+
if (!isObjectOrArray(curr)) {
|
|
763
|
+
return null;
|
|
764
|
+
}
|
|
765
|
+
curr = curr[p];
|
|
766
|
+
}
|
|
767
|
+
return curr;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// util/graph_util.ts
|
|
771
|
+
function depthFirstSearch(args) {
|
|
772
|
+
const { graph, firstVisitF, lastVisitF } = args;
|
|
773
|
+
for (const vs of graph.values()) {
|
|
774
|
+
for (const v of vs.values()) {
|
|
775
|
+
if (!graph.has(v)) {
|
|
776
|
+
throw new Error(`Outgoing vertex ${v} must be a key in the graph`);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
const firstVisitedVertices = /* @__PURE__ */ new Set();
|
|
781
|
+
const visitationOrder = args.visitationOrder ?? [...graph.keys()];
|
|
782
|
+
const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
|
|
783
|
+
while (events.length) {
|
|
784
|
+
const { eventType, vertex, extras } = events.pop();
|
|
785
|
+
if (eventType === "last") {
|
|
786
|
+
lastVisitF?.(vertex);
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
if (firstVisitedVertices.has(vertex)) {
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
firstVisitedVertices.add(vertex);
|
|
793
|
+
firstVisitF?.(vertex, { parentVertex: extras.parentVertex });
|
|
794
|
+
events.push({ eventType: "last", vertex, extras: {} });
|
|
795
|
+
mapAt(graph, vertex).forEach((child) => {
|
|
796
|
+
events.push({
|
|
797
|
+
eventType: "first",
|
|
798
|
+
vertex: child,
|
|
799
|
+
extras: { parentVertex: vertex }
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function undirectedConnectedComponents(graph) {
|
|
805
|
+
const directedGraph = new Map(
|
|
806
|
+
[...graph.vertices].map((v) => [v, /* @__PURE__ */ new Set()])
|
|
807
|
+
);
|
|
808
|
+
for (const [i, j] of graph.edges) {
|
|
809
|
+
mapAt(directedGraph, i).add(j);
|
|
810
|
+
mapAt(directedGraph, j).add(i);
|
|
811
|
+
}
|
|
812
|
+
let labelCounter = 0;
|
|
813
|
+
const vertexLabels = /* @__PURE__ */ new Map();
|
|
814
|
+
const firstVisitF = (vertex, args) => {
|
|
815
|
+
const label = args?.parentVertex !== void 0 ? mapAt(vertexLabels, args?.parentVertex) : labelCounter++;
|
|
816
|
+
vertexLabels.set(vertex, label);
|
|
817
|
+
};
|
|
818
|
+
depthFirstSearch({ graph: directedGraph, firstVisitF });
|
|
819
|
+
const output = Array.from({ length: labelCounter }).map(() => []);
|
|
820
|
+
for (const [vertex, label] of vertexLabels.entries()) {
|
|
821
|
+
output[label].push(vertex);
|
|
822
|
+
}
|
|
823
|
+
return output;
|
|
824
|
+
}
|
|
825
|
+
function topologicalSort(graph, visitationOrder) {
|
|
826
|
+
const reverseOrdering = [];
|
|
827
|
+
const lastVisitF = (vertex) => {
|
|
828
|
+
reverseOrdering.push(vertex);
|
|
829
|
+
};
|
|
830
|
+
depthFirstSearch({ graph, lastVisitF, visitationOrder });
|
|
831
|
+
return reverseOrdering.reverse();
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// util/merge_row_batch.ts
|
|
835
|
+
function generateMergedRowKey(row, useParentIdForId) {
|
|
836
|
+
return JSON.stringify(
|
|
837
|
+
[
|
|
838
|
+
"org_id",
|
|
839
|
+
"project_id",
|
|
840
|
+
"experiment_id",
|
|
841
|
+
"dataset_id",
|
|
842
|
+
"prompt_session_id",
|
|
843
|
+
"log_id",
|
|
844
|
+
useParentIdForId ?? false ? PARENT_ID_FIELD : "id"
|
|
845
|
+
].map((k) => row[k])
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
var MERGE_ROW_SKIP_FIELDS = [
|
|
849
|
+
"created",
|
|
850
|
+
"span_id",
|
|
851
|
+
"root_span_id",
|
|
852
|
+
"span_parents",
|
|
853
|
+
"_parent_id"
|
|
854
|
+
// TODO: handle merge paths.
|
|
855
|
+
];
|
|
856
|
+
function popMergeRowSkipFields(row) {
|
|
857
|
+
const popped = {};
|
|
858
|
+
for (const field of MERGE_ROW_SKIP_FIELDS) {
|
|
859
|
+
if (field in row) {
|
|
860
|
+
popped[field] = row[field];
|
|
861
|
+
delete row[field];
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return popped;
|
|
865
|
+
}
|
|
866
|
+
function restoreMergeRowSkipFields(row, skipFields) {
|
|
867
|
+
for (const field of MERGE_ROW_SKIP_FIELDS) {
|
|
868
|
+
delete row[field];
|
|
869
|
+
if (field in skipFields) {
|
|
870
|
+
row[field] = skipFields[field];
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
function mergeRowBatch(rows) {
|
|
875
|
+
for (const row of rows) {
|
|
876
|
+
if (row.id === void 0) {
|
|
877
|
+
throw new Error(
|
|
878
|
+
"Logged row is missing an id. This is an internal braintrust error. Please contact us at info@braintrust.dev for help"
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
const rowGroups = /* @__PURE__ */ new Map();
|
|
883
|
+
for (const row of rows) {
|
|
884
|
+
const key = generateMergedRowKey(row);
|
|
885
|
+
const existingRow = rowGroups.get(key);
|
|
886
|
+
if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
|
|
887
|
+
const skipFields = popMergeRowSkipFields(existingRow);
|
|
888
|
+
const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
|
|
889
|
+
mergeDicts(existingRow, row);
|
|
890
|
+
restoreMergeRowSkipFields(existingRow, skipFields);
|
|
891
|
+
if (preserveNoMerge) {
|
|
892
|
+
delete existingRow[IS_MERGE_FIELD];
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
rowGroups.set(key, row);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
const merged = [...rowGroups.values()];
|
|
899
|
+
const rowToLabel = new Map(
|
|
900
|
+
merged.map((r, i) => [generateMergedRowKey(r), i])
|
|
901
|
+
);
|
|
902
|
+
const graph = new Map(
|
|
903
|
+
Array.from({ length: merged.length }).map((_, i) => [i, /* @__PURE__ */ new Set()])
|
|
904
|
+
);
|
|
905
|
+
merged.forEach((r, i) => {
|
|
906
|
+
const parentId = r[PARENT_ID_FIELD];
|
|
907
|
+
if (!parentId) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const parentRowKey = generateMergedRowKey(
|
|
911
|
+
r,
|
|
912
|
+
true
|
|
913
|
+
/* useParentIdForId */
|
|
914
|
+
);
|
|
915
|
+
const parentLabel = rowToLabel.get(parentRowKey);
|
|
916
|
+
if (parentLabel !== void 0) {
|
|
917
|
+
mapAt(graph, parentLabel).add(i);
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
const connectedComponents = undirectedConnectedComponents({
|
|
921
|
+
vertices: new Set(graph.keys()),
|
|
922
|
+
edges: new Set(
|
|
923
|
+
[...graph.entries()].flatMap(
|
|
924
|
+
([k, vs]) => [...vs].map((v) => {
|
|
925
|
+
const ret = [k, v];
|
|
926
|
+
return ret;
|
|
927
|
+
})
|
|
928
|
+
)
|
|
929
|
+
)
|
|
930
|
+
});
|
|
931
|
+
const buckets = connectedComponents.map(
|
|
932
|
+
(cc) => topologicalSort(
|
|
933
|
+
graph,
|
|
934
|
+
cc
|
|
935
|
+
/* visitationOrder */
|
|
936
|
+
)
|
|
937
|
+
);
|
|
938
|
+
return buckets.map((bucket) => bucket.map((i) => merged[i]));
|
|
939
|
+
}
|
|
940
|
+
function batchItems(args) {
|
|
941
|
+
let { items } = args;
|
|
942
|
+
const batchMaxNumItems = args.batchMaxNumItems ?? Number.POSITIVE_INFINITY;
|
|
943
|
+
const batchMaxNumBytes = args.batchMaxNumBytes ?? Number.POSITIVE_INFINITY;
|
|
944
|
+
const output = [];
|
|
945
|
+
let nextItems = [];
|
|
946
|
+
let batchSet = [];
|
|
947
|
+
let batch = [];
|
|
948
|
+
let batchLen = 0;
|
|
949
|
+
function addToBatch(item) {
|
|
950
|
+
batch.push(item);
|
|
951
|
+
batchLen += item.length;
|
|
952
|
+
}
|
|
953
|
+
function flushBatch() {
|
|
954
|
+
batchSet.push(batch);
|
|
955
|
+
batch = [];
|
|
956
|
+
batchLen = 0;
|
|
957
|
+
}
|
|
958
|
+
while (items.length) {
|
|
959
|
+
for (const bucket of items) {
|
|
960
|
+
let i = 0;
|
|
961
|
+
for (const item of bucket) {
|
|
962
|
+
if (batch.length === 0 || item.length + batchLen < batchMaxNumBytes && batch.length < batchMaxNumItems) {
|
|
963
|
+
addToBatch(item);
|
|
964
|
+
} else if (i === 0) {
|
|
965
|
+
flushBatch();
|
|
966
|
+
addToBatch(item);
|
|
967
|
+
} else {
|
|
968
|
+
break;
|
|
969
|
+
}
|
|
970
|
+
++i;
|
|
971
|
+
}
|
|
972
|
+
if (i < bucket.length) {
|
|
973
|
+
nextItems.push(bucket.slice(i));
|
|
974
|
+
}
|
|
975
|
+
if (batchLen >= batchMaxNumBytes || batch.length > batchMaxNumItems) {
|
|
976
|
+
flushBatch();
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
if (batch.length) {
|
|
980
|
+
flushBatch();
|
|
981
|
+
}
|
|
982
|
+
if (batchSet.length) {
|
|
983
|
+
output.push(batchSet);
|
|
984
|
+
batchSet = [];
|
|
985
|
+
}
|
|
986
|
+
items = nextItems;
|
|
987
|
+
nextItems = [];
|
|
988
|
+
}
|
|
989
|
+
return output;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// util/object.ts
|
|
993
|
+
var DEFAULT_IS_LEGACY_DATASET = false;
|
|
994
|
+
function ensureDatasetRecord(r, legacy) {
|
|
995
|
+
if (legacy) {
|
|
996
|
+
return ensureLegacyDatasetRecord(r);
|
|
997
|
+
} else {
|
|
998
|
+
return ensureNewDatasetRecord(r);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
function ensureLegacyDatasetRecord(r) {
|
|
1002
|
+
if ("output" in r) {
|
|
1003
|
+
return r;
|
|
1004
|
+
}
|
|
1005
|
+
const row = {
|
|
1006
|
+
...r,
|
|
1007
|
+
output: r.expected
|
|
1008
|
+
};
|
|
1009
|
+
delete row.expected;
|
|
1010
|
+
return row;
|
|
1011
|
+
}
|
|
1012
|
+
function ensureNewDatasetRecord(r) {
|
|
1013
|
+
if ("expected" in r) {
|
|
1014
|
+
return r;
|
|
1015
|
+
}
|
|
1016
|
+
const row = {
|
|
1017
|
+
...r,
|
|
1018
|
+
tags: null,
|
|
1019
|
+
expected: r.output
|
|
1020
|
+
};
|
|
1021
|
+
delete row.output;
|
|
1022
|
+
return row;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// util/json_util.ts
|
|
1026
|
+
function constructJsonArray(items) {
|
|
1027
|
+
return `[${items.join(",")}]`;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// util/string_util.ts
|
|
1031
|
+
function _urljoin(...parts) {
|
|
1032
|
+
return parts.map(
|
|
1033
|
+
(x, i) => x.replace(/^\//, "").replace(i < parts.length - 1 ? /\/$/ : "", "")
|
|
1034
|
+
).filter((x) => x.trim() !== "").join("/");
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
// util/git_fields.ts
|
|
1038
|
+
function mergeGitMetadataSettings(s1, s2) {
|
|
1039
|
+
if (s1.collect === "all") {
|
|
1040
|
+
return s2;
|
|
1041
|
+
} else if (s2.collect === "all") {
|
|
1042
|
+
return s1;
|
|
1043
|
+
} else if (s1.collect === "none") {
|
|
1044
|
+
return s1;
|
|
1045
|
+
} else if (s2.collect === "none") {
|
|
1046
|
+
return s2;
|
|
1047
|
+
}
|
|
1048
|
+
const fields = (s1.fields ?? []).filter((f) => (s2.fields ?? []).includes(f));
|
|
1049
|
+
const collect = fields.length > 0 ? "some" : "none";
|
|
1050
|
+
return { collect, fields };
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// util/xact-ids.ts
|
|
1054
|
+
var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
|
|
1055
|
+
var MOD = BigInt(1) << BigInt(64);
|
|
1056
|
+
var COPRIME = BigInt("205891132094649");
|
|
1057
|
+
var COPRIME_INVERSE = BigInt("1522336535492693385");
|
|
1058
|
+
function modularMultiply(value, prime) {
|
|
1059
|
+
return value * prime % MOD;
|
|
1060
|
+
}
|
|
1061
|
+
function prettifyXact(valueString) {
|
|
1062
|
+
const value = BigInt(valueString);
|
|
1063
|
+
const encoded = modularMultiply(value, COPRIME);
|
|
1064
|
+
return encoded.toString(16).padStart(16, "0");
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// util/zod_util.ts
|
|
1068
|
+
import { z as z4 } from "zod/v3";
|
|
112
1069
|
|
|
113
1070
|
// src/generated_types.ts
|
|
114
|
-
import { z } from "zod";
|
|
115
|
-
var AclObjectType =
|
|
116
|
-
|
|
1071
|
+
import { z as z5 } from "zod/v3";
|
|
1072
|
+
var AclObjectType = z5.union([
|
|
1073
|
+
z5.enum([
|
|
117
1074
|
"organization",
|
|
118
1075
|
"project",
|
|
119
1076
|
"experiment",
|
|
@@ -126,9 +1083,9 @@ var AclObjectType = z.union([
|
|
|
126
1083
|
"project_log",
|
|
127
1084
|
"org_project"
|
|
128
1085
|
]),
|
|
129
|
-
|
|
1086
|
+
z5.null()
|
|
130
1087
|
]);
|
|
131
|
-
var Permission =
|
|
1088
|
+
var Permission = z5.enum([
|
|
132
1089
|
"create",
|
|
133
1090
|
"read",
|
|
134
1091
|
"update",
|
|
@@ -138,310 +1095,310 @@ var Permission = z.enum([
|
|
|
138
1095
|
"update_acls",
|
|
139
1096
|
"delete_acls"
|
|
140
1097
|
]);
|
|
141
|
-
var Acl =
|
|
142
|
-
id:
|
|
143
|
-
object_type: AclObjectType.and(
|
|
144
|
-
object_id:
|
|
145
|
-
user_id:
|
|
146
|
-
group_id:
|
|
147
|
-
permission: Permission.and(
|
|
148
|
-
restrict_object_type: AclObjectType.and(
|
|
149
|
-
role_id:
|
|
150
|
-
_object_org_id:
|
|
151
|
-
created:
|
|
1098
|
+
var Acl = z5.object({
|
|
1099
|
+
id: z5.string().uuid(),
|
|
1100
|
+
object_type: AclObjectType.and(z5.string()),
|
|
1101
|
+
object_id: z5.string().uuid(),
|
|
1102
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1103
|
+
group_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1104
|
+
permission: Permission.and(z5.union([z5.string(), z5.null()])).optional(),
|
|
1105
|
+
restrict_object_type: AclObjectType.and(z5.unknown()).optional(),
|
|
1106
|
+
role_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1107
|
+
_object_org_id: z5.string().uuid(),
|
|
1108
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
152
1109
|
});
|
|
153
|
-
var AISecret =
|
|
154
|
-
id:
|
|
155
|
-
created:
|
|
156
|
-
updated_at:
|
|
157
|
-
org_id:
|
|
158
|
-
name:
|
|
159
|
-
type:
|
|
160
|
-
metadata:
|
|
161
|
-
preview_secret:
|
|
1110
|
+
var AISecret = z5.object({
|
|
1111
|
+
id: z5.string().uuid(),
|
|
1112
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1113
|
+
updated_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
1114
|
+
org_id: z5.string().uuid(),
|
|
1115
|
+
name: z5.string(),
|
|
1116
|
+
type: z5.union([z5.string(), z5.null()]).optional(),
|
|
1117
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
|
|
1118
|
+
preview_secret: z5.union([z5.string(), z5.null()]).optional()
|
|
162
1119
|
});
|
|
163
|
-
var ResponseFormatJsonSchema =
|
|
164
|
-
name:
|
|
165
|
-
description:
|
|
166
|
-
schema:
|
|
167
|
-
strict:
|
|
1120
|
+
var ResponseFormatJsonSchema = z5.object({
|
|
1121
|
+
name: z5.string(),
|
|
1122
|
+
description: z5.string().optional(),
|
|
1123
|
+
schema: z5.union([z5.object({}).partial().passthrough(), z5.string()]).optional(),
|
|
1124
|
+
strict: z5.union([z5.boolean(), z5.null()]).optional()
|
|
168
1125
|
});
|
|
169
|
-
var ResponseFormatNullish =
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
type:
|
|
1126
|
+
var ResponseFormatNullish = z5.union([
|
|
1127
|
+
z5.object({ type: z5.literal("json_object") }),
|
|
1128
|
+
z5.object({
|
|
1129
|
+
type: z5.literal("json_schema"),
|
|
173
1130
|
json_schema: ResponseFormatJsonSchema
|
|
174
1131
|
}),
|
|
175
|
-
|
|
176
|
-
|
|
1132
|
+
z5.object({ type: z5.literal("text") }),
|
|
1133
|
+
z5.null()
|
|
177
1134
|
]);
|
|
178
|
-
var AnyModelParams =
|
|
179
|
-
temperature:
|
|
180
|
-
top_p:
|
|
181
|
-
max_tokens:
|
|
182
|
-
max_completion_tokens:
|
|
183
|
-
frequency_penalty:
|
|
184
|
-
presence_penalty:
|
|
1135
|
+
var AnyModelParams = z5.object({
|
|
1136
|
+
temperature: z5.number().optional(),
|
|
1137
|
+
top_p: z5.number().optional(),
|
|
1138
|
+
max_tokens: z5.number(),
|
|
1139
|
+
max_completion_tokens: z5.number().optional(),
|
|
1140
|
+
frequency_penalty: z5.number().optional(),
|
|
1141
|
+
presence_penalty: z5.number().optional(),
|
|
185
1142
|
response_format: ResponseFormatNullish.optional(),
|
|
186
|
-
tool_choice:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
type:
|
|
192
|
-
function:
|
|
1143
|
+
tool_choice: z5.union([
|
|
1144
|
+
z5.literal("auto"),
|
|
1145
|
+
z5.literal("none"),
|
|
1146
|
+
z5.literal("required"),
|
|
1147
|
+
z5.object({
|
|
1148
|
+
type: z5.literal("function"),
|
|
1149
|
+
function: z5.object({ name: z5.string() })
|
|
193
1150
|
})
|
|
194
1151
|
]).optional(),
|
|
195
|
-
function_call:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
1152
|
+
function_call: z5.union([
|
|
1153
|
+
z5.literal("auto"),
|
|
1154
|
+
z5.literal("none"),
|
|
1155
|
+
z5.object({ name: z5.string() })
|
|
199
1156
|
]).optional(),
|
|
200
|
-
n:
|
|
201
|
-
stop:
|
|
202
|
-
reasoning_effort:
|
|
203
|
-
verbosity:
|
|
204
|
-
top_k:
|
|
205
|
-
stop_sequences:
|
|
206
|
-
max_tokens_to_sample:
|
|
207
|
-
maxOutputTokens:
|
|
208
|
-
topP:
|
|
209
|
-
topK:
|
|
210
|
-
use_cache:
|
|
1157
|
+
n: z5.number().optional(),
|
|
1158
|
+
stop: z5.array(z5.string()).optional(),
|
|
1159
|
+
reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
1160
|
+
verbosity: z5.enum(["low", "medium", "high"]).optional(),
|
|
1161
|
+
top_k: z5.number().optional(),
|
|
1162
|
+
stop_sequences: z5.array(z5.string()).optional(),
|
|
1163
|
+
max_tokens_to_sample: z5.number().optional(),
|
|
1164
|
+
maxOutputTokens: z5.number().optional(),
|
|
1165
|
+
topP: z5.number().optional(),
|
|
1166
|
+
topK: z5.number().optional(),
|
|
1167
|
+
use_cache: z5.boolean().optional()
|
|
211
1168
|
});
|
|
212
|
-
var ApiKey =
|
|
213
|
-
id:
|
|
214
|
-
created:
|
|
215
|
-
name:
|
|
216
|
-
preview_name:
|
|
217
|
-
user_id:
|
|
218
|
-
user_email:
|
|
219
|
-
user_given_name:
|
|
220
|
-
user_family_name:
|
|
221
|
-
org_id:
|
|
1169
|
+
var ApiKey = z5.object({
|
|
1170
|
+
id: z5.string().uuid(),
|
|
1171
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1172
|
+
name: z5.string(),
|
|
1173
|
+
preview_name: z5.string(),
|
|
1174
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1175
|
+
user_email: z5.union([z5.string(), z5.null()]).optional(),
|
|
1176
|
+
user_given_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
1177
|
+
user_family_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
1178
|
+
org_id: z5.union([z5.string(), z5.null()]).optional()
|
|
222
1179
|
});
|
|
223
|
-
var AsyncScoringState =
|
|
224
|
-
|
|
225
|
-
status:
|
|
226
|
-
token:
|
|
227
|
-
function_ids:
|
|
228
|
-
skip_logging:
|
|
1180
|
+
var AsyncScoringState = z5.union([
|
|
1181
|
+
z5.object({
|
|
1182
|
+
status: z5.literal("enabled"),
|
|
1183
|
+
token: z5.string(),
|
|
1184
|
+
function_ids: z5.array(z5.unknown()).min(1),
|
|
1185
|
+
skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
|
|
229
1186
|
}),
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
1187
|
+
z5.object({ status: z5.literal("disabled") }),
|
|
1188
|
+
z5.null(),
|
|
1189
|
+
z5.null()
|
|
233
1190
|
]);
|
|
234
|
-
var AsyncScoringControl =
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
1191
|
+
var AsyncScoringControl = z5.union([
|
|
1192
|
+
z5.object({ kind: z5.literal("score_update"), token: z5.string() }),
|
|
1193
|
+
z5.object({ kind: z5.literal("state_override"), state: AsyncScoringState }),
|
|
1194
|
+
z5.object({ kind: z5.literal("state_force_reselect") }),
|
|
1195
|
+
z5.object({ kind: z5.literal("state_enabled_force_rescore") })
|
|
239
1196
|
]);
|
|
240
|
-
var BraintrustAttachmentReference =
|
|
241
|
-
type:
|
|
242
|
-
filename:
|
|
243
|
-
content_type:
|
|
244
|
-
key:
|
|
1197
|
+
var BraintrustAttachmentReference = z5.object({
|
|
1198
|
+
type: z5.literal("braintrust_attachment"),
|
|
1199
|
+
filename: z5.string().min(1),
|
|
1200
|
+
content_type: z5.string().min(1),
|
|
1201
|
+
key: z5.string().min(1)
|
|
245
1202
|
});
|
|
246
|
-
var ExternalAttachmentReference =
|
|
247
|
-
type:
|
|
248
|
-
filename:
|
|
249
|
-
content_type:
|
|
250
|
-
url:
|
|
1203
|
+
var ExternalAttachmentReference = z5.object({
|
|
1204
|
+
type: z5.literal("external_attachment"),
|
|
1205
|
+
filename: z5.string().min(1),
|
|
1206
|
+
content_type: z5.string().min(1),
|
|
1207
|
+
url: z5.string().min(1)
|
|
251
1208
|
});
|
|
252
|
-
var AttachmentReference =
|
|
1209
|
+
var AttachmentReference = z5.discriminatedUnion("type", [
|
|
253
1210
|
BraintrustAttachmentReference,
|
|
254
1211
|
ExternalAttachmentReference
|
|
255
1212
|
]);
|
|
256
|
-
var UploadStatus =
|
|
257
|
-
var AttachmentStatus =
|
|
1213
|
+
var UploadStatus = z5.enum(["uploading", "done", "error"]);
|
|
1214
|
+
var AttachmentStatus = z5.object({
|
|
258
1215
|
upload_status: UploadStatus,
|
|
259
|
-
error_message:
|
|
1216
|
+
error_message: z5.string().optional()
|
|
260
1217
|
});
|
|
261
|
-
var BraintrustModelParams =
|
|
262
|
-
var CallEvent =
|
|
263
|
-
|
|
264
|
-
id:
|
|
265
|
-
data:
|
|
266
|
-
event:
|
|
1218
|
+
var BraintrustModelParams = z5.object({ use_cache: z5.boolean() }).partial();
|
|
1219
|
+
var CallEvent = z5.union([
|
|
1220
|
+
z5.object({
|
|
1221
|
+
id: z5.string().optional(),
|
|
1222
|
+
data: z5.string(),
|
|
1223
|
+
event: z5.literal("text_delta")
|
|
267
1224
|
}),
|
|
268
|
-
|
|
269
|
-
id:
|
|
270
|
-
data:
|
|
271
|
-
event:
|
|
1225
|
+
z5.object({
|
|
1226
|
+
id: z5.string().optional(),
|
|
1227
|
+
data: z5.string(),
|
|
1228
|
+
event: z5.literal("reasoning_delta")
|
|
272
1229
|
}),
|
|
273
|
-
|
|
274
|
-
id:
|
|
275
|
-
data:
|
|
276
|
-
event:
|
|
1230
|
+
z5.object({
|
|
1231
|
+
id: z5.string().optional(),
|
|
1232
|
+
data: z5.string(),
|
|
1233
|
+
event: z5.literal("json_delta")
|
|
277
1234
|
}),
|
|
278
|
-
|
|
279
|
-
id:
|
|
280
|
-
data:
|
|
281
|
-
event:
|
|
1235
|
+
z5.object({
|
|
1236
|
+
id: z5.string().optional(),
|
|
1237
|
+
data: z5.string(),
|
|
1238
|
+
event: z5.literal("progress")
|
|
282
1239
|
}),
|
|
283
|
-
|
|
284
|
-
id:
|
|
285
|
-
data:
|
|
286
|
-
event:
|
|
1240
|
+
z5.object({
|
|
1241
|
+
id: z5.string().optional(),
|
|
1242
|
+
data: z5.string(),
|
|
1243
|
+
event: z5.literal("error")
|
|
287
1244
|
}),
|
|
288
|
-
|
|
289
|
-
id:
|
|
290
|
-
data:
|
|
291
|
-
event:
|
|
1245
|
+
z5.object({
|
|
1246
|
+
id: z5.string().optional(),
|
|
1247
|
+
data: z5.string(),
|
|
1248
|
+
event: z5.literal("console")
|
|
292
1249
|
}),
|
|
293
|
-
|
|
294
|
-
id:
|
|
295
|
-
event:
|
|
296
|
-
data:
|
|
1250
|
+
z5.object({
|
|
1251
|
+
id: z5.string().optional(),
|
|
1252
|
+
event: z5.literal("start"),
|
|
1253
|
+
data: z5.literal("")
|
|
297
1254
|
}),
|
|
298
|
-
|
|
299
|
-
id:
|
|
300
|
-
event:
|
|
301
|
-
data:
|
|
1255
|
+
z5.object({
|
|
1256
|
+
id: z5.string().optional(),
|
|
1257
|
+
event: z5.literal("done"),
|
|
1258
|
+
data: z5.literal("")
|
|
302
1259
|
})
|
|
303
1260
|
]);
|
|
304
|
-
var ChatCompletionContentPartTextWithTitle =
|
|
305
|
-
text:
|
|
306
|
-
type:
|
|
307
|
-
cache_control:
|
|
1261
|
+
var ChatCompletionContentPartTextWithTitle = z5.object({
|
|
1262
|
+
text: z5.string().default(""),
|
|
1263
|
+
type: z5.literal("text"),
|
|
1264
|
+
cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
|
|
308
1265
|
});
|
|
309
|
-
var ChatCompletionContentPartImageWithTitle =
|
|
310
|
-
image_url:
|
|
311
|
-
url:
|
|
312
|
-
detail:
|
|
1266
|
+
var ChatCompletionContentPartImageWithTitle = z5.object({
|
|
1267
|
+
image_url: z5.object({
|
|
1268
|
+
url: z5.string(),
|
|
1269
|
+
detail: z5.union([z5.literal("auto"), z5.literal("low"), z5.literal("high")]).optional()
|
|
313
1270
|
}),
|
|
314
|
-
type:
|
|
1271
|
+
type: z5.literal("image_url")
|
|
315
1272
|
});
|
|
316
|
-
var ChatCompletionContentPart =
|
|
1273
|
+
var ChatCompletionContentPart = z5.union([
|
|
317
1274
|
ChatCompletionContentPartTextWithTitle,
|
|
318
1275
|
ChatCompletionContentPartImageWithTitle
|
|
319
1276
|
]);
|
|
320
|
-
var ChatCompletionContentPartText =
|
|
321
|
-
text:
|
|
322
|
-
type:
|
|
323
|
-
cache_control:
|
|
1277
|
+
var ChatCompletionContentPartText = z5.object({
|
|
1278
|
+
text: z5.string().default(""),
|
|
1279
|
+
type: z5.literal("text"),
|
|
1280
|
+
cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
|
|
324
1281
|
});
|
|
325
|
-
var ChatCompletionMessageToolCall =
|
|
326
|
-
id:
|
|
327
|
-
function:
|
|
328
|
-
type:
|
|
1282
|
+
var ChatCompletionMessageToolCall = z5.object({
|
|
1283
|
+
id: z5.string(),
|
|
1284
|
+
function: z5.object({ arguments: z5.string(), name: z5.string() }),
|
|
1285
|
+
type: z5.literal("function")
|
|
329
1286
|
});
|
|
330
|
-
var ChatCompletionMessageReasoning =
|
|
331
|
-
var ChatCompletionMessageParam =
|
|
332
|
-
|
|
333
|
-
content:
|
|
334
|
-
role:
|
|
335
|
-
name:
|
|
1287
|
+
var ChatCompletionMessageReasoning = z5.object({ id: z5.string(), content: z5.string() }).partial();
|
|
1288
|
+
var ChatCompletionMessageParam = z5.union([
|
|
1289
|
+
z5.object({
|
|
1290
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
1291
|
+
role: z5.literal("system"),
|
|
1292
|
+
name: z5.string().optional()
|
|
336
1293
|
}),
|
|
337
|
-
|
|
338
|
-
content:
|
|
339
|
-
role:
|
|
340
|
-
name:
|
|
1294
|
+
z5.object({
|
|
1295
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
|
|
1296
|
+
role: z5.literal("user"),
|
|
1297
|
+
name: z5.string().optional()
|
|
341
1298
|
}),
|
|
342
|
-
|
|
343
|
-
role:
|
|
344
|
-
content:
|
|
345
|
-
function_call:
|
|
346
|
-
name:
|
|
347
|
-
tool_calls:
|
|
348
|
-
reasoning:
|
|
1299
|
+
z5.object({
|
|
1300
|
+
role: z5.literal("assistant"),
|
|
1301
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
|
|
1302
|
+
function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
|
|
1303
|
+
name: z5.string().optional(),
|
|
1304
|
+
tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
|
|
1305
|
+
reasoning: z5.array(ChatCompletionMessageReasoning).optional()
|
|
349
1306
|
}),
|
|
350
|
-
|
|
351
|
-
content:
|
|
352
|
-
role:
|
|
353
|
-
tool_call_id:
|
|
1307
|
+
z5.object({
|
|
1308
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
1309
|
+
role: z5.literal("tool"),
|
|
1310
|
+
tool_call_id: z5.string().default("")
|
|
354
1311
|
}),
|
|
355
|
-
|
|
356
|
-
content:
|
|
357
|
-
name:
|
|
358
|
-
role:
|
|
1312
|
+
z5.object({
|
|
1313
|
+
content: z5.union([z5.string(), z5.null()]),
|
|
1314
|
+
name: z5.string(),
|
|
1315
|
+
role: z5.literal("function")
|
|
359
1316
|
}),
|
|
360
|
-
|
|
361
|
-
content:
|
|
362
|
-
role:
|
|
363
|
-
name:
|
|
1317
|
+
z5.object({
|
|
1318
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
1319
|
+
role: z5.literal("developer"),
|
|
1320
|
+
name: z5.string().optional()
|
|
364
1321
|
}),
|
|
365
|
-
|
|
366
|
-
role:
|
|
367
|
-
content:
|
|
1322
|
+
z5.object({
|
|
1323
|
+
role: z5.literal("model"),
|
|
1324
|
+
content: z5.union([z5.string(), z5.null()]).optional()
|
|
368
1325
|
})
|
|
369
1326
|
]);
|
|
370
|
-
var ChatCompletionOpenAIMessageParam =
|
|
371
|
-
|
|
372
|
-
content:
|
|
373
|
-
role:
|
|
374
|
-
name:
|
|
1327
|
+
var ChatCompletionOpenAIMessageParam = z5.union([
|
|
1328
|
+
z5.object({
|
|
1329
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
1330
|
+
role: z5.literal("system"),
|
|
1331
|
+
name: z5.string().optional()
|
|
375
1332
|
}),
|
|
376
|
-
|
|
377
|
-
content:
|
|
378
|
-
role:
|
|
379
|
-
name:
|
|
1333
|
+
z5.object({
|
|
1334
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
|
|
1335
|
+
role: z5.literal("user"),
|
|
1336
|
+
name: z5.string().optional()
|
|
380
1337
|
}),
|
|
381
|
-
|
|
382
|
-
role:
|
|
383
|
-
content:
|
|
384
|
-
function_call:
|
|
385
|
-
name:
|
|
386
|
-
tool_calls:
|
|
387
|
-
reasoning:
|
|
1338
|
+
z5.object({
|
|
1339
|
+
role: z5.literal("assistant"),
|
|
1340
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
|
|
1341
|
+
function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
|
|
1342
|
+
name: z5.string().optional(),
|
|
1343
|
+
tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
|
|
1344
|
+
reasoning: z5.array(ChatCompletionMessageReasoning).optional()
|
|
388
1345
|
}),
|
|
389
|
-
|
|
390
|
-
content:
|
|
391
|
-
role:
|
|
392
|
-
tool_call_id:
|
|
1346
|
+
z5.object({
|
|
1347
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
1348
|
+
role: z5.literal("tool"),
|
|
1349
|
+
tool_call_id: z5.string().default("")
|
|
393
1350
|
}),
|
|
394
|
-
|
|
395
|
-
content:
|
|
396
|
-
name:
|
|
397
|
-
role:
|
|
1351
|
+
z5.object({
|
|
1352
|
+
content: z5.union([z5.string(), z5.null()]),
|
|
1353
|
+
name: z5.string(),
|
|
1354
|
+
role: z5.literal("function")
|
|
398
1355
|
}),
|
|
399
|
-
|
|
400
|
-
content:
|
|
401
|
-
role:
|
|
402
|
-
name:
|
|
1356
|
+
z5.object({
|
|
1357
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
1358
|
+
role: z5.literal("developer"),
|
|
1359
|
+
name: z5.string().optional()
|
|
403
1360
|
})
|
|
404
1361
|
]);
|
|
405
|
-
var ChatCompletionTool =
|
|
406
|
-
function:
|
|
407
|
-
name:
|
|
408
|
-
description:
|
|
409
|
-
parameters:
|
|
1362
|
+
var ChatCompletionTool = z5.object({
|
|
1363
|
+
function: z5.object({
|
|
1364
|
+
name: z5.string(),
|
|
1365
|
+
description: z5.string().optional(),
|
|
1366
|
+
parameters: z5.object({}).partial().passthrough().optional()
|
|
410
1367
|
}),
|
|
411
|
-
type:
|
|
1368
|
+
type: z5.literal("function")
|
|
412
1369
|
});
|
|
413
|
-
var CodeBundle =
|
|
414
|
-
runtime_context:
|
|
415
|
-
runtime:
|
|
416
|
-
version:
|
|
1370
|
+
var CodeBundle = z5.object({
|
|
1371
|
+
runtime_context: z5.object({
|
|
1372
|
+
runtime: z5.enum(["node", "python"]),
|
|
1373
|
+
version: z5.string()
|
|
417
1374
|
}),
|
|
418
|
-
location:
|
|
419
|
-
|
|
420
|
-
type:
|
|
421
|
-
eval_name:
|
|
422
|
-
position:
|
|
423
|
-
|
|
424
|
-
|
|
1375
|
+
location: z5.union([
|
|
1376
|
+
z5.object({
|
|
1377
|
+
type: z5.literal("experiment"),
|
|
1378
|
+
eval_name: z5.string(),
|
|
1379
|
+
position: z5.union([
|
|
1380
|
+
z5.object({ type: z5.literal("task") }),
|
|
1381
|
+
z5.object({ type: z5.literal("scorer"), index: z5.number().int().gte(0) })
|
|
425
1382
|
])
|
|
426
1383
|
}),
|
|
427
|
-
|
|
1384
|
+
z5.object({ type: z5.literal("function"), index: z5.number().int().gte(0) })
|
|
428
1385
|
]),
|
|
429
|
-
bundle_id:
|
|
430
|
-
preview:
|
|
1386
|
+
bundle_id: z5.string(),
|
|
1387
|
+
preview: z5.union([z5.string(), z5.null()]).optional()
|
|
431
1388
|
});
|
|
432
|
-
var Dataset =
|
|
433
|
-
id:
|
|
434
|
-
project_id:
|
|
435
|
-
name:
|
|
436
|
-
description:
|
|
437
|
-
created:
|
|
438
|
-
deleted_at:
|
|
439
|
-
user_id:
|
|
440
|
-
metadata:
|
|
1389
|
+
var Dataset = z5.object({
|
|
1390
|
+
id: z5.string().uuid(),
|
|
1391
|
+
project_id: z5.string().uuid(),
|
|
1392
|
+
name: z5.string(),
|
|
1393
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1394
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1395
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
1396
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1397
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
|
|
441
1398
|
});
|
|
442
|
-
var ObjectReferenceNullish =
|
|
443
|
-
|
|
444
|
-
object_type:
|
|
1399
|
+
var ObjectReferenceNullish = z5.union([
|
|
1400
|
+
z5.object({
|
|
1401
|
+
object_type: z5.enum([
|
|
445
1402
|
"project_logs",
|
|
446
1403
|
"experiment",
|
|
447
1404
|
"dataset",
|
|
@@ -449,399 +1406,399 @@ var ObjectReferenceNullish = z.union([
|
|
|
449
1406
|
"function",
|
|
450
1407
|
"prompt_session"
|
|
451
1408
|
]),
|
|
452
|
-
object_id:
|
|
453
|
-
id:
|
|
454
|
-
_xact_id:
|
|
455
|
-
created:
|
|
1409
|
+
object_id: z5.string().uuid(),
|
|
1410
|
+
id: z5.string(),
|
|
1411
|
+
_xact_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1412
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
456
1413
|
}),
|
|
457
|
-
|
|
1414
|
+
z5.null()
|
|
458
1415
|
]);
|
|
459
|
-
var DatasetEvent =
|
|
460
|
-
id:
|
|
461
|
-
_xact_id:
|
|
462
|
-
created:
|
|
463
|
-
_pagination_key:
|
|
464
|
-
project_id:
|
|
465
|
-
dataset_id:
|
|
466
|
-
input:
|
|
467
|
-
expected:
|
|
468
|
-
metadata:
|
|
469
|
-
|
|
470
|
-
|
|
1416
|
+
var DatasetEvent = z5.object({
|
|
1417
|
+
id: z5.string(),
|
|
1418
|
+
_xact_id: z5.string(),
|
|
1419
|
+
created: z5.string().datetime({ offset: true }),
|
|
1420
|
+
_pagination_key: z5.union([z5.string(), z5.null()]).optional(),
|
|
1421
|
+
project_id: z5.string().uuid(),
|
|
1422
|
+
dataset_id: z5.string().uuid(),
|
|
1423
|
+
input: z5.unknown().optional(),
|
|
1424
|
+
expected: z5.unknown().optional(),
|
|
1425
|
+
metadata: z5.union([
|
|
1426
|
+
z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
|
|
1427
|
+
z5.null()
|
|
471
1428
|
]).optional(),
|
|
472
|
-
tags:
|
|
473
|
-
span_id:
|
|
474
|
-
root_span_id:
|
|
475
|
-
is_root:
|
|
1429
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
1430
|
+
span_id: z5.string(),
|
|
1431
|
+
root_span_id: z5.string(),
|
|
1432
|
+
is_root: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
476
1433
|
origin: ObjectReferenceNullish.optional()
|
|
477
1434
|
});
|
|
478
|
-
var EnvVar =
|
|
479
|
-
id:
|
|
480
|
-
object_type:
|
|
481
|
-
object_id:
|
|
482
|
-
name:
|
|
483
|
-
created:
|
|
484
|
-
used:
|
|
1435
|
+
var EnvVar = z5.object({
|
|
1436
|
+
id: z5.string().uuid(),
|
|
1437
|
+
object_type: z5.enum(["organization", "project", "function"]),
|
|
1438
|
+
object_id: z5.string().uuid(),
|
|
1439
|
+
name: z5.string(),
|
|
1440
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1441
|
+
used: z5.union([z5.string(), z5.null()]).optional()
|
|
485
1442
|
});
|
|
486
|
-
var RepoInfo =
|
|
487
|
-
|
|
488
|
-
commit:
|
|
489
|
-
branch:
|
|
490
|
-
tag:
|
|
491
|
-
dirty:
|
|
492
|
-
author_name:
|
|
493
|
-
author_email:
|
|
494
|
-
commit_message:
|
|
495
|
-
commit_time:
|
|
496
|
-
git_diff:
|
|
1443
|
+
var RepoInfo = z5.union([
|
|
1444
|
+
z5.object({
|
|
1445
|
+
commit: z5.union([z5.string(), z5.null()]),
|
|
1446
|
+
branch: z5.union([z5.string(), z5.null()]),
|
|
1447
|
+
tag: z5.union([z5.string(), z5.null()]),
|
|
1448
|
+
dirty: z5.union([z5.boolean(), z5.null()]),
|
|
1449
|
+
author_name: z5.union([z5.string(), z5.null()]),
|
|
1450
|
+
author_email: z5.union([z5.string(), z5.null()]),
|
|
1451
|
+
commit_message: z5.union([z5.string(), z5.null()]),
|
|
1452
|
+
commit_time: z5.union([z5.string(), z5.null()]),
|
|
1453
|
+
git_diff: z5.union([z5.string(), z5.null()])
|
|
497
1454
|
}).partial(),
|
|
498
|
-
|
|
1455
|
+
z5.null()
|
|
499
1456
|
]);
|
|
500
|
-
var Experiment =
|
|
501
|
-
id:
|
|
502
|
-
project_id:
|
|
503
|
-
name:
|
|
504
|
-
description:
|
|
505
|
-
created:
|
|
1457
|
+
var Experiment = z5.object({
|
|
1458
|
+
id: z5.string().uuid(),
|
|
1459
|
+
project_id: z5.string().uuid(),
|
|
1460
|
+
name: z5.string(),
|
|
1461
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1462
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
506
1463
|
repo_info: RepoInfo.optional(),
|
|
507
|
-
commit:
|
|
508
|
-
base_exp_id:
|
|
509
|
-
deleted_at:
|
|
510
|
-
dataset_id:
|
|
511
|
-
dataset_version:
|
|
512
|
-
public:
|
|
513
|
-
user_id:
|
|
514
|
-
metadata:
|
|
515
|
-
tags:
|
|
1464
|
+
commit: z5.union([z5.string(), z5.null()]).optional(),
|
|
1465
|
+
base_exp_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1466
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
1467
|
+
dataset_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1468
|
+
dataset_version: z5.union([z5.string(), z5.null()]).optional(),
|
|
1469
|
+
public: z5.boolean(),
|
|
1470
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1471
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
|
|
1472
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
|
|
516
1473
|
});
|
|
517
|
-
var SpanType =
|
|
518
|
-
|
|
519
|
-
|
|
1474
|
+
var SpanType = z5.union([
|
|
1475
|
+
z5.enum(["llm", "score", "function", "eval", "task", "tool"]),
|
|
1476
|
+
z5.null()
|
|
520
1477
|
]);
|
|
521
|
-
var SpanAttributes =
|
|
522
|
-
|
|
523
|
-
|
|
1478
|
+
var SpanAttributes = z5.union([
|
|
1479
|
+
z5.object({ name: z5.union([z5.string(), z5.null()]), type: SpanType }).partial().passthrough(),
|
|
1480
|
+
z5.null()
|
|
524
1481
|
]);
|
|
525
|
-
var ExperimentEvent =
|
|
526
|
-
id:
|
|
527
|
-
_xact_id:
|
|
528
|
-
created:
|
|
529
|
-
_pagination_key:
|
|
530
|
-
project_id:
|
|
531
|
-
experiment_id:
|
|
532
|
-
input:
|
|
533
|
-
output:
|
|
534
|
-
expected:
|
|
535
|
-
error:
|
|
536
|
-
scores:
|
|
537
|
-
metadata:
|
|
538
|
-
|
|
539
|
-
|
|
1482
|
+
var ExperimentEvent = z5.object({
|
|
1483
|
+
id: z5.string(),
|
|
1484
|
+
_xact_id: z5.string(),
|
|
1485
|
+
created: z5.string().datetime({ offset: true }),
|
|
1486
|
+
_pagination_key: z5.union([z5.string(), z5.null()]).optional(),
|
|
1487
|
+
project_id: z5.string().uuid(),
|
|
1488
|
+
experiment_id: z5.string().uuid(),
|
|
1489
|
+
input: z5.unknown().optional(),
|
|
1490
|
+
output: z5.unknown().optional(),
|
|
1491
|
+
expected: z5.unknown().optional(),
|
|
1492
|
+
error: z5.unknown().optional(),
|
|
1493
|
+
scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
|
|
1494
|
+
metadata: z5.union([
|
|
1495
|
+
z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
|
|
1496
|
+
z5.null()
|
|
540
1497
|
]).optional(),
|
|
541
|
-
tags:
|
|
542
|
-
metrics:
|
|
543
|
-
context:
|
|
544
|
-
|
|
545
|
-
caller_functionname:
|
|
546
|
-
caller_filename:
|
|
547
|
-
caller_lineno:
|
|
1498
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
1499
|
+
metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
|
|
1500
|
+
context: z5.union([
|
|
1501
|
+
z5.object({
|
|
1502
|
+
caller_functionname: z5.union([z5.string(), z5.null()]),
|
|
1503
|
+
caller_filename: z5.union([z5.string(), z5.null()]),
|
|
1504
|
+
caller_lineno: z5.union([z5.number(), z5.null()])
|
|
548
1505
|
}).partial().passthrough(),
|
|
549
|
-
|
|
1506
|
+
z5.null()
|
|
550
1507
|
]).optional(),
|
|
551
|
-
span_id:
|
|
552
|
-
span_parents:
|
|
553
|
-
root_span_id:
|
|
1508
|
+
span_id: z5.string(),
|
|
1509
|
+
span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
1510
|
+
root_span_id: z5.string(),
|
|
554
1511
|
span_attributes: SpanAttributes.optional(),
|
|
555
|
-
is_root:
|
|
1512
|
+
is_root: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
556
1513
|
origin: ObjectReferenceNullish.optional()
|
|
557
1514
|
});
|
|
558
|
-
var ExtendedSavedFunctionId =
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
type:
|
|
563
|
-
project_id:
|
|
564
|
-
slug:
|
|
1515
|
+
var ExtendedSavedFunctionId = z5.union([
|
|
1516
|
+
z5.object({ type: z5.literal("function"), id: z5.string() }),
|
|
1517
|
+
z5.object({ type: z5.literal("global"), name: z5.string() }),
|
|
1518
|
+
z5.object({
|
|
1519
|
+
type: z5.literal("slug"),
|
|
1520
|
+
project_id: z5.string(),
|
|
1521
|
+
slug: z5.string()
|
|
565
1522
|
})
|
|
566
1523
|
]);
|
|
567
|
-
var PromptBlockDataNullish =
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
type:
|
|
571
|
-
messages:
|
|
572
|
-
tools:
|
|
1524
|
+
var PromptBlockDataNullish = z5.union([
|
|
1525
|
+
z5.object({ type: z5.literal("completion"), content: z5.string() }),
|
|
1526
|
+
z5.object({
|
|
1527
|
+
type: z5.literal("chat"),
|
|
1528
|
+
messages: z5.array(ChatCompletionMessageParam),
|
|
1529
|
+
tools: z5.string().optional()
|
|
573
1530
|
}),
|
|
574
|
-
|
|
1531
|
+
z5.null()
|
|
575
1532
|
]);
|
|
576
|
-
var ModelParams =
|
|
577
|
-
|
|
578
|
-
use_cache:
|
|
579
|
-
temperature:
|
|
580
|
-
top_p:
|
|
581
|
-
max_tokens:
|
|
582
|
-
max_completion_tokens:
|
|
583
|
-
frequency_penalty:
|
|
584
|
-
presence_penalty:
|
|
1533
|
+
var ModelParams = z5.union([
|
|
1534
|
+
z5.object({
|
|
1535
|
+
use_cache: z5.boolean(),
|
|
1536
|
+
temperature: z5.number(),
|
|
1537
|
+
top_p: z5.number(),
|
|
1538
|
+
max_tokens: z5.number(),
|
|
1539
|
+
max_completion_tokens: z5.number(),
|
|
1540
|
+
frequency_penalty: z5.number(),
|
|
1541
|
+
presence_penalty: z5.number(),
|
|
585
1542
|
response_format: ResponseFormatNullish,
|
|
586
|
-
tool_choice:
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
type:
|
|
592
|
-
function:
|
|
1543
|
+
tool_choice: z5.union([
|
|
1544
|
+
z5.literal("auto"),
|
|
1545
|
+
z5.literal("none"),
|
|
1546
|
+
z5.literal("required"),
|
|
1547
|
+
z5.object({
|
|
1548
|
+
type: z5.literal("function"),
|
|
1549
|
+
function: z5.object({ name: z5.string() })
|
|
593
1550
|
})
|
|
594
1551
|
]),
|
|
595
|
-
function_call:
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
1552
|
+
function_call: z5.union([
|
|
1553
|
+
z5.literal("auto"),
|
|
1554
|
+
z5.literal("none"),
|
|
1555
|
+
z5.object({ name: z5.string() })
|
|
599
1556
|
]),
|
|
600
|
-
n:
|
|
601
|
-
stop:
|
|
602
|
-
reasoning_effort:
|
|
603
|
-
verbosity:
|
|
1557
|
+
n: z5.number(),
|
|
1558
|
+
stop: z5.array(z5.string()),
|
|
1559
|
+
reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]),
|
|
1560
|
+
verbosity: z5.enum(["low", "medium", "high"])
|
|
604
1561
|
}).partial().passthrough(),
|
|
605
|
-
|
|
606
|
-
use_cache:
|
|
607
|
-
max_tokens:
|
|
608
|
-
temperature:
|
|
609
|
-
top_p:
|
|
610
|
-
top_k:
|
|
611
|
-
stop_sequences:
|
|
612
|
-
max_tokens_to_sample:
|
|
1562
|
+
z5.object({
|
|
1563
|
+
use_cache: z5.boolean().optional(),
|
|
1564
|
+
max_tokens: z5.number(),
|
|
1565
|
+
temperature: z5.number(),
|
|
1566
|
+
top_p: z5.number().optional(),
|
|
1567
|
+
top_k: z5.number().optional(),
|
|
1568
|
+
stop_sequences: z5.array(z5.string()).optional(),
|
|
1569
|
+
max_tokens_to_sample: z5.number().optional()
|
|
613
1570
|
}).passthrough(),
|
|
614
|
-
|
|
615
|
-
use_cache:
|
|
616
|
-
temperature:
|
|
617
|
-
maxOutputTokens:
|
|
618
|
-
topP:
|
|
619
|
-
topK:
|
|
1571
|
+
z5.object({
|
|
1572
|
+
use_cache: z5.boolean(),
|
|
1573
|
+
temperature: z5.number(),
|
|
1574
|
+
maxOutputTokens: z5.number(),
|
|
1575
|
+
topP: z5.number(),
|
|
1576
|
+
topK: z5.number()
|
|
620
1577
|
}).partial().passthrough(),
|
|
621
|
-
|
|
622
|
-
use_cache:
|
|
623
|
-
temperature:
|
|
624
|
-
topK:
|
|
1578
|
+
z5.object({
|
|
1579
|
+
use_cache: z5.boolean(),
|
|
1580
|
+
temperature: z5.number(),
|
|
1581
|
+
topK: z5.number()
|
|
625
1582
|
}).partial().passthrough(),
|
|
626
|
-
|
|
1583
|
+
z5.object({ use_cache: z5.boolean() }).partial().passthrough()
|
|
627
1584
|
]);
|
|
628
|
-
var PromptOptionsNullish =
|
|
629
|
-
|
|
630
|
-
|
|
1585
|
+
var PromptOptionsNullish = z5.union([
|
|
1586
|
+
z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial(),
|
|
1587
|
+
z5.null()
|
|
631
1588
|
]);
|
|
632
|
-
var PromptParserNullish =
|
|
633
|
-
|
|
634
|
-
type:
|
|
635
|
-
use_cot:
|
|
636
|
-
choice_scores:
|
|
1589
|
+
var PromptParserNullish = z5.union([
|
|
1590
|
+
z5.object({
|
|
1591
|
+
type: z5.literal("llm_classifier"),
|
|
1592
|
+
use_cot: z5.boolean(),
|
|
1593
|
+
choice_scores: z5.record(z5.number().gte(0).lte(1))
|
|
637
1594
|
}),
|
|
638
|
-
|
|
1595
|
+
z5.null()
|
|
639
1596
|
]);
|
|
640
|
-
var SavedFunctionId =
|
|
641
|
-
|
|
642
|
-
|
|
1597
|
+
var SavedFunctionId = z5.union([
|
|
1598
|
+
z5.object({ type: z5.literal("function"), id: z5.string() }),
|
|
1599
|
+
z5.object({ type: z5.literal("global"), name: z5.string() })
|
|
643
1600
|
]);
|
|
644
|
-
var PromptDataNullish =
|
|
645
|
-
|
|
1601
|
+
var PromptDataNullish = z5.union([
|
|
1602
|
+
z5.object({
|
|
646
1603
|
prompt: PromptBlockDataNullish,
|
|
647
1604
|
options: PromptOptionsNullish,
|
|
648
1605
|
parser: PromptParserNullish,
|
|
649
|
-
tool_functions:
|
|
650
|
-
origin:
|
|
651
|
-
|
|
652
|
-
prompt_id:
|
|
653
|
-
project_id:
|
|
654
|
-
prompt_version:
|
|
1606
|
+
tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
|
|
1607
|
+
origin: z5.union([
|
|
1608
|
+
z5.object({
|
|
1609
|
+
prompt_id: z5.string(),
|
|
1610
|
+
project_id: z5.string(),
|
|
1611
|
+
prompt_version: z5.string()
|
|
655
1612
|
}).partial(),
|
|
656
|
-
|
|
1613
|
+
z5.null()
|
|
657
1614
|
])
|
|
658
1615
|
}).partial(),
|
|
659
|
-
|
|
1616
|
+
z5.null()
|
|
660
1617
|
]);
|
|
661
|
-
var FunctionTypeEnumNullish =
|
|
662
|
-
|
|
663
|
-
|
|
1618
|
+
var FunctionTypeEnumNullish = z5.union([
|
|
1619
|
+
z5.enum(["llm", "scorer", "task", "tool"]),
|
|
1620
|
+
z5.null()
|
|
664
1621
|
]);
|
|
665
|
-
var FunctionIdRef =
|
|
666
|
-
var PromptBlockData =
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
type:
|
|
670
|
-
messages:
|
|
671
|
-
tools:
|
|
1622
|
+
var FunctionIdRef = z5.object({}).partial().passthrough();
|
|
1623
|
+
var PromptBlockData = z5.union([
|
|
1624
|
+
z5.object({ type: z5.literal("completion"), content: z5.string() }),
|
|
1625
|
+
z5.object({
|
|
1626
|
+
type: z5.literal("chat"),
|
|
1627
|
+
messages: z5.array(ChatCompletionMessageParam),
|
|
1628
|
+
tools: z5.string().optional()
|
|
672
1629
|
})
|
|
673
1630
|
]);
|
|
674
|
-
var GraphNode =
|
|
675
|
-
|
|
676
|
-
description:
|
|
677
|
-
position:
|
|
678
|
-
type:
|
|
1631
|
+
var GraphNode = z5.union([
|
|
1632
|
+
z5.object({
|
|
1633
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1634
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
1635
|
+
type: z5.literal("function"),
|
|
679
1636
|
function: FunctionIdRef
|
|
680
1637
|
}),
|
|
681
|
-
|
|
682
|
-
description:
|
|
683
|
-
position:
|
|
684
|
-
type:
|
|
1638
|
+
z5.object({
|
|
1639
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1640
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
1641
|
+
type: z5.literal("input")
|
|
685
1642
|
}),
|
|
686
|
-
|
|
687
|
-
description:
|
|
688
|
-
position:
|
|
689
|
-
type:
|
|
1643
|
+
z5.object({
|
|
1644
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1645
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
1646
|
+
type: z5.literal("output")
|
|
690
1647
|
}),
|
|
691
|
-
|
|
692
|
-
description:
|
|
693
|
-
position:
|
|
694
|
-
type:
|
|
695
|
-
value:
|
|
1648
|
+
z5.object({
|
|
1649
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1650
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
1651
|
+
type: z5.literal("literal"),
|
|
1652
|
+
value: z5.unknown().optional()
|
|
696
1653
|
}),
|
|
697
|
-
|
|
698
|
-
description:
|
|
699
|
-
position:
|
|
700
|
-
type:
|
|
701
|
-
expr:
|
|
1654
|
+
z5.object({
|
|
1655
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1656
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
1657
|
+
type: z5.literal("btql"),
|
|
1658
|
+
expr: z5.string()
|
|
702
1659
|
}),
|
|
703
|
-
|
|
704
|
-
description:
|
|
705
|
-
position:
|
|
706
|
-
type:
|
|
707
|
-
condition:
|
|
1660
|
+
z5.object({
|
|
1661
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1662
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
1663
|
+
type: z5.literal("gate"),
|
|
1664
|
+
condition: z5.union([z5.string(), z5.null()]).optional()
|
|
708
1665
|
}),
|
|
709
|
-
|
|
710
|
-
description:
|
|
711
|
-
position:
|
|
712
|
-
type:
|
|
1666
|
+
z5.object({
|
|
1667
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1668
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
1669
|
+
type: z5.literal("aggregator")
|
|
713
1670
|
}),
|
|
714
|
-
|
|
715
|
-
description:
|
|
716
|
-
position:
|
|
717
|
-
type:
|
|
1671
|
+
z5.object({
|
|
1672
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1673
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
1674
|
+
type: z5.literal("prompt_template"),
|
|
718
1675
|
prompt: PromptBlockData
|
|
719
1676
|
})
|
|
720
1677
|
]);
|
|
721
|
-
var GraphEdge =
|
|
722
|
-
source:
|
|
723
|
-
target:
|
|
724
|
-
purpose:
|
|
1678
|
+
var GraphEdge = z5.object({
|
|
1679
|
+
source: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
|
|
1680
|
+
target: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
|
|
1681
|
+
purpose: z5.enum(["control", "data", "messages"])
|
|
725
1682
|
});
|
|
726
|
-
var GraphData =
|
|
727
|
-
type:
|
|
728
|
-
nodes:
|
|
729
|
-
edges:
|
|
1683
|
+
var GraphData = z5.object({
|
|
1684
|
+
type: z5.literal("graph"),
|
|
1685
|
+
nodes: z5.record(GraphNode),
|
|
1686
|
+
edges: z5.record(GraphEdge)
|
|
730
1687
|
});
|
|
731
|
-
var FunctionData =
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
type:
|
|
735
|
-
data:
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
type:
|
|
739
|
-
runtime_context:
|
|
740
|
-
runtime:
|
|
741
|
-
version:
|
|
1688
|
+
var FunctionData = z5.union([
|
|
1689
|
+
z5.object({ type: z5.literal("prompt") }),
|
|
1690
|
+
z5.object({
|
|
1691
|
+
type: z5.literal("code"),
|
|
1692
|
+
data: z5.union([
|
|
1693
|
+
z5.object({ type: z5.literal("bundle") }).and(CodeBundle),
|
|
1694
|
+
z5.object({
|
|
1695
|
+
type: z5.literal("inline"),
|
|
1696
|
+
runtime_context: z5.object({
|
|
1697
|
+
runtime: z5.enum(["node", "python"]),
|
|
1698
|
+
version: z5.string()
|
|
742
1699
|
}),
|
|
743
|
-
code:
|
|
1700
|
+
code: z5.string()
|
|
744
1701
|
})
|
|
745
1702
|
])
|
|
746
1703
|
}),
|
|
747
1704
|
GraphData,
|
|
748
|
-
|
|
749
|
-
type:
|
|
750
|
-
endpoint:
|
|
751
|
-
eval_name:
|
|
752
|
-
parameters:
|
|
1705
|
+
z5.object({
|
|
1706
|
+
type: z5.literal("remote_eval"),
|
|
1707
|
+
endpoint: z5.string(),
|
|
1708
|
+
eval_name: z5.string(),
|
|
1709
|
+
parameters: z5.object({}).partial().passthrough()
|
|
753
1710
|
}),
|
|
754
|
-
|
|
1711
|
+
z5.object({ type: z5.literal("global"), name: z5.string() })
|
|
755
1712
|
]);
|
|
756
|
-
var Function =
|
|
757
|
-
id:
|
|
758
|
-
_xact_id:
|
|
759
|
-
project_id:
|
|
760
|
-
log_id:
|
|
761
|
-
org_id:
|
|
762
|
-
name:
|
|
763
|
-
slug:
|
|
764
|
-
description:
|
|
765
|
-
created:
|
|
1713
|
+
var Function = z5.object({
|
|
1714
|
+
id: z5.string().uuid(),
|
|
1715
|
+
_xact_id: z5.string(),
|
|
1716
|
+
project_id: z5.string().uuid(),
|
|
1717
|
+
log_id: z5.literal("p"),
|
|
1718
|
+
org_id: z5.string().uuid(),
|
|
1719
|
+
name: z5.string(),
|
|
1720
|
+
slug: z5.string(),
|
|
1721
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1722
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
766
1723
|
prompt_data: PromptDataNullish.optional(),
|
|
767
|
-
tags:
|
|
768
|
-
metadata:
|
|
1724
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
1725
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
|
|
769
1726
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
770
1727
|
function_data: FunctionData,
|
|
771
|
-
origin:
|
|
772
|
-
|
|
773
|
-
object_type: AclObjectType.and(
|
|
774
|
-
object_id:
|
|
775
|
-
internal:
|
|
1728
|
+
origin: z5.union([
|
|
1729
|
+
z5.object({
|
|
1730
|
+
object_type: AclObjectType.and(z5.string()),
|
|
1731
|
+
object_id: z5.string().uuid(),
|
|
1732
|
+
internal: z5.union([z5.boolean(), z5.null()]).optional()
|
|
776
1733
|
}),
|
|
777
|
-
|
|
1734
|
+
z5.null()
|
|
778
1735
|
]).optional(),
|
|
779
|
-
function_schema:
|
|
780
|
-
|
|
781
|
-
|
|
1736
|
+
function_schema: z5.union([
|
|
1737
|
+
z5.object({ parameters: z5.unknown(), returns: z5.unknown() }).partial(),
|
|
1738
|
+
z5.null()
|
|
782
1739
|
]).optional()
|
|
783
1740
|
});
|
|
784
|
-
var FunctionFormat =
|
|
785
|
-
var PromptData =
|
|
1741
|
+
var FunctionFormat = z5.enum(["llm", "code", "global", "graph"]);
|
|
1742
|
+
var PromptData = z5.object({
|
|
786
1743
|
prompt: PromptBlockDataNullish,
|
|
787
1744
|
options: PromptOptionsNullish,
|
|
788
1745
|
parser: PromptParserNullish,
|
|
789
|
-
tool_functions:
|
|
790
|
-
origin:
|
|
791
|
-
|
|
792
|
-
prompt_id:
|
|
793
|
-
project_id:
|
|
794
|
-
prompt_version:
|
|
1746
|
+
tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
|
|
1747
|
+
origin: z5.union([
|
|
1748
|
+
z5.object({
|
|
1749
|
+
prompt_id: z5.string(),
|
|
1750
|
+
project_id: z5.string(),
|
|
1751
|
+
prompt_version: z5.string()
|
|
795
1752
|
}).partial(),
|
|
796
|
-
|
|
1753
|
+
z5.null()
|
|
797
1754
|
])
|
|
798
1755
|
}).partial();
|
|
799
|
-
var FunctionTypeEnum =
|
|
800
|
-
var FunctionId =
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
project_name:
|
|
804
|
-
slug:
|
|
805
|
-
version:
|
|
1756
|
+
var FunctionTypeEnum = z5.enum(["llm", "scorer", "task", "tool"]);
|
|
1757
|
+
var FunctionId = z5.union([
|
|
1758
|
+
z5.object({ function_id: z5.string(), version: z5.string().optional() }),
|
|
1759
|
+
z5.object({
|
|
1760
|
+
project_name: z5.string(),
|
|
1761
|
+
slug: z5.string(),
|
|
1762
|
+
version: z5.string().optional()
|
|
806
1763
|
}),
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
prompt_session_id:
|
|
810
|
-
prompt_session_function_id:
|
|
811
|
-
version:
|
|
1764
|
+
z5.object({ global_function: z5.string() }),
|
|
1765
|
+
z5.object({
|
|
1766
|
+
prompt_session_id: z5.string(),
|
|
1767
|
+
prompt_session_function_id: z5.string(),
|
|
1768
|
+
version: z5.string().optional()
|
|
812
1769
|
}),
|
|
813
|
-
|
|
814
|
-
inline_context:
|
|
815
|
-
runtime:
|
|
816
|
-
version:
|
|
1770
|
+
z5.object({
|
|
1771
|
+
inline_context: z5.object({
|
|
1772
|
+
runtime: z5.enum(["node", "python"]),
|
|
1773
|
+
version: z5.string()
|
|
817
1774
|
}),
|
|
818
|
-
code:
|
|
819
|
-
name:
|
|
1775
|
+
code: z5.string(),
|
|
1776
|
+
name: z5.union([z5.string(), z5.null()]).optional()
|
|
820
1777
|
}),
|
|
821
|
-
|
|
1778
|
+
z5.object({
|
|
822
1779
|
inline_prompt: PromptData.optional(),
|
|
823
|
-
inline_function:
|
|
1780
|
+
inline_function: z5.object({}).partial().passthrough(),
|
|
824
1781
|
function_type: FunctionTypeEnum.optional(),
|
|
825
|
-
name:
|
|
1782
|
+
name: z5.union([z5.string(), z5.null()]).optional()
|
|
826
1783
|
}),
|
|
827
|
-
|
|
1784
|
+
z5.object({
|
|
828
1785
|
inline_prompt: PromptData,
|
|
829
1786
|
function_type: FunctionTypeEnum.optional(),
|
|
830
|
-
name:
|
|
1787
|
+
name: z5.union([z5.string(), z5.null()]).optional()
|
|
831
1788
|
})
|
|
832
1789
|
]);
|
|
833
|
-
var FunctionObjectType =
|
|
1790
|
+
var FunctionObjectType = z5.enum([
|
|
834
1791
|
"prompt",
|
|
835
1792
|
"tool",
|
|
836
1793
|
"scorer",
|
|
837
1794
|
"task",
|
|
838
1795
|
"agent"
|
|
839
1796
|
]);
|
|
840
|
-
var FunctionOutputType =
|
|
841
|
-
var GitMetadataSettings =
|
|
842
|
-
collect:
|
|
843
|
-
fields:
|
|
844
|
-
|
|
1797
|
+
var FunctionOutputType = z5.enum(["completion", "score", "any"]);
|
|
1798
|
+
var GitMetadataSettings = z5.object({
|
|
1799
|
+
collect: z5.enum(["all", "none", "some"]),
|
|
1800
|
+
fields: z5.array(
|
|
1801
|
+
z5.enum([
|
|
845
1802
|
"commit",
|
|
846
1803
|
"branch",
|
|
847
1804
|
"tag",
|
|
@@ -854,49 +1811,49 @@ var GitMetadataSettings = z.object({
|
|
|
854
1811
|
])
|
|
855
1812
|
).optional()
|
|
856
1813
|
});
|
|
857
|
-
var Group =
|
|
858
|
-
id:
|
|
859
|
-
org_id:
|
|
860
|
-
user_id:
|
|
861
|
-
created:
|
|
862
|
-
name:
|
|
863
|
-
description:
|
|
864
|
-
deleted_at:
|
|
865
|
-
member_users:
|
|
866
|
-
member_groups:
|
|
1814
|
+
var Group = z5.object({
|
|
1815
|
+
id: z5.string().uuid(),
|
|
1816
|
+
org_id: z5.string().uuid(),
|
|
1817
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1818
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1819
|
+
name: z5.string(),
|
|
1820
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1821
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
1822
|
+
member_users: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional(),
|
|
1823
|
+
member_groups: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
|
|
867
1824
|
});
|
|
868
|
-
var IfExists =
|
|
869
|
-
var InvokeParent =
|
|
870
|
-
|
|
871
|
-
object_type:
|
|
872
|
-
object_id:
|
|
873
|
-
row_ids:
|
|
874
|
-
|
|
875
|
-
id:
|
|
876
|
-
span_id:
|
|
877
|
-
root_span_id:
|
|
1825
|
+
var IfExists = z5.enum(["error", "ignore", "replace"]);
|
|
1826
|
+
var InvokeParent = z5.union([
|
|
1827
|
+
z5.object({
|
|
1828
|
+
object_type: z5.enum(["project_logs", "experiment", "playground_logs"]),
|
|
1829
|
+
object_id: z5.string(),
|
|
1830
|
+
row_ids: z5.union([
|
|
1831
|
+
z5.object({
|
|
1832
|
+
id: z5.string(),
|
|
1833
|
+
span_id: z5.string(),
|
|
1834
|
+
root_span_id: z5.string()
|
|
878
1835
|
}),
|
|
879
|
-
|
|
1836
|
+
z5.null()
|
|
880
1837
|
]).optional(),
|
|
881
|
-
propagated_event:
|
|
1838
|
+
propagated_event: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
|
|
882
1839
|
}),
|
|
883
|
-
|
|
1840
|
+
z5.string()
|
|
884
1841
|
]);
|
|
885
|
-
var StreamingMode =
|
|
1842
|
+
var StreamingMode = z5.union([z5.enum(["auto", "parallel"]), z5.null()]);
|
|
886
1843
|
var InvokeFunction = FunctionId.and(
|
|
887
|
-
|
|
888
|
-
input:
|
|
889
|
-
expected:
|
|
890
|
-
metadata:
|
|
891
|
-
tags:
|
|
892
|
-
messages:
|
|
1844
|
+
z5.object({
|
|
1845
|
+
input: z5.unknown(),
|
|
1846
|
+
expected: z5.unknown(),
|
|
1847
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]),
|
|
1848
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]),
|
|
1849
|
+
messages: z5.array(ChatCompletionMessageParam),
|
|
893
1850
|
parent: InvokeParent,
|
|
894
|
-
stream:
|
|
1851
|
+
stream: z5.union([z5.boolean(), z5.null()]),
|
|
895
1852
|
mode: StreamingMode,
|
|
896
|
-
strict:
|
|
1853
|
+
strict: z5.union([z5.boolean(), z5.null()])
|
|
897
1854
|
}).partial()
|
|
898
1855
|
);
|
|
899
|
-
var MessageRole =
|
|
1856
|
+
var MessageRole = z5.enum([
|
|
900
1857
|
"system",
|
|
901
1858
|
"user",
|
|
902
1859
|
"assistant",
|
|
@@ -905,8 +1862,8 @@ var MessageRole = z.enum([
|
|
|
905
1862
|
"model",
|
|
906
1863
|
"developer"
|
|
907
1864
|
]);
|
|
908
|
-
var ObjectReference =
|
|
909
|
-
object_type:
|
|
1865
|
+
var ObjectReference = z5.object({
|
|
1866
|
+
object_type: z5.enum([
|
|
910
1867
|
"project_logs",
|
|
911
1868
|
"experiment",
|
|
912
1869
|
"dataset",
|
|
@@ -914,146 +1871,146 @@ var ObjectReference = z.object({
|
|
|
914
1871
|
"function",
|
|
915
1872
|
"prompt_session"
|
|
916
1873
|
]),
|
|
917
|
-
object_id:
|
|
918
|
-
id:
|
|
919
|
-
_xact_id:
|
|
920
|
-
created:
|
|
1874
|
+
object_id: z5.string().uuid(),
|
|
1875
|
+
id: z5.string(),
|
|
1876
|
+
_xact_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1877
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
921
1878
|
});
|
|
922
|
-
var OnlineScoreConfig =
|
|
923
|
-
|
|
924
|
-
sampling_rate:
|
|
925
|
-
scorers:
|
|
926
|
-
btql_filter:
|
|
927
|
-
apply_to_root_span:
|
|
928
|
-
apply_to_span_names:
|
|
929
|
-
skip_logging:
|
|
1879
|
+
var OnlineScoreConfig = z5.union([
|
|
1880
|
+
z5.object({
|
|
1881
|
+
sampling_rate: z5.number().gte(0).lte(1),
|
|
1882
|
+
scorers: z5.array(SavedFunctionId),
|
|
1883
|
+
btql_filter: z5.union([z5.string(), z5.null()]).optional(),
|
|
1884
|
+
apply_to_root_span: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
1885
|
+
apply_to_span_names: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
1886
|
+
skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
|
|
930
1887
|
}),
|
|
931
|
-
|
|
1888
|
+
z5.null()
|
|
932
1889
|
]);
|
|
933
|
-
var Organization =
|
|
934
|
-
id:
|
|
935
|
-
name:
|
|
936
|
-
api_url:
|
|
937
|
-
is_universal_api:
|
|
938
|
-
proxy_url:
|
|
939
|
-
realtime_url:
|
|
940
|
-
created:
|
|
1890
|
+
var Organization = z5.object({
|
|
1891
|
+
id: z5.string().uuid(),
|
|
1892
|
+
name: z5.string(),
|
|
1893
|
+
api_url: z5.union([z5.string(), z5.null()]).optional(),
|
|
1894
|
+
is_universal_api: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
1895
|
+
proxy_url: z5.union([z5.string(), z5.null()]).optional(),
|
|
1896
|
+
realtime_url: z5.union([z5.string(), z5.null()]).optional(),
|
|
1897
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
941
1898
|
});
|
|
942
|
-
var ProjectSettings =
|
|
943
|
-
|
|
944
|
-
comparison_key:
|
|
945
|
-
baseline_experiment_id:
|
|
946
|
-
spanFieldOrder:
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
object_type:
|
|
950
|
-
column_id:
|
|
951
|
-
position:
|
|
952
|
-
layout:
|
|
1899
|
+
var ProjectSettings = z5.union([
|
|
1900
|
+
z5.object({
|
|
1901
|
+
comparison_key: z5.union([z5.string(), z5.null()]),
|
|
1902
|
+
baseline_experiment_id: z5.union([z5.string(), z5.null()]),
|
|
1903
|
+
spanFieldOrder: z5.union([
|
|
1904
|
+
z5.array(
|
|
1905
|
+
z5.object({
|
|
1906
|
+
object_type: z5.string(),
|
|
1907
|
+
column_id: z5.string(),
|
|
1908
|
+
position: z5.string(),
|
|
1909
|
+
layout: z5.union([z5.literal("full"), z5.literal("two_column"), z5.null()]).optional()
|
|
953
1910
|
})
|
|
954
1911
|
),
|
|
955
|
-
|
|
1912
|
+
z5.null()
|
|
956
1913
|
]),
|
|
957
|
-
remote_eval_sources:
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
url:
|
|
961
|
-
name:
|
|
962
|
-
description:
|
|
1914
|
+
remote_eval_sources: z5.union([
|
|
1915
|
+
z5.array(
|
|
1916
|
+
z5.object({
|
|
1917
|
+
url: z5.string(),
|
|
1918
|
+
name: z5.string(),
|
|
1919
|
+
description: z5.union([z5.string(), z5.null()]).optional()
|
|
963
1920
|
})
|
|
964
1921
|
),
|
|
965
|
-
|
|
1922
|
+
z5.null()
|
|
966
1923
|
])
|
|
967
1924
|
}).partial(),
|
|
968
|
-
|
|
1925
|
+
z5.null()
|
|
969
1926
|
]);
|
|
970
|
-
var Project =
|
|
971
|
-
id:
|
|
972
|
-
org_id:
|
|
973
|
-
name:
|
|
974
|
-
created:
|
|
975
|
-
deleted_at:
|
|
976
|
-
user_id:
|
|
1927
|
+
var Project = z5.object({
|
|
1928
|
+
id: z5.string().uuid(),
|
|
1929
|
+
org_id: z5.string().uuid(),
|
|
1930
|
+
name: z5.string(),
|
|
1931
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1932
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
1933
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
977
1934
|
settings: ProjectSettings.optional()
|
|
978
1935
|
});
|
|
979
|
-
var RetentionObjectType =
|
|
1936
|
+
var RetentionObjectType = z5.enum([
|
|
980
1937
|
"project_logs",
|
|
981
1938
|
"experiment",
|
|
982
1939
|
"dataset"
|
|
983
1940
|
]);
|
|
984
|
-
var ProjectAutomation =
|
|
985
|
-
id:
|
|
986
|
-
project_id:
|
|
987
|
-
user_id:
|
|
988
|
-
created:
|
|
989
|
-
name:
|
|
990
|
-
description:
|
|
991
|
-
config:
|
|
992
|
-
|
|
993
|
-
event_type:
|
|
994
|
-
btql_filter:
|
|
995
|
-
interval_seconds:
|
|
996
|
-
action:
|
|
1941
|
+
var ProjectAutomation = z5.object({
|
|
1942
|
+
id: z5.string().uuid(),
|
|
1943
|
+
project_id: z5.string().uuid(),
|
|
1944
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1945
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1946
|
+
name: z5.string(),
|
|
1947
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1948
|
+
config: z5.union([
|
|
1949
|
+
z5.object({
|
|
1950
|
+
event_type: z5.literal("logs"),
|
|
1951
|
+
btql_filter: z5.string(),
|
|
1952
|
+
interval_seconds: z5.number().gte(1).lte(2592e3),
|
|
1953
|
+
action: z5.object({ type: z5.literal("webhook"), url: z5.string() })
|
|
997
1954
|
}),
|
|
998
|
-
|
|
999
|
-
event_type:
|
|
1000
|
-
export_definition:
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1955
|
+
z5.object({
|
|
1956
|
+
event_type: z5.literal("btql_export"),
|
|
1957
|
+
export_definition: z5.union([
|
|
1958
|
+
z5.object({ type: z5.literal("log_traces") }),
|
|
1959
|
+
z5.object({ type: z5.literal("log_spans") }),
|
|
1960
|
+
z5.object({ type: z5.literal("btql_query"), btql_query: z5.string() })
|
|
1004
1961
|
]),
|
|
1005
|
-
export_path:
|
|
1006
|
-
format:
|
|
1007
|
-
interval_seconds:
|
|
1008
|
-
credentials:
|
|
1009
|
-
type:
|
|
1010
|
-
role_arn:
|
|
1011
|
-
external_id:
|
|
1962
|
+
export_path: z5.string(),
|
|
1963
|
+
format: z5.enum(["jsonl", "parquet"]),
|
|
1964
|
+
interval_seconds: z5.number().gte(1).lte(2592e3),
|
|
1965
|
+
credentials: z5.object({
|
|
1966
|
+
type: z5.literal("aws_iam"),
|
|
1967
|
+
role_arn: z5.string(),
|
|
1968
|
+
external_id: z5.string()
|
|
1012
1969
|
}),
|
|
1013
|
-
batch_size:
|
|
1970
|
+
batch_size: z5.union([z5.number(), z5.null()]).optional()
|
|
1014
1971
|
}),
|
|
1015
|
-
|
|
1016
|
-
event_type:
|
|
1972
|
+
z5.object({
|
|
1973
|
+
event_type: z5.literal("retention"),
|
|
1017
1974
|
object_type: RetentionObjectType,
|
|
1018
|
-
retention_days:
|
|
1975
|
+
retention_days: z5.number().gte(0)
|
|
1019
1976
|
})
|
|
1020
1977
|
])
|
|
1021
1978
|
});
|
|
1022
|
-
var ProjectLogsEvent =
|
|
1023
|
-
id:
|
|
1024
|
-
_xact_id:
|
|
1025
|
-
_pagination_key:
|
|
1026
|
-
created:
|
|
1027
|
-
org_id:
|
|
1028
|
-
project_id:
|
|
1029
|
-
log_id:
|
|
1030
|
-
input:
|
|
1031
|
-
output:
|
|
1032
|
-
expected:
|
|
1033
|
-
error:
|
|
1034
|
-
scores:
|
|
1035
|
-
metadata:
|
|
1036
|
-
|
|
1037
|
-
|
|
1979
|
+
var ProjectLogsEvent = z5.object({
|
|
1980
|
+
id: z5.string(),
|
|
1981
|
+
_xact_id: z5.string(),
|
|
1982
|
+
_pagination_key: z5.union([z5.string(), z5.null()]).optional(),
|
|
1983
|
+
created: z5.string().datetime({ offset: true }),
|
|
1984
|
+
org_id: z5.string().uuid(),
|
|
1985
|
+
project_id: z5.string().uuid(),
|
|
1986
|
+
log_id: z5.literal("g"),
|
|
1987
|
+
input: z5.unknown().optional(),
|
|
1988
|
+
output: z5.unknown().optional(),
|
|
1989
|
+
expected: z5.unknown().optional(),
|
|
1990
|
+
error: z5.unknown().optional(),
|
|
1991
|
+
scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
|
|
1992
|
+
metadata: z5.union([
|
|
1993
|
+
z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
|
|
1994
|
+
z5.null()
|
|
1038
1995
|
]).optional(),
|
|
1039
|
-
tags:
|
|
1040
|
-
metrics:
|
|
1041
|
-
context:
|
|
1042
|
-
|
|
1043
|
-
caller_functionname:
|
|
1044
|
-
caller_filename:
|
|
1045
|
-
caller_lineno:
|
|
1996
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
1997
|
+
metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
|
|
1998
|
+
context: z5.union([
|
|
1999
|
+
z5.object({
|
|
2000
|
+
caller_functionname: z5.union([z5.string(), z5.null()]),
|
|
2001
|
+
caller_filename: z5.union([z5.string(), z5.null()]),
|
|
2002
|
+
caller_lineno: z5.union([z5.number(), z5.null()])
|
|
1046
2003
|
}).partial().passthrough(),
|
|
1047
|
-
|
|
2004
|
+
z5.null()
|
|
1048
2005
|
]).optional(),
|
|
1049
|
-
span_id:
|
|
1050
|
-
span_parents:
|
|
1051
|
-
root_span_id:
|
|
1052
|
-
is_root:
|
|
2006
|
+
span_id: z5.string(),
|
|
2007
|
+
span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
2008
|
+
root_span_id: z5.string(),
|
|
2009
|
+
is_root: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
1053
2010
|
span_attributes: SpanAttributes.optional(),
|
|
1054
2011
|
origin: ObjectReferenceNullish.optional()
|
|
1055
2012
|
});
|
|
1056
|
-
var ProjectScoreType =
|
|
2013
|
+
var ProjectScoreType = z5.enum([
|
|
1057
2014
|
"slider",
|
|
1058
2015
|
"categorical",
|
|
1059
2016
|
"weighted",
|
|
@@ -1062,172 +2019,172 @@ var ProjectScoreType = z.enum([
|
|
|
1062
2019
|
"online",
|
|
1063
2020
|
"free-form"
|
|
1064
2021
|
]);
|
|
1065
|
-
var ProjectScoreCategory =
|
|
1066
|
-
name:
|
|
1067
|
-
value:
|
|
2022
|
+
var ProjectScoreCategory = z5.object({
|
|
2023
|
+
name: z5.string(),
|
|
2024
|
+
value: z5.number()
|
|
1068
2025
|
});
|
|
1069
|
-
var ProjectScoreCategories =
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
2026
|
+
var ProjectScoreCategories = z5.union([
|
|
2027
|
+
z5.array(ProjectScoreCategory),
|
|
2028
|
+
z5.record(z5.number()),
|
|
2029
|
+
z5.array(z5.string()),
|
|
2030
|
+
z5.null()
|
|
1074
2031
|
]);
|
|
1075
|
-
var ProjectScoreConfig =
|
|
1076
|
-
|
|
1077
|
-
multi_select:
|
|
1078
|
-
destination:
|
|
2032
|
+
var ProjectScoreConfig = z5.union([
|
|
2033
|
+
z5.object({
|
|
2034
|
+
multi_select: z5.union([z5.boolean(), z5.null()]),
|
|
2035
|
+
destination: z5.union([z5.string(), z5.null()]),
|
|
1079
2036
|
online: OnlineScoreConfig
|
|
1080
2037
|
}).partial(),
|
|
1081
|
-
|
|
2038
|
+
z5.null()
|
|
1082
2039
|
]);
|
|
1083
|
-
var ProjectScore =
|
|
1084
|
-
id:
|
|
1085
|
-
project_id:
|
|
1086
|
-
user_id:
|
|
1087
|
-
created:
|
|
1088
|
-
name:
|
|
1089
|
-
description:
|
|
2040
|
+
var ProjectScore = z5.object({
|
|
2041
|
+
id: z5.string().uuid(),
|
|
2042
|
+
project_id: z5.string().uuid(),
|
|
2043
|
+
user_id: z5.string().uuid(),
|
|
2044
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
2045
|
+
name: z5.string(),
|
|
2046
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
1090
2047
|
score_type: ProjectScoreType,
|
|
1091
2048
|
categories: ProjectScoreCategories.optional(),
|
|
1092
2049
|
config: ProjectScoreConfig.optional(),
|
|
1093
|
-
position:
|
|
2050
|
+
position: z5.union([z5.string(), z5.null()]).optional()
|
|
1094
2051
|
});
|
|
1095
|
-
var ProjectTag =
|
|
1096
|
-
id:
|
|
1097
|
-
project_id:
|
|
1098
|
-
user_id:
|
|
1099
|
-
created:
|
|
1100
|
-
name:
|
|
1101
|
-
description:
|
|
1102
|
-
color:
|
|
1103
|
-
position:
|
|
2052
|
+
var ProjectTag = z5.object({
|
|
2053
|
+
id: z5.string().uuid(),
|
|
2054
|
+
project_id: z5.string().uuid(),
|
|
2055
|
+
user_id: z5.string().uuid(),
|
|
2056
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
2057
|
+
name: z5.string(),
|
|
2058
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
2059
|
+
color: z5.union([z5.string(), z5.null()]).optional(),
|
|
2060
|
+
position: z5.union([z5.string(), z5.null()]).optional()
|
|
1104
2061
|
});
|
|
1105
|
-
var Prompt =
|
|
1106
|
-
id:
|
|
1107
|
-
_xact_id:
|
|
1108
|
-
project_id:
|
|
1109
|
-
log_id:
|
|
1110
|
-
org_id:
|
|
1111
|
-
name:
|
|
1112
|
-
slug:
|
|
1113
|
-
description:
|
|
1114
|
-
created:
|
|
2062
|
+
var Prompt = z5.object({
|
|
2063
|
+
id: z5.string().uuid(),
|
|
2064
|
+
_xact_id: z5.string(),
|
|
2065
|
+
project_id: z5.string().uuid(),
|
|
2066
|
+
log_id: z5.literal("p"),
|
|
2067
|
+
org_id: z5.string().uuid(),
|
|
2068
|
+
name: z5.string(),
|
|
2069
|
+
slug: z5.string(),
|
|
2070
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
2071
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1115
2072
|
prompt_data: PromptDataNullish.optional(),
|
|
1116
|
-
tags:
|
|
1117
|
-
metadata:
|
|
2073
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
2074
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
|
|
1118
2075
|
function_type: FunctionTypeEnumNullish.optional()
|
|
1119
2076
|
});
|
|
1120
|
-
var PromptOptions =
|
|
1121
|
-
var PromptSessionEvent =
|
|
1122
|
-
id:
|
|
1123
|
-
_xact_id:
|
|
1124
|
-
created:
|
|
1125
|
-
_pagination_key:
|
|
1126
|
-
project_id:
|
|
1127
|
-
prompt_session_id:
|
|
1128
|
-
prompt_session_data:
|
|
1129
|
-
prompt_data:
|
|
1130
|
-
function_data:
|
|
2077
|
+
var PromptOptions = z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial();
|
|
2078
|
+
var PromptSessionEvent = z5.object({
|
|
2079
|
+
id: z5.string(),
|
|
2080
|
+
_xact_id: z5.string(),
|
|
2081
|
+
created: z5.string().datetime({ offset: true }),
|
|
2082
|
+
_pagination_key: z5.union([z5.string(), z5.null()]).optional(),
|
|
2083
|
+
project_id: z5.string().uuid(),
|
|
2084
|
+
prompt_session_id: z5.string().uuid(),
|
|
2085
|
+
prompt_session_data: z5.unknown().optional(),
|
|
2086
|
+
prompt_data: z5.unknown().optional(),
|
|
2087
|
+
function_data: z5.unknown().optional(),
|
|
1131
2088
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
1132
|
-
object_data:
|
|
1133
|
-
completion:
|
|
1134
|
-
tags:
|
|
2089
|
+
object_data: z5.unknown().optional(),
|
|
2090
|
+
completion: z5.unknown().optional(),
|
|
2091
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
|
|
1135
2092
|
});
|
|
1136
|
-
var ResponseFormat =
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
type:
|
|
2093
|
+
var ResponseFormat = z5.union([
|
|
2094
|
+
z5.object({ type: z5.literal("json_object") }),
|
|
2095
|
+
z5.object({
|
|
2096
|
+
type: z5.literal("json_schema"),
|
|
1140
2097
|
json_schema: ResponseFormatJsonSchema
|
|
1141
2098
|
}),
|
|
1142
|
-
|
|
2099
|
+
z5.object({ type: z5.literal("text") })
|
|
1143
2100
|
]);
|
|
1144
|
-
var Role =
|
|
1145
|
-
id:
|
|
1146
|
-
org_id:
|
|
1147
|
-
user_id:
|
|
1148
|
-
created:
|
|
1149
|
-
name:
|
|
1150
|
-
description:
|
|
1151
|
-
deleted_at:
|
|
1152
|
-
member_permissions:
|
|
1153
|
-
|
|
1154
|
-
|
|
2101
|
+
var Role = z5.object({
|
|
2102
|
+
id: z5.string().uuid(),
|
|
2103
|
+
org_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
2104
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
2105
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
2106
|
+
name: z5.string(),
|
|
2107
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
2108
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
2109
|
+
member_permissions: z5.union([
|
|
2110
|
+
z5.array(
|
|
2111
|
+
z5.object({
|
|
1155
2112
|
permission: Permission,
|
|
1156
2113
|
restrict_object_type: AclObjectType.optional()
|
|
1157
2114
|
})
|
|
1158
2115
|
),
|
|
1159
|
-
|
|
2116
|
+
z5.null()
|
|
1160
2117
|
]).optional(),
|
|
1161
|
-
member_roles:
|
|
2118
|
+
member_roles: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
|
|
1162
2119
|
});
|
|
1163
|
-
var RunEval =
|
|
1164
|
-
project_id:
|
|
1165
|
-
data:
|
|
1166
|
-
|
|
1167
|
-
dataset_id:
|
|
1168
|
-
_internal_btql:
|
|
2120
|
+
var RunEval = z5.object({
|
|
2121
|
+
project_id: z5.string(),
|
|
2122
|
+
data: z5.union([
|
|
2123
|
+
z5.object({
|
|
2124
|
+
dataset_id: z5.string(),
|
|
2125
|
+
_internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
|
|
1169
2126
|
}),
|
|
1170
|
-
|
|
1171
|
-
project_name:
|
|
1172
|
-
dataset_name:
|
|
1173
|
-
_internal_btql:
|
|
2127
|
+
z5.object({
|
|
2128
|
+
project_name: z5.string(),
|
|
2129
|
+
dataset_name: z5.string(),
|
|
2130
|
+
_internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
|
|
1174
2131
|
}),
|
|
1175
|
-
|
|
2132
|
+
z5.object({ data: z5.array(z5.unknown()) })
|
|
1176
2133
|
]),
|
|
1177
|
-
task: FunctionId.and(
|
|
1178
|
-
scores:
|
|
1179
|
-
experiment_name:
|
|
1180
|
-
metadata:
|
|
1181
|
-
parent: InvokeParent.and(
|
|
1182
|
-
stream:
|
|
1183
|
-
trial_count:
|
|
1184
|
-
is_public:
|
|
1185
|
-
timeout:
|
|
1186
|
-
max_concurrency:
|
|
1187
|
-
base_experiment_name:
|
|
1188
|
-
base_experiment_id:
|
|
2134
|
+
task: FunctionId.and(z5.unknown()),
|
|
2135
|
+
scores: z5.array(FunctionId),
|
|
2136
|
+
experiment_name: z5.string().optional(),
|
|
2137
|
+
metadata: z5.object({}).partial().passthrough().optional(),
|
|
2138
|
+
parent: InvokeParent.and(z5.unknown()).optional(),
|
|
2139
|
+
stream: z5.boolean().optional(),
|
|
2140
|
+
trial_count: z5.union([z5.number(), z5.null()]).optional(),
|
|
2141
|
+
is_public: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
2142
|
+
timeout: z5.union([z5.number(), z5.null()]).optional(),
|
|
2143
|
+
max_concurrency: z5.union([z5.number(), z5.null()]).optional().default(10),
|
|
2144
|
+
base_experiment_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
2145
|
+
base_experiment_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
1189
2146
|
git_metadata_settings: GitMetadataSettings.and(
|
|
1190
|
-
|
|
2147
|
+
z5.union([z5.object({}).partial(), z5.null()])
|
|
1191
2148
|
).optional(),
|
|
1192
|
-
repo_info: RepoInfo.and(
|
|
1193
|
-
strict:
|
|
1194
|
-
stop_token:
|
|
1195
|
-
extra_messages:
|
|
1196
|
-
tags:
|
|
2149
|
+
repo_info: RepoInfo.and(z5.unknown()).optional(),
|
|
2150
|
+
strict: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
2151
|
+
stop_token: z5.union([z5.string(), z5.null()]).optional(),
|
|
2152
|
+
extra_messages: z5.string().optional(),
|
|
2153
|
+
tags: z5.array(z5.string()).optional()
|
|
1197
2154
|
});
|
|
1198
|
-
var ServiceToken =
|
|
1199
|
-
id:
|
|
1200
|
-
created:
|
|
1201
|
-
name:
|
|
1202
|
-
preview_name:
|
|
1203
|
-
service_account_id:
|
|
1204
|
-
service_account_email:
|
|
1205
|
-
service_account_name:
|
|
1206
|
-
org_id:
|
|
2155
|
+
var ServiceToken = z5.object({
|
|
2156
|
+
id: z5.string().uuid(),
|
|
2157
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
2158
|
+
name: z5.string(),
|
|
2159
|
+
preview_name: z5.string(),
|
|
2160
|
+
service_account_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
2161
|
+
service_account_email: z5.union([z5.string(), z5.null()]).optional(),
|
|
2162
|
+
service_account_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
2163
|
+
org_id: z5.union([z5.string(), z5.null()]).optional()
|
|
1207
2164
|
});
|
|
1208
|
-
var SpanIFrame =
|
|
1209
|
-
id:
|
|
1210
|
-
project_id:
|
|
1211
|
-
user_id:
|
|
1212
|
-
created:
|
|
1213
|
-
deleted_at:
|
|
1214
|
-
name:
|
|
1215
|
-
description:
|
|
1216
|
-
url:
|
|
1217
|
-
post_message:
|
|
2165
|
+
var SpanIFrame = z5.object({
|
|
2166
|
+
id: z5.string().uuid(),
|
|
2167
|
+
project_id: z5.string().uuid(),
|
|
2168
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
2169
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
2170
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
2171
|
+
name: z5.string(),
|
|
2172
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
2173
|
+
url: z5.string(),
|
|
2174
|
+
post_message: z5.union([z5.boolean(), z5.null()]).optional()
|
|
1218
2175
|
});
|
|
1219
|
-
var SSEConsoleEventData =
|
|
1220
|
-
stream:
|
|
1221
|
-
message:
|
|
2176
|
+
var SSEConsoleEventData = z5.object({
|
|
2177
|
+
stream: z5.enum(["stderr", "stdout"]),
|
|
2178
|
+
message: z5.string()
|
|
1222
2179
|
});
|
|
1223
|
-
var SSEProgressEventData =
|
|
1224
|
-
id:
|
|
2180
|
+
var SSEProgressEventData = z5.object({
|
|
2181
|
+
id: z5.string(),
|
|
1225
2182
|
object_type: FunctionObjectType,
|
|
1226
|
-
origin: ObjectReferenceNullish.and(
|
|
2183
|
+
origin: ObjectReferenceNullish.and(z5.unknown()).optional(),
|
|
1227
2184
|
format: FunctionFormat,
|
|
1228
2185
|
output_type: FunctionOutputType,
|
|
1229
|
-
name:
|
|
1230
|
-
event:
|
|
2186
|
+
name: z5.string(),
|
|
2187
|
+
event: z5.enum([
|
|
1231
2188
|
"reasoning_delta",
|
|
1232
2189
|
"text_delta",
|
|
1233
2190
|
"json_delta",
|
|
@@ -1237,110 +2194,110 @@ var SSEProgressEventData = z.object({
|
|
|
1237
2194
|
"done",
|
|
1238
2195
|
"progress"
|
|
1239
2196
|
]),
|
|
1240
|
-
data:
|
|
2197
|
+
data: z5.string()
|
|
1241
2198
|
});
|
|
1242
|
-
var ToolFunctionDefinition =
|
|
1243
|
-
type:
|
|
1244
|
-
function:
|
|
1245
|
-
name:
|
|
1246
|
-
description:
|
|
1247
|
-
parameters:
|
|
1248
|
-
strict:
|
|
2199
|
+
var ToolFunctionDefinition = z5.object({
|
|
2200
|
+
type: z5.literal("function"),
|
|
2201
|
+
function: z5.object({
|
|
2202
|
+
name: z5.string(),
|
|
2203
|
+
description: z5.string().optional(),
|
|
2204
|
+
parameters: z5.object({}).partial().passthrough().optional(),
|
|
2205
|
+
strict: z5.union([z5.boolean(), z5.null()]).optional()
|
|
1249
2206
|
})
|
|
1250
2207
|
});
|
|
1251
|
-
var User =
|
|
1252
|
-
id:
|
|
1253
|
-
given_name:
|
|
1254
|
-
family_name:
|
|
1255
|
-
email:
|
|
1256
|
-
avatar_url:
|
|
1257
|
-
created:
|
|
2208
|
+
var User = z5.object({
|
|
2209
|
+
id: z5.string().uuid(),
|
|
2210
|
+
given_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
2211
|
+
family_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
2212
|
+
email: z5.union([z5.string(), z5.null()]).optional(),
|
|
2213
|
+
avatar_url: z5.union([z5.string(), z5.null()]).optional(),
|
|
2214
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
1258
2215
|
});
|
|
1259
|
-
var ViewDataSearch =
|
|
1260
|
-
|
|
1261
|
-
filter:
|
|
1262
|
-
tag:
|
|
1263
|
-
match:
|
|
1264
|
-
sort:
|
|
2216
|
+
var ViewDataSearch = z5.union([
|
|
2217
|
+
z5.object({
|
|
2218
|
+
filter: z5.union([z5.array(z5.unknown()), z5.null()]),
|
|
2219
|
+
tag: z5.union([z5.array(z5.unknown()), z5.null()]),
|
|
2220
|
+
match: z5.union([z5.array(z5.unknown()), z5.null()]),
|
|
2221
|
+
sort: z5.union([z5.array(z5.unknown()), z5.null()])
|
|
1265
2222
|
}).partial(),
|
|
1266
|
-
|
|
2223
|
+
z5.null()
|
|
1267
2224
|
]);
|
|
1268
|
-
var ViewData =
|
|
1269
|
-
|
|
1270
|
-
|
|
2225
|
+
var ViewData = z5.union([
|
|
2226
|
+
z5.object({ search: ViewDataSearch }).partial(),
|
|
2227
|
+
z5.null()
|
|
1271
2228
|
]);
|
|
1272
|
-
var ViewOptions =
|
|
1273
|
-
|
|
1274
|
-
viewType:
|
|
1275
|
-
options:
|
|
1276
|
-
spanType:
|
|
1277
|
-
rangeValue:
|
|
1278
|
-
frameStart:
|
|
1279
|
-
frameEnd:
|
|
1280
|
-
tzUTC:
|
|
1281
|
-
chartVisibility:
|
|
1282
|
-
projectId:
|
|
1283
|
-
type:
|
|
1284
|
-
groupBy:
|
|
2229
|
+
var ViewOptions = z5.union([
|
|
2230
|
+
z5.object({
|
|
2231
|
+
viewType: z5.literal("monitor"),
|
|
2232
|
+
options: z5.object({
|
|
2233
|
+
spanType: z5.union([z5.enum(["range", "frame"]), z5.null()]),
|
|
2234
|
+
rangeValue: z5.union([z5.string(), z5.null()]),
|
|
2235
|
+
frameStart: z5.union([z5.string(), z5.null()]),
|
|
2236
|
+
frameEnd: z5.union([z5.string(), z5.null()]),
|
|
2237
|
+
tzUTC: z5.union([z5.boolean(), z5.null()]),
|
|
2238
|
+
chartVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
|
|
2239
|
+
projectId: z5.union([z5.string(), z5.null()]),
|
|
2240
|
+
type: z5.union([z5.enum(["project", "experiment"]), z5.null()]),
|
|
2241
|
+
groupBy: z5.union([z5.string(), z5.null()])
|
|
1285
2242
|
}).partial()
|
|
1286
2243
|
}),
|
|
1287
|
-
|
|
1288
|
-
columnVisibility:
|
|
1289
|
-
columnOrder:
|
|
1290
|
-
columnSizing:
|
|
1291
|
-
grouping:
|
|
1292
|
-
rowHeight:
|
|
1293
|
-
tallGroupRows:
|
|
1294
|
-
layout:
|
|
1295
|
-
chartHeight:
|
|
1296
|
-
excludedMeasures:
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
type:
|
|
1300
|
-
value:
|
|
2244
|
+
z5.object({
|
|
2245
|
+
columnVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
|
|
2246
|
+
columnOrder: z5.union([z5.array(z5.string()), z5.null()]),
|
|
2247
|
+
columnSizing: z5.union([z5.record(z5.number()), z5.null()]),
|
|
2248
|
+
grouping: z5.union([z5.string(), z5.null()]),
|
|
2249
|
+
rowHeight: z5.union([z5.string(), z5.null()]),
|
|
2250
|
+
tallGroupRows: z5.union([z5.boolean(), z5.null()]),
|
|
2251
|
+
layout: z5.union([z5.string(), z5.null()]),
|
|
2252
|
+
chartHeight: z5.union([z5.number(), z5.null()]),
|
|
2253
|
+
excludedMeasures: z5.union([
|
|
2254
|
+
z5.array(
|
|
2255
|
+
z5.object({
|
|
2256
|
+
type: z5.enum(["none", "score", "metric", "metadata"]),
|
|
2257
|
+
value: z5.string()
|
|
1301
2258
|
})
|
|
1302
2259
|
),
|
|
1303
|
-
|
|
2260
|
+
z5.null()
|
|
1304
2261
|
]),
|
|
1305
|
-
yMetric:
|
|
1306
|
-
|
|
1307
|
-
type:
|
|
1308
|
-
value:
|
|
2262
|
+
yMetric: z5.union([
|
|
2263
|
+
z5.object({
|
|
2264
|
+
type: z5.enum(["none", "score", "metric", "metadata"]),
|
|
2265
|
+
value: z5.string()
|
|
1309
2266
|
}),
|
|
1310
|
-
|
|
2267
|
+
z5.null()
|
|
1311
2268
|
]),
|
|
1312
|
-
xAxis:
|
|
1313
|
-
|
|
1314
|
-
type:
|
|
1315
|
-
value:
|
|
2269
|
+
xAxis: z5.union([
|
|
2270
|
+
z5.object({
|
|
2271
|
+
type: z5.enum(["none", "score", "metric", "metadata"]),
|
|
2272
|
+
value: z5.string()
|
|
1316
2273
|
}),
|
|
1317
|
-
|
|
2274
|
+
z5.null()
|
|
1318
2275
|
]),
|
|
1319
|
-
symbolGrouping:
|
|
1320
|
-
|
|
1321
|
-
type:
|
|
1322
|
-
value:
|
|
2276
|
+
symbolGrouping: z5.union([
|
|
2277
|
+
z5.object({
|
|
2278
|
+
type: z5.enum(["none", "score", "metric", "metadata"]),
|
|
2279
|
+
value: z5.string()
|
|
1323
2280
|
}),
|
|
1324
|
-
|
|
2281
|
+
z5.null()
|
|
1325
2282
|
]),
|
|
1326
|
-
xAxisAggregation:
|
|
1327
|
-
chartAnnotations:
|
|
1328
|
-
|
|
1329
|
-
|
|
2283
|
+
xAxisAggregation: z5.union([z5.string(), z5.null()]),
|
|
2284
|
+
chartAnnotations: z5.union([
|
|
2285
|
+
z5.array(z5.object({ id: z5.string(), text: z5.string() })),
|
|
2286
|
+
z5.null()
|
|
1330
2287
|
]),
|
|
1331
|
-
timeRangeFilter:
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
2288
|
+
timeRangeFilter: z5.union([
|
|
2289
|
+
z5.string(),
|
|
2290
|
+
z5.object({ from: z5.string(), to: z5.string() }),
|
|
2291
|
+
z5.null()
|
|
1335
2292
|
])
|
|
1336
2293
|
}).partial(),
|
|
1337
|
-
|
|
2294
|
+
z5.null()
|
|
1338
2295
|
]);
|
|
1339
|
-
var View =
|
|
1340
|
-
id:
|
|
1341
|
-
object_type: AclObjectType.and(
|
|
1342
|
-
object_id:
|
|
1343
|
-
view_type:
|
|
2296
|
+
var View = z5.object({
|
|
2297
|
+
id: z5.string().uuid(),
|
|
2298
|
+
object_type: AclObjectType.and(z5.string()),
|
|
2299
|
+
object_id: z5.string().uuid(),
|
|
2300
|
+
view_type: z5.enum([
|
|
1344
2301
|
"projects",
|
|
1345
2302
|
"experiments",
|
|
1346
2303
|
"experiment",
|
|
@@ -1355,56 +2312,56 @@ var View = z.object({
|
|
|
1355
2312
|
"agents",
|
|
1356
2313
|
"monitor"
|
|
1357
2314
|
]),
|
|
1358
|
-
name:
|
|
1359
|
-
created:
|
|
2315
|
+
name: z5.string(),
|
|
2316
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
1360
2317
|
view_data: ViewData.optional(),
|
|
1361
2318
|
options: ViewOptions.optional(),
|
|
1362
|
-
user_id:
|
|
1363
|
-
deleted_at:
|
|
2319
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
2320
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional()
|
|
1364
2321
|
});
|
|
1365
2322
|
|
|
1366
2323
|
// src/logger.ts
|
|
1367
2324
|
import { waitUntil } from "@vercel/functions";
|
|
1368
2325
|
import Mustache2 from "mustache";
|
|
1369
|
-
import { z as
|
|
2326
|
+
import { z as z7, ZodError } from "zod";
|
|
1370
2327
|
|
|
1371
2328
|
// src/functions/stream.ts
|
|
1372
2329
|
import {
|
|
1373
2330
|
createParser
|
|
1374
2331
|
} from "eventsource-parser";
|
|
1375
|
-
import { z as
|
|
1376
|
-
var braintrustStreamChunkSchema =
|
|
1377
|
-
|
|
1378
|
-
type:
|
|
1379
|
-
data:
|
|
2332
|
+
import { z as z6 } from "zod/v3";
|
|
2333
|
+
var braintrustStreamChunkSchema = z6.union([
|
|
2334
|
+
z6.object({
|
|
2335
|
+
type: z6.literal("text_delta"),
|
|
2336
|
+
data: z6.string()
|
|
1380
2337
|
}),
|
|
1381
|
-
|
|
1382
|
-
type:
|
|
1383
|
-
data:
|
|
2338
|
+
z6.object({
|
|
2339
|
+
type: z6.literal("reasoning_delta"),
|
|
2340
|
+
data: z6.string()
|
|
1384
2341
|
}),
|
|
1385
|
-
|
|
1386
|
-
type:
|
|
1387
|
-
data:
|
|
2342
|
+
z6.object({
|
|
2343
|
+
type: z6.literal("json_delta"),
|
|
2344
|
+
data: z6.string()
|
|
1388
2345
|
}),
|
|
1389
|
-
|
|
1390
|
-
type:
|
|
1391
|
-
data:
|
|
2346
|
+
z6.object({
|
|
2347
|
+
type: z6.literal("error"),
|
|
2348
|
+
data: z6.string()
|
|
1392
2349
|
}),
|
|
1393
|
-
|
|
1394
|
-
type:
|
|
2350
|
+
z6.object({
|
|
2351
|
+
type: z6.literal("console"),
|
|
1395
2352
|
data: SSEConsoleEventData
|
|
1396
2353
|
}),
|
|
1397
|
-
|
|
1398
|
-
type:
|
|
2354
|
+
z6.object({
|
|
2355
|
+
type: z6.literal("progress"),
|
|
1399
2356
|
data: SSEProgressEventData
|
|
1400
2357
|
}),
|
|
1401
|
-
|
|
1402
|
-
type:
|
|
1403
|
-
data:
|
|
2358
|
+
z6.object({
|
|
2359
|
+
type: z6.literal("start"),
|
|
2360
|
+
data: z6.string()
|
|
1404
2361
|
}),
|
|
1405
|
-
|
|
1406
|
-
type:
|
|
1407
|
-
data:
|
|
2362
|
+
z6.object({
|
|
2363
|
+
type: z6.literal("done"),
|
|
2364
|
+
data: z6.string()
|
|
1408
2365
|
})
|
|
1409
2366
|
]);
|
|
1410
2367
|
var BraintrustStream = class _BraintrustStream {
|
|
@@ -1995,7 +2952,6 @@ function objectIsEmpty(obj) {
|
|
|
1995
2952
|
}
|
|
1996
2953
|
|
|
1997
2954
|
// src/mustache-utils.ts
|
|
1998
|
-
import { getObjValueByPath } from "@braintrust/core";
|
|
1999
2955
|
import Mustache from "mustache";
|
|
2000
2956
|
function lintTemplate(template, context) {
|
|
2001
2957
|
const variables = getMustacheVars(template);
|
|
@@ -2018,7 +2974,6 @@ function getMustacheVars(prompt) {
|
|
|
2018
2974
|
}
|
|
2019
2975
|
|
|
2020
2976
|
// src/logger.ts
|
|
2021
|
-
import { prettifyXact } from "@braintrust/core";
|
|
2022
2977
|
var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
|
|
2023
2978
|
var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
|
|
2024
2979
|
var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
|
|
@@ -2106,14 +3061,14 @@ var NoopSpan = class {
|
|
|
2106
3061
|
};
|
|
2107
3062
|
var NOOP_SPAN = new NoopSpan();
|
|
2108
3063
|
var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
|
|
2109
|
-
var loginSchema =
|
|
2110
|
-
appUrl:
|
|
2111
|
-
appPublicUrl:
|
|
2112
|
-
orgName:
|
|
2113
|
-
apiUrl:
|
|
2114
|
-
proxyUrl:
|
|
2115
|
-
loginToken:
|
|
2116
|
-
orgId:
|
|
3064
|
+
var loginSchema = z7.strictObject({
|
|
3065
|
+
appUrl: z7.string(),
|
|
3066
|
+
appPublicUrl: z7.string(),
|
|
3067
|
+
orgName: z7.string(),
|
|
3068
|
+
apiUrl: z7.string(),
|
|
3069
|
+
proxyUrl: z7.string(),
|
|
3070
|
+
loginToken: z7.string(),
|
|
3071
|
+
orgId: z7.string().nullish(),
|
|
2117
3072
|
gitMetadataSettings: GitMetadataSettings.nullish()
|
|
2118
3073
|
});
|
|
2119
3074
|
var stateNonce = 0;
|
|
@@ -2590,9 +3545,9 @@ var Attachment = class extends BaseAttachment {
|
|
|
2590
3545
|
let signedUrl;
|
|
2591
3546
|
let headers;
|
|
2592
3547
|
try {
|
|
2593
|
-
({ signedUrl, headers } =
|
|
2594
|
-
signedUrl:
|
|
2595
|
-
headers:
|
|
3548
|
+
({ signedUrl, headers } = z7.object({
|
|
3549
|
+
signedUrl: z7.string().url(),
|
|
3550
|
+
headers: z7.record(z7.string())
|
|
2596
3551
|
}).parse(await metadataResponse.json()));
|
|
2597
3552
|
} catch (error) {
|
|
2598
3553
|
if (error instanceof ZodError) {
|
|
@@ -2747,8 +3702,8 @@ var ExternalAttachment = class extends BaseAttachment {
|
|
|
2747
3702
|
});
|
|
2748
3703
|
}
|
|
2749
3704
|
};
|
|
2750
|
-
var attachmentMetadataSchema =
|
|
2751
|
-
downloadUrl:
|
|
3705
|
+
var attachmentMetadataSchema = z7.object({
|
|
3706
|
+
downloadUrl: z7.string(),
|
|
2752
3707
|
status: AttachmentStatus
|
|
2753
3708
|
});
|
|
2754
3709
|
var ReadonlyAttachment = class {
|
|
@@ -2960,15 +3915,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
2960
3915
|
);
|
|
2961
3916
|
}
|
|
2962
3917
|
switch (components.data.object_type) {
|
|
2963
|
-
case
|
|
3918
|
+
case 1 /* EXPERIMENT */:
|
|
2964
3919
|
throw new Error(
|
|
2965
3920
|
"Impossible: computeObjectMetadataArgs not supported for experiments"
|
|
2966
3921
|
);
|
|
2967
|
-
case
|
|
3922
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
2968
3923
|
throw new Error(
|
|
2969
3924
|
"Impossible: computeObjectMetadataArgs not supported for prompt sessions"
|
|
2970
3925
|
);
|
|
2971
|
-
case
|
|
3926
|
+
case 2 /* PROJECT_LOGS */:
|
|
2972
3927
|
return async () => (await computeLoggerMetadata(state, {
|
|
2973
3928
|
...components.data.compute_object_metadata_args
|
|
2974
3929
|
})).project.id;
|
|
@@ -3120,7 +4075,7 @@ var Logger = class {
|
|
|
3120
4075
|
return (async () => (await this.project).id)();
|
|
3121
4076
|
}
|
|
3122
4077
|
parentObjectType() {
|
|
3123
|
-
return
|
|
4078
|
+
return 2 /* PROJECT_LOGS */;
|
|
3124
4079
|
}
|
|
3125
4080
|
/**
|
|
3126
4081
|
* Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
|
|
@@ -3214,7 +4169,7 @@ var Logger = class {
|
|
|
3214
4169
|
parentSpanIds: args?.parentSpanIds,
|
|
3215
4170
|
propagatedEvent: args?.propagatedEvent
|
|
3216
4171
|
}),
|
|
3217
|
-
defaultRootType:
|
|
4172
|
+
defaultRootType: "task" /* TASK */
|
|
3218
4173
|
});
|
|
3219
4174
|
}
|
|
3220
4175
|
/**
|
|
@@ -4332,6 +5287,8 @@ function getSpanParentObject(options) {
|
|
|
4332
5287
|
if (!Object.is(parentSpan, NOOP_SPAN)) {
|
|
4333
5288
|
return parentSpan;
|
|
4334
5289
|
}
|
|
5290
|
+
const parentStr = options?.parent ?? state.currentParent.getStore();
|
|
5291
|
+
if (parentStr) return SpanComponentsV3.fromStr(parentStr);
|
|
4335
5292
|
const experiment = currentExperiment();
|
|
4336
5293
|
if (experiment) {
|
|
4337
5294
|
return experiment;
|
|
@@ -4548,35 +5505,35 @@ function setFetch(fetch2) {
|
|
|
4548
5505
|
}
|
|
4549
5506
|
function startSpanAndIsLogger(args) {
|
|
4550
5507
|
const state = args?.state ?? _globalState;
|
|
4551
|
-
const
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
5508
|
+
const parentObject = getSpanParentObject({
|
|
5509
|
+
asyncFlush: args?.asyncFlush,
|
|
5510
|
+
parent: args?.parent,
|
|
5511
|
+
state
|
|
5512
|
+
});
|
|
5513
|
+
if (parentObject instanceof SpanComponentsV3) {
|
|
5514
|
+
const parentSpanIds = parentObject.data.row_id ? {
|
|
5515
|
+
spanId: parentObject.data.span_id,
|
|
5516
|
+
rootSpanId: parentObject.data.root_span_id
|
|
4557
5517
|
} : void 0;
|
|
4558
5518
|
const span = new SpanImpl({
|
|
4559
5519
|
state,
|
|
4560
5520
|
...args,
|
|
4561
|
-
parentObjectType:
|
|
5521
|
+
parentObjectType: parentObject.data.object_type,
|
|
4562
5522
|
parentObjectId: new LazyValue(
|
|
4563
|
-
spanComponentsToObjectIdLambda(state,
|
|
5523
|
+
spanComponentsToObjectIdLambda(state, parentObject)
|
|
4564
5524
|
),
|
|
4565
|
-
parentComputeObjectMetadataArgs:
|
|
5525
|
+
parentComputeObjectMetadataArgs: parentObject.data.compute_object_metadata_args ?? void 0,
|
|
4566
5526
|
parentSpanIds,
|
|
4567
5527
|
propagatedEvent: args?.propagatedEvent ?? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
4568
|
-
(
|
|
5528
|
+
(parentObject.data.propagated_event ?? void 0)
|
|
4569
5529
|
});
|
|
4570
5530
|
return {
|
|
4571
5531
|
span,
|
|
4572
|
-
isSyncFlushLogger:
|
|
5532
|
+
isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
|
|
4573
5533
|
// behavior, and therefore propagate along whatever we get from the arguments
|
|
4574
5534
|
args?.asyncFlush === false
|
|
4575
5535
|
};
|
|
4576
5536
|
} else {
|
|
4577
|
-
const parentObject = getSpanParentObject({
|
|
4578
|
-
asyncFlush: args?.asyncFlush
|
|
4579
|
-
});
|
|
4580
5537
|
const span = parentObject.startSpan(args);
|
|
4581
5538
|
return {
|
|
4582
5539
|
span,
|
|
@@ -4726,7 +5683,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
|
|
|
4726
5683
|
function deepCopyEvent(event) {
|
|
4727
5684
|
const attachments = [];
|
|
4728
5685
|
const IDENTIFIER = "_bt_internal_saved_attachment";
|
|
4729
|
-
const savedAttachmentSchema =
|
|
5686
|
+
const savedAttachmentSchema = z7.strictObject({ [IDENTIFIER]: z7.number() });
|
|
4730
5687
|
const serialized = JSON.stringify(event, (_k, v) => {
|
|
4731
5688
|
if (v instanceof SpanImpl || v instanceof NoopSpan) {
|
|
4732
5689
|
return `<span>`;
|
|
@@ -4961,7 +5918,7 @@ var Experiment2 = class extends ObjectFetcher {
|
|
|
4961
5918
|
})();
|
|
4962
5919
|
}
|
|
4963
5920
|
parentObjectType() {
|
|
4964
|
-
return
|
|
5921
|
+
return 1 /* EXPERIMENT */;
|
|
4965
5922
|
}
|
|
4966
5923
|
async getState() {
|
|
4967
5924
|
await this.lazyMetadata.get();
|
|
@@ -5045,7 +6002,7 @@ var Experiment2 = class extends ObjectFetcher {
|
|
|
5045
6002
|
parentSpanIds: void 0,
|
|
5046
6003
|
propagatedEvent: args?.propagatedEvent
|
|
5047
6004
|
}),
|
|
5048
|
-
defaultRootType:
|
|
6005
|
+
defaultRootType: "eval" /* EVAL */
|
|
5049
6006
|
});
|
|
5050
6007
|
}
|
|
5051
6008
|
async fetchBaseExperiment() {
|
|
@@ -5464,7 +6421,7 @@ var SpanImpl = class _SpanImpl {
|
|
|
5464
6421
|
const baseUrl = `${appUrl}/app/${orgName}`;
|
|
5465
6422
|
const args = this.parentComputeObjectMetadataArgs;
|
|
5466
6423
|
switch (this.parentObjectType) {
|
|
5467
|
-
case
|
|
6424
|
+
case 2 /* PROJECT_LOGS */: {
|
|
5468
6425
|
const projectID = args?.project_id || this.parentObjectId.getSync().value;
|
|
5469
6426
|
const projectName = args?.project_name;
|
|
5470
6427
|
if (projectID) {
|
|
@@ -5475,7 +6432,7 @@ var SpanImpl = class _SpanImpl {
|
|
|
5475
6432
|
return getErrPermlink("provide-project-name-or-id");
|
|
5476
6433
|
}
|
|
5477
6434
|
}
|
|
5478
|
-
case
|
|
6435
|
+
case 1 /* EXPERIMENT */: {
|
|
5479
6436
|
const expID = args?.experiment_id || this.parentObjectId?.getSync()?.value;
|
|
5480
6437
|
if (!expID) {
|
|
5481
6438
|
return getErrPermlink("provide-experiment-id");
|
|
@@ -5483,7 +6440,7 @@ var SpanImpl = class _SpanImpl {
|
|
|
5483
6440
|
return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
|
|
5484
6441
|
}
|
|
5485
6442
|
}
|
|
5486
|
-
case
|
|
6443
|
+
case 3 /* PLAYGROUND_LOGS */: {
|
|
5487
6444
|
return NOOP_SPAN_PERMALINK;
|
|
5488
6445
|
}
|
|
5489
6446
|
default: {
|
|
@@ -5731,8 +6688,8 @@ var Dataset2 = class extends ObjectFetcher {
|
|
|
5731
6688
|
)}`;
|
|
5732
6689
|
let dataSummary;
|
|
5733
6690
|
if (summarizeData) {
|
|
5734
|
-
const rawDataSummary =
|
|
5735
|
-
total_records:
|
|
6691
|
+
const rawDataSummary = z7.object({
|
|
6692
|
+
total_records: z7.number()
|
|
5736
6693
|
}).parse(
|
|
5737
6694
|
await state.apiConn().get_json(
|
|
5738
6695
|
"dataset-summary",
|
|
@@ -5855,11 +6812,11 @@ function renderTemplatedObject(obj, args, options) {
|
|
|
5855
6812
|
return obj;
|
|
5856
6813
|
}
|
|
5857
6814
|
function renderPromptParams(params, args, options) {
|
|
5858
|
-
const schemaParsed =
|
|
5859
|
-
response_format:
|
|
5860
|
-
type:
|
|
6815
|
+
const schemaParsed = z7.object({
|
|
6816
|
+
response_format: z7.object({
|
|
6817
|
+
type: z7.literal("json_schema"),
|
|
5861
6818
|
json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
|
|
5862
|
-
schema:
|
|
6819
|
+
schema: z7.unknown()
|
|
5863
6820
|
})
|
|
5864
6821
|
})
|
|
5865
6822
|
}).safeParse(params);
|
|
@@ -5977,7 +6934,7 @@ var Prompt2 = class _Prompt {
|
|
|
5977
6934
|
if (!prompt) {
|
|
5978
6935
|
throw new Error("Empty prompt");
|
|
5979
6936
|
}
|
|
5980
|
-
const dictArgParsed =
|
|
6937
|
+
const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
|
|
5981
6938
|
const variables = {
|
|
5982
6939
|
input: buildArgs,
|
|
5983
6940
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -6032,7 +6989,7 @@ var Prompt2 = class _Prompt {
|
|
|
6032
6989
|
return JSON.stringify(v);
|
|
6033
6990
|
}
|
|
6034
6991
|
};
|
|
6035
|
-
const dictArgParsed =
|
|
6992
|
+
const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
|
|
6036
6993
|
const variables = {
|
|
6037
6994
|
input: buildArgs,
|
|
6038
6995
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -6380,12 +7337,7 @@ function initFunction({
|
|
|
6380
7337
|
return f;
|
|
6381
7338
|
}
|
|
6382
7339
|
|
|
6383
|
-
// src/wrappers/oai.ts
|
|
6384
|
-
import { SpanTypeAttribute as SpanTypeAttribute2 } from "@braintrust/core";
|
|
6385
|
-
import { mergeDicts as mergeDicts2 } from "@braintrust/core";
|
|
6386
|
-
|
|
6387
7340
|
// src/wrappers/oai_responses.ts
|
|
6388
|
-
import { isObject as isObject2 } from "@braintrust/core";
|
|
6389
7341
|
function responsesProxy(openai) {
|
|
6390
7342
|
if (!openai.responses) {
|
|
6391
7343
|
return openai;
|
|
@@ -6583,7 +7535,7 @@ function parseMetricsFromUsage(usage) {
|
|
|
6583
7535
|
const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
|
|
6584
7536
|
metrics[metricName] = value;
|
|
6585
7537
|
} else if (oai_name.endsWith("_tokens_details")) {
|
|
6586
|
-
if (!
|
|
7538
|
+
if (!isObject(value)) {
|
|
6587
7539
|
continue;
|
|
6588
7540
|
}
|
|
6589
7541
|
const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
|
|
@@ -6765,11 +7717,11 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
6765
7717
|
return async (allParams) => {
|
|
6766
7718
|
const { span_info: _, ...params } = allParams;
|
|
6767
7719
|
const span = startSpan(
|
|
6768
|
-
|
|
7720
|
+
mergeDicts(
|
|
6769
7721
|
{
|
|
6770
7722
|
name: "Chat Completion",
|
|
6771
7723
|
spanAttributes: {
|
|
6772
|
-
type:
|
|
7724
|
+
type: "llm" /* LLM */
|
|
6773
7725
|
}
|
|
6774
7726
|
},
|
|
6775
7727
|
parseChatCompletionParams(allParams)
|
|
@@ -6789,11 +7741,11 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
6789
7741
|
return (allParams) => {
|
|
6790
7742
|
const { span_info: _, ...params } = allParams;
|
|
6791
7743
|
const span = startSpan(
|
|
6792
|
-
|
|
7744
|
+
mergeDicts(
|
|
6793
7745
|
{
|
|
6794
7746
|
name: "Chat Completion",
|
|
6795
7747
|
spanAttributes: {
|
|
6796
|
-
type:
|
|
7748
|
+
type: "llm" /* LLM */
|
|
6797
7749
|
}
|
|
6798
7750
|
},
|
|
6799
7751
|
parseChatCompletionParams(allParams)
|
|
@@ -6852,15 +7804,16 @@ function wrapChatCompletion(completion) {
|
|
|
6852
7804
|
return (allParams, options) => {
|
|
6853
7805
|
const { span_info: _, ...params } = allParams;
|
|
6854
7806
|
let executionPromise = null;
|
|
6855
|
-
|
|
7807
|
+
let dataPromise = null;
|
|
7808
|
+
const ensureExecuted = () => {
|
|
6856
7809
|
if (!executionPromise) {
|
|
6857
7810
|
executionPromise = (async () => {
|
|
6858
7811
|
const span = startSpan(
|
|
6859
|
-
|
|
7812
|
+
mergeDicts(
|
|
6860
7813
|
{
|
|
6861
7814
|
name: "Chat Completion",
|
|
6862
7815
|
spanAttributes: {
|
|
6863
|
-
type:
|
|
7816
|
+
type: "llm" /* LLM */
|
|
6864
7817
|
}
|
|
6865
7818
|
},
|
|
6866
7819
|
parseChatCompletionParams(allParams)
|
|
@@ -6910,17 +7863,19 @@ function wrapChatCompletion(completion) {
|
|
|
6910
7863
|
}
|
|
6911
7864
|
return executionPromise;
|
|
6912
7865
|
};
|
|
6913
|
-
|
|
6914
|
-
return new Proxy(dataPromise, {
|
|
7866
|
+
return new Proxy({}, {
|
|
6915
7867
|
get(target, prop, receiver) {
|
|
6916
7868
|
if (prop === "withResponse") {
|
|
6917
|
-
return
|
|
7869
|
+
return () => ensureExecuted();
|
|
6918
7870
|
}
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
7871
|
+
if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
|
|
7872
|
+
if (!dataPromise) {
|
|
7873
|
+
dataPromise = ensureExecuted().then((result) => result.data);
|
|
7874
|
+
}
|
|
7875
|
+
const value = Reflect.get(dataPromise, prop, receiver);
|
|
7876
|
+
return typeof value === "function" ? value.bind(dataPromise) : value;
|
|
6922
7877
|
}
|
|
6923
|
-
return
|
|
7878
|
+
return Reflect.get(target, prop, receiver);
|
|
6924
7879
|
}
|
|
6925
7880
|
});
|
|
6926
7881
|
};
|
|
@@ -6937,7 +7892,7 @@ function parseBaseParams(allParams, inputField) {
|
|
|
6937
7892
|
const input = params[inputField];
|
|
6938
7893
|
const paramsRest = { ...params, provider: "openai" };
|
|
6939
7894
|
delete paramsRest[inputField];
|
|
6940
|
-
return
|
|
7895
|
+
return mergeDicts(ret, { event: { input, metadata: paramsRest } });
|
|
6941
7896
|
}
|
|
6942
7897
|
function createApiWrapper(name, create, processResponse, parseParams) {
|
|
6943
7898
|
return async (allParams, options) => {
|
|
@@ -6952,11 +7907,11 @@ function createApiWrapper(name, create, processResponse, parseParams) {
|
|
|
6952
7907
|
processResponse(result, span);
|
|
6953
7908
|
return result;
|
|
6954
7909
|
},
|
|
6955
|
-
|
|
7910
|
+
mergeDicts(
|
|
6956
7911
|
{
|
|
6957
7912
|
name,
|
|
6958
7913
|
spanAttributes: {
|
|
6959
|
-
type:
|
|
7914
|
+
type: "llm" /* LLM */
|
|
6960
7915
|
}
|
|
6961
7916
|
},
|
|
6962
7917
|
parseParams(allParams)
|
|
@@ -7095,44 +8050,44 @@ var WrapperStream = class {
|
|
|
7095
8050
|
};
|
|
7096
8051
|
|
|
7097
8052
|
// dev/types.ts
|
|
7098
|
-
import { z as
|
|
7099
|
-
var evalBodySchema =
|
|
7100
|
-
name:
|
|
7101
|
-
parameters:
|
|
8053
|
+
import { z as z8 } from "zod/v3";
|
|
8054
|
+
var evalBodySchema = z8.object({
|
|
8055
|
+
name: z8.string(),
|
|
8056
|
+
parameters: z8.record(z8.string(), z8.unknown()).nullish(),
|
|
7102
8057
|
data: RunEval.shape.data,
|
|
7103
|
-
scores:
|
|
7104
|
-
|
|
8058
|
+
scores: z8.array(
|
|
8059
|
+
z8.object({
|
|
7105
8060
|
function_id: FunctionId,
|
|
7106
|
-
name:
|
|
8061
|
+
name: z8.string()
|
|
7107
8062
|
})
|
|
7108
8063
|
).nullish(),
|
|
7109
|
-
experiment_name:
|
|
7110
|
-
project_id:
|
|
8064
|
+
experiment_name: z8.string().nullish(),
|
|
8065
|
+
project_id: z8.string().nullish(),
|
|
7111
8066
|
parent: InvokeParent.optional(),
|
|
7112
|
-
stream:
|
|
8067
|
+
stream: z8.boolean().optional()
|
|
7113
8068
|
});
|
|
7114
|
-
var evalParametersSerializedSchema =
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
type:
|
|
8069
|
+
var evalParametersSerializedSchema = z8.record(
|
|
8070
|
+
z8.string(),
|
|
8071
|
+
z8.union([
|
|
8072
|
+
z8.object({
|
|
8073
|
+
type: z8.literal("prompt"),
|
|
7119
8074
|
default: PromptData.optional(),
|
|
7120
|
-
description:
|
|
8075
|
+
description: z8.string().optional()
|
|
7121
8076
|
}),
|
|
7122
|
-
|
|
7123
|
-
type:
|
|
7124
|
-
schema:
|
|
8077
|
+
z8.object({
|
|
8078
|
+
type: z8.literal("data"),
|
|
8079
|
+
schema: z8.record(z8.unknown()),
|
|
7125
8080
|
// JSON Schema
|
|
7126
|
-
default:
|
|
7127
|
-
description:
|
|
8081
|
+
default: z8.unknown().optional(),
|
|
8082
|
+
description: z8.string().optional()
|
|
7128
8083
|
})
|
|
7129
8084
|
])
|
|
7130
8085
|
);
|
|
7131
|
-
var evaluatorDefinitionSchema =
|
|
8086
|
+
var evaluatorDefinitionSchema = z8.object({
|
|
7132
8087
|
parameters: evalParametersSerializedSchema.optional()
|
|
7133
8088
|
});
|
|
7134
|
-
var evaluatorDefinitionsSchema =
|
|
7135
|
-
|
|
8089
|
+
var evaluatorDefinitionsSchema = z8.record(
|
|
8090
|
+
z8.string(),
|
|
7136
8091
|
evaluatorDefinitionSchema
|
|
7137
8092
|
);
|
|
7138
8093
|
|