braintrust 0.3.6 → 0.3.8
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 +234 -16
- package/dev/dist/index.d.ts +234 -16
- package/dev/dist/index.js +2192 -1134
- package/dev/dist/index.mjs +2148 -1090
- package/dist/browser.d.mts +339 -39
- package/dist/browser.d.ts +339 -39
- package/dist/browser.js +2170 -1114
- package/dist/browser.mjs +2105 -1049
- package/dist/cli.js +2326 -1219
- package/dist/index.d.mts +403 -28
- package/dist/index.d.ts +403 -28
- package/dist/index.js +2799 -1233
- package/dist/index.mjs +2711 -1145
- package/package.json +15 -9
- 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/dev/dist/index.js
CHANGED
|
@@ -245,7 +245,7 @@ function getCallerLocation() {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
// src/logger.ts
|
|
248
|
-
var _uuid = require('uuid');
|
|
248
|
+
var _uuid = require('uuid'); var uuid3 = _interopRequireWildcard(_uuid); var uuid2 = _interopRequireWildcard(_uuid); var uuid = _interopRequireWildcard(_uuid);
|
|
249
249
|
|
|
250
250
|
// src/queue.ts
|
|
251
251
|
var DEFAULT_QUEUE_SIZE = 15e3;
|
|
@@ -303,33 +303,1014 @@ var Queue = (_class = class {
|
|
|
303
303
|
}
|
|
304
304
|
}, _class);
|
|
305
305
|
|
|
306
|
-
//
|
|
306
|
+
// util/db_fields.ts
|
|
307
|
+
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
308
|
+
var IS_MERGE_FIELD = "_is_merge";
|
|
309
|
+
var AUDIT_SOURCE_FIELD = "_audit_source";
|
|
310
|
+
var AUDIT_METADATA_FIELD = "_audit_metadata";
|
|
311
|
+
var VALID_SOURCES = ["app", "api", "external"];
|
|
312
|
+
var PARENT_ID_FIELD = "_parent_id";
|
|
307
313
|
|
|
314
|
+
// util/span_identifier_v3.ts
|
|
308
315
|
|
|
309
316
|
|
|
317
|
+
// util/span_identifier_v2.ts
|
|
310
318
|
|
|
311
319
|
|
|
320
|
+
// util/span_identifier_v1.ts
|
|
312
321
|
|
|
322
|
+
var _v3 = require('zod/v3');
|
|
323
|
+
function tryMakeUuid(s) {
|
|
324
|
+
try {
|
|
325
|
+
const ret = uuid.parse(s);
|
|
326
|
+
if (ret.length !== 16) {
|
|
327
|
+
throw new Error();
|
|
328
|
+
}
|
|
329
|
+
return { bytes: Buffer.from(ret), isUUID: true };
|
|
330
|
+
} catch (e) {
|
|
331
|
+
return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
var ENCODING_VERSION_NUMBER = 1;
|
|
335
|
+
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";
|
|
336
|
+
var SpanObjectTypeV1 = /* @__PURE__ */ ((SpanObjectTypeV12) => {
|
|
337
|
+
SpanObjectTypeV12[SpanObjectTypeV12["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
338
|
+
SpanObjectTypeV12[SpanObjectTypeV12["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
339
|
+
return SpanObjectTypeV12;
|
|
340
|
+
})(SpanObjectTypeV1 || {});
|
|
341
|
+
var SpanObjectTypeV1EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV1);
|
|
342
|
+
var SpanRowIdsV1 = class {
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
constructor(args) {
|
|
347
|
+
this.rowId = args.rowId;
|
|
348
|
+
this.spanId = args.spanId;
|
|
349
|
+
this.rootSpanId = args.rootSpanId;
|
|
350
|
+
if (!this.rowId) {
|
|
351
|
+
throw new Error("rowId must be nonempty string");
|
|
352
|
+
}
|
|
353
|
+
if (!this.spanId) {
|
|
354
|
+
throw new Error("spanId must be nonempty string");
|
|
355
|
+
}
|
|
356
|
+
if (!this.rootSpanId) {
|
|
357
|
+
throw new Error("rootSpanId must be nonempty string");
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
toObject() {
|
|
361
|
+
return {
|
|
362
|
+
rowId: this.rowId,
|
|
363
|
+
spanId: this.spanId,
|
|
364
|
+
rootSpanId: this.rootSpanId
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
var SpanComponentsV1 = class _SpanComponentsV1 {
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
constructor(args) {
|
|
373
|
+
this.objectType = args.objectType;
|
|
374
|
+
this.objectId = args.objectId;
|
|
375
|
+
this.rowIds = args.rowIds;
|
|
376
|
+
}
|
|
377
|
+
toStr() {
|
|
378
|
+
const allBuffers = [];
|
|
379
|
+
const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
|
|
380
|
+
allBuffers.push(
|
|
381
|
+
Buffer.from([
|
|
382
|
+
ENCODING_VERSION_NUMBER,
|
|
383
|
+
this.objectType,
|
|
384
|
+
this.rowIds ? 1 : 0,
|
|
385
|
+
rowIdIsUUID ? 1 : 0
|
|
386
|
+
])
|
|
387
|
+
);
|
|
388
|
+
const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid(
|
|
389
|
+
this.objectId
|
|
390
|
+
);
|
|
391
|
+
if (!objectIdIsUUID) {
|
|
392
|
+
throw new Error("object_id component must be a valid UUID");
|
|
393
|
+
}
|
|
394
|
+
allBuffers.push(objectIdBytes);
|
|
395
|
+
if (this.rowIds) {
|
|
396
|
+
const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid(
|
|
397
|
+
this.rowIds.spanId
|
|
398
|
+
);
|
|
399
|
+
if (!spanIdIsUUID) {
|
|
400
|
+
throw new Error("span_id component must be a valid UUID");
|
|
401
|
+
}
|
|
402
|
+
const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid(
|
|
403
|
+
this.rowIds.rootSpanId
|
|
404
|
+
);
|
|
405
|
+
if (!rootSpanIdIsUUID) {
|
|
406
|
+
throw new Error("root_span_id component must be a valid UUID");
|
|
407
|
+
}
|
|
408
|
+
allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
|
|
409
|
+
}
|
|
410
|
+
return Buffer.concat(allBuffers).toString("base64");
|
|
411
|
+
}
|
|
412
|
+
static fromStr(s) {
|
|
413
|
+
try {
|
|
414
|
+
const rawBytes = Buffer.from(s, "base64");
|
|
415
|
+
if (rawBytes[0] !== ENCODING_VERSION_NUMBER) {
|
|
416
|
+
throw new Error();
|
|
417
|
+
}
|
|
418
|
+
const objectType = SpanObjectTypeV1EnumSchema.parse(rawBytes[1]);
|
|
419
|
+
if (![0, 1].includes(rawBytes[2])) {
|
|
420
|
+
throw new Error();
|
|
421
|
+
}
|
|
422
|
+
if (![0, 1].includes(rawBytes[3])) {
|
|
423
|
+
throw new Error();
|
|
424
|
+
}
|
|
425
|
+
const hasRowId = rawBytes[2] == 1;
|
|
426
|
+
const rowIdIsUUID = rawBytes[3] == 1;
|
|
427
|
+
const objectId = uuid.stringify(rawBytes.subarray(4, 20));
|
|
428
|
+
const rowIds = (() => {
|
|
429
|
+
if (!hasRowId) {
|
|
430
|
+
return void 0;
|
|
431
|
+
}
|
|
432
|
+
const spanId = uuid.stringify(rawBytes.subarray(20, 36));
|
|
433
|
+
const rootSpanId = uuid.stringify(rawBytes.subarray(36, 52));
|
|
434
|
+
const rowId = rowIdIsUUID ? uuid.stringify(rawBytes.subarray(52)) : rawBytes.subarray(52).toString("utf-8");
|
|
435
|
+
return new SpanRowIdsV1({ rowId, spanId, rootSpanId });
|
|
436
|
+
})();
|
|
437
|
+
return new _SpanComponentsV1({ objectType, objectId, rowIds });
|
|
438
|
+
} catch (e) {
|
|
439
|
+
throw new Error(INVALID_ENCODING_ERRMSG);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
objectIdFields() {
|
|
443
|
+
switch (this.objectType) {
|
|
444
|
+
case 1 /* EXPERIMENT */:
|
|
445
|
+
return { experiment_id: this.objectId };
|
|
446
|
+
case 2 /* PROJECT_LOGS */:
|
|
447
|
+
return { project_id: this.objectId, log_id: "g" };
|
|
448
|
+
default:
|
|
449
|
+
throw new Error("Impossible");
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
toObject() {
|
|
453
|
+
return {
|
|
454
|
+
objectType: this.objectType,
|
|
455
|
+
objectId: this.objectId,
|
|
456
|
+
rowIds: _optionalChain([this, 'access', _11 => _11.rowIds, 'optionalAccess', _12 => _12.toObject, 'call', _13 => _13()])
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
};
|
|
313
460
|
|
|
461
|
+
// util/span_identifier_v2.ts
|
|
314
462
|
|
|
463
|
+
function tryMakeUuid2(s) {
|
|
464
|
+
try {
|
|
465
|
+
const ret = uuid2.parse(s);
|
|
466
|
+
if (ret.length !== 16) {
|
|
467
|
+
throw new Error();
|
|
468
|
+
}
|
|
469
|
+
return { bytes: Buffer.from(ret), isUUID: true };
|
|
470
|
+
} catch (e) {
|
|
471
|
+
return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
var ENCODING_VERSION_NUMBER2 = 2;
|
|
475
|
+
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.`;
|
|
476
|
+
var INTEGER_ENCODING_NUM_BYTES = 4;
|
|
477
|
+
var SpanObjectTypeV2 = /* @__PURE__ */ ((SpanObjectTypeV22) => {
|
|
478
|
+
SpanObjectTypeV22[SpanObjectTypeV22["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
479
|
+
SpanObjectTypeV22[SpanObjectTypeV22["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
480
|
+
return SpanObjectTypeV22;
|
|
481
|
+
})(SpanObjectTypeV2 || {});
|
|
482
|
+
var SpanObjectTypeV2EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV2);
|
|
483
|
+
var SpanRowIdsV2 = class {
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
constructor(args) {
|
|
488
|
+
this.rowId = args.rowId;
|
|
489
|
+
this.spanId = args.spanId;
|
|
490
|
+
this.rootSpanId = args.rootSpanId;
|
|
491
|
+
if (!this.rowId) {
|
|
492
|
+
throw new Error("rowId must be nonempty string");
|
|
493
|
+
}
|
|
494
|
+
if (!this.spanId) {
|
|
495
|
+
throw new Error("spanId must be nonempty string");
|
|
496
|
+
}
|
|
497
|
+
if (!this.rootSpanId) {
|
|
498
|
+
throw new Error("rootSpanId must be nonempty string");
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
toObject() {
|
|
502
|
+
return {
|
|
503
|
+
rowId: this.rowId,
|
|
504
|
+
spanId: this.spanId,
|
|
505
|
+
rootSpanId: this.rootSpanId
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
var SpanComponentsV2 = class _SpanComponentsV2 {
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
constructor(args) {
|
|
515
|
+
this.objectType = args.objectType;
|
|
516
|
+
this.objectId = args.objectId;
|
|
517
|
+
this.computeObjectMetadataArgs = args.computeObjectMetadataArgs;
|
|
518
|
+
this.rowIds = args.rowIds;
|
|
519
|
+
if (!(this.objectId || this.computeObjectMetadataArgs)) {
|
|
520
|
+
throw new Error(
|
|
521
|
+
"Must provide either objectId or computeObjectMetadataArgs"
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
toStr() {
|
|
526
|
+
const allBuffers = [];
|
|
527
|
+
const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid2(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
|
|
528
|
+
allBuffers.push(
|
|
529
|
+
Buffer.from([
|
|
530
|
+
ENCODING_VERSION_NUMBER2,
|
|
531
|
+
this.objectType,
|
|
532
|
+
this.objectId ? 1 : 0,
|
|
533
|
+
this.computeObjectMetadataArgs ? 1 : 0,
|
|
534
|
+
this.rowIds ? 1 : 0,
|
|
535
|
+
rowIdIsUUID ? 1 : 0
|
|
536
|
+
])
|
|
537
|
+
);
|
|
538
|
+
if (this.objectId) {
|
|
539
|
+
const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid2(
|
|
540
|
+
this.objectId
|
|
541
|
+
);
|
|
542
|
+
if (!objectIdIsUUID) {
|
|
543
|
+
throw new Error("object_id component must be a valid UUID");
|
|
544
|
+
}
|
|
545
|
+
allBuffers.push(objectIdBytes);
|
|
546
|
+
}
|
|
547
|
+
if (this.computeObjectMetadataArgs) {
|
|
548
|
+
const computeObjectMetadataBytes = Buffer.from(
|
|
549
|
+
JSON.stringify(this.computeObjectMetadataArgs),
|
|
550
|
+
"utf-8"
|
|
551
|
+
);
|
|
552
|
+
const serializedLenBytes = Buffer.alloc(INTEGER_ENCODING_NUM_BYTES);
|
|
553
|
+
serializedLenBytes.writeInt32BE(computeObjectMetadataBytes.length);
|
|
554
|
+
allBuffers.push(serializedLenBytes, computeObjectMetadataBytes);
|
|
555
|
+
}
|
|
556
|
+
if (this.rowIds) {
|
|
557
|
+
const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid2(
|
|
558
|
+
this.rowIds.spanId
|
|
559
|
+
);
|
|
560
|
+
if (!spanIdIsUUID) {
|
|
561
|
+
throw new Error("span_id component must be a valid UUID");
|
|
562
|
+
}
|
|
563
|
+
const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid2(
|
|
564
|
+
this.rowIds.rootSpanId
|
|
565
|
+
);
|
|
566
|
+
if (!rootSpanIdIsUUID) {
|
|
567
|
+
throw new Error("root_span_id component must be a valid UUID");
|
|
568
|
+
}
|
|
569
|
+
allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
|
|
570
|
+
}
|
|
571
|
+
return Buffer.concat(allBuffers).toString("base64");
|
|
572
|
+
}
|
|
573
|
+
static fromStr(s) {
|
|
574
|
+
try {
|
|
575
|
+
const rawBytes = Buffer.from(s, "base64");
|
|
576
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER2) {
|
|
577
|
+
const spanComponentsOld = SpanComponentsV1.fromStr(s);
|
|
578
|
+
return new _SpanComponentsV2({
|
|
579
|
+
objectType: SpanObjectTypeV2EnumSchema.parse(
|
|
580
|
+
spanComponentsOld.objectType
|
|
581
|
+
),
|
|
582
|
+
objectId: spanComponentsOld.objectId,
|
|
583
|
+
rowIds: spanComponentsOld.rowIds ? new SpanRowIdsV2({
|
|
584
|
+
rowId: spanComponentsOld.rowIds.rowId,
|
|
585
|
+
spanId: spanComponentsOld.rowIds.spanId,
|
|
586
|
+
rootSpanId: spanComponentsOld.rowIds.rootSpanId
|
|
587
|
+
}) : void 0
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
if (rawBytes[0] !== ENCODING_VERSION_NUMBER2) {
|
|
591
|
+
throw new Error();
|
|
592
|
+
}
|
|
593
|
+
const objectType = SpanObjectTypeV2EnumSchema.parse(rawBytes[1]);
|
|
594
|
+
for (let i = 2; i < 6; ++i) {
|
|
595
|
+
if (![0, 1].includes(rawBytes[i])) {
|
|
596
|
+
throw new Error();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
const hasObjectId = rawBytes[2] == 1;
|
|
600
|
+
const hasComputeObjectMetadataArgs = rawBytes[3] == 1;
|
|
601
|
+
const hasRowId = rawBytes[4] == 1;
|
|
602
|
+
const rowIdIsUUID = rawBytes[5] == 1;
|
|
603
|
+
let byteCursor = 6;
|
|
604
|
+
let objectId = void 0;
|
|
605
|
+
if (hasObjectId) {
|
|
606
|
+
const nextByteCursor = byteCursor + 16;
|
|
607
|
+
objectId = uuid2.stringify(
|
|
608
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
609
|
+
);
|
|
610
|
+
byteCursor = nextByteCursor;
|
|
611
|
+
}
|
|
612
|
+
let computeObjectMetadataArgs;
|
|
613
|
+
if (hasComputeObjectMetadataArgs) {
|
|
614
|
+
let nextByteCursor = byteCursor + INTEGER_ENCODING_NUM_BYTES;
|
|
615
|
+
const serializedLenBytes = rawBytes.readInt32BE(byteCursor);
|
|
616
|
+
byteCursor = nextByteCursor;
|
|
617
|
+
nextByteCursor = byteCursor + serializedLenBytes;
|
|
618
|
+
computeObjectMetadataArgs = JSON.parse(
|
|
619
|
+
rawBytes.subarray(byteCursor, nextByteCursor).toString("utf-8")
|
|
620
|
+
);
|
|
621
|
+
byteCursor = nextByteCursor;
|
|
622
|
+
}
|
|
623
|
+
const rowIds = (() => {
|
|
624
|
+
if (!hasRowId) {
|
|
625
|
+
return void 0;
|
|
626
|
+
}
|
|
627
|
+
let nextByteCursor = byteCursor + 16;
|
|
628
|
+
const spanId = uuid2.stringify(
|
|
629
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
630
|
+
);
|
|
631
|
+
byteCursor = nextByteCursor;
|
|
632
|
+
nextByteCursor = byteCursor + 16;
|
|
633
|
+
const rootSpanId = uuid2.stringify(
|
|
634
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
635
|
+
);
|
|
636
|
+
byteCursor = nextByteCursor;
|
|
637
|
+
const rowId = rowIdIsUUID ? uuid2.stringify(rawBytes.subarray(byteCursor)) : rawBytes.subarray(byteCursor).toString("utf-8");
|
|
638
|
+
return new SpanRowIdsV2({ rowId, spanId, rootSpanId });
|
|
639
|
+
})();
|
|
640
|
+
return new _SpanComponentsV2({
|
|
641
|
+
objectType,
|
|
642
|
+
objectId,
|
|
643
|
+
computeObjectMetadataArgs,
|
|
644
|
+
rowIds
|
|
645
|
+
});
|
|
646
|
+
} catch (e) {
|
|
647
|
+
throw new Error(INVALID_ENCODING_ERRMSG2);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
objectIdFields() {
|
|
651
|
+
if (!this.objectId) {
|
|
652
|
+
throw new Error(
|
|
653
|
+
"Impossible: cannot invoke `object_id_fields` unless SpanComponentsV2 is initialized with an `object_id`"
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
switch (this.objectType) {
|
|
657
|
+
case 1 /* EXPERIMENT */:
|
|
658
|
+
return { experiment_id: this.objectId };
|
|
659
|
+
case 2 /* PROJECT_LOGS */:
|
|
660
|
+
return { project_id: this.objectId, log_id: "g" };
|
|
661
|
+
default:
|
|
662
|
+
throw new Error("Impossible");
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
toObject() {
|
|
666
|
+
return {
|
|
667
|
+
objectType: this.objectType,
|
|
668
|
+
objectId: this.objectId,
|
|
669
|
+
computeObjectMetadataArgs: this.computeObjectMetadataArgs,
|
|
670
|
+
rowIds: _optionalChain([this, 'access', _14 => _14.rowIds, 'optionalAccess', _15 => _15.toObject, 'call', _16 => _16()])
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
};
|
|
315
674
|
|
|
675
|
+
// util/span_identifier_v3.ts
|
|
316
676
|
|
|
317
677
|
|
|
678
|
+
// util/bytes.ts
|
|
679
|
+
function concatUint8Arrays(...arrays) {
|
|
680
|
+
const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
|
|
681
|
+
const result = new Uint8Array(totalLength);
|
|
682
|
+
let offset = 0;
|
|
683
|
+
for (const arr of arrays) {
|
|
684
|
+
result.set(arr, offset);
|
|
685
|
+
offset += arr.length;
|
|
686
|
+
}
|
|
687
|
+
return result;
|
|
688
|
+
}
|
|
689
|
+
function uint8ArrayToBase64(uint8Array) {
|
|
690
|
+
let binary = "";
|
|
691
|
+
for (let i = 0; i < uint8Array.length; i++) {
|
|
692
|
+
binary += String.fromCharCode(uint8Array[i]);
|
|
693
|
+
}
|
|
694
|
+
return btoa(binary);
|
|
695
|
+
}
|
|
696
|
+
function base64ToUint8Array(base64) {
|
|
697
|
+
const binary = atob(base64);
|
|
698
|
+
const uint8Array = new Uint8Array(binary.length);
|
|
699
|
+
for (let i = 0; i < binary.length; i++) {
|
|
700
|
+
uint8Array[i] = binary.charCodeAt(i);
|
|
701
|
+
}
|
|
702
|
+
return uint8Array;
|
|
703
|
+
}
|
|
704
|
+
function uint8ArrayToString(uint8Array) {
|
|
705
|
+
const decoder = new TextDecoder("utf-8");
|
|
706
|
+
return decoder.decode(uint8Array);
|
|
707
|
+
}
|
|
708
|
+
function stringToUint8Array(str) {
|
|
709
|
+
const encoder = new TextEncoder();
|
|
710
|
+
return encoder.encode(str);
|
|
711
|
+
}
|
|
318
712
|
|
|
713
|
+
// util/span_identifier_v3.ts
|
|
714
|
+
function tryMakeUuid3(s) {
|
|
715
|
+
try {
|
|
716
|
+
const ret = uuid3.parse(s);
|
|
717
|
+
if (ret.length !== 16) {
|
|
718
|
+
throw new Error();
|
|
719
|
+
}
|
|
720
|
+
return { bytes: new Uint8Array(ret), isUUID: true };
|
|
721
|
+
} catch (e3) {
|
|
722
|
+
return { bytes: void 0, isUUID: false };
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
var ENCODING_VERSION_NUMBER3 = 3;
|
|
726
|
+
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.`;
|
|
727
|
+
var SpanObjectTypeV3 = /* @__PURE__ */ ((SpanObjectTypeV32) => {
|
|
728
|
+
SpanObjectTypeV32[SpanObjectTypeV32["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
729
|
+
SpanObjectTypeV32[SpanObjectTypeV32["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
730
|
+
SpanObjectTypeV32[SpanObjectTypeV32["PLAYGROUND_LOGS"] = 3] = "PLAYGROUND_LOGS";
|
|
731
|
+
return SpanObjectTypeV32;
|
|
732
|
+
})(SpanObjectTypeV3 || {});
|
|
733
|
+
var spanObjectTypeV3EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV3);
|
|
734
|
+
function spanObjectTypeV3ToString(objectType) {
|
|
735
|
+
switch (objectType) {
|
|
736
|
+
case 1 /* EXPERIMENT */:
|
|
737
|
+
return "experiment";
|
|
738
|
+
case 2 /* PROJECT_LOGS */:
|
|
739
|
+
return "project_logs";
|
|
740
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
741
|
+
return "playground_logs";
|
|
742
|
+
default:
|
|
743
|
+
const x = objectType;
|
|
744
|
+
throw new Error(`Unknown SpanObjectTypeV3: ${x}`);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
var InternalSpanComponentUUIDFields = /* @__PURE__ */ ((InternalSpanComponentUUIDFields2) => {
|
|
748
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["OBJECT_ID"] = 1] = "OBJECT_ID";
|
|
749
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROW_ID"] = 2] = "ROW_ID";
|
|
750
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["SPAN_ID"] = 3] = "SPAN_ID";
|
|
751
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROOT_SPAN_ID"] = 4] = "ROOT_SPAN_ID";
|
|
752
|
+
return InternalSpanComponentUUIDFields2;
|
|
753
|
+
})(InternalSpanComponentUUIDFields || {});
|
|
754
|
+
var internalSpanComponentUUIDFieldsEnumSchema = _v3.z.nativeEnum(
|
|
755
|
+
InternalSpanComponentUUIDFields
|
|
756
|
+
);
|
|
757
|
+
var _INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME = {
|
|
758
|
+
[1 /* OBJECT_ID */]: "object_id",
|
|
759
|
+
[2 /* ROW_ID */]: "row_id",
|
|
760
|
+
[3 /* SPAN_ID */]: "span_id",
|
|
761
|
+
[4 /* ROOT_SPAN_ID */]: "root_span_id"
|
|
762
|
+
};
|
|
763
|
+
var spanComponentsV3Schema = _v3.z.object({
|
|
764
|
+
object_type: spanObjectTypeV3EnumSchema,
|
|
765
|
+
// TODO(manu): We should have a more elaborate zod schema for
|
|
766
|
+
// `propagated_event`. This will required zod-ifying the contents of
|
|
767
|
+
// sdk/js/util/object.ts.
|
|
768
|
+
propagated_event: _v3.z.record(_v3.z.unknown()).nullish()
|
|
769
|
+
}).and(
|
|
770
|
+
_v3.z.union([
|
|
771
|
+
// Must provide one or the other.
|
|
772
|
+
_v3.z.object({
|
|
773
|
+
object_id: _v3.z.string().nullish(),
|
|
774
|
+
compute_object_metadata_args: _v3.z.optional(_v3.z.null())
|
|
775
|
+
}),
|
|
776
|
+
_v3.z.object({
|
|
777
|
+
object_id: _v3.z.optional(_v3.z.null()),
|
|
778
|
+
compute_object_metadata_args: _v3.z.record(_v3.z.unknown())
|
|
779
|
+
})
|
|
780
|
+
])
|
|
781
|
+
).and(
|
|
782
|
+
_v3.z.union([
|
|
783
|
+
// Either all of these must be provided or none.
|
|
784
|
+
_v3.z.object({
|
|
785
|
+
row_id: _v3.z.string(),
|
|
786
|
+
span_id: _v3.z.string(),
|
|
787
|
+
root_span_id: _v3.z.string()
|
|
788
|
+
}),
|
|
789
|
+
_v3.z.object({
|
|
790
|
+
row_id: _v3.z.optional(_v3.z.null()),
|
|
791
|
+
span_id: _v3.z.optional(_v3.z.null()),
|
|
792
|
+
root_span_id: _v3.z.optional(_v3.z.null())
|
|
793
|
+
})
|
|
794
|
+
])
|
|
795
|
+
);
|
|
796
|
+
var SpanComponentsV3 = class _SpanComponentsV3 {
|
|
797
|
+
constructor(data) {
|
|
798
|
+
this.data = data;
|
|
799
|
+
}
|
|
800
|
+
toStr() {
|
|
801
|
+
const jsonObj = {
|
|
802
|
+
compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
|
|
803
|
+
propagated_event: this.data.propagated_event || void 0
|
|
804
|
+
};
|
|
805
|
+
const allBuffers = [];
|
|
806
|
+
allBuffers.push(
|
|
807
|
+
new Uint8Array([ENCODING_VERSION_NUMBER3, this.data.object_type])
|
|
808
|
+
);
|
|
809
|
+
const uuidEntries = [];
|
|
810
|
+
function addUuidField(origVal, fieldId) {
|
|
811
|
+
const ret = tryMakeUuid3(origVal);
|
|
812
|
+
if (ret.isUUID) {
|
|
813
|
+
uuidEntries.push(
|
|
814
|
+
concatUint8Arrays(new Uint8Array([fieldId]), ret.bytes)
|
|
815
|
+
);
|
|
816
|
+
} else {
|
|
817
|
+
jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = origVal;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
if (this.data.object_id) {
|
|
821
|
+
addUuidField(
|
|
822
|
+
this.data.object_id,
|
|
823
|
+
1 /* OBJECT_ID */
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
if (this.data.row_id) {
|
|
827
|
+
addUuidField(this.data.row_id, 2 /* ROW_ID */);
|
|
828
|
+
}
|
|
829
|
+
if (this.data.span_id) {
|
|
830
|
+
addUuidField(this.data.span_id, 3 /* SPAN_ID */);
|
|
831
|
+
}
|
|
832
|
+
if (this.data.root_span_id) {
|
|
833
|
+
addUuidField(
|
|
834
|
+
this.data.root_span_id,
|
|
835
|
+
4 /* ROOT_SPAN_ID */
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
if (uuidEntries.length > 255) {
|
|
839
|
+
throw new Error("Impossible: too many UUID entries to encode");
|
|
840
|
+
}
|
|
841
|
+
allBuffers.push(new Uint8Array([uuidEntries.length]));
|
|
842
|
+
allBuffers.push(...uuidEntries);
|
|
843
|
+
if (Object.keys(jsonObj).length > 0) {
|
|
844
|
+
allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
|
|
845
|
+
}
|
|
846
|
+
return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
|
|
847
|
+
}
|
|
848
|
+
static fromStr(s) {
|
|
849
|
+
try {
|
|
850
|
+
const rawBytes = base64ToUint8Array(s);
|
|
851
|
+
const jsonObj = {};
|
|
852
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER3) {
|
|
853
|
+
const spanComponentsOld = SpanComponentsV2.fromStr(s);
|
|
854
|
+
jsonObj["object_type"] = spanComponentsOld.objectType;
|
|
855
|
+
jsonObj["object_id"] = spanComponentsOld.objectId;
|
|
856
|
+
jsonObj["compute_object_metadata_args"] = spanComponentsOld.computeObjectMetadataArgs;
|
|
857
|
+
if (spanComponentsOld.rowIds) {
|
|
858
|
+
jsonObj["row_id"] = spanComponentsOld.rowIds.rowId;
|
|
859
|
+
jsonObj["span_id"] = spanComponentsOld.rowIds.spanId;
|
|
860
|
+
jsonObj["root_span_id"] = spanComponentsOld.rowIds.rootSpanId;
|
|
861
|
+
}
|
|
862
|
+
} else {
|
|
863
|
+
jsonObj["object_type"] = rawBytes[1];
|
|
864
|
+
const numUuidEntries = rawBytes[2];
|
|
865
|
+
let byteOffset = 3;
|
|
866
|
+
for (let i = 0; i < numUuidEntries; ++i) {
|
|
867
|
+
const fieldId = internalSpanComponentUUIDFieldsEnumSchema.parse(
|
|
868
|
+
rawBytes[byteOffset]
|
|
869
|
+
);
|
|
870
|
+
const fieldBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
|
|
871
|
+
byteOffset += 17;
|
|
872
|
+
jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = uuid3.stringify(fieldBytes);
|
|
873
|
+
}
|
|
874
|
+
if (byteOffset < rawBytes.length) {
|
|
875
|
+
const remainingJsonObj = JSON.parse(
|
|
876
|
+
uint8ArrayToString(rawBytes.subarray(byteOffset))
|
|
877
|
+
);
|
|
878
|
+
Object.assign(jsonObj, remainingJsonObj);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return _SpanComponentsV3.fromJsonObj(jsonObj);
|
|
882
|
+
} catch (e4) {
|
|
883
|
+
throw new Error(INVALID_ENCODING_ERRMSG3);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
objectIdFields() {
|
|
887
|
+
if (!this.data.object_id) {
|
|
888
|
+
throw new Error(
|
|
889
|
+
"Impossible: cannot invoke `objectIdFields` unless SpanComponentsV3 is initialized with an `object_id`"
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
switch (this.data.object_type) {
|
|
893
|
+
case 1 /* EXPERIMENT */:
|
|
894
|
+
return { experiment_id: this.data.object_id };
|
|
895
|
+
case 2 /* PROJECT_LOGS */:
|
|
896
|
+
return { project_id: this.data.object_id, log_id: "g" };
|
|
897
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
898
|
+
return { prompt_session_id: this.data.object_id, log_id: "x" };
|
|
899
|
+
default:
|
|
900
|
+
const _ = this.data.object_type;
|
|
901
|
+
throw new Error("Impossible");
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
async export() {
|
|
905
|
+
return this.toStr();
|
|
906
|
+
}
|
|
907
|
+
static fromJsonObj(jsonObj) {
|
|
908
|
+
return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
function parseParent(parent) {
|
|
912
|
+
return typeof parent === "string" ? parent : parent ? new SpanComponentsV3({
|
|
913
|
+
object_type: parent.object_type === "experiment" ? 1 /* EXPERIMENT */ : parent.object_type === "playground_logs" ? 3 /* PLAYGROUND_LOGS */ : 2 /* PROJECT_LOGS */,
|
|
914
|
+
object_id: parent.object_id,
|
|
915
|
+
...parent.row_ids ? {
|
|
916
|
+
row_id: parent.row_ids.id,
|
|
917
|
+
span_id: parent.row_ids.span_id,
|
|
918
|
+
root_span_id: parent.row_ids.root_span_id
|
|
919
|
+
} : {
|
|
920
|
+
row_id: void 0,
|
|
921
|
+
span_id: void 0,
|
|
922
|
+
root_span_id: void 0
|
|
923
|
+
},
|
|
924
|
+
propagated_event: parent.propagated_event
|
|
925
|
+
}).toStr() : void 0;
|
|
926
|
+
}
|
|
319
927
|
|
|
928
|
+
// util/http_headers.ts
|
|
929
|
+
var BT_FOUND_EXISTING_HEADER = "x-bt-found-existing";
|
|
930
|
+
var BT_CURSOR_HEADER = "x-bt-cursor";
|
|
320
931
|
|
|
932
|
+
// util/type_util.ts
|
|
933
|
+
function isObject(value) {
|
|
934
|
+
return value instanceof Object && !(value instanceof Array);
|
|
935
|
+
}
|
|
936
|
+
function isArray(value) {
|
|
937
|
+
return value instanceof Array;
|
|
938
|
+
}
|
|
939
|
+
function isObjectOrArray(value) {
|
|
940
|
+
return value instanceof Object;
|
|
941
|
+
}
|
|
321
942
|
|
|
943
|
+
// util/object_util.ts
|
|
944
|
+
function mergeDictsWithPaths({
|
|
945
|
+
mergeInto,
|
|
946
|
+
mergeFrom,
|
|
947
|
+
mergePaths
|
|
948
|
+
}) {
|
|
949
|
+
const mergePathsSerialized = new Set(
|
|
950
|
+
mergePaths.map((p) => JSON.stringify(p))
|
|
951
|
+
);
|
|
952
|
+
return mergeDictsWithPathsHelper({
|
|
953
|
+
mergeInto,
|
|
954
|
+
mergeFrom,
|
|
955
|
+
path: [],
|
|
956
|
+
mergePaths: mergePathsSerialized
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
function mergeDictsWithPathsHelper({
|
|
960
|
+
mergeInto,
|
|
961
|
+
mergeFrom,
|
|
962
|
+
path: path3,
|
|
963
|
+
mergePaths
|
|
964
|
+
}) {
|
|
965
|
+
Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
|
|
966
|
+
const fullPath = path3.concat([k]);
|
|
967
|
+
const fullPathSerialized = JSON.stringify(fullPath);
|
|
968
|
+
const mergeIntoV = recordFind(mergeInto, k);
|
|
969
|
+
if (isObject(mergeIntoV) && isObject(mergeFromV) && !mergePaths.has(fullPathSerialized)) {
|
|
970
|
+
mergeDictsWithPathsHelper({
|
|
971
|
+
mergeInto: mergeIntoV,
|
|
972
|
+
mergeFrom: mergeFromV,
|
|
973
|
+
path: fullPath,
|
|
974
|
+
mergePaths
|
|
975
|
+
});
|
|
976
|
+
} else {
|
|
977
|
+
mergeInto[k] = mergeFromV;
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
return mergeInto;
|
|
981
|
+
}
|
|
982
|
+
function mergeDicts(mergeInto, mergeFrom) {
|
|
983
|
+
return mergeDictsWithPaths({ mergeInto, mergeFrom, mergePaths: [] });
|
|
984
|
+
}
|
|
985
|
+
function mapAt(m, k) {
|
|
986
|
+
const ret = m.get(k);
|
|
987
|
+
if (ret === void 0) {
|
|
988
|
+
throw new Error(`Map does not contain key ${k}`);
|
|
989
|
+
}
|
|
990
|
+
return ret;
|
|
991
|
+
}
|
|
992
|
+
function recordFind(m, k) {
|
|
993
|
+
return m[k];
|
|
994
|
+
}
|
|
995
|
+
function getObjValueByPath(row, path3) {
|
|
996
|
+
let curr = row;
|
|
997
|
+
for (const p of path3) {
|
|
998
|
+
if (!isObjectOrArray(curr)) {
|
|
999
|
+
return null;
|
|
1000
|
+
}
|
|
1001
|
+
curr = curr[p];
|
|
1002
|
+
}
|
|
1003
|
+
return curr;
|
|
1004
|
+
}
|
|
322
1005
|
|
|
1006
|
+
// util/graph_util.ts
|
|
1007
|
+
function depthFirstSearch(args) {
|
|
1008
|
+
const { graph, firstVisitF, lastVisitF } = args;
|
|
1009
|
+
for (const vs of graph.values()) {
|
|
1010
|
+
for (const v of vs.values()) {
|
|
1011
|
+
if (!graph.has(v)) {
|
|
1012
|
+
throw new Error(`Outgoing vertex ${v} must be a key in the graph`);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
const firstVisitedVertices = /* @__PURE__ */ new Set();
|
|
1017
|
+
const visitationOrder = _nullishCoalesce(args.visitationOrder, () => ( [...graph.keys()]));
|
|
1018
|
+
const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
|
|
1019
|
+
while (events.length) {
|
|
1020
|
+
const { eventType, vertex, extras } = events.pop();
|
|
1021
|
+
if (eventType === "last") {
|
|
1022
|
+
_optionalChain([lastVisitF, 'optionalCall', _17 => _17(vertex)]);
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
if (firstVisitedVertices.has(vertex)) {
|
|
1026
|
+
continue;
|
|
1027
|
+
}
|
|
1028
|
+
firstVisitedVertices.add(vertex);
|
|
1029
|
+
_optionalChain([firstVisitF, 'optionalCall', _18 => _18(vertex, { parentVertex: extras.parentVertex })]);
|
|
1030
|
+
events.push({ eventType: "last", vertex, extras: {} });
|
|
1031
|
+
mapAt(graph, vertex).forEach((child) => {
|
|
1032
|
+
events.push({
|
|
1033
|
+
eventType: "first",
|
|
1034
|
+
vertex: child,
|
|
1035
|
+
extras: { parentVertex: vertex }
|
|
1036
|
+
});
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
function undirectedConnectedComponents(graph) {
|
|
1041
|
+
const directedGraph = new Map(
|
|
1042
|
+
[...graph.vertices].map((v) => [v, /* @__PURE__ */ new Set()])
|
|
1043
|
+
);
|
|
1044
|
+
for (const [i, j] of graph.edges) {
|
|
1045
|
+
mapAt(directedGraph, i).add(j);
|
|
1046
|
+
mapAt(directedGraph, j).add(i);
|
|
1047
|
+
}
|
|
1048
|
+
let labelCounter = 0;
|
|
1049
|
+
const vertexLabels = /* @__PURE__ */ new Map();
|
|
1050
|
+
const firstVisitF = (vertex, args) => {
|
|
1051
|
+
const label = _optionalChain([args, 'optionalAccess', _19 => _19.parentVertex]) !== void 0 ? mapAt(vertexLabels, _optionalChain([args, 'optionalAccess', _20 => _20.parentVertex])) : labelCounter++;
|
|
1052
|
+
vertexLabels.set(vertex, label);
|
|
1053
|
+
};
|
|
1054
|
+
depthFirstSearch({ graph: directedGraph, firstVisitF });
|
|
1055
|
+
const output = Array.from({ length: labelCounter }).map(() => []);
|
|
1056
|
+
for (const [vertex, label] of vertexLabels.entries()) {
|
|
1057
|
+
output[label].push(vertex);
|
|
1058
|
+
}
|
|
1059
|
+
return output;
|
|
1060
|
+
}
|
|
1061
|
+
function topologicalSort(graph, visitationOrder) {
|
|
1062
|
+
const reverseOrdering = [];
|
|
1063
|
+
const lastVisitF = (vertex) => {
|
|
1064
|
+
reverseOrdering.push(vertex);
|
|
1065
|
+
};
|
|
1066
|
+
depthFirstSearch({ graph, lastVisitF, visitationOrder });
|
|
1067
|
+
return reverseOrdering.reverse();
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// util/merge_row_batch.ts
|
|
1071
|
+
function generateMergedRowKey(row, useParentIdForId) {
|
|
1072
|
+
return JSON.stringify(
|
|
1073
|
+
[
|
|
1074
|
+
"org_id",
|
|
1075
|
+
"project_id",
|
|
1076
|
+
"experiment_id",
|
|
1077
|
+
"dataset_id",
|
|
1078
|
+
"prompt_session_id",
|
|
1079
|
+
"log_id",
|
|
1080
|
+
_nullishCoalesce(useParentIdForId, () => ( false)) ? PARENT_ID_FIELD : "id"
|
|
1081
|
+
].map((k) => row[k])
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
var MERGE_ROW_SKIP_FIELDS = [
|
|
1085
|
+
"created",
|
|
1086
|
+
"span_id",
|
|
1087
|
+
"root_span_id",
|
|
1088
|
+
"span_parents",
|
|
1089
|
+
"_parent_id"
|
|
1090
|
+
// TODO: handle merge paths.
|
|
1091
|
+
];
|
|
1092
|
+
function popMergeRowSkipFields(row) {
|
|
1093
|
+
const popped = {};
|
|
1094
|
+
for (const field of MERGE_ROW_SKIP_FIELDS) {
|
|
1095
|
+
if (field in row) {
|
|
1096
|
+
popped[field] = row[field];
|
|
1097
|
+
delete row[field];
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return popped;
|
|
1101
|
+
}
|
|
1102
|
+
function restoreMergeRowSkipFields(row, skipFields) {
|
|
1103
|
+
for (const field of MERGE_ROW_SKIP_FIELDS) {
|
|
1104
|
+
delete row[field];
|
|
1105
|
+
if (field in skipFields) {
|
|
1106
|
+
row[field] = skipFields[field];
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
function mergeRowBatch(rows) {
|
|
1111
|
+
for (const row of rows) {
|
|
1112
|
+
if (row.id === void 0) {
|
|
1113
|
+
throw new Error(
|
|
1114
|
+
"Logged row is missing an id. This is an internal braintrust error. Please contact us at info@braintrust.dev for help"
|
|
1115
|
+
);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
const rowGroups = /* @__PURE__ */ new Map();
|
|
1119
|
+
for (const row of rows) {
|
|
1120
|
+
const key = generateMergedRowKey(row);
|
|
1121
|
+
const existingRow = rowGroups.get(key);
|
|
1122
|
+
if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
|
|
1123
|
+
const skipFields = popMergeRowSkipFields(existingRow);
|
|
1124
|
+
const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
|
|
1125
|
+
mergeDicts(existingRow, row);
|
|
1126
|
+
restoreMergeRowSkipFields(existingRow, skipFields);
|
|
1127
|
+
if (preserveNoMerge) {
|
|
1128
|
+
delete existingRow[IS_MERGE_FIELD];
|
|
1129
|
+
}
|
|
1130
|
+
} else {
|
|
1131
|
+
rowGroups.set(key, row);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
const merged = [...rowGroups.values()];
|
|
1135
|
+
const rowToLabel = new Map(
|
|
1136
|
+
merged.map((r, i) => [generateMergedRowKey(r), i])
|
|
1137
|
+
);
|
|
1138
|
+
const graph = new Map(
|
|
1139
|
+
Array.from({ length: merged.length }).map((_, i) => [i, /* @__PURE__ */ new Set()])
|
|
1140
|
+
);
|
|
1141
|
+
merged.forEach((r, i) => {
|
|
1142
|
+
const parentId = r[PARENT_ID_FIELD];
|
|
1143
|
+
if (!parentId) {
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
const parentRowKey = generateMergedRowKey(
|
|
1147
|
+
r,
|
|
1148
|
+
true
|
|
1149
|
+
/* useParentIdForId */
|
|
1150
|
+
);
|
|
1151
|
+
const parentLabel = rowToLabel.get(parentRowKey);
|
|
1152
|
+
if (parentLabel !== void 0) {
|
|
1153
|
+
mapAt(graph, parentLabel).add(i);
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
const connectedComponents = undirectedConnectedComponents({
|
|
1157
|
+
vertices: new Set(graph.keys()),
|
|
1158
|
+
edges: new Set(
|
|
1159
|
+
[...graph.entries()].flatMap(
|
|
1160
|
+
([k, vs]) => [...vs].map((v) => {
|
|
1161
|
+
const ret = [k, v];
|
|
1162
|
+
return ret;
|
|
1163
|
+
})
|
|
1164
|
+
)
|
|
1165
|
+
)
|
|
1166
|
+
});
|
|
1167
|
+
const buckets = connectedComponents.map(
|
|
1168
|
+
(cc) => topologicalSort(
|
|
1169
|
+
graph,
|
|
1170
|
+
cc
|
|
1171
|
+
/* visitationOrder */
|
|
1172
|
+
)
|
|
1173
|
+
);
|
|
1174
|
+
return buckets.map((bucket) => bucket.map((i) => merged[i]));
|
|
1175
|
+
}
|
|
1176
|
+
function batchItems(args) {
|
|
1177
|
+
let { items } = args;
|
|
1178
|
+
const batchMaxNumItems = _nullishCoalesce(args.batchMaxNumItems, () => ( Number.POSITIVE_INFINITY));
|
|
1179
|
+
const batchMaxNumBytes = _nullishCoalesce(args.batchMaxNumBytes, () => ( Number.POSITIVE_INFINITY));
|
|
1180
|
+
const output = [];
|
|
1181
|
+
let nextItems = [];
|
|
1182
|
+
let batchSet = [];
|
|
1183
|
+
let batch = [];
|
|
1184
|
+
let batchLen = 0;
|
|
1185
|
+
function addToBatch(item) {
|
|
1186
|
+
batch.push(item);
|
|
1187
|
+
batchLen += item.length;
|
|
1188
|
+
}
|
|
1189
|
+
function flushBatch() {
|
|
1190
|
+
batchSet.push(batch);
|
|
1191
|
+
batch = [];
|
|
1192
|
+
batchLen = 0;
|
|
1193
|
+
}
|
|
1194
|
+
while (items.length) {
|
|
1195
|
+
for (const bucket of items) {
|
|
1196
|
+
let i = 0;
|
|
1197
|
+
for (const item of bucket) {
|
|
1198
|
+
if (batch.length === 0 || item.length + batchLen < batchMaxNumBytes && batch.length < batchMaxNumItems) {
|
|
1199
|
+
addToBatch(item);
|
|
1200
|
+
} else if (i === 0) {
|
|
1201
|
+
flushBatch();
|
|
1202
|
+
addToBatch(item);
|
|
1203
|
+
} else {
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
++i;
|
|
1207
|
+
}
|
|
1208
|
+
if (i < bucket.length) {
|
|
1209
|
+
nextItems.push(bucket.slice(i));
|
|
1210
|
+
}
|
|
1211
|
+
if (batchLen >= batchMaxNumBytes || batch.length > batchMaxNumItems) {
|
|
1212
|
+
flushBatch();
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
if (batch.length) {
|
|
1216
|
+
flushBatch();
|
|
1217
|
+
}
|
|
1218
|
+
if (batchSet.length) {
|
|
1219
|
+
output.push(batchSet);
|
|
1220
|
+
batchSet = [];
|
|
1221
|
+
}
|
|
1222
|
+
items = nextItems;
|
|
1223
|
+
nextItems = [];
|
|
1224
|
+
}
|
|
1225
|
+
return output;
|
|
1226
|
+
}
|
|
323
1227
|
|
|
1228
|
+
// util/object.ts
|
|
1229
|
+
var DEFAULT_IS_LEGACY_DATASET = false;
|
|
1230
|
+
function ensureDatasetRecord(r, legacy) {
|
|
1231
|
+
if (legacy) {
|
|
1232
|
+
return ensureLegacyDatasetRecord(r);
|
|
1233
|
+
} else {
|
|
1234
|
+
return ensureNewDatasetRecord(r);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
function ensureLegacyDatasetRecord(r) {
|
|
1238
|
+
if ("output" in r) {
|
|
1239
|
+
return r;
|
|
1240
|
+
}
|
|
1241
|
+
const row = {
|
|
1242
|
+
...r,
|
|
1243
|
+
output: r.expected
|
|
1244
|
+
};
|
|
1245
|
+
delete row.expected;
|
|
1246
|
+
return row;
|
|
1247
|
+
}
|
|
1248
|
+
function ensureNewDatasetRecord(r) {
|
|
1249
|
+
if ("expected" in r) {
|
|
1250
|
+
return r;
|
|
1251
|
+
}
|
|
1252
|
+
const row = {
|
|
1253
|
+
...r,
|
|
1254
|
+
tags: null,
|
|
1255
|
+
expected: r.output
|
|
1256
|
+
};
|
|
1257
|
+
delete row.output;
|
|
1258
|
+
return row;
|
|
1259
|
+
}
|
|
324
1260
|
|
|
1261
|
+
// util/json_util.ts
|
|
1262
|
+
function constructJsonArray(items) {
|
|
1263
|
+
return `[${items.join(",")}]`;
|
|
1264
|
+
}
|
|
325
1265
|
|
|
1266
|
+
// util/string_util.ts
|
|
1267
|
+
function _urljoin(...parts) {
|
|
1268
|
+
return parts.map(
|
|
1269
|
+
(x, i) => x.replace(/^\//, "").replace(i < parts.length - 1 ? /\/$/ : "", "")
|
|
1270
|
+
).filter((x) => x.trim() !== "").join("/");
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// util/git_fields.ts
|
|
1274
|
+
function mergeGitMetadataSettings(s1, s2) {
|
|
1275
|
+
if (s1.collect === "all") {
|
|
1276
|
+
return s2;
|
|
1277
|
+
} else if (s2.collect === "all") {
|
|
1278
|
+
return s1;
|
|
1279
|
+
} else if (s1.collect === "none") {
|
|
1280
|
+
return s1;
|
|
1281
|
+
} else if (s2.collect === "none") {
|
|
1282
|
+
return s2;
|
|
1283
|
+
}
|
|
1284
|
+
const fields = (_nullishCoalesce(s1.fields, () => ( []))).filter((f) => (_nullishCoalesce(s2.fields, () => ( []))).includes(f));
|
|
1285
|
+
const collect = fields.length > 0 ? "some" : "none";
|
|
1286
|
+
return { collect, fields };
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// util/xact-ids.ts
|
|
1290
|
+
var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
|
|
1291
|
+
var MOD = BigInt(1) << BigInt(64);
|
|
1292
|
+
var COPRIME = BigInt("205891132094649");
|
|
1293
|
+
var COPRIME_INVERSE = BigInt("1522336535492693385");
|
|
1294
|
+
function modularMultiply(value, prime) {
|
|
1295
|
+
return value * prime % MOD;
|
|
1296
|
+
}
|
|
1297
|
+
function loadPrettyXact(encodedHex) {
|
|
1298
|
+
if (encodedHex.length !== 16) {
|
|
1299
|
+
return encodedHex;
|
|
1300
|
+
}
|
|
1301
|
+
const value = BigInt(`0x${encodedHex}`);
|
|
1302
|
+
const multipliedInverse = modularMultiply(value, COPRIME_INVERSE);
|
|
1303
|
+
const withTopBits = TOP_BITS | multipliedInverse;
|
|
1304
|
+
return withTopBits.toString();
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
// util/zod_util.ts
|
|
326
1308
|
|
|
327
|
-
var _core = require('@braintrust/core');
|
|
328
1309
|
|
|
329
1310
|
// src/generated_types.ts
|
|
330
|
-
|
|
331
|
-
var AclObjectType =
|
|
332
|
-
|
|
1311
|
+
|
|
1312
|
+
var AclObjectType = _v3.z.union([
|
|
1313
|
+
_v3.z.enum([
|
|
333
1314
|
"organization",
|
|
334
1315
|
"project",
|
|
335
1316
|
"experiment",
|
|
@@ -342,9 +1323,9 @@ var AclObjectType = _zod.z.union([
|
|
|
342
1323
|
"project_log",
|
|
343
1324
|
"org_project"
|
|
344
1325
|
]),
|
|
345
|
-
|
|
1326
|
+
_v3.z.null()
|
|
346
1327
|
]);
|
|
347
|
-
var Permission =
|
|
1328
|
+
var Permission = _v3.z.enum([
|
|
348
1329
|
"create",
|
|
349
1330
|
"read",
|
|
350
1331
|
"update",
|
|
@@ -354,310 +1335,310 @@ var Permission = _zod.z.enum([
|
|
|
354
1335
|
"update_acls",
|
|
355
1336
|
"delete_acls"
|
|
356
1337
|
]);
|
|
357
|
-
var Acl =
|
|
358
|
-
id:
|
|
359
|
-
object_type: AclObjectType.and(
|
|
360
|
-
object_id:
|
|
361
|
-
user_id:
|
|
362
|
-
group_id:
|
|
363
|
-
permission: Permission.and(
|
|
364
|
-
restrict_object_type: AclObjectType.and(
|
|
365
|
-
role_id:
|
|
366
|
-
_object_org_id:
|
|
367
|
-
created:
|
|
1338
|
+
var Acl = _v3.z.object({
|
|
1339
|
+
id: _v3.z.string().uuid(),
|
|
1340
|
+
object_type: AclObjectType.and(_v3.z.string()),
|
|
1341
|
+
object_id: _v3.z.string().uuid(),
|
|
1342
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1343
|
+
group_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1344
|
+
permission: Permission.and(_v3.z.union([_v3.z.string(), _v3.z.null()])).optional(),
|
|
1345
|
+
restrict_object_type: AclObjectType.and(_v3.z.unknown()).optional(),
|
|
1346
|
+
role_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1347
|
+
_object_org_id: _v3.z.string().uuid(),
|
|
1348
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
368
1349
|
});
|
|
369
|
-
var AISecret =
|
|
370
|
-
id:
|
|
371
|
-
created:
|
|
372
|
-
updated_at:
|
|
373
|
-
org_id:
|
|
374
|
-
name:
|
|
375
|
-
type:
|
|
376
|
-
metadata:
|
|
377
|
-
preview_secret:
|
|
1350
|
+
var AISecret = _v3.z.object({
|
|
1351
|
+
id: _v3.z.string().uuid(),
|
|
1352
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1353
|
+
updated_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1354
|
+
org_id: _v3.z.string().uuid(),
|
|
1355
|
+
name: _v3.z.string(),
|
|
1356
|
+
type: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1357
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
|
|
1358
|
+
preview_secret: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
378
1359
|
});
|
|
379
|
-
var ResponseFormatJsonSchema =
|
|
380
|
-
name:
|
|
381
|
-
description:
|
|
382
|
-
schema:
|
|
383
|
-
strict:
|
|
1360
|
+
var ResponseFormatJsonSchema = _v3.z.object({
|
|
1361
|
+
name: _v3.z.string(),
|
|
1362
|
+
description: _v3.z.string().optional(),
|
|
1363
|
+
schema: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.string()]).optional(),
|
|
1364
|
+
strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
384
1365
|
});
|
|
385
|
-
var ResponseFormatNullish =
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
type:
|
|
1366
|
+
var ResponseFormatNullish = _v3.z.union([
|
|
1367
|
+
_v3.z.object({ type: _v3.z.literal("json_object") }),
|
|
1368
|
+
_v3.z.object({
|
|
1369
|
+
type: _v3.z.literal("json_schema"),
|
|
389
1370
|
json_schema: ResponseFormatJsonSchema
|
|
390
1371
|
}),
|
|
391
|
-
|
|
392
|
-
|
|
1372
|
+
_v3.z.object({ type: _v3.z.literal("text") }),
|
|
1373
|
+
_v3.z.null()
|
|
393
1374
|
]);
|
|
394
|
-
var AnyModelParams =
|
|
395
|
-
temperature:
|
|
396
|
-
top_p:
|
|
397
|
-
max_tokens:
|
|
398
|
-
max_completion_tokens:
|
|
399
|
-
frequency_penalty:
|
|
400
|
-
presence_penalty:
|
|
1375
|
+
var AnyModelParams = _v3.z.object({
|
|
1376
|
+
temperature: _v3.z.number().optional(),
|
|
1377
|
+
top_p: _v3.z.number().optional(),
|
|
1378
|
+
max_tokens: _v3.z.number(),
|
|
1379
|
+
max_completion_tokens: _v3.z.number().optional(),
|
|
1380
|
+
frequency_penalty: _v3.z.number().optional(),
|
|
1381
|
+
presence_penalty: _v3.z.number().optional(),
|
|
401
1382
|
response_format: ResponseFormatNullish.optional(),
|
|
402
|
-
tool_choice:
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
type:
|
|
408
|
-
function:
|
|
1383
|
+
tool_choice: _v3.z.union([
|
|
1384
|
+
_v3.z.literal("auto"),
|
|
1385
|
+
_v3.z.literal("none"),
|
|
1386
|
+
_v3.z.literal("required"),
|
|
1387
|
+
_v3.z.object({
|
|
1388
|
+
type: _v3.z.literal("function"),
|
|
1389
|
+
function: _v3.z.object({ name: _v3.z.string() })
|
|
409
1390
|
})
|
|
410
1391
|
]).optional(),
|
|
411
|
-
function_call:
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
1392
|
+
function_call: _v3.z.union([
|
|
1393
|
+
_v3.z.literal("auto"),
|
|
1394
|
+
_v3.z.literal("none"),
|
|
1395
|
+
_v3.z.object({ name: _v3.z.string() })
|
|
415
1396
|
]).optional(),
|
|
416
|
-
n:
|
|
417
|
-
stop:
|
|
418
|
-
reasoning_effort:
|
|
419
|
-
verbosity:
|
|
420
|
-
top_k:
|
|
421
|
-
stop_sequences:
|
|
422
|
-
max_tokens_to_sample:
|
|
423
|
-
maxOutputTokens:
|
|
424
|
-
topP:
|
|
425
|
-
topK:
|
|
426
|
-
use_cache:
|
|
1397
|
+
n: _v3.z.number().optional(),
|
|
1398
|
+
stop: _v3.z.array(_v3.z.string()).optional(),
|
|
1399
|
+
reasoning_effort: _v3.z.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
1400
|
+
verbosity: _v3.z.enum(["low", "medium", "high"]).optional(),
|
|
1401
|
+
top_k: _v3.z.number().optional(),
|
|
1402
|
+
stop_sequences: _v3.z.array(_v3.z.string()).optional(),
|
|
1403
|
+
max_tokens_to_sample: _v3.z.number().optional(),
|
|
1404
|
+
maxOutputTokens: _v3.z.number().optional(),
|
|
1405
|
+
topP: _v3.z.number().optional(),
|
|
1406
|
+
topK: _v3.z.number().optional(),
|
|
1407
|
+
use_cache: _v3.z.boolean().optional()
|
|
427
1408
|
});
|
|
428
|
-
var ApiKey =
|
|
429
|
-
id:
|
|
430
|
-
created:
|
|
431
|
-
name:
|
|
432
|
-
preview_name:
|
|
433
|
-
user_id:
|
|
434
|
-
user_email:
|
|
435
|
-
user_given_name:
|
|
436
|
-
user_family_name:
|
|
437
|
-
org_id:
|
|
1409
|
+
var ApiKey = _v3.z.object({
|
|
1410
|
+
id: _v3.z.string().uuid(),
|
|
1411
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1412
|
+
name: _v3.z.string(),
|
|
1413
|
+
preview_name: _v3.z.string(),
|
|
1414
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1415
|
+
user_email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1416
|
+
user_given_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1417
|
+
user_family_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1418
|
+
org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
438
1419
|
});
|
|
439
|
-
var AsyncScoringState =
|
|
440
|
-
|
|
441
|
-
status:
|
|
442
|
-
token:
|
|
443
|
-
function_ids:
|
|
444
|
-
skip_logging:
|
|
1420
|
+
var AsyncScoringState = _v3.z.union([
|
|
1421
|
+
_v3.z.object({
|
|
1422
|
+
status: _v3.z.literal("enabled"),
|
|
1423
|
+
token: _v3.z.string(),
|
|
1424
|
+
function_ids: _v3.z.array(_v3.z.unknown()).min(1),
|
|
1425
|
+
skip_logging: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
445
1426
|
}),
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
1427
|
+
_v3.z.object({ status: _v3.z.literal("disabled") }),
|
|
1428
|
+
_v3.z.null(),
|
|
1429
|
+
_v3.z.null()
|
|
449
1430
|
]);
|
|
450
|
-
var AsyncScoringControl =
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
1431
|
+
var AsyncScoringControl = _v3.z.union([
|
|
1432
|
+
_v3.z.object({ kind: _v3.z.literal("score_update"), token: _v3.z.string() }),
|
|
1433
|
+
_v3.z.object({ kind: _v3.z.literal("state_override"), state: AsyncScoringState }),
|
|
1434
|
+
_v3.z.object({ kind: _v3.z.literal("state_force_reselect") }),
|
|
1435
|
+
_v3.z.object({ kind: _v3.z.literal("state_enabled_force_rescore") })
|
|
455
1436
|
]);
|
|
456
|
-
var BraintrustAttachmentReference =
|
|
457
|
-
type:
|
|
458
|
-
filename:
|
|
459
|
-
content_type:
|
|
460
|
-
key:
|
|
1437
|
+
var BraintrustAttachmentReference = _v3.z.object({
|
|
1438
|
+
type: _v3.z.literal("braintrust_attachment"),
|
|
1439
|
+
filename: _v3.z.string().min(1),
|
|
1440
|
+
content_type: _v3.z.string().min(1),
|
|
1441
|
+
key: _v3.z.string().min(1)
|
|
461
1442
|
});
|
|
462
|
-
var ExternalAttachmentReference =
|
|
463
|
-
type:
|
|
464
|
-
filename:
|
|
465
|
-
content_type:
|
|
466
|
-
url:
|
|
1443
|
+
var ExternalAttachmentReference = _v3.z.object({
|
|
1444
|
+
type: _v3.z.literal("external_attachment"),
|
|
1445
|
+
filename: _v3.z.string().min(1),
|
|
1446
|
+
content_type: _v3.z.string().min(1),
|
|
1447
|
+
url: _v3.z.string().min(1)
|
|
467
1448
|
});
|
|
468
|
-
var AttachmentReference =
|
|
1449
|
+
var AttachmentReference = _v3.z.discriminatedUnion("type", [
|
|
469
1450
|
BraintrustAttachmentReference,
|
|
470
1451
|
ExternalAttachmentReference
|
|
471
1452
|
]);
|
|
472
|
-
var UploadStatus =
|
|
473
|
-
var AttachmentStatus =
|
|
1453
|
+
var UploadStatus = _v3.z.enum(["uploading", "done", "error"]);
|
|
1454
|
+
var AttachmentStatus = _v3.z.object({
|
|
474
1455
|
upload_status: UploadStatus,
|
|
475
|
-
error_message:
|
|
1456
|
+
error_message: _v3.z.string().optional()
|
|
476
1457
|
});
|
|
477
|
-
var BraintrustModelParams =
|
|
478
|
-
var CallEvent =
|
|
479
|
-
|
|
480
|
-
id:
|
|
481
|
-
data:
|
|
482
|
-
event:
|
|
1458
|
+
var BraintrustModelParams = _v3.z.object({ use_cache: _v3.z.boolean() }).partial();
|
|
1459
|
+
var CallEvent = _v3.z.union([
|
|
1460
|
+
_v3.z.object({
|
|
1461
|
+
id: _v3.z.string().optional(),
|
|
1462
|
+
data: _v3.z.string(),
|
|
1463
|
+
event: _v3.z.literal("text_delta")
|
|
483
1464
|
}),
|
|
484
|
-
|
|
485
|
-
id:
|
|
486
|
-
data:
|
|
487
|
-
event:
|
|
1465
|
+
_v3.z.object({
|
|
1466
|
+
id: _v3.z.string().optional(),
|
|
1467
|
+
data: _v3.z.string(),
|
|
1468
|
+
event: _v3.z.literal("reasoning_delta")
|
|
488
1469
|
}),
|
|
489
|
-
|
|
490
|
-
id:
|
|
491
|
-
data:
|
|
492
|
-
event:
|
|
1470
|
+
_v3.z.object({
|
|
1471
|
+
id: _v3.z.string().optional(),
|
|
1472
|
+
data: _v3.z.string(),
|
|
1473
|
+
event: _v3.z.literal("json_delta")
|
|
493
1474
|
}),
|
|
494
|
-
|
|
495
|
-
id:
|
|
496
|
-
data:
|
|
497
|
-
event:
|
|
1475
|
+
_v3.z.object({
|
|
1476
|
+
id: _v3.z.string().optional(),
|
|
1477
|
+
data: _v3.z.string(),
|
|
1478
|
+
event: _v3.z.literal("progress")
|
|
498
1479
|
}),
|
|
499
|
-
|
|
500
|
-
id:
|
|
501
|
-
data:
|
|
502
|
-
event:
|
|
1480
|
+
_v3.z.object({
|
|
1481
|
+
id: _v3.z.string().optional(),
|
|
1482
|
+
data: _v3.z.string(),
|
|
1483
|
+
event: _v3.z.literal("error")
|
|
503
1484
|
}),
|
|
504
|
-
|
|
505
|
-
id:
|
|
506
|
-
data:
|
|
507
|
-
event:
|
|
1485
|
+
_v3.z.object({
|
|
1486
|
+
id: _v3.z.string().optional(),
|
|
1487
|
+
data: _v3.z.string(),
|
|
1488
|
+
event: _v3.z.literal("console")
|
|
508
1489
|
}),
|
|
509
|
-
|
|
510
|
-
id:
|
|
511
|
-
event:
|
|
512
|
-
data:
|
|
1490
|
+
_v3.z.object({
|
|
1491
|
+
id: _v3.z.string().optional(),
|
|
1492
|
+
event: _v3.z.literal("start"),
|
|
1493
|
+
data: _v3.z.literal("")
|
|
513
1494
|
}),
|
|
514
|
-
|
|
515
|
-
id:
|
|
516
|
-
event:
|
|
517
|
-
data:
|
|
1495
|
+
_v3.z.object({
|
|
1496
|
+
id: _v3.z.string().optional(),
|
|
1497
|
+
event: _v3.z.literal("done"),
|
|
1498
|
+
data: _v3.z.literal("")
|
|
518
1499
|
})
|
|
519
1500
|
]);
|
|
520
|
-
var ChatCompletionContentPartTextWithTitle =
|
|
521
|
-
text:
|
|
522
|
-
type:
|
|
523
|
-
cache_control:
|
|
1501
|
+
var ChatCompletionContentPartTextWithTitle = _v3.z.object({
|
|
1502
|
+
text: _v3.z.string().default(""),
|
|
1503
|
+
type: _v3.z.literal("text"),
|
|
1504
|
+
cache_control: _v3.z.object({ type: _v3.z.literal("ephemeral") }).optional()
|
|
524
1505
|
});
|
|
525
|
-
var ChatCompletionContentPartImageWithTitle =
|
|
526
|
-
image_url:
|
|
527
|
-
url:
|
|
528
|
-
detail:
|
|
1506
|
+
var ChatCompletionContentPartImageWithTitle = _v3.z.object({
|
|
1507
|
+
image_url: _v3.z.object({
|
|
1508
|
+
url: _v3.z.string(),
|
|
1509
|
+
detail: _v3.z.union([_v3.z.literal("auto"), _v3.z.literal("low"), _v3.z.literal("high")]).optional()
|
|
529
1510
|
}),
|
|
530
|
-
type:
|
|
1511
|
+
type: _v3.z.literal("image_url")
|
|
531
1512
|
});
|
|
532
|
-
var ChatCompletionContentPart =
|
|
1513
|
+
var ChatCompletionContentPart = _v3.z.union([
|
|
533
1514
|
ChatCompletionContentPartTextWithTitle,
|
|
534
1515
|
ChatCompletionContentPartImageWithTitle
|
|
535
1516
|
]);
|
|
536
|
-
var ChatCompletionContentPartText =
|
|
537
|
-
text:
|
|
538
|
-
type:
|
|
539
|
-
cache_control:
|
|
1517
|
+
var ChatCompletionContentPartText = _v3.z.object({
|
|
1518
|
+
text: _v3.z.string().default(""),
|
|
1519
|
+
type: _v3.z.literal("text"),
|
|
1520
|
+
cache_control: _v3.z.object({ type: _v3.z.literal("ephemeral") }).optional()
|
|
540
1521
|
});
|
|
541
|
-
var ChatCompletionMessageToolCall =
|
|
542
|
-
id:
|
|
543
|
-
function:
|
|
544
|
-
type:
|
|
1522
|
+
var ChatCompletionMessageToolCall = _v3.z.object({
|
|
1523
|
+
id: _v3.z.string(),
|
|
1524
|
+
function: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }),
|
|
1525
|
+
type: _v3.z.literal("function")
|
|
545
1526
|
});
|
|
546
|
-
var ChatCompletionMessageReasoning =
|
|
547
|
-
var ChatCompletionMessageParam =
|
|
548
|
-
|
|
549
|
-
content:
|
|
550
|
-
role:
|
|
551
|
-
name:
|
|
1527
|
+
var ChatCompletionMessageReasoning = _v3.z.object({ id: _v3.z.string(), content: _v3.z.string() }).partial();
|
|
1528
|
+
var ChatCompletionMessageParam = _v3.z.union([
|
|
1529
|
+
_v3.z.object({
|
|
1530
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1531
|
+
role: _v3.z.literal("system"),
|
|
1532
|
+
name: _v3.z.string().optional()
|
|
552
1533
|
}),
|
|
553
|
-
|
|
554
|
-
content:
|
|
555
|
-
role:
|
|
556
|
-
name:
|
|
1534
|
+
_v3.z.object({
|
|
1535
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPart)]),
|
|
1536
|
+
role: _v3.z.literal("user"),
|
|
1537
|
+
name: _v3.z.string().optional()
|
|
557
1538
|
}),
|
|
558
|
-
|
|
559
|
-
role:
|
|
560
|
-
content:
|
|
561
|
-
function_call:
|
|
562
|
-
name:
|
|
563
|
-
tool_calls:
|
|
564
|
-
reasoning:
|
|
1539
|
+
_v3.z.object({
|
|
1540
|
+
role: _v3.z.literal("assistant"),
|
|
1541
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText), _v3.z.null()]).optional(),
|
|
1542
|
+
function_call: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }).optional(),
|
|
1543
|
+
name: _v3.z.string().optional(),
|
|
1544
|
+
tool_calls: _v3.z.array(ChatCompletionMessageToolCall).optional(),
|
|
1545
|
+
reasoning: _v3.z.array(ChatCompletionMessageReasoning).optional()
|
|
565
1546
|
}),
|
|
566
|
-
|
|
567
|
-
content:
|
|
568
|
-
role:
|
|
569
|
-
tool_call_id:
|
|
1547
|
+
_v3.z.object({
|
|
1548
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1549
|
+
role: _v3.z.literal("tool"),
|
|
1550
|
+
tool_call_id: _v3.z.string().default("")
|
|
570
1551
|
}),
|
|
571
|
-
|
|
572
|
-
content:
|
|
573
|
-
name:
|
|
574
|
-
role:
|
|
1552
|
+
_v3.z.object({
|
|
1553
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1554
|
+
name: _v3.z.string(),
|
|
1555
|
+
role: _v3.z.literal("function")
|
|
575
1556
|
}),
|
|
576
|
-
|
|
577
|
-
content:
|
|
578
|
-
role:
|
|
579
|
-
name:
|
|
1557
|
+
_v3.z.object({
|
|
1558
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1559
|
+
role: _v3.z.literal("developer"),
|
|
1560
|
+
name: _v3.z.string().optional()
|
|
580
1561
|
}),
|
|
581
|
-
|
|
582
|
-
role:
|
|
583
|
-
content:
|
|
1562
|
+
_v3.z.object({
|
|
1563
|
+
role: _v3.z.literal("model"),
|
|
1564
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
584
1565
|
})
|
|
585
1566
|
]);
|
|
586
|
-
var ChatCompletionOpenAIMessageParam =
|
|
587
|
-
|
|
588
|
-
content:
|
|
589
|
-
role:
|
|
590
|
-
name:
|
|
1567
|
+
var ChatCompletionOpenAIMessageParam = _v3.z.union([
|
|
1568
|
+
_v3.z.object({
|
|
1569
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1570
|
+
role: _v3.z.literal("system"),
|
|
1571
|
+
name: _v3.z.string().optional()
|
|
591
1572
|
}),
|
|
592
|
-
|
|
593
|
-
content:
|
|
594
|
-
role:
|
|
595
|
-
name:
|
|
1573
|
+
_v3.z.object({
|
|
1574
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPart)]),
|
|
1575
|
+
role: _v3.z.literal("user"),
|
|
1576
|
+
name: _v3.z.string().optional()
|
|
596
1577
|
}),
|
|
597
|
-
|
|
598
|
-
role:
|
|
599
|
-
content:
|
|
600
|
-
function_call:
|
|
601
|
-
name:
|
|
602
|
-
tool_calls:
|
|
603
|
-
reasoning:
|
|
1578
|
+
_v3.z.object({
|
|
1579
|
+
role: _v3.z.literal("assistant"),
|
|
1580
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText), _v3.z.null()]).optional(),
|
|
1581
|
+
function_call: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }).optional(),
|
|
1582
|
+
name: _v3.z.string().optional(),
|
|
1583
|
+
tool_calls: _v3.z.array(ChatCompletionMessageToolCall).optional(),
|
|
1584
|
+
reasoning: _v3.z.array(ChatCompletionMessageReasoning).optional()
|
|
604
1585
|
}),
|
|
605
|
-
|
|
606
|
-
content:
|
|
607
|
-
role:
|
|
608
|
-
tool_call_id:
|
|
1586
|
+
_v3.z.object({
|
|
1587
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1588
|
+
role: _v3.z.literal("tool"),
|
|
1589
|
+
tool_call_id: _v3.z.string().default("")
|
|
609
1590
|
}),
|
|
610
|
-
|
|
611
|
-
content:
|
|
612
|
-
name:
|
|
613
|
-
role:
|
|
1591
|
+
_v3.z.object({
|
|
1592
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1593
|
+
name: _v3.z.string(),
|
|
1594
|
+
role: _v3.z.literal("function")
|
|
614
1595
|
}),
|
|
615
|
-
|
|
616
|
-
content:
|
|
617
|
-
role:
|
|
618
|
-
name:
|
|
1596
|
+
_v3.z.object({
|
|
1597
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1598
|
+
role: _v3.z.literal("developer"),
|
|
1599
|
+
name: _v3.z.string().optional()
|
|
619
1600
|
})
|
|
620
1601
|
]);
|
|
621
|
-
var ChatCompletionTool =
|
|
622
|
-
function:
|
|
623
|
-
name:
|
|
624
|
-
description:
|
|
625
|
-
parameters:
|
|
1602
|
+
var ChatCompletionTool = _v3.z.object({
|
|
1603
|
+
function: _v3.z.object({
|
|
1604
|
+
name: _v3.z.string(),
|
|
1605
|
+
description: _v3.z.string().optional(),
|
|
1606
|
+
parameters: _v3.z.object({}).partial().passthrough().optional()
|
|
626
1607
|
}),
|
|
627
|
-
type:
|
|
1608
|
+
type: _v3.z.literal("function")
|
|
628
1609
|
});
|
|
629
|
-
var CodeBundle =
|
|
630
|
-
runtime_context:
|
|
631
|
-
runtime:
|
|
632
|
-
version:
|
|
1610
|
+
var CodeBundle = _v3.z.object({
|
|
1611
|
+
runtime_context: _v3.z.object({
|
|
1612
|
+
runtime: _v3.z.enum(["node", "python"]),
|
|
1613
|
+
version: _v3.z.string()
|
|
633
1614
|
}),
|
|
634
|
-
location:
|
|
635
|
-
|
|
636
|
-
type:
|
|
637
|
-
eval_name:
|
|
638
|
-
position:
|
|
639
|
-
|
|
640
|
-
|
|
1615
|
+
location: _v3.z.union([
|
|
1616
|
+
_v3.z.object({
|
|
1617
|
+
type: _v3.z.literal("experiment"),
|
|
1618
|
+
eval_name: _v3.z.string(),
|
|
1619
|
+
position: _v3.z.union([
|
|
1620
|
+
_v3.z.object({ type: _v3.z.literal("task") }),
|
|
1621
|
+
_v3.z.object({ type: _v3.z.literal("scorer"), index: _v3.z.number().int().gte(0) })
|
|
641
1622
|
])
|
|
642
1623
|
}),
|
|
643
|
-
|
|
1624
|
+
_v3.z.object({ type: _v3.z.literal("function"), index: _v3.z.number().int().gte(0) })
|
|
644
1625
|
]),
|
|
645
|
-
bundle_id:
|
|
646
|
-
preview:
|
|
1626
|
+
bundle_id: _v3.z.string(),
|
|
1627
|
+
preview: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
647
1628
|
});
|
|
648
|
-
var Dataset =
|
|
649
|
-
id:
|
|
650
|
-
project_id:
|
|
651
|
-
name:
|
|
652
|
-
description:
|
|
653
|
-
created:
|
|
654
|
-
deleted_at:
|
|
655
|
-
user_id:
|
|
656
|
-
metadata:
|
|
1629
|
+
var Dataset = _v3.z.object({
|
|
1630
|
+
id: _v3.z.string().uuid(),
|
|
1631
|
+
project_id: _v3.z.string().uuid(),
|
|
1632
|
+
name: _v3.z.string(),
|
|
1633
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1634
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1635
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1636
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1637
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
|
|
657
1638
|
});
|
|
658
|
-
var ObjectReferenceNullish =
|
|
659
|
-
|
|
660
|
-
object_type:
|
|
1639
|
+
var ObjectReferenceNullish = _v3.z.union([
|
|
1640
|
+
_v3.z.object({
|
|
1641
|
+
object_type: _v3.z.enum([
|
|
661
1642
|
"project_logs",
|
|
662
1643
|
"experiment",
|
|
663
1644
|
"dataset",
|
|
@@ -665,399 +1646,399 @@ var ObjectReferenceNullish = _zod.z.union([
|
|
|
665
1646
|
"function",
|
|
666
1647
|
"prompt_session"
|
|
667
1648
|
]),
|
|
668
|
-
object_id:
|
|
669
|
-
id:
|
|
670
|
-
_xact_id:
|
|
671
|
-
created:
|
|
1649
|
+
object_id: _v3.z.string().uuid(),
|
|
1650
|
+
id: _v3.z.string(),
|
|
1651
|
+
_xact_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1652
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
672
1653
|
}),
|
|
673
|
-
|
|
1654
|
+
_v3.z.null()
|
|
674
1655
|
]);
|
|
675
|
-
var DatasetEvent =
|
|
676
|
-
id:
|
|
677
|
-
_xact_id:
|
|
678
|
-
created:
|
|
679
|
-
_pagination_key:
|
|
680
|
-
project_id:
|
|
681
|
-
dataset_id:
|
|
682
|
-
input:
|
|
683
|
-
expected:
|
|
684
|
-
metadata:
|
|
685
|
-
|
|
686
|
-
|
|
1656
|
+
var DatasetEvent = _v3.z.object({
|
|
1657
|
+
id: _v3.z.string(),
|
|
1658
|
+
_xact_id: _v3.z.string(),
|
|
1659
|
+
created: _v3.z.string().datetime({ offset: true }),
|
|
1660
|
+
_pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1661
|
+
project_id: _v3.z.string().uuid(),
|
|
1662
|
+
dataset_id: _v3.z.string().uuid(),
|
|
1663
|
+
input: _v3.z.unknown().optional(),
|
|
1664
|
+
expected: _v3.z.unknown().optional(),
|
|
1665
|
+
metadata: _v3.z.union([
|
|
1666
|
+
_v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
|
|
1667
|
+
_v3.z.null()
|
|
687
1668
|
]).optional(),
|
|
688
|
-
tags:
|
|
689
|
-
span_id:
|
|
690
|
-
root_span_id:
|
|
691
|
-
is_root:
|
|
1669
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1670
|
+
span_id: _v3.z.string(),
|
|
1671
|
+
root_span_id: _v3.z.string(),
|
|
1672
|
+
is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
692
1673
|
origin: ObjectReferenceNullish.optional()
|
|
693
1674
|
});
|
|
694
|
-
var EnvVar =
|
|
695
|
-
id:
|
|
696
|
-
object_type:
|
|
697
|
-
object_id:
|
|
698
|
-
name:
|
|
699
|
-
created:
|
|
700
|
-
used:
|
|
1675
|
+
var EnvVar = _v3.z.object({
|
|
1676
|
+
id: _v3.z.string().uuid(),
|
|
1677
|
+
object_type: _v3.z.enum(["organization", "project", "function"]),
|
|
1678
|
+
object_id: _v3.z.string().uuid(),
|
|
1679
|
+
name: _v3.z.string(),
|
|
1680
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1681
|
+
used: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
701
1682
|
});
|
|
702
|
-
var RepoInfo =
|
|
703
|
-
|
|
704
|
-
commit:
|
|
705
|
-
branch:
|
|
706
|
-
tag:
|
|
707
|
-
dirty:
|
|
708
|
-
author_name:
|
|
709
|
-
author_email:
|
|
710
|
-
commit_message:
|
|
711
|
-
commit_time:
|
|
712
|
-
git_diff:
|
|
1683
|
+
var RepoInfo = _v3.z.union([
|
|
1684
|
+
_v3.z.object({
|
|
1685
|
+
commit: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1686
|
+
branch: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1687
|
+
tag: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1688
|
+
dirty: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
1689
|
+
author_name: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1690
|
+
author_email: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1691
|
+
commit_message: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1692
|
+
commit_time: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1693
|
+
git_diff: _v3.z.union([_v3.z.string(), _v3.z.null()])
|
|
713
1694
|
}).partial(),
|
|
714
|
-
|
|
1695
|
+
_v3.z.null()
|
|
715
1696
|
]);
|
|
716
|
-
var Experiment =
|
|
717
|
-
id:
|
|
718
|
-
project_id:
|
|
719
|
-
name:
|
|
720
|
-
description:
|
|
721
|
-
created:
|
|
1697
|
+
var Experiment = _v3.z.object({
|
|
1698
|
+
id: _v3.z.string().uuid(),
|
|
1699
|
+
project_id: _v3.z.string().uuid(),
|
|
1700
|
+
name: _v3.z.string(),
|
|
1701
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1702
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
722
1703
|
repo_info: RepoInfo.optional(),
|
|
723
|
-
commit:
|
|
724
|
-
base_exp_id:
|
|
725
|
-
deleted_at:
|
|
726
|
-
dataset_id:
|
|
727
|
-
dataset_version:
|
|
728
|
-
public:
|
|
729
|
-
user_id:
|
|
730
|
-
metadata:
|
|
731
|
-
tags:
|
|
1704
|
+
commit: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1705
|
+
base_exp_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1706
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1707
|
+
dataset_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1708
|
+
dataset_version: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1709
|
+
public: _v3.z.boolean(),
|
|
1710
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1711
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
|
|
1712
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional()
|
|
732
1713
|
});
|
|
733
|
-
var SpanType =
|
|
734
|
-
|
|
735
|
-
|
|
1714
|
+
var SpanType = _v3.z.union([
|
|
1715
|
+
_v3.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
|
|
1716
|
+
_v3.z.null()
|
|
736
1717
|
]);
|
|
737
|
-
var SpanAttributes =
|
|
738
|
-
|
|
739
|
-
|
|
1718
|
+
var SpanAttributes = _v3.z.union([
|
|
1719
|
+
_v3.z.object({ name: _v3.z.union([_v3.z.string(), _v3.z.null()]), type: SpanType }).partial().passthrough(),
|
|
1720
|
+
_v3.z.null()
|
|
740
1721
|
]);
|
|
741
|
-
var ExperimentEvent =
|
|
742
|
-
id:
|
|
743
|
-
_xact_id:
|
|
744
|
-
created:
|
|
745
|
-
_pagination_key:
|
|
746
|
-
project_id:
|
|
747
|
-
experiment_id:
|
|
748
|
-
input:
|
|
749
|
-
output:
|
|
750
|
-
expected:
|
|
751
|
-
error:
|
|
752
|
-
scores:
|
|
753
|
-
metadata:
|
|
754
|
-
|
|
755
|
-
|
|
1722
|
+
var ExperimentEvent = _v3.z.object({
|
|
1723
|
+
id: _v3.z.string(),
|
|
1724
|
+
_xact_id: _v3.z.string(),
|
|
1725
|
+
created: _v3.z.string().datetime({ offset: true }),
|
|
1726
|
+
_pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1727
|
+
project_id: _v3.z.string().uuid(),
|
|
1728
|
+
experiment_id: _v3.z.string().uuid(),
|
|
1729
|
+
input: _v3.z.unknown().optional(),
|
|
1730
|
+
output: _v3.z.unknown().optional(),
|
|
1731
|
+
expected: _v3.z.unknown().optional(),
|
|
1732
|
+
error: _v3.z.unknown().optional(),
|
|
1733
|
+
scores: _v3.z.union([_v3.z.record(_v3.z.union([_v3.z.number(), _v3.z.null()])), _v3.z.null()]).optional(),
|
|
1734
|
+
metadata: _v3.z.union([
|
|
1735
|
+
_v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
|
|
1736
|
+
_v3.z.null()
|
|
756
1737
|
]).optional(),
|
|
757
|
-
tags:
|
|
758
|
-
metrics:
|
|
759
|
-
context:
|
|
760
|
-
|
|
761
|
-
caller_functionname:
|
|
762
|
-
caller_filename:
|
|
763
|
-
caller_lineno:
|
|
1738
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1739
|
+
metrics: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]).optional(),
|
|
1740
|
+
context: _v3.z.union([
|
|
1741
|
+
_v3.z.object({
|
|
1742
|
+
caller_functionname: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1743
|
+
caller_filename: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1744
|
+
caller_lineno: _v3.z.union([_v3.z.number(), _v3.z.null()])
|
|
764
1745
|
}).partial().passthrough(),
|
|
765
|
-
|
|
1746
|
+
_v3.z.null()
|
|
766
1747
|
]).optional(),
|
|
767
|
-
span_id:
|
|
768
|
-
span_parents:
|
|
769
|
-
root_span_id:
|
|
1748
|
+
span_id: _v3.z.string(),
|
|
1749
|
+
span_parents: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1750
|
+
root_span_id: _v3.z.string(),
|
|
770
1751
|
span_attributes: SpanAttributes.optional(),
|
|
771
|
-
is_root:
|
|
1752
|
+
is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
772
1753
|
origin: ObjectReferenceNullish.optional()
|
|
773
1754
|
});
|
|
774
|
-
var ExtendedSavedFunctionId =
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
type:
|
|
779
|
-
project_id:
|
|
780
|
-
slug:
|
|
1755
|
+
var ExtendedSavedFunctionId = _v3.z.union([
|
|
1756
|
+
_v3.z.object({ type: _v3.z.literal("function"), id: _v3.z.string() }),
|
|
1757
|
+
_v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() }),
|
|
1758
|
+
_v3.z.object({
|
|
1759
|
+
type: _v3.z.literal("slug"),
|
|
1760
|
+
project_id: _v3.z.string(),
|
|
1761
|
+
slug: _v3.z.string()
|
|
781
1762
|
})
|
|
782
1763
|
]);
|
|
783
|
-
var PromptBlockDataNullish =
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
type:
|
|
787
|
-
messages:
|
|
788
|
-
tools:
|
|
1764
|
+
var PromptBlockDataNullish = _v3.z.union([
|
|
1765
|
+
_v3.z.object({ type: _v3.z.literal("completion"), content: _v3.z.string() }),
|
|
1766
|
+
_v3.z.object({
|
|
1767
|
+
type: _v3.z.literal("chat"),
|
|
1768
|
+
messages: _v3.z.array(ChatCompletionMessageParam),
|
|
1769
|
+
tools: _v3.z.string().optional()
|
|
789
1770
|
}),
|
|
790
|
-
|
|
1771
|
+
_v3.z.null()
|
|
791
1772
|
]);
|
|
792
|
-
var ModelParams =
|
|
793
|
-
|
|
794
|
-
use_cache:
|
|
795
|
-
temperature:
|
|
796
|
-
top_p:
|
|
797
|
-
max_tokens:
|
|
798
|
-
max_completion_tokens:
|
|
799
|
-
frequency_penalty:
|
|
800
|
-
presence_penalty:
|
|
1773
|
+
var ModelParams = _v3.z.union([
|
|
1774
|
+
_v3.z.object({
|
|
1775
|
+
use_cache: _v3.z.boolean(),
|
|
1776
|
+
temperature: _v3.z.number(),
|
|
1777
|
+
top_p: _v3.z.number(),
|
|
1778
|
+
max_tokens: _v3.z.number(),
|
|
1779
|
+
max_completion_tokens: _v3.z.number(),
|
|
1780
|
+
frequency_penalty: _v3.z.number(),
|
|
1781
|
+
presence_penalty: _v3.z.number(),
|
|
801
1782
|
response_format: ResponseFormatNullish,
|
|
802
|
-
tool_choice:
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
type:
|
|
808
|
-
function:
|
|
1783
|
+
tool_choice: _v3.z.union([
|
|
1784
|
+
_v3.z.literal("auto"),
|
|
1785
|
+
_v3.z.literal("none"),
|
|
1786
|
+
_v3.z.literal("required"),
|
|
1787
|
+
_v3.z.object({
|
|
1788
|
+
type: _v3.z.literal("function"),
|
|
1789
|
+
function: _v3.z.object({ name: _v3.z.string() })
|
|
809
1790
|
})
|
|
810
1791
|
]),
|
|
811
|
-
function_call:
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
1792
|
+
function_call: _v3.z.union([
|
|
1793
|
+
_v3.z.literal("auto"),
|
|
1794
|
+
_v3.z.literal("none"),
|
|
1795
|
+
_v3.z.object({ name: _v3.z.string() })
|
|
815
1796
|
]),
|
|
816
|
-
n:
|
|
817
|
-
stop:
|
|
818
|
-
reasoning_effort:
|
|
819
|
-
verbosity:
|
|
1797
|
+
n: _v3.z.number(),
|
|
1798
|
+
stop: _v3.z.array(_v3.z.string()),
|
|
1799
|
+
reasoning_effort: _v3.z.enum(["minimal", "low", "medium", "high"]),
|
|
1800
|
+
verbosity: _v3.z.enum(["low", "medium", "high"])
|
|
820
1801
|
}).partial().passthrough(),
|
|
821
|
-
|
|
822
|
-
use_cache:
|
|
823
|
-
max_tokens:
|
|
824
|
-
temperature:
|
|
825
|
-
top_p:
|
|
826
|
-
top_k:
|
|
827
|
-
stop_sequences:
|
|
828
|
-
max_tokens_to_sample:
|
|
1802
|
+
_v3.z.object({
|
|
1803
|
+
use_cache: _v3.z.boolean().optional(),
|
|
1804
|
+
max_tokens: _v3.z.number(),
|
|
1805
|
+
temperature: _v3.z.number(),
|
|
1806
|
+
top_p: _v3.z.number().optional(),
|
|
1807
|
+
top_k: _v3.z.number().optional(),
|
|
1808
|
+
stop_sequences: _v3.z.array(_v3.z.string()).optional(),
|
|
1809
|
+
max_tokens_to_sample: _v3.z.number().optional()
|
|
829
1810
|
}).passthrough(),
|
|
830
|
-
|
|
831
|
-
use_cache:
|
|
832
|
-
temperature:
|
|
833
|
-
maxOutputTokens:
|
|
834
|
-
topP:
|
|
835
|
-
topK:
|
|
1811
|
+
_v3.z.object({
|
|
1812
|
+
use_cache: _v3.z.boolean(),
|
|
1813
|
+
temperature: _v3.z.number(),
|
|
1814
|
+
maxOutputTokens: _v3.z.number(),
|
|
1815
|
+
topP: _v3.z.number(),
|
|
1816
|
+
topK: _v3.z.number()
|
|
836
1817
|
}).partial().passthrough(),
|
|
837
|
-
|
|
838
|
-
use_cache:
|
|
839
|
-
temperature:
|
|
840
|
-
topK:
|
|
1818
|
+
_v3.z.object({
|
|
1819
|
+
use_cache: _v3.z.boolean(),
|
|
1820
|
+
temperature: _v3.z.number(),
|
|
1821
|
+
topK: _v3.z.number()
|
|
841
1822
|
}).partial().passthrough(),
|
|
842
|
-
|
|
1823
|
+
_v3.z.object({ use_cache: _v3.z.boolean() }).partial().passthrough()
|
|
843
1824
|
]);
|
|
844
|
-
var PromptOptionsNullish =
|
|
845
|
-
|
|
846
|
-
|
|
1825
|
+
var PromptOptionsNullish = _v3.z.union([
|
|
1826
|
+
_v3.z.object({ model: _v3.z.string(), params: ModelParams, position: _v3.z.string() }).partial(),
|
|
1827
|
+
_v3.z.null()
|
|
847
1828
|
]);
|
|
848
|
-
var PromptParserNullish =
|
|
849
|
-
|
|
850
|
-
type:
|
|
851
|
-
use_cot:
|
|
852
|
-
choice_scores:
|
|
1829
|
+
var PromptParserNullish = _v3.z.union([
|
|
1830
|
+
_v3.z.object({
|
|
1831
|
+
type: _v3.z.literal("llm_classifier"),
|
|
1832
|
+
use_cot: _v3.z.boolean(),
|
|
1833
|
+
choice_scores: _v3.z.record(_v3.z.number().gte(0).lte(1))
|
|
853
1834
|
}),
|
|
854
|
-
|
|
1835
|
+
_v3.z.null()
|
|
855
1836
|
]);
|
|
856
|
-
var SavedFunctionId =
|
|
857
|
-
|
|
858
|
-
|
|
1837
|
+
var SavedFunctionId = _v3.z.union([
|
|
1838
|
+
_v3.z.object({ type: _v3.z.literal("function"), id: _v3.z.string() }),
|
|
1839
|
+
_v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() })
|
|
859
1840
|
]);
|
|
860
|
-
var PromptDataNullish =
|
|
861
|
-
|
|
1841
|
+
var PromptDataNullish = _v3.z.union([
|
|
1842
|
+
_v3.z.object({
|
|
862
1843
|
prompt: PromptBlockDataNullish,
|
|
863
1844
|
options: PromptOptionsNullish,
|
|
864
1845
|
parser: PromptParserNullish,
|
|
865
|
-
tool_functions:
|
|
866
|
-
origin:
|
|
867
|
-
|
|
868
|
-
prompt_id:
|
|
869
|
-
project_id:
|
|
870
|
-
prompt_version:
|
|
1846
|
+
tool_functions: _v3.z.union([_v3.z.array(SavedFunctionId), _v3.z.null()]),
|
|
1847
|
+
origin: _v3.z.union([
|
|
1848
|
+
_v3.z.object({
|
|
1849
|
+
prompt_id: _v3.z.string(),
|
|
1850
|
+
project_id: _v3.z.string(),
|
|
1851
|
+
prompt_version: _v3.z.string()
|
|
871
1852
|
}).partial(),
|
|
872
|
-
|
|
1853
|
+
_v3.z.null()
|
|
873
1854
|
])
|
|
874
1855
|
}).partial(),
|
|
875
|
-
|
|
1856
|
+
_v3.z.null()
|
|
876
1857
|
]);
|
|
877
|
-
var FunctionTypeEnumNullish =
|
|
878
|
-
|
|
879
|
-
|
|
1858
|
+
var FunctionTypeEnumNullish = _v3.z.union([
|
|
1859
|
+
_v3.z.enum(["llm", "scorer", "task", "tool"]),
|
|
1860
|
+
_v3.z.null()
|
|
880
1861
|
]);
|
|
881
|
-
var FunctionIdRef =
|
|
882
|
-
var PromptBlockData =
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
type:
|
|
886
|
-
messages:
|
|
887
|
-
tools:
|
|
1862
|
+
var FunctionIdRef = _v3.z.object({}).partial().passthrough();
|
|
1863
|
+
var PromptBlockData = _v3.z.union([
|
|
1864
|
+
_v3.z.object({ type: _v3.z.literal("completion"), content: _v3.z.string() }),
|
|
1865
|
+
_v3.z.object({
|
|
1866
|
+
type: _v3.z.literal("chat"),
|
|
1867
|
+
messages: _v3.z.array(ChatCompletionMessageParam),
|
|
1868
|
+
tools: _v3.z.string().optional()
|
|
888
1869
|
})
|
|
889
1870
|
]);
|
|
890
|
-
var GraphNode =
|
|
891
|
-
|
|
892
|
-
description:
|
|
893
|
-
position:
|
|
894
|
-
type:
|
|
1871
|
+
var GraphNode = _v3.z.union([
|
|
1872
|
+
_v3.z.object({
|
|
1873
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1874
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1875
|
+
type: _v3.z.literal("function"),
|
|
895
1876
|
function: FunctionIdRef
|
|
896
1877
|
}),
|
|
897
|
-
|
|
898
|
-
description:
|
|
899
|
-
position:
|
|
900
|
-
type:
|
|
1878
|
+
_v3.z.object({
|
|
1879
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1880
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1881
|
+
type: _v3.z.literal("input")
|
|
901
1882
|
}),
|
|
902
|
-
|
|
903
|
-
description:
|
|
904
|
-
position:
|
|
905
|
-
type:
|
|
1883
|
+
_v3.z.object({
|
|
1884
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1885
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1886
|
+
type: _v3.z.literal("output")
|
|
906
1887
|
}),
|
|
907
|
-
|
|
908
|
-
description:
|
|
909
|
-
position:
|
|
910
|
-
type:
|
|
911
|
-
value:
|
|
1888
|
+
_v3.z.object({
|
|
1889
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1890
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1891
|
+
type: _v3.z.literal("literal"),
|
|
1892
|
+
value: _v3.z.unknown().optional()
|
|
912
1893
|
}),
|
|
913
|
-
|
|
914
|
-
description:
|
|
915
|
-
position:
|
|
916
|
-
type:
|
|
917
|
-
expr:
|
|
1894
|
+
_v3.z.object({
|
|
1895
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1896
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1897
|
+
type: _v3.z.literal("btql"),
|
|
1898
|
+
expr: _v3.z.string()
|
|
918
1899
|
}),
|
|
919
|
-
|
|
920
|
-
description:
|
|
921
|
-
position:
|
|
922
|
-
type:
|
|
923
|
-
condition:
|
|
1900
|
+
_v3.z.object({
|
|
1901
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1902
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1903
|
+
type: _v3.z.literal("gate"),
|
|
1904
|
+
condition: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
924
1905
|
}),
|
|
925
|
-
|
|
926
|
-
description:
|
|
927
|
-
position:
|
|
928
|
-
type:
|
|
1906
|
+
_v3.z.object({
|
|
1907
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1908
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1909
|
+
type: _v3.z.literal("aggregator")
|
|
929
1910
|
}),
|
|
930
|
-
|
|
931
|
-
description:
|
|
932
|
-
position:
|
|
933
|
-
type:
|
|
1911
|
+
_v3.z.object({
|
|
1912
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1913
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1914
|
+
type: _v3.z.literal("prompt_template"),
|
|
934
1915
|
prompt: PromptBlockData
|
|
935
1916
|
})
|
|
936
1917
|
]);
|
|
937
|
-
var GraphEdge =
|
|
938
|
-
source:
|
|
939
|
-
target:
|
|
940
|
-
purpose:
|
|
1918
|
+
var GraphEdge = _v3.z.object({
|
|
1919
|
+
source: _v3.z.object({ node: _v3.z.string().max(1024), variable: _v3.z.string() }),
|
|
1920
|
+
target: _v3.z.object({ node: _v3.z.string().max(1024), variable: _v3.z.string() }),
|
|
1921
|
+
purpose: _v3.z.enum(["control", "data", "messages"])
|
|
941
1922
|
});
|
|
942
|
-
var GraphData =
|
|
943
|
-
type:
|
|
944
|
-
nodes:
|
|
945
|
-
edges:
|
|
1923
|
+
var GraphData = _v3.z.object({
|
|
1924
|
+
type: _v3.z.literal("graph"),
|
|
1925
|
+
nodes: _v3.z.record(GraphNode),
|
|
1926
|
+
edges: _v3.z.record(GraphEdge)
|
|
946
1927
|
});
|
|
947
|
-
var FunctionData =
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
type:
|
|
951
|
-
data:
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
type:
|
|
955
|
-
runtime_context:
|
|
956
|
-
runtime:
|
|
957
|
-
version:
|
|
1928
|
+
var FunctionData = _v3.z.union([
|
|
1929
|
+
_v3.z.object({ type: _v3.z.literal("prompt") }),
|
|
1930
|
+
_v3.z.object({
|
|
1931
|
+
type: _v3.z.literal("code"),
|
|
1932
|
+
data: _v3.z.union([
|
|
1933
|
+
_v3.z.object({ type: _v3.z.literal("bundle") }).and(CodeBundle),
|
|
1934
|
+
_v3.z.object({
|
|
1935
|
+
type: _v3.z.literal("inline"),
|
|
1936
|
+
runtime_context: _v3.z.object({
|
|
1937
|
+
runtime: _v3.z.enum(["node", "python"]),
|
|
1938
|
+
version: _v3.z.string()
|
|
958
1939
|
}),
|
|
959
|
-
code:
|
|
1940
|
+
code: _v3.z.string()
|
|
960
1941
|
})
|
|
961
1942
|
])
|
|
962
1943
|
}),
|
|
963
1944
|
GraphData,
|
|
964
|
-
|
|
965
|
-
type:
|
|
966
|
-
endpoint:
|
|
967
|
-
eval_name:
|
|
968
|
-
parameters:
|
|
1945
|
+
_v3.z.object({
|
|
1946
|
+
type: _v3.z.literal("remote_eval"),
|
|
1947
|
+
endpoint: _v3.z.string(),
|
|
1948
|
+
eval_name: _v3.z.string(),
|
|
1949
|
+
parameters: _v3.z.object({}).partial().passthrough()
|
|
969
1950
|
}),
|
|
970
|
-
|
|
1951
|
+
_v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() })
|
|
971
1952
|
]);
|
|
972
|
-
var Function =
|
|
973
|
-
id:
|
|
974
|
-
_xact_id:
|
|
975
|
-
project_id:
|
|
976
|
-
log_id:
|
|
977
|
-
org_id:
|
|
978
|
-
name:
|
|
979
|
-
slug:
|
|
980
|
-
description:
|
|
981
|
-
created:
|
|
1953
|
+
var Function = _v3.z.object({
|
|
1954
|
+
id: _v3.z.string().uuid(),
|
|
1955
|
+
_xact_id: _v3.z.string(),
|
|
1956
|
+
project_id: _v3.z.string().uuid(),
|
|
1957
|
+
log_id: _v3.z.literal("p"),
|
|
1958
|
+
org_id: _v3.z.string().uuid(),
|
|
1959
|
+
name: _v3.z.string(),
|
|
1960
|
+
slug: _v3.z.string(),
|
|
1961
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1962
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
982
1963
|
prompt_data: PromptDataNullish.optional(),
|
|
983
|
-
tags:
|
|
984
|
-
metadata:
|
|
1964
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1965
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
|
|
985
1966
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
986
1967
|
function_data: FunctionData,
|
|
987
|
-
origin:
|
|
988
|
-
|
|
989
|
-
object_type: AclObjectType.and(
|
|
990
|
-
object_id:
|
|
991
|
-
internal:
|
|
1968
|
+
origin: _v3.z.union([
|
|
1969
|
+
_v3.z.object({
|
|
1970
|
+
object_type: AclObjectType.and(_v3.z.string()),
|
|
1971
|
+
object_id: _v3.z.string().uuid(),
|
|
1972
|
+
internal: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
992
1973
|
}),
|
|
993
|
-
|
|
1974
|
+
_v3.z.null()
|
|
994
1975
|
]).optional(),
|
|
995
|
-
function_schema:
|
|
996
|
-
|
|
997
|
-
|
|
1976
|
+
function_schema: _v3.z.union([
|
|
1977
|
+
_v3.z.object({ parameters: _v3.z.unknown(), returns: _v3.z.unknown() }).partial(),
|
|
1978
|
+
_v3.z.null()
|
|
998
1979
|
]).optional()
|
|
999
1980
|
});
|
|
1000
|
-
var FunctionFormat =
|
|
1001
|
-
var PromptData =
|
|
1981
|
+
var FunctionFormat = _v3.z.enum(["llm", "code", "global", "graph"]);
|
|
1982
|
+
var PromptData = _v3.z.object({
|
|
1002
1983
|
prompt: PromptBlockDataNullish,
|
|
1003
1984
|
options: PromptOptionsNullish,
|
|
1004
1985
|
parser: PromptParserNullish,
|
|
1005
|
-
tool_functions:
|
|
1006
|
-
origin:
|
|
1007
|
-
|
|
1008
|
-
prompt_id:
|
|
1009
|
-
project_id:
|
|
1010
|
-
prompt_version:
|
|
1986
|
+
tool_functions: _v3.z.union([_v3.z.array(SavedFunctionId), _v3.z.null()]),
|
|
1987
|
+
origin: _v3.z.union([
|
|
1988
|
+
_v3.z.object({
|
|
1989
|
+
prompt_id: _v3.z.string(),
|
|
1990
|
+
project_id: _v3.z.string(),
|
|
1991
|
+
prompt_version: _v3.z.string()
|
|
1011
1992
|
}).partial(),
|
|
1012
|
-
|
|
1993
|
+
_v3.z.null()
|
|
1013
1994
|
])
|
|
1014
1995
|
}).partial();
|
|
1015
|
-
var FunctionTypeEnum =
|
|
1016
|
-
var FunctionId =
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
project_name:
|
|
1020
|
-
slug:
|
|
1021
|
-
version:
|
|
1996
|
+
var FunctionTypeEnum = _v3.z.enum(["llm", "scorer", "task", "tool"]);
|
|
1997
|
+
var FunctionId = _v3.z.union([
|
|
1998
|
+
_v3.z.object({ function_id: _v3.z.string(), version: _v3.z.string().optional() }),
|
|
1999
|
+
_v3.z.object({
|
|
2000
|
+
project_name: _v3.z.string(),
|
|
2001
|
+
slug: _v3.z.string(),
|
|
2002
|
+
version: _v3.z.string().optional()
|
|
1022
2003
|
}),
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
prompt_session_id:
|
|
1026
|
-
prompt_session_function_id:
|
|
1027
|
-
version:
|
|
2004
|
+
_v3.z.object({ global_function: _v3.z.string() }),
|
|
2005
|
+
_v3.z.object({
|
|
2006
|
+
prompt_session_id: _v3.z.string(),
|
|
2007
|
+
prompt_session_function_id: _v3.z.string(),
|
|
2008
|
+
version: _v3.z.string().optional()
|
|
1028
2009
|
}),
|
|
1029
|
-
|
|
1030
|
-
inline_context:
|
|
1031
|
-
runtime:
|
|
1032
|
-
version:
|
|
2010
|
+
_v3.z.object({
|
|
2011
|
+
inline_context: _v3.z.object({
|
|
2012
|
+
runtime: _v3.z.enum(["node", "python"]),
|
|
2013
|
+
version: _v3.z.string()
|
|
1033
2014
|
}),
|
|
1034
|
-
code:
|
|
1035
|
-
name:
|
|
2015
|
+
code: _v3.z.string(),
|
|
2016
|
+
name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1036
2017
|
}),
|
|
1037
|
-
|
|
2018
|
+
_v3.z.object({
|
|
1038
2019
|
inline_prompt: PromptData.optional(),
|
|
1039
|
-
inline_function:
|
|
2020
|
+
inline_function: _v3.z.object({}).partial().passthrough(),
|
|
1040
2021
|
function_type: FunctionTypeEnum.optional(),
|
|
1041
|
-
name:
|
|
2022
|
+
name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1042
2023
|
}),
|
|
1043
|
-
|
|
2024
|
+
_v3.z.object({
|
|
1044
2025
|
inline_prompt: PromptData,
|
|
1045
2026
|
function_type: FunctionTypeEnum.optional(),
|
|
1046
|
-
name:
|
|
2027
|
+
name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1047
2028
|
})
|
|
1048
2029
|
]);
|
|
1049
|
-
var FunctionObjectType =
|
|
2030
|
+
var FunctionObjectType = _v3.z.enum([
|
|
1050
2031
|
"prompt",
|
|
1051
2032
|
"tool",
|
|
1052
2033
|
"scorer",
|
|
1053
2034
|
"task",
|
|
1054
2035
|
"agent"
|
|
1055
2036
|
]);
|
|
1056
|
-
var FunctionOutputType =
|
|
1057
|
-
var GitMetadataSettings =
|
|
1058
|
-
collect:
|
|
1059
|
-
fields:
|
|
1060
|
-
|
|
2037
|
+
var FunctionOutputType = _v3.z.enum(["completion", "score", "any"]);
|
|
2038
|
+
var GitMetadataSettings = _v3.z.object({
|
|
2039
|
+
collect: _v3.z.enum(["all", "none", "some"]),
|
|
2040
|
+
fields: _v3.z.array(
|
|
2041
|
+
_v3.z.enum([
|
|
1061
2042
|
"commit",
|
|
1062
2043
|
"branch",
|
|
1063
2044
|
"tag",
|
|
@@ -1070,49 +2051,49 @@ var GitMetadataSettings = _zod.z.object({
|
|
|
1070
2051
|
])
|
|
1071
2052
|
).optional()
|
|
1072
2053
|
});
|
|
1073
|
-
var Group =
|
|
1074
|
-
id:
|
|
1075
|
-
org_id:
|
|
1076
|
-
user_id:
|
|
1077
|
-
created:
|
|
1078
|
-
name:
|
|
1079
|
-
description:
|
|
1080
|
-
deleted_at:
|
|
1081
|
-
member_users:
|
|
1082
|
-
member_groups:
|
|
2054
|
+
var Group = _v3.z.object({
|
|
2055
|
+
id: _v3.z.string().uuid(),
|
|
2056
|
+
org_id: _v3.z.string().uuid(),
|
|
2057
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2058
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2059
|
+
name: _v3.z.string(),
|
|
2060
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2061
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2062
|
+
member_users: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional(),
|
|
2063
|
+
member_groups: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional()
|
|
1083
2064
|
});
|
|
1084
|
-
var IfExists =
|
|
1085
|
-
var InvokeParent =
|
|
1086
|
-
|
|
1087
|
-
object_type:
|
|
1088
|
-
object_id:
|
|
1089
|
-
row_ids:
|
|
1090
|
-
|
|
1091
|
-
id:
|
|
1092
|
-
span_id:
|
|
1093
|
-
root_span_id:
|
|
2065
|
+
var IfExists = _v3.z.enum(["error", "ignore", "replace"]);
|
|
2066
|
+
var InvokeParent = _v3.z.union([
|
|
2067
|
+
_v3.z.object({
|
|
2068
|
+
object_type: _v3.z.enum(["project_logs", "experiment", "playground_logs"]),
|
|
2069
|
+
object_id: _v3.z.string(),
|
|
2070
|
+
row_ids: _v3.z.union([
|
|
2071
|
+
_v3.z.object({
|
|
2072
|
+
id: _v3.z.string(),
|
|
2073
|
+
span_id: _v3.z.string(),
|
|
2074
|
+
root_span_id: _v3.z.string()
|
|
1094
2075
|
}),
|
|
1095
|
-
|
|
2076
|
+
_v3.z.null()
|
|
1096
2077
|
]).optional(),
|
|
1097
|
-
propagated_event:
|
|
2078
|
+
propagated_event: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
|
|
1098
2079
|
}),
|
|
1099
|
-
|
|
2080
|
+
_v3.z.string()
|
|
1100
2081
|
]);
|
|
1101
|
-
var StreamingMode =
|
|
2082
|
+
var StreamingMode = _v3.z.union([_v3.z.enum(["auto", "parallel"]), _v3.z.null()]);
|
|
1102
2083
|
var InvokeFunction = FunctionId.and(
|
|
1103
|
-
|
|
1104
|
-
input:
|
|
1105
|
-
expected:
|
|
1106
|
-
metadata:
|
|
1107
|
-
tags:
|
|
1108
|
-
messages:
|
|
2084
|
+
_v3.z.object({
|
|
2085
|
+
input: _v3.z.unknown(),
|
|
2086
|
+
expected: _v3.z.unknown(),
|
|
2087
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]),
|
|
2088
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]),
|
|
2089
|
+
messages: _v3.z.array(ChatCompletionMessageParam),
|
|
1109
2090
|
parent: InvokeParent,
|
|
1110
|
-
stream:
|
|
2091
|
+
stream: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
1111
2092
|
mode: StreamingMode,
|
|
1112
|
-
strict:
|
|
2093
|
+
strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()])
|
|
1113
2094
|
}).partial()
|
|
1114
2095
|
);
|
|
1115
|
-
var MessageRole =
|
|
2096
|
+
var MessageRole = _v3.z.enum([
|
|
1116
2097
|
"system",
|
|
1117
2098
|
"user",
|
|
1118
2099
|
"assistant",
|
|
@@ -1121,8 +2102,8 @@ var MessageRole = _zod.z.enum([
|
|
|
1121
2102
|
"model",
|
|
1122
2103
|
"developer"
|
|
1123
2104
|
]);
|
|
1124
|
-
var ObjectReference =
|
|
1125
|
-
object_type:
|
|
2105
|
+
var ObjectReference = _v3.z.object({
|
|
2106
|
+
object_type: _v3.z.enum([
|
|
1126
2107
|
"project_logs",
|
|
1127
2108
|
"experiment",
|
|
1128
2109
|
"dataset",
|
|
@@ -1130,146 +2111,146 @@ var ObjectReference = _zod.z.object({
|
|
|
1130
2111
|
"function",
|
|
1131
2112
|
"prompt_session"
|
|
1132
2113
|
]),
|
|
1133
|
-
object_id:
|
|
1134
|
-
id:
|
|
1135
|
-
_xact_id:
|
|
1136
|
-
created:
|
|
2114
|
+
object_id: _v3.z.string().uuid(),
|
|
2115
|
+
id: _v3.z.string(),
|
|
2116
|
+
_xact_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2117
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1137
2118
|
});
|
|
1138
|
-
var OnlineScoreConfig =
|
|
1139
|
-
|
|
1140
|
-
sampling_rate:
|
|
1141
|
-
scorers:
|
|
1142
|
-
btql_filter:
|
|
1143
|
-
apply_to_root_span:
|
|
1144
|
-
apply_to_span_names:
|
|
1145
|
-
skip_logging:
|
|
2119
|
+
var OnlineScoreConfig = _v3.z.union([
|
|
2120
|
+
_v3.z.object({
|
|
2121
|
+
sampling_rate: _v3.z.number().gte(0).lte(1),
|
|
2122
|
+
scorers: _v3.z.array(SavedFunctionId),
|
|
2123
|
+
btql_filter: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2124
|
+
apply_to_root_span: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
2125
|
+
apply_to_span_names: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
2126
|
+
skip_logging: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
1146
2127
|
}),
|
|
1147
|
-
|
|
2128
|
+
_v3.z.null()
|
|
1148
2129
|
]);
|
|
1149
|
-
var Organization =
|
|
1150
|
-
id:
|
|
1151
|
-
name:
|
|
1152
|
-
api_url:
|
|
1153
|
-
is_universal_api:
|
|
1154
|
-
proxy_url:
|
|
1155
|
-
realtime_url:
|
|
1156
|
-
created:
|
|
2130
|
+
var Organization = _v3.z.object({
|
|
2131
|
+
id: _v3.z.string().uuid(),
|
|
2132
|
+
name: _v3.z.string(),
|
|
2133
|
+
api_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2134
|
+
is_universal_api: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
2135
|
+
proxy_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2136
|
+
realtime_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2137
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1157
2138
|
});
|
|
1158
|
-
var ProjectSettings =
|
|
1159
|
-
|
|
1160
|
-
comparison_key:
|
|
1161
|
-
baseline_experiment_id:
|
|
1162
|
-
spanFieldOrder:
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
object_type:
|
|
1166
|
-
column_id:
|
|
1167
|
-
position:
|
|
1168
|
-
layout:
|
|
2139
|
+
var ProjectSettings = _v3.z.union([
|
|
2140
|
+
_v3.z.object({
|
|
2141
|
+
comparison_key: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2142
|
+
baseline_experiment_id: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2143
|
+
spanFieldOrder: _v3.z.union([
|
|
2144
|
+
_v3.z.array(
|
|
2145
|
+
_v3.z.object({
|
|
2146
|
+
object_type: _v3.z.string(),
|
|
2147
|
+
column_id: _v3.z.string(),
|
|
2148
|
+
position: _v3.z.string(),
|
|
2149
|
+
layout: _v3.z.union([_v3.z.literal("full"), _v3.z.literal("two_column"), _v3.z.null()]).optional()
|
|
1169
2150
|
})
|
|
1170
2151
|
),
|
|
1171
|
-
|
|
2152
|
+
_v3.z.null()
|
|
1172
2153
|
]),
|
|
1173
|
-
remote_eval_sources:
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
url:
|
|
1177
|
-
name:
|
|
1178
|
-
description:
|
|
2154
|
+
remote_eval_sources: _v3.z.union([
|
|
2155
|
+
_v3.z.array(
|
|
2156
|
+
_v3.z.object({
|
|
2157
|
+
url: _v3.z.string(),
|
|
2158
|
+
name: _v3.z.string(),
|
|
2159
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1179
2160
|
})
|
|
1180
2161
|
),
|
|
1181
|
-
|
|
2162
|
+
_v3.z.null()
|
|
1182
2163
|
])
|
|
1183
2164
|
}).partial(),
|
|
1184
|
-
|
|
2165
|
+
_v3.z.null()
|
|
1185
2166
|
]);
|
|
1186
|
-
var Project =
|
|
1187
|
-
id:
|
|
1188
|
-
org_id:
|
|
1189
|
-
name:
|
|
1190
|
-
created:
|
|
1191
|
-
deleted_at:
|
|
1192
|
-
user_id:
|
|
2167
|
+
var Project = _v3.z.object({
|
|
2168
|
+
id: _v3.z.string().uuid(),
|
|
2169
|
+
org_id: _v3.z.string().uuid(),
|
|
2170
|
+
name: _v3.z.string(),
|
|
2171
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2172
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2173
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1193
2174
|
settings: ProjectSettings.optional()
|
|
1194
2175
|
});
|
|
1195
|
-
var RetentionObjectType =
|
|
2176
|
+
var RetentionObjectType = _v3.z.enum([
|
|
1196
2177
|
"project_logs",
|
|
1197
2178
|
"experiment",
|
|
1198
2179
|
"dataset"
|
|
1199
2180
|
]);
|
|
1200
|
-
var ProjectAutomation =
|
|
1201
|
-
id:
|
|
1202
|
-
project_id:
|
|
1203
|
-
user_id:
|
|
1204
|
-
created:
|
|
1205
|
-
name:
|
|
1206
|
-
description:
|
|
1207
|
-
config:
|
|
1208
|
-
|
|
1209
|
-
event_type:
|
|
1210
|
-
btql_filter:
|
|
1211
|
-
interval_seconds:
|
|
1212
|
-
action:
|
|
2181
|
+
var ProjectAutomation = _v3.z.object({
|
|
2182
|
+
id: _v3.z.string().uuid(),
|
|
2183
|
+
project_id: _v3.z.string().uuid(),
|
|
2184
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2185
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2186
|
+
name: _v3.z.string(),
|
|
2187
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2188
|
+
config: _v3.z.union([
|
|
2189
|
+
_v3.z.object({
|
|
2190
|
+
event_type: _v3.z.literal("logs"),
|
|
2191
|
+
btql_filter: _v3.z.string(),
|
|
2192
|
+
interval_seconds: _v3.z.number().gte(1).lte(2592e3),
|
|
2193
|
+
action: _v3.z.object({ type: _v3.z.literal("webhook"), url: _v3.z.string() })
|
|
1213
2194
|
}),
|
|
1214
|
-
|
|
1215
|
-
event_type:
|
|
1216
|
-
export_definition:
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
2195
|
+
_v3.z.object({
|
|
2196
|
+
event_type: _v3.z.literal("btql_export"),
|
|
2197
|
+
export_definition: _v3.z.union([
|
|
2198
|
+
_v3.z.object({ type: _v3.z.literal("log_traces") }),
|
|
2199
|
+
_v3.z.object({ type: _v3.z.literal("log_spans") }),
|
|
2200
|
+
_v3.z.object({ type: _v3.z.literal("btql_query"), btql_query: _v3.z.string() })
|
|
1220
2201
|
]),
|
|
1221
|
-
export_path:
|
|
1222
|
-
format:
|
|
1223
|
-
interval_seconds:
|
|
1224
|
-
credentials:
|
|
1225
|
-
type:
|
|
1226
|
-
role_arn:
|
|
1227
|
-
external_id:
|
|
2202
|
+
export_path: _v3.z.string(),
|
|
2203
|
+
format: _v3.z.enum(["jsonl", "parquet"]),
|
|
2204
|
+
interval_seconds: _v3.z.number().gte(1).lte(2592e3),
|
|
2205
|
+
credentials: _v3.z.object({
|
|
2206
|
+
type: _v3.z.literal("aws_iam"),
|
|
2207
|
+
role_arn: _v3.z.string(),
|
|
2208
|
+
external_id: _v3.z.string()
|
|
1228
2209
|
}),
|
|
1229
|
-
batch_size:
|
|
2210
|
+
batch_size: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional()
|
|
1230
2211
|
}),
|
|
1231
|
-
|
|
1232
|
-
event_type:
|
|
2212
|
+
_v3.z.object({
|
|
2213
|
+
event_type: _v3.z.literal("retention"),
|
|
1233
2214
|
object_type: RetentionObjectType,
|
|
1234
|
-
retention_days:
|
|
2215
|
+
retention_days: _v3.z.number().gte(0)
|
|
1235
2216
|
})
|
|
1236
2217
|
])
|
|
1237
2218
|
});
|
|
1238
|
-
var ProjectLogsEvent =
|
|
1239
|
-
id:
|
|
1240
|
-
_xact_id:
|
|
1241
|
-
_pagination_key:
|
|
1242
|
-
created:
|
|
1243
|
-
org_id:
|
|
1244
|
-
project_id:
|
|
1245
|
-
log_id:
|
|
1246
|
-
input:
|
|
1247
|
-
output:
|
|
1248
|
-
expected:
|
|
1249
|
-
error:
|
|
1250
|
-
scores:
|
|
1251
|
-
metadata:
|
|
1252
|
-
|
|
1253
|
-
|
|
2219
|
+
var ProjectLogsEvent = _v3.z.object({
|
|
2220
|
+
id: _v3.z.string(),
|
|
2221
|
+
_xact_id: _v3.z.string(),
|
|
2222
|
+
_pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2223
|
+
created: _v3.z.string().datetime({ offset: true }),
|
|
2224
|
+
org_id: _v3.z.string().uuid(),
|
|
2225
|
+
project_id: _v3.z.string().uuid(),
|
|
2226
|
+
log_id: _v3.z.literal("g"),
|
|
2227
|
+
input: _v3.z.unknown().optional(),
|
|
2228
|
+
output: _v3.z.unknown().optional(),
|
|
2229
|
+
expected: _v3.z.unknown().optional(),
|
|
2230
|
+
error: _v3.z.unknown().optional(),
|
|
2231
|
+
scores: _v3.z.union([_v3.z.record(_v3.z.union([_v3.z.number(), _v3.z.null()])), _v3.z.null()]).optional(),
|
|
2232
|
+
metadata: _v3.z.union([
|
|
2233
|
+
_v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
|
|
2234
|
+
_v3.z.null()
|
|
1254
2235
|
]).optional(),
|
|
1255
|
-
tags:
|
|
1256
|
-
metrics:
|
|
1257
|
-
context:
|
|
1258
|
-
|
|
1259
|
-
caller_functionname:
|
|
1260
|
-
caller_filename:
|
|
1261
|
-
caller_lineno:
|
|
2236
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
2237
|
+
metrics: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]).optional(),
|
|
2238
|
+
context: _v3.z.union([
|
|
2239
|
+
_v3.z.object({
|
|
2240
|
+
caller_functionname: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2241
|
+
caller_filename: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2242
|
+
caller_lineno: _v3.z.union([_v3.z.number(), _v3.z.null()])
|
|
1262
2243
|
}).partial().passthrough(),
|
|
1263
|
-
|
|
2244
|
+
_v3.z.null()
|
|
1264
2245
|
]).optional(),
|
|
1265
|
-
span_id:
|
|
1266
|
-
span_parents:
|
|
1267
|
-
root_span_id:
|
|
1268
|
-
is_root:
|
|
2246
|
+
span_id: _v3.z.string(),
|
|
2247
|
+
span_parents: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
2248
|
+
root_span_id: _v3.z.string(),
|
|
2249
|
+
is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
1269
2250
|
span_attributes: SpanAttributes.optional(),
|
|
1270
2251
|
origin: ObjectReferenceNullish.optional()
|
|
1271
2252
|
});
|
|
1272
|
-
var ProjectScoreType =
|
|
2253
|
+
var ProjectScoreType = _v3.z.enum([
|
|
1273
2254
|
"slider",
|
|
1274
2255
|
"categorical",
|
|
1275
2256
|
"weighted",
|
|
@@ -1278,172 +2259,172 @@ var ProjectScoreType = _zod.z.enum([
|
|
|
1278
2259
|
"online",
|
|
1279
2260
|
"free-form"
|
|
1280
2261
|
]);
|
|
1281
|
-
var ProjectScoreCategory =
|
|
1282
|
-
name:
|
|
1283
|
-
value:
|
|
2262
|
+
var ProjectScoreCategory = _v3.z.object({
|
|
2263
|
+
name: _v3.z.string(),
|
|
2264
|
+
value: _v3.z.number()
|
|
1284
2265
|
});
|
|
1285
|
-
var ProjectScoreCategories =
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
2266
|
+
var ProjectScoreCategories = _v3.z.union([
|
|
2267
|
+
_v3.z.array(ProjectScoreCategory),
|
|
2268
|
+
_v3.z.record(_v3.z.number()),
|
|
2269
|
+
_v3.z.array(_v3.z.string()),
|
|
2270
|
+
_v3.z.null()
|
|
1290
2271
|
]);
|
|
1291
|
-
var ProjectScoreConfig =
|
|
1292
|
-
|
|
1293
|
-
multi_select:
|
|
1294
|
-
destination:
|
|
2272
|
+
var ProjectScoreConfig = _v3.z.union([
|
|
2273
|
+
_v3.z.object({
|
|
2274
|
+
multi_select: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
2275
|
+
destination: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1295
2276
|
online: OnlineScoreConfig
|
|
1296
2277
|
}).partial(),
|
|
1297
|
-
|
|
2278
|
+
_v3.z.null()
|
|
1298
2279
|
]);
|
|
1299
|
-
var ProjectScore =
|
|
1300
|
-
id:
|
|
1301
|
-
project_id:
|
|
1302
|
-
user_id:
|
|
1303
|
-
created:
|
|
1304
|
-
name:
|
|
1305
|
-
description:
|
|
2280
|
+
var ProjectScore = _v3.z.object({
|
|
2281
|
+
id: _v3.z.string().uuid(),
|
|
2282
|
+
project_id: _v3.z.string().uuid(),
|
|
2283
|
+
user_id: _v3.z.string().uuid(),
|
|
2284
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2285
|
+
name: _v3.z.string(),
|
|
2286
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1306
2287
|
score_type: ProjectScoreType,
|
|
1307
2288
|
categories: ProjectScoreCategories.optional(),
|
|
1308
2289
|
config: ProjectScoreConfig.optional(),
|
|
1309
|
-
position:
|
|
2290
|
+
position: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1310
2291
|
});
|
|
1311
|
-
var ProjectTag =
|
|
1312
|
-
id:
|
|
1313
|
-
project_id:
|
|
1314
|
-
user_id:
|
|
1315
|
-
created:
|
|
1316
|
-
name:
|
|
1317
|
-
description:
|
|
1318
|
-
color:
|
|
1319
|
-
position:
|
|
2292
|
+
var ProjectTag = _v3.z.object({
|
|
2293
|
+
id: _v3.z.string().uuid(),
|
|
2294
|
+
project_id: _v3.z.string().uuid(),
|
|
2295
|
+
user_id: _v3.z.string().uuid(),
|
|
2296
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2297
|
+
name: _v3.z.string(),
|
|
2298
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2299
|
+
color: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2300
|
+
position: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1320
2301
|
});
|
|
1321
|
-
var Prompt =
|
|
1322
|
-
id:
|
|
1323
|
-
_xact_id:
|
|
1324
|
-
project_id:
|
|
1325
|
-
log_id:
|
|
1326
|
-
org_id:
|
|
1327
|
-
name:
|
|
1328
|
-
slug:
|
|
1329
|
-
description:
|
|
1330
|
-
created:
|
|
2302
|
+
var Prompt = _v3.z.object({
|
|
2303
|
+
id: _v3.z.string().uuid(),
|
|
2304
|
+
_xact_id: _v3.z.string(),
|
|
2305
|
+
project_id: _v3.z.string().uuid(),
|
|
2306
|
+
log_id: _v3.z.literal("p"),
|
|
2307
|
+
org_id: _v3.z.string().uuid(),
|
|
2308
|
+
name: _v3.z.string(),
|
|
2309
|
+
slug: _v3.z.string(),
|
|
2310
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2311
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1331
2312
|
prompt_data: PromptDataNullish.optional(),
|
|
1332
|
-
tags:
|
|
1333
|
-
metadata:
|
|
2313
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
2314
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
|
|
1334
2315
|
function_type: FunctionTypeEnumNullish.optional()
|
|
1335
2316
|
});
|
|
1336
|
-
var PromptOptions =
|
|
1337
|
-
var PromptSessionEvent =
|
|
1338
|
-
id:
|
|
1339
|
-
_xact_id:
|
|
1340
|
-
created:
|
|
1341
|
-
_pagination_key:
|
|
1342
|
-
project_id:
|
|
1343
|
-
prompt_session_id:
|
|
1344
|
-
prompt_session_data:
|
|
1345
|
-
prompt_data:
|
|
1346
|
-
function_data:
|
|
2317
|
+
var PromptOptions = _v3.z.object({ model: _v3.z.string(), params: ModelParams, position: _v3.z.string() }).partial();
|
|
2318
|
+
var PromptSessionEvent = _v3.z.object({
|
|
2319
|
+
id: _v3.z.string(),
|
|
2320
|
+
_xact_id: _v3.z.string(),
|
|
2321
|
+
created: _v3.z.string().datetime({ offset: true }),
|
|
2322
|
+
_pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2323
|
+
project_id: _v3.z.string().uuid(),
|
|
2324
|
+
prompt_session_id: _v3.z.string().uuid(),
|
|
2325
|
+
prompt_session_data: _v3.z.unknown().optional(),
|
|
2326
|
+
prompt_data: _v3.z.unknown().optional(),
|
|
2327
|
+
function_data: _v3.z.unknown().optional(),
|
|
1347
2328
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
1348
|
-
object_data:
|
|
1349
|
-
completion:
|
|
1350
|
-
tags:
|
|
2329
|
+
object_data: _v3.z.unknown().optional(),
|
|
2330
|
+
completion: _v3.z.unknown().optional(),
|
|
2331
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional()
|
|
1351
2332
|
});
|
|
1352
|
-
var ResponseFormat =
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
type:
|
|
2333
|
+
var ResponseFormat = _v3.z.union([
|
|
2334
|
+
_v3.z.object({ type: _v3.z.literal("json_object") }),
|
|
2335
|
+
_v3.z.object({
|
|
2336
|
+
type: _v3.z.literal("json_schema"),
|
|
1356
2337
|
json_schema: ResponseFormatJsonSchema
|
|
1357
2338
|
}),
|
|
1358
|
-
|
|
2339
|
+
_v3.z.object({ type: _v3.z.literal("text") })
|
|
1359
2340
|
]);
|
|
1360
|
-
var Role =
|
|
1361
|
-
id:
|
|
1362
|
-
org_id:
|
|
1363
|
-
user_id:
|
|
1364
|
-
created:
|
|
1365
|
-
name:
|
|
1366
|
-
description:
|
|
1367
|
-
deleted_at:
|
|
1368
|
-
member_permissions:
|
|
1369
|
-
|
|
1370
|
-
|
|
2341
|
+
var Role = _v3.z.object({
|
|
2342
|
+
id: _v3.z.string().uuid(),
|
|
2343
|
+
org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2344
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2345
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2346
|
+
name: _v3.z.string(),
|
|
2347
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2348
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2349
|
+
member_permissions: _v3.z.union([
|
|
2350
|
+
_v3.z.array(
|
|
2351
|
+
_v3.z.object({
|
|
1371
2352
|
permission: Permission,
|
|
1372
2353
|
restrict_object_type: AclObjectType.optional()
|
|
1373
2354
|
})
|
|
1374
2355
|
),
|
|
1375
|
-
|
|
2356
|
+
_v3.z.null()
|
|
1376
2357
|
]).optional(),
|
|
1377
|
-
member_roles:
|
|
2358
|
+
member_roles: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional()
|
|
1378
2359
|
});
|
|
1379
|
-
var RunEval =
|
|
1380
|
-
project_id:
|
|
1381
|
-
data:
|
|
1382
|
-
|
|
1383
|
-
dataset_id:
|
|
1384
|
-
_internal_btql:
|
|
2360
|
+
var RunEval = _v3.z.object({
|
|
2361
|
+
project_id: _v3.z.string(),
|
|
2362
|
+
data: _v3.z.union([
|
|
2363
|
+
_v3.z.object({
|
|
2364
|
+
dataset_id: _v3.z.string(),
|
|
2365
|
+
_internal_btql: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
|
|
1385
2366
|
}),
|
|
1386
|
-
|
|
1387
|
-
project_name:
|
|
1388
|
-
dataset_name:
|
|
1389
|
-
_internal_btql:
|
|
2367
|
+
_v3.z.object({
|
|
2368
|
+
project_name: _v3.z.string(),
|
|
2369
|
+
dataset_name: _v3.z.string(),
|
|
2370
|
+
_internal_btql: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
|
|
1390
2371
|
}),
|
|
1391
|
-
|
|
2372
|
+
_v3.z.object({ data: _v3.z.array(_v3.z.unknown()) })
|
|
1392
2373
|
]),
|
|
1393
|
-
task: FunctionId.and(
|
|
1394
|
-
scores:
|
|
1395
|
-
experiment_name:
|
|
1396
|
-
metadata:
|
|
1397
|
-
parent: InvokeParent.and(
|
|
1398
|
-
stream:
|
|
1399
|
-
trial_count:
|
|
1400
|
-
is_public:
|
|
1401
|
-
timeout:
|
|
1402
|
-
max_concurrency:
|
|
1403
|
-
base_experiment_name:
|
|
1404
|
-
base_experiment_id:
|
|
2374
|
+
task: FunctionId.and(_v3.z.unknown()),
|
|
2375
|
+
scores: _v3.z.array(FunctionId),
|
|
2376
|
+
experiment_name: _v3.z.string().optional(),
|
|
2377
|
+
metadata: _v3.z.object({}).partial().passthrough().optional(),
|
|
2378
|
+
parent: InvokeParent.and(_v3.z.unknown()).optional(),
|
|
2379
|
+
stream: _v3.z.boolean().optional(),
|
|
2380
|
+
trial_count: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional(),
|
|
2381
|
+
is_public: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
2382
|
+
timeout: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional(),
|
|
2383
|
+
max_concurrency: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional().default(10),
|
|
2384
|
+
base_experiment_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2385
|
+
base_experiment_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1405
2386
|
git_metadata_settings: GitMetadataSettings.and(
|
|
1406
|
-
|
|
2387
|
+
_v3.z.union([_v3.z.object({}).partial(), _v3.z.null()])
|
|
1407
2388
|
).optional(),
|
|
1408
|
-
repo_info: RepoInfo.and(
|
|
1409
|
-
strict:
|
|
1410
|
-
stop_token:
|
|
1411
|
-
extra_messages:
|
|
1412
|
-
tags:
|
|
2389
|
+
repo_info: RepoInfo.and(_v3.z.unknown()).optional(),
|
|
2390
|
+
strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
2391
|
+
stop_token: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2392
|
+
extra_messages: _v3.z.string().optional(),
|
|
2393
|
+
tags: _v3.z.array(_v3.z.string()).optional()
|
|
1413
2394
|
});
|
|
1414
|
-
var ServiceToken =
|
|
1415
|
-
id:
|
|
1416
|
-
created:
|
|
1417
|
-
name:
|
|
1418
|
-
preview_name:
|
|
1419
|
-
service_account_id:
|
|
1420
|
-
service_account_email:
|
|
1421
|
-
service_account_name:
|
|
1422
|
-
org_id:
|
|
2395
|
+
var ServiceToken = _v3.z.object({
|
|
2396
|
+
id: _v3.z.string().uuid(),
|
|
2397
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2398
|
+
name: _v3.z.string(),
|
|
2399
|
+
preview_name: _v3.z.string(),
|
|
2400
|
+
service_account_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2401
|
+
service_account_email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2402
|
+
service_account_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2403
|
+
org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1423
2404
|
});
|
|
1424
|
-
var SpanIFrame =
|
|
1425
|
-
id:
|
|
1426
|
-
project_id:
|
|
1427
|
-
user_id:
|
|
1428
|
-
created:
|
|
1429
|
-
deleted_at:
|
|
1430
|
-
name:
|
|
1431
|
-
description:
|
|
1432
|
-
url:
|
|
1433
|
-
post_message:
|
|
2405
|
+
var SpanIFrame = _v3.z.object({
|
|
2406
|
+
id: _v3.z.string().uuid(),
|
|
2407
|
+
project_id: _v3.z.string().uuid(),
|
|
2408
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2409
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2410
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2411
|
+
name: _v3.z.string(),
|
|
2412
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2413
|
+
url: _v3.z.string(),
|
|
2414
|
+
post_message: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
1434
2415
|
});
|
|
1435
|
-
var SSEConsoleEventData =
|
|
1436
|
-
stream:
|
|
1437
|
-
message:
|
|
2416
|
+
var SSEConsoleEventData = _v3.z.object({
|
|
2417
|
+
stream: _v3.z.enum(["stderr", "stdout"]),
|
|
2418
|
+
message: _v3.z.string()
|
|
1438
2419
|
});
|
|
1439
|
-
var SSEProgressEventData =
|
|
1440
|
-
id:
|
|
2420
|
+
var SSEProgressEventData = _v3.z.object({
|
|
2421
|
+
id: _v3.z.string(),
|
|
1441
2422
|
object_type: FunctionObjectType,
|
|
1442
|
-
origin: ObjectReferenceNullish.and(
|
|
2423
|
+
origin: ObjectReferenceNullish.and(_v3.z.unknown()).optional(),
|
|
1443
2424
|
format: FunctionFormat,
|
|
1444
2425
|
output_type: FunctionOutputType,
|
|
1445
|
-
name:
|
|
1446
|
-
event:
|
|
2426
|
+
name: _v3.z.string(),
|
|
2427
|
+
event: _v3.z.enum([
|
|
1447
2428
|
"reasoning_delta",
|
|
1448
2429
|
"text_delta",
|
|
1449
2430
|
"json_delta",
|
|
@@ -1453,110 +2434,110 @@ var SSEProgressEventData = _zod.z.object({
|
|
|
1453
2434
|
"done",
|
|
1454
2435
|
"progress"
|
|
1455
2436
|
]),
|
|
1456
|
-
data:
|
|
2437
|
+
data: _v3.z.string()
|
|
1457
2438
|
});
|
|
1458
|
-
var ToolFunctionDefinition =
|
|
1459
|
-
type:
|
|
1460
|
-
function:
|
|
1461
|
-
name:
|
|
1462
|
-
description:
|
|
1463
|
-
parameters:
|
|
1464
|
-
strict:
|
|
2439
|
+
var ToolFunctionDefinition = _v3.z.object({
|
|
2440
|
+
type: _v3.z.literal("function"),
|
|
2441
|
+
function: _v3.z.object({
|
|
2442
|
+
name: _v3.z.string(),
|
|
2443
|
+
description: _v3.z.string().optional(),
|
|
2444
|
+
parameters: _v3.z.object({}).partial().passthrough().optional(),
|
|
2445
|
+
strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
1465
2446
|
})
|
|
1466
2447
|
});
|
|
1467
|
-
var User =
|
|
1468
|
-
id:
|
|
1469
|
-
given_name:
|
|
1470
|
-
family_name:
|
|
1471
|
-
email:
|
|
1472
|
-
avatar_url:
|
|
1473
|
-
created:
|
|
2448
|
+
var User = _v3.z.object({
|
|
2449
|
+
id: _v3.z.string().uuid(),
|
|
2450
|
+
given_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2451
|
+
family_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2452
|
+
email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2453
|
+
avatar_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2454
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1474
2455
|
});
|
|
1475
|
-
var ViewDataSearch =
|
|
1476
|
-
|
|
1477
|
-
filter:
|
|
1478
|
-
tag:
|
|
1479
|
-
match:
|
|
1480
|
-
sort:
|
|
2456
|
+
var ViewDataSearch = _v3.z.union([
|
|
2457
|
+
_v3.z.object({
|
|
2458
|
+
filter: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
|
|
2459
|
+
tag: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
|
|
2460
|
+
match: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
|
|
2461
|
+
sort: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()])
|
|
1481
2462
|
}).partial(),
|
|
1482
|
-
|
|
2463
|
+
_v3.z.null()
|
|
1483
2464
|
]);
|
|
1484
|
-
var ViewData =
|
|
1485
|
-
|
|
1486
|
-
|
|
2465
|
+
var ViewData = _v3.z.union([
|
|
2466
|
+
_v3.z.object({ search: ViewDataSearch }).partial(),
|
|
2467
|
+
_v3.z.null()
|
|
1487
2468
|
]);
|
|
1488
|
-
var ViewOptions =
|
|
1489
|
-
|
|
1490
|
-
viewType:
|
|
1491
|
-
options:
|
|
1492
|
-
spanType:
|
|
1493
|
-
rangeValue:
|
|
1494
|
-
frameStart:
|
|
1495
|
-
frameEnd:
|
|
1496
|
-
tzUTC:
|
|
1497
|
-
chartVisibility:
|
|
1498
|
-
projectId:
|
|
1499
|
-
type:
|
|
1500
|
-
groupBy:
|
|
2469
|
+
var ViewOptions = _v3.z.union([
|
|
2470
|
+
_v3.z.object({
|
|
2471
|
+
viewType: _v3.z.literal("monitor"),
|
|
2472
|
+
options: _v3.z.object({
|
|
2473
|
+
spanType: _v3.z.union([_v3.z.enum(["range", "frame"]), _v3.z.null()]),
|
|
2474
|
+
rangeValue: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2475
|
+
frameStart: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2476
|
+
frameEnd: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2477
|
+
tzUTC: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
2478
|
+
chartVisibility: _v3.z.union([_v3.z.record(_v3.z.boolean()), _v3.z.null()]),
|
|
2479
|
+
projectId: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2480
|
+
type: _v3.z.union([_v3.z.enum(["project", "experiment"]), _v3.z.null()]),
|
|
2481
|
+
groupBy: _v3.z.union([_v3.z.string(), _v3.z.null()])
|
|
1501
2482
|
}).partial()
|
|
1502
2483
|
}),
|
|
1503
|
-
|
|
1504
|
-
columnVisibility:
|
|
1505
|
-
columnOrder:
|
|
1506
|
-
columnSizing:
|
|
1507
|
-
grouping:
|
|
1508
|
-
rowHeight:
|
|
1509
|
-
tallGroupRows:
|
|
1510
|
-
layout:
|
|
1511
|
-
chartHeight:
|
|
1512
|
-
excludedMeasures:
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
type:
|
|
1516
|
-
value:
|
|
2484
|
+
_v3.z.object({
|
|
2485
|
+
columnVisibility: _v3.z.union([_v3.z.record(_v3.z.boolean()), _v3.z.null()]),
|
|
2486
|
+
columnOrder: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]),
|
|
2487
|
+
columnSizing: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]),
|
|
2488
|
+
grouping: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2489
|
+
rowHeight: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2490
|
+
tallGroupRows: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
2491
|
+
layout: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2492
|
+
chartHeight: _v3.z.union([_v3.z.number(), _v3.z.null()]),
|
|
2493
|
+
excludedMeasures: _v3.z.union([
|
|
2494
|
+
_v3.z.array(
|
|
2495
|
+
_v3.z.object({
|
|
2496
|
+
type: _v3.z.enum(["none", "score", "metric", "metadata"]),
|
|
2497
|
+
value: _v3.z.string()
|
|
1517
2498
|
})
|
|
1518
2499
|
),
|
|
1519
|
-
|
|
2500
|
+
_v3.z.null()
|
|
1520
2501
|
]),
|
|
1521
|
-
yMetric:
|
|
1522
|
-
|
|
1523
|
-
type:
|
|
1524
|
-
value:
|
|
2502
|
+
yMetric: _v3.z.union([
|
|
2503
|
+
_v3.z.object({
|
|
2504
|
+
type: _v3.z.enum(["none", "score", "metric", "metadata"]),
|
|
2505
|
+
value: _v3.z.string()
|
|
1525
2506
|
}),
|
|
1526
|
-
|
|
2507
|
+
_v3.z.null()
|
|
1527
2508
|
]),
|
|
1528
|
-
xAxis:
|
|
1529
|
-
|
|
1530
|
-
type:
|
|
1531
|
-
value:
|
|
2509
|
+
xAxis: _v3.z.union([
|
|
2510
|
+
_v3.z.object({
|
|
2511
|
+
type: _v3.z.enum(["none", "score", "metric", "metadata"]),
|
|
2512
|
+
value: _v3.z.string()
|
|
1532
2513
|
}),
|
|
1533
|
-
|
|
2514
|
+
_v3.z.null()
|
|
1534
2515
|
]),
|
|
1535
|
-
symbolGrouping:
|
|
1536
|
-
|
|
1537
|
-
type:
|
|
1538
|
-
value:
|
|
2516
|
+
symbolGrouping: _v3.z.union([
|
|
2517
|
+
_v3.z.object({
|
|
2518
|
+
type: _v3.z.enum(["none", "score", "metric", "metadata"]),
|
|
2519
|
+
value: _v3.z.string()
|
|
1539
2520
|
}),
|
|
1540
|
-
|
|
2521
|
+
_v3.z.null()
|
|
1541
2522
|
]),
|
|
1542
|
-
xAxisAggregation:
|
|
1543
|
-
chartAnnotations:
|
|
1544
|
-
|
|
1545
|
-
|
|
2523
|
+
xAxisAggregation: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2524
|
+
chartAnnotations: _v3.z.union([
|
|
2525
|
+
_v3.z.array(_v3.z.object({ id: _v3.z.string(), text: _v3.z.string() })),
|
|
2526
|
+
_v3.z.null()
|
|
1546
2527
|
]),
|
|
1547
|
-
timeRangeFilter:
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
2528
|
+
timeRangeFilter: _v3.z.union([
|
|
2529
|
+
_v3.z.string(),
|
|
2530
|
+
_v3.z.object({ from: _v3.z.string(), to: _v3.z.string() }),
|
|
2531
|
+
_v3.z.null()
|
|
1551
2532
|
])
|
|
1552
2533
|
}).partial(),
|
|
1553
|
-
|
|
2534
|
+
_v3.z.null()
|
|
1554
2535
|
]);
|
|
1555
|
-
var View =
|
|
1556
|
-
id:
|
|
1557
|
-
object_type: AclObjectType.and(
|
|
1558
|
-
object_id:
|
|
1559
|
-
view_type:
|
|
2536
|
+
var View = _v3.z.object({
|
|
2537
|
+
id: _v3.z.string().uuid(),
|
|
2538
|
+
object_type: AclObjectType.and(_v3.z.string()),
|
|
2539
|
+
object_id: _v3.z.string().uuid(),
|
|
2540
|
+
view_type: _v3.z.enum([
|
|
1560
2541
|
"projects",
|
|
1561
2542
|
"experiments",
|
|
1562
2543
|
"experiment",
|
|
@@ -1571,56 +2552,56 @@ var View = _zod.z.object({
|
|
|
1571
2552
|
"agents",
|
|
1572
2553
|
"monitor"
|
|
1573
2554
|
]),
|
|
1574
|
-
name:
|
|
1575
|
-
created:
|
|
2555
|
+
name: _v3.z.string(),
|
|
2556
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1576
2557
|
view_data: ViewData.optional(),
|
|
1577
2558
|
options: ViewOptions.optional(),
|
|
1578
|
-
user_id:
|
|
1579
|
-
deleted_at:
|
|
2559
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2560
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1580
2561
|
});
|
|
1581
2562
|
|
|
1582
2563
|
// src/logger.ts
|
|
1583
2564
|
var _functions = require('@vercel/functions');
|
|
1584
2565
|
var _mustache = require('mustache'); var _mustache2 = _interopRequireDefault(_mustache);
|
|
1585
|
-
|
|
2566
|
+
var _zod = require('zod');
|
|
1586
2567
|
|
|
1587
2568
|
// src/functions/stream.ts
|
|
1588
2569
|
|
|
1589
2570
|
|
|
1590
2571
|
var _eventsourceparser = require('eventsource-parser');
|
|
1591
2572
|
|
|
1592
|
-
var braintrustStreamChunkSchema =
|
|
1593
|
-
|
|
1594
|
-
type:
|
|
1595
|
-
data:
|
|
2573
|
+
var braintrustStreamChunkSchema = _v3.z.union([
|
|
2574
|
+
_v3.z.object({
|
|
2575
|
+
type: _v3.z.literal("text_delta"),
|
|
2576
|
+
data: _v3.z.string()
|
|
1596
2577
|
}),
|
|
1597
|
-
|
|
1598
|
-
type:
|
|
1599
|
-
data:
|
|
2578
|
+
_v3.z.object({
|
|
2579
|
+
type: _v3.z.literal("reasoning_delta"),
|
|
2580
|
+
data: _v3.z.string()
|
|
1600
2581
|
}),
|
|
1601
|
-
|
|
1602
|
-
type:
|
|
1603
|
-
data:
|
|
2582
|
+
_v3.z.object({
|
|
2583
|
+
type: _v3.z.literal("json_delta"),
|
|
2584
|
+
data: _v3.z.string()
|
|
1604
2585
|
}),
|
|
1605
|
-
|
|
1606
|
-
type:
|
|
1607
|
-
data:
|
|
2586
|
+
_v3.z.object({
|
|
2587
|
+
type: _v3.z.literal("error"),
|
|
2588
|
+
data: _v3.z.string()
|
|
1608
2589
|
}),
|
|
1609
|
-
|
|
1610
|
-
type:
|
|
2590
|
+
_v3.z.object({
|
|
2591
|
+
type: _v3.z.literal("console"),
|
|
1611
2592
|
data: SSEConsoleEventData
|
|
1612
2593
|
}),
|
|
1613
|
-
|
|
1614
|
-
type:
|
|
2594
|
+
_v3.z.object({
|
|
2595
|
+
type: _v3.z.literal("progress"),
|
|
1615
2596
|
data: SSEProgressEventData
|
|
1616
2597
|
}),
|
|
1617
|
-
|
|
1618
|
-
type:
|
|
1619
|
-
data:
|
|
2598
|
+
_v3.z.object({
|
|
2599
|
+
type: _v3.z.literal("start"),
|
|
2600
|
+
data: _v3.z.string()
|
|
1620
2601
|
}),
|
|
1621
|
-
|
|
1622
|
-
type:
|
|
1623
|
-
data:
|
|
2602
|
+
_v3.z.object({
|
|
2603
|
+
type: _v3.z.literal("done"),
|
|
2604
|
+
data: _v3.z.string()
|
|
1624
2605
|
})
|
|
1625
2606
|
]);
|
|
1626
2607
|
var BraintrustStream = class _BraintrustStream {
|
|
@@ -2206,12 +3187,11 @@ var InternalAbortError = class extends Error {
|
|
|
2206
3187
|
|
|
2207
3188
|
// src/mustache-utils.ts
|
|
2208
3189
|
|
|
2209
|
-
|
|
2210
3190
|
function lintTemplate(template, context) {
|
|
2211
3191
|
const variables = getMustacheVars(template);
|
|
2212
3192
|
for (const variable of variables) {
|
|
2213
3193
|
const arrPathsReplaced = variable[1].replaceAll(/\.\d+/g, ".0");
|
|
2214
|
-
const fieldExists =
|
|
3194
|
+
const fieldExists = getObjValueByPath(context, arrPathsReplaced.split(".")) !== void 0;
|
|
2215
3195
|
if (!fieldExists) {
|
|
2216
3196
|
throw new Error(`Variable '${variable[1]}' does not exist.`);
|
|
2217
3197
|
}
|
|
@@ -2222,13 +3202,12 @@ function getMustacheVars(prompt) {
|
|
|
2222
3202
|
return _mustache2.default.parse(prompt).filter(
|
|
2223
3203
|
(span) => span[0] === "name" || span[0] === "&"
|
|
2224
3204
|
);
|
|
2225
|
-
} catch (
|
|
3205
|
+
} catch (e5) {
|
|
2226
3206
|
return [];
|
|
2227
3207
|
}
|
|
2228
3208
|
}
|
|
2229
3209
|
|
|
2230
3210
|
// src/logger.ts
|
|
2231
|
-
|
|
2232
3211
|
var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
|
|
2233
3212
|
var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
|
|
2234
3213
|
var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
|
|
@@ -2289,7 +3268,7 @@ var NoopSpan = (_class4 = class {
|
|
|
2289
3268
|
return this;
|
|
2290
3269
|
}
|
|
2291
3270
|
end(args) {
|
|
2292
|
-
return _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
3271
|
+
return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _21 => _21.endTime]), () => ( getCurrentUnixTimestamp()));
|
|
2293
3272
|
}
|
|
2294
3273
|
async export() {
|
|
2295
3274
|
return "";
|
|
@@ -2313,6 +3292,20 @@ var NoopSpan = (_class4 = class {
|
|
|
2313
3292
|
state() {
|
|
2314
3293
|
return _internalGetGlobalState();
|
|
2315
3294
|
}
|
|
3295
|
+
// Custom inspect for Node.js console.log
|
|
3296
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
3297
|
+
return `NoopSpan {
|
|
3298
|
+
kind: '${this.kind}',
|
|
3299
|
+
id: '${this.id}',
|
|
3300
|
+
spanId: '${this.spanId}',
|
|
3301
|
+
rootSpanId: '${this.rootSpanId}',
|
|
3302
|
+
spanParents: ${JSON.stringify(this.spanParents)}
|
|
3303
|
+
}`;
|
|
3304
|
+
}
|
|
3305
|
+
// Custom toString
|
|
3306
|
+
toString() {
|
|
3307
|
+
return `NoopSpan(id=${this.id}, spanId=${this.spanId})`;
|
|
3308
|
+
}
|
|
2316
3309
|
}, _class4);
|
|
2317
3310
|
var NOOP_SPAN = new NoopSpan();
|
|
2318
3311
|
var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
|
|
@@ -2463,8 +3456,8 @@ var BraintrustState = (_class5 = class _BraintrustState {
|
|
|
2463
3456
|
setFetch(fetch2) {
|
|
2464
3457
|
this.loginParams.fetch = fetch2;
|
|
2465
3458
|
this.fetch = fetch2;
|
|
2466
|
-
_optionalChain([this, 'access',
|
|
2467
|
-
_optionalChain([this, 'access',
|
|
3459
|
+
_optionalChain([this, 'access', _22 => _22._apiConn, 'optionalAccess', _23 => _23.setFetch, 'call', _24 => _24(fetch2)]);
|
|
3460
|
+
_optionalChain([this, 'access', _25 => _25._appConn, 'optionalAccess', _26 => _26.setFetch, 'call', _27 => _27(fetch2)]);
|
|
2468
3461
|
}
|
|
2469
3462
|
setMaskingFunction(maskingFunction) {
|
|
2470
3463
|
this.bgLogger().setMaskingFunction(maskingFunction);
|
|
@@ -2533,6 +3526,37 @@ var BraintrustState = (_class5 = class _BraintrustState {
|
|
|
2533
3526
|
enforceQueueSizeLimit(enforce) {
|
|
2534
3527
|
this._bgLogger.get().enforceQueueSizeLimit(enforce);
|
|
2535
3528
|
}
|
|
3529
|
+
// Custom serialization to avoid logging sensitive data
|
|
3530
|
+
toJSON() {
|
|
3531
|
+
return {
|
|
3532
|
+
id: this.id,
|
|
3533
|
+
orgId: this.orgId,
|
|
3534
|
+
orgName: this.orgName,
|
|
3535
|
+
appUrl: this.appUrl,
|
|
3536
|
+
appPublicUrl: this.appPublicUrl,
|
|
3537
|
+
apiUrl: this.apiUrl,
|
|
3538
|
+
proxyUrl: this.proxyUrl,
|
|
3539
|
+
loggedIn: this.loggedIn
|
|
3540
|
+
// Explicitly exclude loginToken, _apiConn, _appConn, _proxyConn and other sensitive fields
|
|
3541
|
+
};
|
|
3542
|
+
}
|
|
3543
|
+
// Custom inspect for Node.js console.log
|
|
3544
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
3545
|
+
return `BraintrustState {
|
|
3546
|
+
id: '${this.id}',
|
|
3547
|
+
orgId: ${this.orgId ? `'${this.orgId}'` : "null"},
|
|
3548
|
+
orgName: ${this.orgName ? `'${this.orgName}'` : "null"},
|
|
3549
|
+
appUrl: ${this.appUrl ? `'${this.appUrl}'` : "null"},
|
|
3550
|
+
apiUrl: ${this.apiUrl ? `'${this.apiUrl}'` : "null"},
|
|
3551
|
+
proxyUrl: ${this.proxyUrl ? `'${this.proxyUrl}'` : "null"},
|
|
3552
|
+
loggedIn: ${this.loggedIn},
|
|
3553
|
+
loginToken: '[REDACTED]'
|
|
3554
|
+
}`;
|
|
3555
|
+
}
|
|
3556
|
+
// Custom toString
|
|
3557
|
+
toString() {
|
|
3558
|
+
return `BraintrustState(id=${this.id}, org=${this.orgName || "none"}, loggedIn=${this.loggedIn})`;
|
|
3559
|
+
}
|
|
2536
3560
|
}, _class5);
|
|
2537
3561
|
var _globalState;
|
|
2538
3562
|
function _internalSetInitialState() {
|
|
@@ -2612,7 +3636,7 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
2612
3636
|
}
|
|
2613
3637
|
async get(path3, params = void 0, config) {
|
|
2614
3638
|
const { headers, ...rest } = config || {};
|
|
2615
|
-
const url = new URL(
|
|
3639
|
+
const url = new URL(_urljoin(this.base_url, path3));
|
|
2616
3640
|
url.search = new URLSearchParams(
|
|
2617
3641
|
params ? Object.entries(params).filter(([_, v]) => v !== void 0).flatMap(
|
|
2618
3642
|
([k, v]) => v !== void 0 ? typeof v === "string" ? [[k, v]] : v.map((x) => [k, x]) : []
|
|
@@ -2639,7 +3663,7 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
2639
3663
|
const this_base_url = this.base_url;
|
|
2640
3664
|
const this_headers = this.headers;
|
|
2641
3665
|
return await checkResponse(
|
|
2642
|
-
await this_fetch(
|
|
3666
|
+
await this_fetch(_urljoin(this_base_url, path3), {
|
|
2643
3667
|
method: "POST",
|
|
2644
3668
|
headers: {
|
|
2645
3669
|
Accept: "application/json",
|
|
@@ -2676,6 +3700,17 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
2676
3700
|
});
|
|
2677
3701
|
return await resp.json();
|
|
2678
3702
|
}
|
|
3703
|
+
// Custom inspect for Node.js console.log
|
|
3704
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
3705
|
+
return `HTTPConnection {
|
|
3706
|
+
base_url: '${this.base_url}',
|
|
3707
|
+
token: '[REDACTED]'
|
|
3708
|
+
}`;
|
|
3709
|
+
}
|
|
3710
|
+
// Custom toString
|
|
3711
|
+
toString() {
|
|
3712
|
+
return `HTTPConnection(${this.base_url})`;
|
|
3713
|
+
}
|
|
2679
3714
|
};
|
|
2680
3715
|
var BaseAttachment = class {
|
|
2681
3716
|
|
|
@@ -2967,8 +4002,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2967
4002
|
source: inputSource
|
|
2968
4003
|
}) {
|
|
2969
4004
|
const source = _nullishCoalesce(inputSource, () => ( "external"));
|
|
2970
|
-
if (!
|
|
2971
|
-
throw new Error(`source must be one of ${
|
|
4005
|
+
if (!VALID_SOURCES.includes(source)) {
|
|
4006
|
+
throw new Error(`source must be one of ${VALID_SOURCES}`);
|
|
2972
4007
|
}
|
|
2973
4008
|
if (isEmpty(scores) && isEmpty(expected) && isEmpty(tags) && isEmpty(comment)) {
|
|
2974
4009
|
throw new Error(
|
|
@@ -2985,7 +4020,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2985
4020
|
updateEvent = Object.fromEntries(
|
|
2986
4021
|
Object.entries(updateEvent).filter(([_, v]) => !isEmpty(v))
|
|
2987
4022
|
);
|
|
2988
|
-
const parentIds = async () => new
|
|
4023
|
+
const parentIds = async () => new SpanComponentsV3({
|
|
2989
4024
|
object_type: parentObjectType,
|
|
2990
4025
|
object_id: await parentObjectId.get()
|
|
2991
4026
|
}).objectIdFields();
|
|
@@ -2995,9 +4030,9 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2995
4030
|
id,
|
|
2996
4031
|
...updateEvent,
|
|
2997
4032
|
...await parentIds(),
|
|
2998
|
-
[
|
|
2999
|
-
[
|
|
3000
|
-
[
|
|
4033
|
+
[AUDIT_SOURCE_FIELD]: source,
|
|
4034
|
+
[AUDIT_METADATA_FIELD]: metadata,
|
|
4035
|
+
[IS_MERGE_FIELD]: true
|
|
3001
4036
|
};
|
|
3002
4037
|
});
|
|
3003
4038
|
state.bgLogger().log([record]);
|
|
@@ -3016,8 +4051,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
3016
4051
|
text: comment
|
|
3017
4052
|
},
|
|
3018
4053
|
...await parentIds(),
|
|
3019
|
-
[
|
|
3020
|
-
[
|
|
4054
|
+
[AUDIT_SOURCE_FIELD]: source,
|
|
4055
|
+
[AUDIT_METADATA_FIELD]: metadata
|
|
3021
4056
|
};
|
|
3022
4057
|
});
|
|
3023
4058
|
state.bgLogger().log([record]);
|
|
@@ -3036,7 +4071,7 @@ function updateSpanImpl({
|
|
|
3036
4071
|
...event
|
|
3037
4072
|
})
|
|
3038
4073
|
);
|
|
3039
|
-
const parentIds = async () => new
|
|
4074
|
+
const parentIds = async () => new SpanComponentsV3({
|
|
3040
4075
|
object_type: parentObjectType,
|
|
3041
4076
|
object_id: await parentObjectId.get()
|
|
3042
4077
|
}).objectIdFields();
|
|
@@ -3044,7 +4079,7 @@ function updateSpanImpl({
|
|
|
3044
4079
|
id,
|
|
3045
4080
|
...updateEvent,
|
|
3046
4081
|
...await parentIds(),
|
|
3047
|
-
[
|
|
4082
|
+
[IS_MERGE_FIELD]: true
|
|
3048
4083
|
}));
|
|
3049
4084
|
state.bgLogger().log([record]);
|
|
3050
4085
|
}
|
|
@@ -3059,15 +4094,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
3059
4094
|
);
|
|
3060
4095
|
}
|
|
3061
4096
|
switch (components.data.object_type) {
|
|
3062
|
-
case
|
|
4097
|
+
case 1 /* EXPERIMENT */:
|
|
3063
4098
|
throw new Error(
|
|
3064
4099
|
"Impossible: computeObjectMetadataArgs not supported for experiments"
|
|
3065
4100
|
);
|
|
3066
|
-
case
|
|
4101
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
3067
4102
|
throw new Error(
|
|
3068
4103
|
"Impossible: computeObjectMetadataArgs not supported for prompt sessions"
|
|
3069
4104
|
);
|
|
3070
|
-
case
|
|
4105
|
+
case 2 /* PROJECT_LOGS */:
|
|
3071
4106
|
return async () => (await computeLoggerMetadata(state, {
|
|
3072
4107
|
...components.data.compute_object_metadata_args
|
|
3073
4108
|
})).project.id;
|
|
@@ -3096,9 +4131,9 @@ async function permalink(slug, opts) {
|
|
|
3096
4131
|
if (slug === "") {
|
|
3097
4132
|
return NOOP_SPAN_PERMALINK;
|
|
3098
4133
|
}
|
|
3099
|
-
const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
4134
|
+
const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _28 => _28.state]), () => ( _globalState));
|
|
3100
4135
|
const getOrgName = async () => {
|
|
3101
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
4136
|
+
if (_optionalChain([opts, 'optionalAccess', _29 => _29.orgName])) {
|
|
3102
4137
|
return opts.orgName;
|
|
3103
4138
|
}
|
|
3104
4139
|
await state.login({});
|
|
@@ -3108,7 +4143,7 @@ async function permalink(slug, opts) {
|
|
|
3108
4143
|
return state.orgName;
|
|
3109
4144
|
};
|
|
3110
4145
|
const getAppUrl = async () => {
|
|
3111
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
4146
|
+
if (_optionalChain([opts, 'optionalAccess', _30 => _30.appUrl])) {
|
|
3112
4147
|
return opts.appUrl;
|
|
3113
4148
|
}
|
|
3114
4149
|
await state.login({});
|
|
@@ -3118,8 +4153,8 @@ async function permalink(slug, opts) {
|
|
|
3118
4153
|
return state.appUrl;
|
|
3119
4154
|
};
|
|
3120
4155
|
try {
|
|
3121
|
-
const components =
|
|
3122
|
-
const object_type =
|
|
4156
|
+
const components = SpanComponentsV3.fromStr(slug);
|
|
4157
|
+
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
3123
4158
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
3124
4159
|
getOrgName(),
|
|
3125
4160
|
getAppUrl(),
|
|
@@ -3146,7 +4181,7 @@ function startSpanParentArgs(args) {
|
|
|
3146
4181
|
if (args.parentSpanIds) {
|
|
3147
4182
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
3148
4183
|
}
|
|
3149
|
-
const parentComponents =
|
|
4184
|
+
const parentComponents = SpanComponentsV3.fromStr(args.parent);
|
|
3150
4185
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
3151
4186
|
throw new Error(
|
|
3152
4187
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
@@ -3219,7 +4254,7 @@ var Logger = (_class6 = class {
|
|
|
3219
4254
|
return (async () => (await this.project).id)();
|
|
3220
4255
|
}
|
|
3221
4256
|
parentObjectType() {
|
|
3222
|
-
return
|
|
4257
|
+
return 2 /* PROJECT_LOGS */;
|
|
3223
4258
|
}
|
|
3224
4259
|
/**
|
|
3225
4260
|
* Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
|
|
@@ -3238,7 +4273,7 @@ var Logger = (_class6 = class {
|
|
|
3238
4273
|
* @returns The `id` of the logged event.
|
|
3239
4274
|
*/
|
|
3240
4275
|
log(event, options) {
|
|
3241
|
-
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess',
|
|
4276
|
+
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _31 => _31.allowConcurrentWithSpans])) {
|
|
3242
4277
|
throw new Error(
|
|
3243
4278
|
"Cannot run toplevel `log` method while using spans. To log to the span, call `logger.traced` and then log with `span.log`"
|
|
3244
4279
|
);
|
|
@@ -3306,14 +4341,14 @@ var Logger = (_class6 = class {
|
|
|
3306
4341
|
state: this.state,
|
|
3307
4342
|
...startSpanParentArgs({
|
|
3308
4343
|
state: this.state,
|
|
3309
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
4344
|
+
parent: _optionalChain([args, 'optionalAccess', _32 => _32.parent]),
|
|
3310
4345
|
parentObjectType: this.parentObjectType(),
|
|
3311
4346
|
parentObjectId: this.lazyId,
|
|
3312
4347
|
parentComputeObjectMetadataArgs: this.computeMetadataArgs,
|
|
3313
|
-
parentSpanIds: _optionalChain([args, 'optionalAccess',
|
|
3314
|
-
propagatedEvent: _optionalChain([args, 'optionalAccess',
|
|
4348
|
+
parentSpanIds: _optionalChain([args, 'optionalAccess', _33 => _33.parentSpanIds]),
|
|
4349
|
+
propagatedEvent: _optionalChain([args, 'optionalAccess', _34 => _34.propagatedEvent])
|
|
3315
4350
|
}),
|
|
3316
|
-
defaultRootType:
|
|
4351
|
+
defaultRootType: "task" /* TASK */
|
|
3317
4352
|
});
|
|
3318
4353
|
}
|
|
3319
4354
|
/**
|
|
@@ -3355,7 +4390,7 @@ var Logger = (_class6 = class {
|
|
|
3355
4390
|
* See {@link Span.startSpan} for more details.
|
|
3356
4391
|
*/
|
|
3357
4392
|
async export() {
|
|
3358
|
-
return new
|
|
4393
|
+
return new SpanComponentsV3({
|
|
3359
4394
|
object_type: this.parentObjectType(),
|
|
3360
4395
|
...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
|
|
3361
4396
|
}).toStr();
|
|
@@ -3380,7 +4415,7 @@ function castLogger(logger, asyncFlush) {
|
|
|
3380
4415
|
return logger;
|
|
3381
4416
|
}
|
|
3382
4417
|
function constructLogs3Data(items) {
|
|
3383
|
-
return `{"rows": ${
|
|
4418
|
+
return `{"rows": ${constructJsonArray(items)}, "api_version": 2}`;
|
|
3384
4419
|
}
|
|
3385
4420
|
function now() {
|
|
3386
4421
|
return (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -3497,7 +4532,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
|
|
|
3497
4532
|
this.queue.clear();
|
|
3498
4533
|
return;
|
|
3499
4534
|
}
|
|
3500
|
-
const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4535
|
+
const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _35 => _35.batchSize]), () => ( this.defaultBatchSize));
|
|
3501
4536
|
const wrappedItems = this.queue.drain();
|
|
3502
4537
|
const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
|
|
3503
4538
|
if (allItems.length === 0) {
|
|
@@ -3506,7 +4541,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
|
|
|
3506
4541
|
const allItemsStr = allItems.map(
|
|
3507
4542
|
(bucket) => bucket.map((item) => JSON.stringify(item))
|
|
3508
4543
|
);
|
|
3509
|
-
const batchSets =
|
|
4544
|
+
const batchSets = batchItems({
|
|
3510
4545
|
items: allItemsStr,
|
|
3511
4546
|
batchMaxNumItems: batchSize,
|
|
3512
4547
|
batchMaxNumBytes: this.maxRequestSize / 2
|
|
@@ -3560,7 +4595,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
|
|
|
3560
4595
|
const items = await Promise.all(wrappedItems.map((x) => x.get()));
|
|
3561
4596
|
const attachments = [];
|
|
3562
4597
|
items.forEach((item) => extractAttachments(item, attachments));
|
|
3563
|
-
let mergedItems =
|
|
4598
|
+
let mergedItems = mergeRowBatch(items);
|
|
3564
4599
|
if (this.maskingFunction) {
|
|
3565
4600
|
mergedItems = mergedItems.map(
|
|
3566
4601
|
(batch) => batch.map((item) => {
|
|
@@ -3746,10 +4781,10 @@ Error: ${errorText}`;
|
|
|
3746
4781
|
} catch (err) {
|
|
3747
4782
|
if (err instanceof AggregateError) {
|
|
3748
4783
|
for (const e of err.errors) {
|
|
3749
|
-
_optionalChain([this, 'access',
|
|
4784
|
+
_optionalChain([this, 'access', _36 => _36.onFlushError, 'optionalCall', _37 => _37(e)]);
|
|
3750
4785
|
}
|
|
3751
4786
|
} else {
|
|
3752
|
-
_optionalChain([this, 'access',
|
|
4787
|
+
_optionalChain([this, 'access', _38 => _38.onFlushError, 'optionalCall', _39 => _39(err)]);
|
|
3753
4788
|
}
|
|
3754
4789
|
this.activeFlushError = err;
|
|
3755
4790
|
} finally {
|
|
@@ -3879,7 +4914,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
3879
4914
|
}
|
|
3880
4915
|
};
|
|
3881
4916
|
if (gitMetadataSettings) {
|
|
3882
|
-
mergedGitMetadataSettings =
|
|
4917
|
+
mergedGitMetadataSettings = mergeGitMetadataSettings(
|
|
3883
4918
|
mergedGitMetadataSettings,
|
|
3884
4919
|
gitMetadataSettings
|
|
3885
4920
|
);
|
|
@@ -4106,7 +5141,7 @@ async function loginToState(options = {}) {
|
|
|
4106
5141
|
return state;
|
|
4107
5142
|
} else {
|
|
4108
5143
|
const resp = await checkResponse(
|
|
4109
|
-
await fetch2(
|
|
5144
|
+
await fetch2(_urljoin(state.appUrl, `/api/apikey/login`), {
|
|
4110
5145
|
method: "POST",
|
|
4111
5146
|
headers: {
|
|
4112
5147
|
"Content-Type": "application/json",
|
|
@@ -4144,23 +5179,25 @@ async function loginToState(options = {}) {
|
|
|
4144
5179
|
return state;
|
|
4145
5180
|
}
|
|
4146
5181
|
function currentExperiment(options) {
|
|
4147
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5182
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.state]), () => ( _globalState));
|
|
4148
5183
|
return state.currentExperiment;
|
|
4149
5184
|
}
|
|
4150
5185
|
function currentLogger(options) {
|
|
4151
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4152
|
-
return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess',
|
|
5186
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.state]), () => ( _globalState));
|
|
5187
|
+
return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _42 => _42.asyncFlush]));
|
|
4153
5188
|
}
|
|
4154
5189
|
function currentSpan(options) {
|
|
4155
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5190
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _43 => _43.state]), () => ( _globalState));
|
|
4156
5191
|
return _nullishCoalesce(state.currentSpan.getStore(), () => ( NOOP_SPAN));
|
|
4157
5192
|
}
|
|
4158
5193
|
function getSpanParentObject(options) {
|
|
4159
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5194
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _44 => _44.state]), () => ( _globalState));
|
|
4160
5195
|
const parentSpan = currentSpan({ state });
|
|
4161
5196
|
if (!Object.is(parentSpan, NOOP_SPAN)) {
|
|
4162
5197
|
return parentSpan;
|
|
4163
5198
|
}
|
|
5199
|
+
const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.parent]), () => ( state.currentParent.getStore()));
|
|
5200
|
+
if (parentStr) return SpanComponentsV3.fromStr(parentStr);
|
|
4164
5201
|
const experiment = currentExperiment();
|
|
4165
5202
|
if (experiment) {
|
|
4166
5203
|
return experiment;
|
|
@@ -4188,7 +5225,7 @@ function traced(callback, args) {
|
|
|
4188
5225
|
const { span, isSyncFlushLogger } = startSpanAndIsLogger(args);
|
|
4189
5226
|
const ret = runCatchFinally(
|
|
4190
5227
|
() => {
|
|
4191
|
-
if (_nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
5228
|
+
if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _46 => _46.setCurrent]), () => ( true))) {
|
|
4192
5229
|
return withCurrent(span, callback);
|
|
4193
5230
|
} else {
|
|
4194
5231
|
return callback(span);
|
|
@@ -4200,7 +5237,7 @@ function traced(callback, args) {
|
|
|
4200
5237
|
},
|
|
4201
5238
|
() => span.end()
|
|
4202
5239
|
);
|
|
4203
|
-
if (_optionalChain([args, 'optionalAccess',
|
|
5240
|
+
if (_optionalChain([args, 'optionalAccess', _47 => _47.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _48 => _48.asyncFlush])) {
|
|
4204
5241
|
return ret;
|
|
4205
5242
|
} else {
|
|
4206
5243
|
return (async () => {
|
|
@@ -4216,40 +5253,40 @@ function startSpan(args) {
|
|
|
4216
5253
|
return startSpanAndIsLogger(args).span;
|
|
4217
5254
|
}
|
|
4218
5255
|
async function flush(options) {
|
|
4219
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5256
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.state]), () => ( _globalState));
|
|
4220
5257
|
return await state.bgLogger().flush();
|
|
4221
5258
|
}
|
|
4222
5259
|
function startSpanAndIsLogger(args) {
|
|
4223
|
-
const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4224
|
-
const
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
5260
|
+
const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _50 => _50.state]), () => ( _globalState));
|
|
5261
|
+
const parentObject = getSpanParentObject({
|
|
5262
|
+
asyncFlush: _optionalChain([args, 'optionalAccess', _51 => _51.asyncFlush]),
|
|
5263
|
+
parent: _optionalChain([args, 'optionalAccess', _52 => _52.parent]),
|
|
5264
|
+
state
|
|
5265
|
+
});
|
|
5266
|
+
if (parentObject instanceof SpanComponentsV3) {
|
|
5267
|
+
const parentSpanIds = parentObject.data.row_id ? {
|
|
5268
|
+
spanId: parentObject.data.span_id,
|
|
5269
|
+
rootSpanId: parentObject.data.root_span_id
|
|
4230
5270
|
} : void 0;
|
|
4231
5271
|
const span = new SpanImpl({
|
|
4232
5272
|
state,
|
|
4233
5273
|
...args,
|
|
4234
|
-
parentObjectType:
|
|
5274
|
+
parentObjectType: parentObject.data.object_type,
|
|
4235
5275
|
parentObjectId: new LazyValue(
|
|
4236
|
-
spanComponentsToObjectIdLambda(state,
|
|
5276
|
+
spanComponentsToObjectIdLambda(state, parentObject)
|
|
4237
5277
|
),
|
|
4238
|
-
parentComputeObjectMetadataArgs: _nullishCoalesce(
|
|
5278
|
+
parentComputeObjectMetadataArgs: _nullishCoalesce(parentObject.data.compute_object_metadata_args, () => ( void 0)),
|
|
4239
5279
|
parentSpanIds,
|
|
4240
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4241
|
-
(_nullishCoalesce(
|
|
5280
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _53 => _53.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5281
|
+
(_nullishCoalesce(parentObject.data.propagated_event, () => ( void 0)))))
|
|
4242
5282
|
});
|
|
4243
5283
|
return {
|
|
4244
5284
|
span,
|
|
4245
|
-
isSyncFlushLogger:
|
|
5285
|
+
isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
|
|
4246
5286
|
// behavior, and therefore propagate along whatever we get from the arguments
|
|
4247
|
-
_optionalChain([args, 'optionalAccess',
|
|
5287
|
+
_optionalChain([args, 'optionalAccess', _54 => _54.asyncFlush]) === false
|
|
4248
5288
|
};
|
|
4249
5289
|
} else {
|
|
4250
|
-
const parentObject = getSpanParentObject({
|
|
4251
|
-
asyncFlush: _optionalChain([args, 'optionalAccess', _43 => _43.asyncFlush])
|
|
4252
|
-
});
|
|
4253
5290
|
const span = parentObject.startSpan(args);
|
|
4254
5291
|
return {
|
|
4255
5292
|
span,
|
|
@@ -4390,10 +5427,10 @@ function extractAttachments(event, attachments) {
|
|
|
4390
5427
|
event[key] = value.reference;
|
|
4391
5428
|
continue;
|
|
4392
5429
|
}
|
|
4393
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
5430
|
+
if (_optionalChain([value, 'optionalAccess', _55 => _55.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
|
|
4394
5431
|
continue;
|
|
4395
5432
|
}
|
|
4396
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
5433
|
+
if (_optionalChain([value, 'optionalAccess', _56 => _56.reference, 'optionalAccess', _57 => _57.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _58 => _58.uploader])) {
|
|
4397
5434
|
const attachment = new Attachment({
|
|
4398
5435
|
data: value.dataDebugString,
|
|
4399
5436
|
filename: value.reference.filename,
|
|
@@ -4531,7 +5568,7 @@ var ObjectFetcher = (_class8 = class {
|
|
|
4531
5568
|
throw new Error("Too many BTQL iterations");
|
|
4532
5569
|
}
|
|
4533
5570
|
}
|
|
4534
|
-
this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess',
|
|
5571
|
+
this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _59 => _59.map, 'call', _60 => _60(this.mutateRecord)]) : data;
|
|
4535
5572
|
}
|
|
4536
5573
|
return this._fetchedData || [];
|
|
4537
5574
|
}
|
|
@@ -4545,7 +5582,7 @@ var ObjectFetcher = (_class8 = class {
|
|
|
4545
5582
|
const fetchedData = await this.fetchedData();
|
|
4546
5583
|
let maxVersion = void 0;
|
|
4547
5584
|
for (const record of fetchedData) {
|
|
4548
|
-
const xactId = String(_nullishCoalesce(record[
|
|
5585
|
+
const xactId = String(_nullishCoalesce(record[TRANSACTION_ID_FIELD], () => ( "0")));
|
|
4549
5586
|
if (maxVersion === void 0 || xactId > maxVersion) {
|
|
4550
5587
|
maxVersion = xactId;
|
|
4551
5588
|
}
|
|
@@ -4588,7 +5625,7 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
4588
5625
|
})();
|
|
4589
5626
|
}
|
|
4590
5627
|
parentObjectType() {
|
|
4591
|
-
return
|
|
5628
|
+
return 1 /* EXPERIMENT */;
|
|
4592
5629
|
}
|
|
4593
5630
|
async getState() {
|
|
4594
5631
|
await this.lazyMetadata.get();
|
|
@@ -4612,7 +5649,7 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
4612
5649
|
* @returns The `id` of the logged event.
|
|
4613
5650
|
*/
|
|
4614
5651
|
log(event, options) {
|
|
4615
|
-
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess',
|
|
5652
|
+
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _61 => _61.allowConcurrentWithSpans])) {
|
|
4616
5653
|
throw new Error(
|
|
4617
5654
|
"Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
|
|
4618
5655
|
);
|
|
@@ -4665,14 +5702,14 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
4665
5702
|
state: this.state,
|
|
4666
5703
|
...startSpanParentArgs({
|
|
4667
5704
|
state: this.state,
|
|
4668
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
5705
|
+
parent: _optionalChain([args, 'optionalAccess', _62 => _62.parent]),
|
|
4669
5706
|
parentObjectType: this.parentObjectType(),
|
|
4670
5707
|
parentObjectId: this.lazyId,
|
|
4671
5708
|
parentComputeObjectMetadataArgs: void 0,
|
|
4672
5709
|
parentSpanIds: void 0,
|
|
4673
|
-
propagatedEvent: _optionalChain([args, 'optionalAccess',
|
|
5710
|
+
propagatedEvent: _optionalChain([args, 'optionalAccess', _63 => _63.propagatedEvent])
|
|
4674
5711
|
}),
|
|
4675
|
-
defaultRootType:
|
|
5712
|
+
defaultRootType: "eval" /* EVAL */
|
|
4676
5713
|
});
|
|
4677
5714
|
}
|
|
4678
5715
|
async fetchBaseExperiment() {
|
|
@@ -4796,7 +5833,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
4796
5833
|
* See {@link Span.startSpan} for more details.
|
|
4797
5834
|
*/
|
|
4798
5835
|
async export() {
|
|
4799
|
-
return new
|
|
5836
|
+
return new SpanComponentsV3({
|
|
4800
5837
|
object_type: this.parentObjectType(),
|
|
4801
5838
|
object_id: await this.id
|
|
4802
5839
|
}).toStr();
|
|
@@ -4883,7 +5920,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
4883
5920
|
this.parentComputeObjectMetadataArgs = args.parentComputeObjectMetadataArgs;
|
|
4884
5921
|
this.propagatedEvent = args.propagatedEvent;
|
|
4885
5922
|
if (this.propagatedEvent) {
|
|
4886
|
-
|
|
5923
|
+
mergeDicts(rawEvent, this.propagatedEvent);
|
|
4887
5924
|
}
|
|
4888
5925
|
const { id: eventId, ...event } = rawEvent;
|
|
4889
5926
|
const callerLocation = isomorph_default.getCallerLocation();
|
|
@@ -4960,12 +5997,12 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
4960
5997
|
root_span_id: this._rootSpanId,
|
|
4961
5998
|
span_parents: this._spanParents,
|
|
4962
5999
|
...serializableInternalData,
|
|
4963
|
-
[
|
|
6000
|
+
[IS_MERGE_FIELD]: this.isMerge
|
|
4964
6001
|
});
|
|
4965
|
-
if (_optionalChain([partialRecord, 'access',
|
|
4966
|
-
this.loggedEndTime = _optionalChain([partialRecord, 'access',
|
|
6002
|
+
if (_optionalChain([partialRecord, 'access', _64 => _64.metrics, 'optionalAccess', _65 => _65.end])) {
|
|
6003
|
+
this.loggedEndTime = _optionalChain([partialRecord, 'access', _66 => _66.metrics, 'optionalAccess', _67 => _67.end]);
|
|
4967
6004
|
}
|
|
4968
|
-
if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access',
|
|
6005
|
+
if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _68 => _68._spanParents, 'optionalAccess', _69 => _69.length])) {
|
|
4969
6006
|
throw new Error("Tags can only be logged to the root span");
|
|
4970
6007
|
}
|
|
4971
6008
|
const computeRecord = async () => ({
|
|
@@ -4978,7 +6015,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
4978
6015
|
])
|
|
4979
6016
|
)
|
|
4980
6017
|
),
|
|
4981
|
-
...new
|
|
6018
|
+
...new SpanComponentsV3({
|
|
4982
6019
|
object_type: this.parentObjectType,
|
|
4983
6020
|
object_id: await this.parentObjectId.get()
|
|
4984
6021
|
}).objectIdFields()
|
|
@@ -5010,18 +6047,18 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5010
6047
|
);
|
|
5011
6048
|
}
|
|
5012
6049
|
startSpan(args) {
|
|
5013
|
-
const parentSpanIds = _optionalChain([args, 'optionalAccess',
|
|
6050
|
+
const parentSpanIds = _optionalChain([args, 'optionalAccess', _70 => _70.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
|
|
5014
6051
|
return new _SpanImpl({
|
|
5015
6052
|
state: this._state,
|
|
5016
6053
|
...args,
|
|
5017
6054
|
...startSpanParentArgs({
|
|
5018
6055
|
state: this._state,
|
|
5019
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
6056
|
+
parent: _optionalChain([args, 'optionalAccess', _71 => _71.parent]),
|
|
5020
6057
|
parentObjectType: this.parentObjectType,
|
|
5021
6058
|
parentObjectId: this.parentObjectId,
|
|
5022
6059
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
5023
6060
|
parentSpanIds,
|
|
5024
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6061
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.propagatedEvent]), () => ( this.propagatedEvent))
|
|
5025
6062
|
})
|
|
5026
6063
|
});
|
|
5027
6064
|
}
|
|
@@ -5035,12 +6072,12 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5035
6072
|
...args,
|
|
5036
6073
|
...startSpanParentArgs({
|
|
5037
6074
|
state: this._state,
|
|
5038
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
6075
|
+
parent: _optionalChain([args, 'optionalAccess', _73 => _73.parent]),
|
|
5039
6076
|
parentObjectType: this.parentObjectType,
|
|
5040
6077
|
parentObjectId: this.parentObjectId,
|
|
5041
6078
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
5042
6079
|
parentSpanIds,
|
|
5043
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6080
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _74 => _74.propagatedEvent]), () => ( this.propagatedEvent))
|
|
5044
6081
|
}),
|
|
5045
6082
|
spanId
|
|
5046
6083
|
});
|
|
@@ -5049,7 +6086,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5049
6086
|
let endTime;
|
|
5050
6087
|
let internalData = {};
|
|
5051
6088
|
if (!this.loggedEndTime) {
|
|
5052
|
-
endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6089
|
+
endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.endTime]), () => ( getCurrentUnixTimestamp()));
|
|
5053
6090
|
internalData = { metrics: { end: endTime } };
|
|
5054
6091
|
} else {
|
|
5055
6092
|
endTime = this.loggedEndTime;
|
|
@@ -5058,7 +6095,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5058
6095
|
return endTime;
|
|
5059
6096
|
}
|
|
5060
6097
|
async export() {
|
|
5061
|
-
return new
|
|
6098
|
+
return new SpanComponentsV3({
|
|
5062
6099
|
object_type: this.parentObjectType,
|
|
5063
6100
|
...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
|
|
5064
6101
|
row_id: this.id,
|
|
@@ -5091,9 +6128,9 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5091
6128
|
const baseUrl = `${appUrl}/app/${orgName}`;
|
|
5092
6129
|
const args = this.parentComputeObjectMetadataArgs;
|
|
5093
6130
|
switch (this.parentObjectType) {
|
|
5094
|
-
case
|
|
5095
|
-
const projectID = _optionalChain([args, 'optionalAccess',
|
|
5096
|
-
const projectName = _optionalChain([args, 'optionalAccess',
|
|
6131
|
+
case 2 /* PROJECT_LOGS */: {
|
|
6132
|
+
const projectID = _optionalChain([args, 'optionalAccess', _76 => _76.project_id]) || this.parentObjectId.getSync().value;
|
|
6133
|
+
const projectName = _optionalChain([args, 'optionalAccess', _77 => _77.project_name]);
|
|
5097
6134
|
if (projectID) {
|
|
5098
6135
|
return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
|
|
5099
6136
|
} else if (projectName) {
|
|
@@ -5102,15 +6139,15 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5102
6139
|
return getErrPermlink("provide-project-name-or-id");
|
|
5103
6140
|
}
|
|
5104
6141
|
}
|
|
5105
|
-
case
|
|
5106
|
-
const expID = _optionalChain([args, 'optionalAccess',
|
|
6142
|
+
case 1 /* EXPERIMENT */: {
|
|
6143
|
+
const expID = _optionalChain([args, 'optionalAccess', _78 => _78.experiment_id]) || _optionalChain([this, 'access', _79 => _79.parentObjectId, 'optionalAccess', _80 => _80.getSync, 'call', _81 => _81(), 'optionalAccess', _82 => _82.value]);
|
|
5107
6144
|
if (!expID) {
|
|
5108
6145
|
return getErrPermlink("provide-experiment-id");
|
|
5109
6146
|
} else {
|
|
5110
6147
|
return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
|
|
5111
6148
|
}
|
|
5112
6149
|
}
|
|
5113
|
-
case
|
|
6150
|
+
case 3 /* PLAYGROUND_LOGS */: {
|
|
5114
6151
|
return NOOP_SPAN_PERMALINK;
|
|
5115
6152
|
}
|
|
5116
6153
|
default: {
|
|
@@ -5129,6 +6166,20 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5129
6166
|
state() {
|
|
5130
6167
|
return this._state;
|
|
5131
6168
|
}
|
|
6169
|
+
// Custom inspect for Node.js console.log
|
|
6170
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
6171
|
+
return `SpanImpl {
|
|
6172
|
+
kind: '${this.kind}',
|
|
6173
|
+
id: '${this.id}',
|
|
6174
|
+
spanId: '${this.spanId}',
|
|
6175
|
+
rootSpanId: '${this.rootSpanId}',
|
|
6176
|
+
spanParents: ${JSON.stringify(this.spanParents)}
|
|
6177
|
+
}`;
|
|
6178
|
+
}
|
|
6179
|
+
// Custom toString
|
|
6180
|
+
toString() {
|
|
6181
|
+
return `SpanImpl(id=${this.id}, spanId=${this.spanId})`;
|
|
6182
|
+
}
|
|
5132
6183
|
}, _class10);
|
|
5133
6184
|
function splitLoggingData({
|
|
5134
6185
|
event,
|
|
@@ -5136,8 +6187,8 @@ function splitLoggingData({
|
|
|
5136
6187
|
}) {
|
|
5137
6188
|
const sanitized = validateAndSanitizeExperimentLogPartialArgs(_nullishCoalesce(event, () => ( {})));
|
|
5138
6189
|
const sanitizedAndInternalData = {};
|
|
5139
|
-
|
|
5140
|
-
|
|
6190
|
+
mergeDicts(sanitizedAndInternalData, internalData || {});
|
|
6191
|
+
mergeDicts(sanitizedAndInternalData, sanitized);
|
|
5141
6192
|
const serializableInternalData = {};
|
|
5142
6193
|
const lazyInternalData = {};
|
|
5143
6194
|
for (const [key, value] of Object.entries(sanitizedAndInternalData)) {
|
|
@@ -5162,7 +6213,7 @@ function splitLoggingData({
|
|
|
5162
6213
|
}
|
|
5163
6214
|
var Dataset2 = (_class11 = class extends ObjectFetcher {
|
|
5164
6215
|
constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
|
|
5165
|
-
const isLegacyDataset = _nullishCoalesce(legacy, () => (
|
|
6216
|
+
const isLegacyDataset = _nullishCoalesce(legacy, () => ( DEFAULT_IS_LEGACY_DATASET));
|
|
5166
6217
|
if (isLegacyDataset) {
|
|
5167
6218
|
console.warn(
|
|
5168
6219
|
`Records will be fetched from this dataset in the legacy format, with the "expected" field renamed to "output". Please update your code to use "expected", and use \`braintrust.initDataset()\` with \`{ useOutput: false }\`, which will become the default in a future version of Braintrust.`
|
|
@@ -5173,7 +6224,7 @@ var Dataset2 = (_class11 = class extends ObjectFetcher {
|
|
|
5173
6224
|
pinnedVersion,
|
|
5174
6225
|
(r) => (
|
|
5175
6226
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5176
|
-
|
|
6227
|
+
ensureDatasetRecord(
|
|
5177
6228
|
enrichAttachments(r, this.state),
|
|
5178
6229
|
isLegacyDataset
|
|
5179
6230
|
)
|
|
@@ -5249,7 +6300,7 @@ var Dataset2 = (_class11 = class extends ObjectFetcher {
|
|
|
5249
6300
|
//if we're merging/updating an event we will not add this ts
|
|
5250
6301
|
metadata,
|
|
5251
6302
|
...!!isMerge ? {
|
|
5252
|
-
[
|
|
6303
|
+
[IS_MERGE_FIELD]: true
|
|
5253
6304
|
} : {}
|
|
5254
6305
|
};
|
|
5255
6306
|
return args;
|
|
@@ -5410,7 +6461,7 @@ function renderMessage(render, message) {
|
|
|
5410
6461
|
case "text":
|
|
5411
6462
|
return { ...c, text: render(c.text) };
|
|
5412
6463
|
case "image_url":
|
|
5413
|
-
if (
|
|
6464
|
+
if (isObject(c.image_url.url)) {
|
|
5414
6465
|
throw new Error(
|
|
5415
6466
|
"Attachments must be replaced with URLs before calling `build()`"
|
|
5416
6467
|
);
|
|
@@ -5469,9 +6520,9 @@ function renderTemplatedObject(obj, args, options) {
|
|
|
5469
6520
|
}
|
|
5470
6521
|
}
|
|
5471
6522
|
});
|
|
5472
|
-
} else if (
|
|
6523
|
+
} else if (isArray(obj)) {
|
|
5473
6524
|
return obj.map((item) => renderTemplatedObject(item, args, options));
|
|
5474
|
-
} else if (
|
|
6525
|
+
} else if (isObject(obj)) {
|
|
5475
6526
|
return Object.fromEntries(
|
|
5476
6527
|
Object.entries(obj).map(([key, value]) => [
|
|
5477
6528
|
key,
|
|
@@ -5529,13 +6580,13 @@ var Prompt2 = (_class12 = class _Prompt {
|
|
|
5529
6580
|
return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
|
|
5530
6581
|
}
|
|
5531
6582
|
get prompt() {
|
|
5532
|
-
return _optionalChain([this, 'access',
|
|
6583
|
+
return _optionalChain([this, 'access', _83 => _83.getParsedPromptData, 'call', _84 => _84(), 'optionalAccess', _85 => _85.prompt]);
|
|
5533
6584
|
}
|
|
5534
6585
|
get version() {
|
|
5535
|
-
return this.metadata[
|
|
6586
|
+
return this.metadata[TRANSACTION_ID_FIELD];
|
|
5536
6587
|
}
|
|
5537
6588
|
get options() {
|
|
5538
|
-
return _optionalChain([this, 'access',
|
|
6589
|
+
return _optionalChain([this, 'access', _86 => _86.getParsedPromptData, 'call', _87 => _87(), 'optionalAccess', _88 => _88.options]) || {};
|
|
5539
6590
|
}
|
|
5540
6591
|
get promptData() {
|
|
5541
6592
|
return this.getParsedPromptData();
|
|
@@ -5686,7 +6737,7 @@ var Prompt2 = (_class12 = class _Prompt {
|
|
|
5686
6737
|
return {
|
|
5687
6738
|
type: "chat",
|
|
5688
6739
|
messages,
|
|
5689
|
-
..._optionalChain([prompt, 'access',
|
|
6740
|
+
..._optionalChain([prompt, 'access', _89 => _89.tools, 'optionalAccess', _90 => _90.trim, 'call', _91 => _91()]) ? {
|
|
5690
6741
|
tools: render(prompt.tools)
|
|
5691
6742
|
} : void 0
|
|
5692
6743
|
};
|
|
@@ -5767,10 +6818,7 @@ function configureNode() {
|
|
|
5767
6818
|
var _express = require('express'); var _express2 = _interopRequireDefault(_express);
|
|
5768
6819
|
var _cors = require('cors'); var _cors2 = _interopRequireDefault(_cors);
|
|
5769
6820
|
|
|
5770
|
-
//
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
// ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
|
|
6821
|
+
// ../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
|
|
5774
6822
|
function initialParams(fn) {
|
|
5775
6823
|
return function(...args) {
|
|
5776
6824
|
var callback = args.pop();
|
|
@@ -6855,7 +7903,6 @@ var BarProgressReporter = (_class13 = class {
|
|
|
6855
7903
|
|
|
6856
7904
|
var _slugify = require('slugify'); var _slugify2 = _interopRequireDefault(_slugify);
|
|
6857
7905
|
|
|
6858
|
-
|
|
6859
7906
|
var ProjectBuilder = class {
|
|
6860
7907
|
create(opts) {
|
|
6861
7908
|
return new Project2(opts);
|
|
@@ -7089,23 +8136,23 @@ var CodePrompt = class {
|
|
|
7089
8136
|
};
|
|
7090
8137
|
}
|
|
7091
8138
|
};
|
|
7092
|
-
var promptContentsSchema =
|
|
7093
|
-
|
|
7094
|
-
prompt:
|
|
8139
|
+
var promptContentsSchema = _v3.z.union([
|
|
8140
|
+
_v3.z.object({
|
|
8141
|
+
prompt: _v3.z.string()
|
|
7095
8142
|
}),
|
|
7096
|
-
|
|
7097
|
-
messages:
|
|
8143
|
+
_v3.z.object({
|
|
8144
|
+
messages: _v3.z.array(ChatCompletionMessageParam)
|
|
7098
8145
|
})
|
|
7099
8146
|
]);
|
|
7100
8147
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
7101
|
-
|
|
7102
|
-
model:
|
|
8148
|
+
_v3.z.object({
|
|
8149
|
+
model: _v3.z.string(),
|
|
7103
8150
|
params: ModelParams.optional()
|
|
7104
8151
|
})
|
|
7105
8152
|
);
|
|
7106
8153
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
7107
|
-
|
|
7108
|
-
tools:
|
|
8154
|
+
_v3.z.object({
|
|
8155
|
+
tools: _v3.z.array(ToolFunctionDefinition).optional()
|
|
7109
8156
|
})
|
|
7110
8157
|
);
|
|
7111
8158
|
var PromptBuilder = class {
|
|
@@ -7128,7 +8175,7 @@ var PromptBuilder = class {
|
|
|
7128
8175
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
7129
8176
|
const promptRow = {
|
|
7130
8177
|
id: opts.id,
|
|
7131
|
-
_xact_id: opts.version ?
|
|
8178
|
+
_xact_id: opts.version ? loadPrettyXact(opts.version) : void 0,
|
|
7132
8179
|
name: opts.name,
|
|
7133
8180
|
slug,
|
|
7134
8181
|
prompt_data: promptData,
|
|
@@ -7173,7 +8220,7 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
|
|
|
7173
8220
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
|
|
7174
8221
|
project_name: projectName
|
|
7175
8222
|
});
|
|
7176
|
-
const result =
|
|
8223
|
+
const result = _v3.z.object({
|
|
7177
8224
|
project: Project
|
|
7178
8225
|
}).parse(response);
|
|
7179
8226
|
const projectId = result.project.id;
|
|
@@ -7187,7 +8234,7 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
|
|
|
7187
8234
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
|
|
7188
8235
|
id: projectId
|
|
7189
8236
|
});
|
|
7190
|
-
const result =
|
|
8237
|
+
const result = _v3.z.array(Project).nonempty().parse(response);
|
|
7191
8238
|
const projectName = result[0].name;
|
|
7192
8239
|
this.idToName[projectId] = projectName;
|
|
7193
8240
|
this.nameToId[projectName] = projectId;
|
|
@@ -7203,15 +8250,15 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
|
|
|
7203
8250
|
}, _class17);
|
|
7204
8251
|
|
|
7205
8252
|
// src/eval-parameters.ts
|
|
7206
|
-
var evalParametersSchema =
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
type:
|
|
8253
|
+
var evalParametersSchema = _v3.z.record(
|
|
8254
|
+
_v3.z.string(),
|
|
8255
|
+
_v3.z.union([
|
|
8256
|
+
_v3.z.object({
|
|
8257
|
+
type: _v3.z.literal("prompt"),
|
|
7211
8258
|
default: promptDefinitionWithToolsSchema.optional(),
|
|
7212
|
-
description:
|
|
8259
|
+
description: _v3.z.string().optional()
|
|
7213
8260
|
}),
|
|
7214
|
-
|
|
8261
|
+
_v3.z.instanceof(_v3.z.ZodType)
|
|
7215
8262
|
// For Zod schemas
|
|
7216
8263
|
])
|
|
7217
8264
|
);
|
|
@@ -7491,7 +8538,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7491
8538
|
const baseEvent = {
|
|
7492
8539
|
name: "eval",
|
|
7493
8540
|
spanAttributes: {
|
|
7494
|
-
type:
|
|
8541
|
+
type: "eval" /* EVAL */
|
|
7495
8542
|
},
|
|
7496
8543
|
event: {
|
|
7497
8544
|
input: datum.input,
|
|
@@ -7529,10 +8576,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7529
8576
|
span,
|
|
7530
8577
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
7531
8578
|
reportProgress: (event) => {
|
|
7532
|
-
_optionalChain([stream, 'optionalCall',
|
|
8579
|
+
_optionalChain([stream, 'optionalCall', _92 => _92({
|
|
7533
8580
|
...event,
|
|
7534
8581
|
id: rootSpan.id,
|
|
7535
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8582
|
+
origin: _optionalChain([baseEvent, 'access', _93 => _93.event, 'optionalAccess', _94 => _94.origin]),
|
|
7536
8583
|
name: evaluator.evalName,
|
|
7537
8584
|
object_type: "task"
|
|
7538
8585
|
})]);
|
|
@@ -7551,7 +8598,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7551
8598
|
},
|
|
7552
8599
|
{
|
|
7553
8600
|
name: "task",
|
|
7554
|
-
spanAttributes: { type:
|
|
8601
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
7555
8602
|
event: { input: datum.input }
|
|
7556
8603
|
}
|
|
7557
8604
|
);
|
|
@@ -7597,17 +8644,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7597
8644
|
return rest;
|
|
7598
8645
|
};
|
|
7599
8646
|
const resultMetadata = results3.length === 1 ? results3[0].metadata : results3.reduce(
|
|
7600
|
-
(prev, s) =>
|
|
8647
|
+
(prev, s) => mergeDicts(prev, {
|
|
7601
8648
|
[s.name]: s.metadata
|
|
7602
8649
|
}),
|
|
7603
8650
|
{}
|
|
7604
8651
|
);
|
|
7605
8652
|
const resultOutput = results3.length === 1 ? getOtherFields(results3[0]) : results3.reduce(
|
|
7606
|
-
(prev, s) =>
|
|
8653
|
+
(prev, s) => mergeDicts(prev, { [s.name]: getOtherFields(s) }),
|
|
7607
8654
|
{}
|
|
7608
8655
|
);
|
|
7609
8656
|
const scores2 = results3.reduce(
|
|
7610
|
-
(prev, s) =>
|
|
8657
|
+
(prev, s) => mergeDicts(prev, { [s.name]: s.score }),
|
|
7611
8658
|
{}
|
|
7612
8659
|
);
|
|
7613
8660
|
span.log({
|
|
@@ -7620,7 +8667,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7620
8667
|
const results2 = await rootSpan.traced(runScorer, {
|
|
7621
8668
|
name: scorerNames[score_idx],
|
|
7622
8669
|
spanAttributes: {
|
|
7623
|
-
type:
|
|
8670
|
+
type: "score" /* SCORE */
|
|
7624
8671
|
},
|
|
7625
8672
|
event: { input: scoringArgs }
|
|
7626
8673
|
});
|
|
@@ -7682,7 +8729,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7682
8729
|
...scores
|
|
7683
8730
|
},
|
|
7684
8731
|
error: error2,
|
|
7685
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8732
|
+
origin: _optionalChain([baseEvent, 'access', _95 => _95.event, 'optionalAccess', _96 => _96.origin])
|
|
7686
8733
|
});
|
|
7687
8734
|
};
|
|
7688
8735
|
if (!experiment) {
|
|
@@ -7849,7 +8896,7 @@ var errorHandler = (err, req, res, next) => {
|
|
|
7849
8896
|
});
|
|
7850
8897
|
return;
|
|
7851
8898
|
}
|
|
7852
|
-
if (err instanceof
|
|
8899
|
+
if (err instanceof _v3.z.ZodError) {
|
|
7853
8900
|
res.status(400).json({
|
|
7854
8901
|
error: {
|
|
7855
8902
|
message: "Invalid request",
|
|
@@ -7873,7 +8920,8 @@ function authorizeRequest(req, res, next) {
|
|
|
7873
8920
|
try {
|
|
7874
8921
|
const ctx = {
|
|
7875
8922
|
appOrigin: extractAllowedOrigin(req.headers[ORIGIN_HEADER]),
|
|
7876
|
-
token: void 0
|
|
8923
|
+
token: void 0,
|
|
8924
|
+
state: void 0
|
|
7877
8925
|
};
|
|
7878
8926
|
if (req.headers.authorization || req.headers[BRAINTRUST_AUTH_TOKEN_HEADER]) {
|
|
7879
8927
|
const tokenText = parseBraintrustAuthHeader(req.headers);
|
|
@@ -7888,11 +8936,37 @@ function authorizeRequest(req, res, next) {
|
|
|
7888
8936
|
next(e);
|
|
7889
8937
|
}
|
|
7890
8938
|
}
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
8939
|
+
var loginCache = new LRUCache({
|
|
8940
|
+
max: 32
|
|
8941
|
+
// TODO: Make this configurable
|
|
8942
|
+
});
|
|
8943
|
+
async function cachedLogin(options) {
|
|
8944
|
+
const key = JSON.stringify(options);
|
|
8945
|
+
const cached = loginCache.get(key);
|
|
8946
|
+
if (cached) {
|
|
8947
|
+
return cached;
|
|
7894
8948
|
}
|
|
7895
|
-
|
|
8949
|
+
const state = await loginToState(options);
|
|
8950
|
+
loginCache.set(key, state);
|
|
8951
|
+
return state;
|
|
8952
|
+
}
|
|
8953
|
+
function makeCheckAuthorized(allowedOrgName) {
|
|
8954
|
+
return async (req, _res, next) => {
|
|
8955
|
+
if (!_optionalChain([req, 'access', _97 => _97.ctx, 'optionalAccess', _98 => _98.token])) {
|
|
8956
|
+
return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
|
|
8957
|
+
}
|
|
8958
|
+
try {
|
|
8959
|
+
const state = await cachedLogin({
|
|
8960
|
+
apiKey: _optionalChain([req, 'access', _99 => _99.ctx, 'optionalAccess', _100 => _100.token]),
|
|
8961
|
+
orgName: allowedOrgName
|
|
8962
|
+
});
|
|
8963
|
+
req.ctx.state = state;
|
|
8964
|
+
next();
|
|
8965
|
+
} catch (e) {
|
|
8966
|
+
console.error("Authorization error:", e);
|
|
8967
|
+
return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
|
|
8968
|
+
}
|
|
8969
|
+
};
|
|
7896
8970
|
}
|
|
7897
8971
|
function parseBraintrustAuthHeader(headers) {
|
|
7898
8972
|
const tokenString = parseHeader(headers, BRAINTRUST_AUTH_TOKEN_HEADER);
|
|
@@ -7977,13 +9051,6 @@ var baseAllowedHeaders = [
|
|
|
7977
9051
|
"x-stainless-arch"
|
|
7978
9052
|
];
|
|
7979
9053
|
|
|
7980
|
-
// dev/server.ts
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
9054
|
// dev/stream.ts
|
|
7988
9055
|
function serializeSSEEvent(event) {
|
|
7989
9056
|
return Object.entries(event).filter(([_key, value]) => value !== void 0).map(([key, value]) => `${key}: ${value}`).join("\n") + "\n\n";
|
|
@@ -7991,43 +9058,43 @@ function serializeSSEEvent(event) {
|
|
|
7991
9058
|
|
|
7992
9059
|
// dev/types.ts
|
|
7993
9060
|
|
|
7994
|
-
var evalBodySchema =
|
|
7995
|
-
name:
|
|
7996
|
-
parameters:
|
|
9061
|
+
var evalBodySchema = _v3.z.object({
|
|
9062
|
+
name: _v3.z.string(),
|
|
9063
|
+
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
7997
9064
|
data: RunEval.shape.data,
|
|
7998
|
-
scores:
|
|
7999
|
-
|
|
9065
|
+
scores: _v3.z.array(
|
|
9066
|
+
_v3.z.object({
|
|
8000
9067
|
function_id: FunctionId,
|
|
8001
|
-
name:
|
|
9068
|
+
name: _v3.z.string()
|
|
8002
9069
|
})
|
|
8003
9070
|
).nullish(),
|
|
8004
|
-
experiment_name:
|
|
8005
|
-
project_id:
|
|
9071
|
+
experiment_name: _v3.z.string().nullish(),
|
|
9072
|
+
project_id: _v3.z.string().nullish(),
|
|
8006
9073
|
parent: InvokeParent.optional(),
|
|
8007
|
-
stream:
|
|
9074
|
+
stream: _v3.z.boolean().optional()
|
|
8008
9075
|
});
|
|
8009
|
-
var evalParametersSerializedSchema =
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
type:
|
|
9076
|
+
var evalParametersSerializedSchema = _v3.z.record(
|
|
9077
|
+
_v3.z.string(),
|
|
9078
|
+
_v3.z.union([
|
|
9079
|
+
_v3.z.object({
|
|
9080
|
+
type: _v3.z.literal("prompt"),
|
|
8014
9081
|
default: PromptData.optional(),
|
|
8015
|
-
description:
|
|
9082
|
+
description: _v3.z.string().optional()
|
|
8016
9083
|
}),
|
|
8017
|
-
|
|
8018
|
-
type:
|
|
8019
|
-
schema:
|
|
9084
|
+
_v3.z.object({
|
|
9085
|
+
type: _v3.z.literal("data"),
|
|
9086
|
+
schema: _v3.z.record(_v3.z.unknown()),
|
|
8020
9087
|
// JSON Schema
|
|
8021
|
-
default:
|
|
8022
|
-
description:
|
|
9088
|
+
default: _v3.z.unknown().optional(),
|
|
9089
|
+
description: _v3.z.string().optional()
|
|
8023
9090
|
})
|
|
8024
9091
|
])
|
|
8025
9092
|
);
|
|
8026
|
-
var evaluatorDefinitionSchema =
|
|
9093
|
+
var evaluatorDefinitionSchema = _v3.z.object({
|
|
8027
9094
|
parameters: evalParametersSerializedSchema.optional()
|
|
8028
9095
|
});
|
|
8029
|
-
var evaluatorDefinitionsSchema =
|
|
8030
|
-
|
|
9096
|
+
var evaluatorDefinitionsSchema = _v3.z.record(
|
|
9097
|
+
_v3.z.string(),
|
|
8031
9098
|
evaluatorDefinitionSchema
|
|
8032
9099
|
);
|
|
8033
9100
|
|
|
@@ -8048,6 +9115,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8048
9115
|
}
|
|
8049
9116
|
next();
|
|
8050
9117
|
});
|
|
9118
|
+
const checkAuthorized = makeCheckAuthorized(opts.orgName);
|
|
8051
9119
|
app.use(
|
|
8052
9120
|
_cors2.default.call(void 0, {
|
|
8053
9121
|
origin: checkOrigin,
|
|
@@ -8055,8 +9123,8 @@ function runDevServer(evaluators, opts) {
|
|
|
8055
9123
|
allowedHeaders: baseAllowedHeaders,
|
|
8056
9124
|
credentials: true,
|
|
8057
9125
|
exposedHeaders: [
|
|
8058
|
-
|
|
8059
|
-
|
|
9126
|
+
BT_CURSOR_HEADER,
|
|
9127
|
+
BT_FOUND_EXISTING_HEADER,
|
|
8060
9128
|
"x-bt-span-id",
|
|
8061
9129
|
"x-bt-span-export"
|
|
8062
9130
|
],
|
|
@@ -8067,7 +9135,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8067
9135
|
app.get("/", (req, res) => {
|
|
8068
9136
|
res.send("Hello, world!");
|
|
8069
9137
|
});
|
|
8070
|
-
app.get("/list", (req, res) => {
|
|
9138
|
+
app.get("/list", checkAuthorized, (req, res) => {
|
|
8071
9139
|
const evalDefs = Object.fromEntries(
|
|
8072
9140
|
Object.entries(allEvaluators).map(([name, evaluator]) => [
|
|
8073
9141
|
name,
|
|
@@ -8095,7 +9163,11 @@ function runDevServer(evaluators, opts) {
|
|
|
8095
9163
|
scores,
|
|
8096
9164
|
stream
|
|
8097
9165
|
} = evalBodySchema.parse(req.body);
|
|
8098
|
-
|
|
9166
|
+
if (!_optionalChain([req, 'access', _101 => _101.ctx, 'optionalAccess', _102 => _102.state])) {
|
|
9167
|
+
res.status(500).json({ error: "Braintrust state not initialized in request" });
|
|
9168
|
+
return;
|
|
9169
|
+
}
|
|
9170
|
+
const state = req.ctx.state;
|
|
8099
9171
|
const evaluator = allEvaluators[name];
|
|
8100
9172
|
if (!evaluator) {
|
|
8101
9173
|
res.status(404).json({ error: `Evaluator '${name}' not found` });
|
|
@@ -8112,7 +9184,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8112
9184
|
validateParameters(_nullishCoalesce(parameters, () => ( {})), evaluator.parameters);
|
|
8113
9185
|
} catch (e) {
|
|
8114
9186
|
console.error("Error validating parameters", e);
|
|
8115
|
-
if (e instanceof
|
|
9187
|
+
if (e instanceof _v3.z.ZodError || e instanceof Error) {
|
|
8116
9188
|
res.status(400).json({
|
|
8117
9189
|
error: e.message
|
|
8118
9190
|
});
|
|
@@ -8148,7 +9220,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8148
9220
|
...evaluator,
|
|
8149
9221
|
data: evalData.data,
|
|
8150
9222
|
scores: evaluator.scores.concat(
|
|
8151
|
-
_nullishCoalesce(_optionalChain([scores, 'optionalAccess',
|
|
9223
|
+
_nullishCoalesce(_optionalChain([scores, 'optionalAccess', _103 => _103.map, 'call', _104 => _104(
|
|
8152
9224
|
(score) => makeScorer(state, score.name, score.function_id)
|
|
8153
9225
|
)]), () => ( []))
|
|
8154
9226
|
),
|
|
@@ -8188,7 +9260,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8188
9260
|
);
|
|
8189
9261
|
}
|
|
8190
9262
|
},
|
|
8191
|
-
parent:
|
|
9263
|
+
parent: parseParent(parent),
|
|
8192
9264
|
parameters: _nullishCoalesce(parameters, () => ( {}))
|
|
8193
9265
|
}
|
|
8194
9266
|
);
|
|
@@ -8233,20 +9305,6 @@ function runDevServer(evaluators, opts) {
|
|
|
8233
9305
|
var asyncHandler = (fn) => (req, res, next) => {
|
|
8234
9306
|
Promise.resolve(fn(req, res, next)).catch(next);
|
|
8235
9307
|
};
|
|
8236
|
-
var loginCache = new LRUCache({
|
|
8237
|
-
max: 32
|
|
8238
|
-
// TODO: Make this configurable
|
|
8239
|
-
});
|
|
8240
|
-
async function cachedLogin(options) {
|
|
8241
|
-
const key = JSON.stringify(options);
|
|
8242
|
-
const cached = loginCache.get(key);
|
|
8243
|
-
if (cached) {
|
|
8244
|
-
return cached;
|
|
8245
|
-
}
|
|
8246
|
-
const state = await loginToState(options);
|
|
8247
|
-
loginCache.set(key, state);
|
|
8248
|
-
return state;
|
|
8249
|
-
}
|
|
8250
9308
|
async function getDataset(state, data) {
|
|
8251
9309
|
if ("project_name" in data) {
|
|
8252
9310
|
return initDataset({
|
|
@@ -8270,9 +9328,9 @@ async function getDataset(state, data) {
|
|
|
8270
9328
|
return data.data;
|
|
8271
9329
|
}
|
|
8272
9330
|
}
|
|
8273
|
-
var datasetFetchSchema =
|
|
8274
|
-
project_id:
|
|
8275
|
-
name:
|
|
9331
|
+
var datasetFetchSchema = _v3.z.object({
|
|
9332
|
+
project_id: _v3.z.string(),
|
|
9333
|
+
name: _v3.z.string()
|
|
8276
9334
|
});
|
|
8277
9335
|
async function getDatasetById({
|
|
8278
9336
|
state,
|
|
@@ -8281,7 +9339,7 @@ async function getDatasetById({
|
|
|
8281
9339
|
const dataset = await state.appConn().post_json("api/dataset/get", {
|
|
8282
9340
|
id: datasetId
|
|
8283
9341
|
});
|
|
8284
|
-
const parsed =
|
|
9342
|
+
const parsed = _v3.z.array(datasetFetchSchema).parse(dataset);
|
|
8285
9343
|
if (parsed.length === 0) {
|
|
8286
9344
|
throw new Error(`Dataset '${datasetId}' not found`);
|
|
8287
9345
|
}
|