braintrust 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev/dist/index.d.mts +228 -16
- package/dev/dist/index.d.ts +228 -16
- package/dev/dist/index.js +2121 -1133
- package/dev/dist/index.mjs +2077 -1089
- package/dist/browser.d.mts +331 -39
- package/dist/browser.d.ts +331 -39
- package/dist/browser.js +2065 -1110
- package/dist/browser.mjs +2001 -1046
- package/dist/cli.js +2191 -1159
- package/dist/index.d.mts +356 -28
- package/dist/index.d.ts +356 -28
- package/dist/index.js +2550 -1227
- package/dist/index.mjs +2464 -1141
- package/package.json +13 -8
- package/util/dist/index.d.mts +5229 -0
- package/util/dist/index.d.ts +5229 -0
- package/util/dist/index.js +1264 -0
- package/util/dist/index.mjs +1264 -0
package/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
|
+
}
|
|
323
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
|
+
}
|
|
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
|
+
}
|
|
1260
|
+
|
|
1261
|
+
// util/json_util.ts
|
|
1262
|
+
function constructJsonArray(items) {
|
|
1263
|
+
return `[${items.join(",")}]`;
|
|
1264
|
+
}
|
|
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
|
+
}
|
|
324
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
|
+
}
|
|
325
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 "";
|
|
@@ -2463,8 +3442,8 @@ var BraintrustState = (_class5 = class _BraintrustState {
|
|
|
2463
3442
|
setFetch(fetch2) {
|
|
2464
3443
|
this.loginParams.fetch = fetch2;
|
|
2465
3444
|
this.fetch = fetch2;
|
|
2466
|
-
_optionalChain([this, 'access',
|
|
2467
|
-
_optionalChain([this, 'access',
|
|
3445
|
+
_optionalChain([this, 'access', _22 => _22._apiConn, 'optionalAccess', _23 => _23.setFetch, 'call', _24 => _24(fetch2)]);
|
|
3446
|
+
_optionalChain([this, 'access', _25 => _25._appConn, 'optionalAccess', _26 => _26.setFetch, 'call', _27 => _27(fetch2)]);
|
|
2468
3447
|
}
|
|
2469
3448
|
setMaskingFunction(maskingFunction) {
|
|
2470
3449
|
this.bgLogger().setMaskingFunction(maskingFunction);
|
|
@@ -2612,7 +3591,7 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
2612
3591
|
}
|
|
2613
3592
|
async get(path3, params = void 0, config) {
|
|
2614
3593
|
const { headers, ...rest } = config || {};
|
|
2615
|
-
const url = new URL(
|
|
3594
|
+
const url = new URL(_urljoin(this.base_url, path3));
|
|
2616
3595
|
url.search = new URLSearchParams(
|
|
2617
3596
|
params ? Object.entries(params).filter(([_, v]) => v !== void 0).flatMap(
|
|
2618
3597
|
([k, v]) => v !== void 0 ? typeof v === "string" ? [[k, v]] : v.map((x) => [k, x]) : []
|
|
@@ -2639,7 +3618,7 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
2639
3618
|
const this_base_url = this.base_url;
|
|
2640
3619
|
const this_headers = this.headers;
|
|
2641
3620
|
return await checkResponse(
|
|
2642
|
-
await this_fetch(
|
|
3621
|
+
await this_fetch(_urljoin(this_base_url, path3), {
|
|
2643
3622
|
method: "POST",
|
|
2644
3623
|
headers: {
|
|
2645
3624
|
Accept: "application/json",
|
|
@@ -2967,8 +3946,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2967
3946
|
source: inputSource
|
|
2968
3947
|
}) {
|
|
2969
3948
|
const source = _nullishCoalesce(inputSource, () => ( "external"));
|
|
2970
|
-
if (!
|
|
2971
|
-
throw new Error(`source must be one of ${
|
|
3949
|
+
if (!VALID_SOURCES.includes(source)) {
|
|
3950
|
+
throw new Error(`source must be one of ${VALID_SOURCES}`);
|
|
2972
3951
|
}
|
|
2973
3952
|
if (isEmpty(scores) && isEmpty(expected) && isEmpty(tags) && isEmpty(comment)) {
|
|
2974
3953
|
throw new Error(
|
|
@@ -2985,7 +3964,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2985
3964
|
updateEvent = Object.fromEntries(
|
|
2986
3965
|
Object.entries(updateEvent).filter(([_, v]) => !isEmpty(v))
|
|
2987
3966
|
);
|
|
2988
|
-
const parentIds = async () => new
|
|
3967
|
+
const parentIds = async () => new SpanComponentsV3({
|
|
2989
3968
|
object_type: parentObjectType,
|
|
2990
3969
|
object_id: await parentObjectId.get()
|
|
2991
3970
|
}).objectIdFields();
|
|
@@ -2995,9 +3974,9 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2995
3974
|
id,
|
|
2996
3975
|
...updateEvent,
|
|
2997
3976
|
...await parentIds(),
|
|
2998
|
-
[
|
|
2999
|
-
[
|
|
3000
|
-
[
|
|
3977
|
+
[AUDIT_SOURCE_FIELD]: source,
|
|
3978
|
+
[AUDIT_METADATA_FIELD]: metadata,
|
|
3979
|
+
[IS_MERGE_FIELD]: true
|
|
3001
3980
|
};
|
|
3002
3981
|
});
|
|
3003
3982
|
state.bgLogger().log([record]);
|
|
@@ -3016,8 +3995,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
3016
3995
|
text: comment
|
|
3017
3996
|
},
|
|
3018
3997
|
...await parentIds(),
|
|
3019
|
-
[
|
|
3020
|
-
[
|
|
3998
|
+
[AUDIT_SOURCE_FIELD]: source,
|
|
3999
|
+
[AUDIT_METADATA_FIELD]: metadata
|
|
3021
4000
|
};
|
|
3022
4001
|
});
|
|
3023
4002
|
state.bgLogger().log([record]);
|
|
@@ -3036,7 +4015,7 @@ function updateSpanImpl({
|
|
|
3036
4015
|
...event
|
|
3037
4016
|
})
|
|
3038
4017
|
);
|
|
3039
|
-
const parentIds = async () => new
|
|
4018
|
+
const parentIds = async () => new SpanComponentsV3({
|
|
3040
4019
|
object_type: parentObjectType,
|
|
3041
4020
|
object_id: await parentObjectId.get()
|
|
3042
4021
|
}).objectIdFields();
|
|
@@ -3044,7 +4023,7 @@ function updateSpanImpl({
|
|
|
3044
4023
|
id,
|
|
3045
4024
|
...updateEvent,
|
|
3046
4025
|
...await parentIds(),
|
|
3047
|
-
[
|
|
4026
|
+
[IS_MERGE_FIELD]: true
|
|
3048
4027
|
}));
|
|
3049
4028
|
state.bgLogger().log([record]);
|
|
3050
4029
|
}
|
|
@@ -3059,15 +4038,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
3059
4038
|
);
|
|
3060
4039
|
}
|
|
3061
4040
|
switch (components.data.object_type) {
|
|
3062
|
-
case
|
|
4041
|
+
case 1 /* EXPERIMENT */:
|
|
3063
4042
|
throw new Error(
|
|
3064
4043
|
"Impossible: computeObjectMetadataArgs not supported for experiments"
|
|
3065
4044
|
);
|
|
3066
|
-
case
|
|
4045
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
3067
4046
|
throw new Error(
|
|
3068
4047
|
"Impossible: computeObjectMetadataArgs not supported for prompt sessions"
|
|
3069
4048
|
);
|
|
3070
|
-
case
|
|
4049
|
+
case 2 /* PROJECT_LOGS */:
|
|
3071
4050
|
return async () => (await computeLoggerMetadata(state, {
|
|
3072
4051
|
...components.data.compute_object_metadata_args
|
|
3073
4052
|
})).project.id;
|
|
@@ -3096,9 +4075,9 @@ async function permalink(slug, opts) {
|
|
|
3096
4075
|
if (slug === "") {
|
|
3097
4076
|
return NOOP_SPAN_PERMALINK;
|
|
3098
4077
|
}
|
|
3099
|
-
const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
4078
|
+
const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _28 => _28.state]), () => ( _globalState));
|
|
3100
4079
|
const getOrgName = async () => {
|
|
3101
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
4080
|
+
if (_optionalChain([opts, 'optionalAccess', _29 => _29.orgName])) {
|
|
3102
4081
|
return opts.orgName;
|
|
3103
4082
|
}
|
|
3104
4083
|
await state.login({});
|
|
@@ -3108,7 +4087,7 @@ async function permalink(slug, opts) {
|
|
|
3108
4087
|
return state.orgName;
|
|
3109
4088
|
};
|
|
3110
4089
|
const getAppUrl = async () => {
|
|
3111
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
4090
|
+
if (_optionalChain([opts, 'optionalAccess', _30 => _30.appUrl])) {
|
|
3112
4091
|
return opts.appUrl;
|
|
3113
4092
|
}
|
|
3114
4093
|
await state.login({});
|
|
@@ -3118,8 +4097,8 @@ async function permalink(slug, opts) {
|
|
|
3118
4097
|
return state.appUrl;
|
|
3119
4098
|
};
|
|
3120
4099
|
try {
|
|
3121
|
-
const components =
|
|
3122
|
-
const object_type =
|
|
4100
|
+
const components = SpanComponentsV3.fromStr(slug);
|
|
4101
|
+
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
3123
4102
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
3124
4103
|
getOrgName(),
|
|
3125
4104
|
getAppUrl(),
|
|
@@ -3146,7 +4125,7 @@ function startSpanParentArgs(args) {
|
|
|
3146
4125
|
if (args.parentSpanIds) {
|
|
3147
4126
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
3148
4127
|
}
|
|
3149
|
-
const parentComponents =
|
|
4128
|
+
const parentComponents = SpanComponentsV3.fromStr(args.parent);
|
|
3150
4129
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
3151
4130
|
throw new Error(
|
|
3152
4131
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
@@ -3219,7 +4198,7 @@ var Logger = (_class6 = class {
|
|
|
3219
4198
|
return (async () => (await this.project).id)();
|
|
3220
4199
|
}
|
|
3221
4200
|
parentObjectType() {
|
|
3222
|
-
return
|
|
4201
|
+
return 2 /* PROJECT_LOGS */;
|
|
3223
4202
|
}
|
|
3224
4203
|
/**
|
|
3225
4204
|
* Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
|
|
@@ -3238,7 +4217,7 @@ var Logger = (_class6 = class {
|
|
|
3238
4217
|
* @returns The `id` of the logged event.
|
|
3239
4218
|
*/
|
|
3240
4219
|
log(event, options) {
|
|
3241
|
-
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess',
|
|
4220
|
+
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _31 => _31.allowConcurrentWithSpans])) {
|
|
3242
4221
|
throw new Error(
|
|
3243
4222
|
"Cannot run toplevel `log` method while using spans. To log to the span, call `logger.traced` and then log with `span.log`"
|
|
3244
4223
|
);
|
|
@@ -3306,14 +4285,14 @@ var Logger = (_class6 = class {
|
|
|
3306
4285
|
state: this.state,
|
|
3307
4286
|
...startSpanParentArgs({
|
|
3308
4287
|
state: this.state,
|
|
3309
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
4288
|
+
parent: _optionalChain([args, 'optionalAccess', _32 => _32.parent]),
|
|
3310
4289
|
parentObjectType: this.parentObjectType(),
|
|
3311
4290
|
parentObjectId: this.lazyId,
|
|
3312
4291
|
parentComputeObjectMetadataArgs: this.computeMetadataArgs,
|
|
3313
|
-
parentSpanIds: _optionalChain([args, 'optionalAccess',
|
|
3314
|
-
propagatedEvent: _optionalChain([args, 'optionalAccess',
|
|
4292
|
+
parentSpanIds: _optionalChain([args, 'optionalAccess', _33 => _33.parentSpanIds]),
|
|
4293
|
+
propagatedEvent: _optionalChain([args, 'optionalAccess', _34 => _34.propagatedEvent])
|
|
3315
4294
|
}),
|
|
3316
|
-
defaultRootType:
|
|
4295
|
+
defaultRootType: "task" /* TASK */
|
|
3317
4296
|
});
|
|
3318
4297
|
}
|
|
3319
4298
|
/**
|
|
@@ -3355,7 +4334,7 @@ var Logger = (_class6 = class {
|
|
|
3355
4334
|
* See {@link Span.startSpan} for more details.
|
|
3356
4335
|
*/
|
|
3357
4336
|
async export() {
|
|
3358
|
-
return new
|
|
4337
|
+
return new SpanComponentsV3({
|
|
3359
4338
|
object_type: this.parentObjectType(),
|
|
3360
4339
|
...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
|
|
3361
4340
|
}).toStr();
|
|
@@ -3380,7 +4359,7 @@ function castLogger(logger, asyncFlush) {
|
|
|
3380
4359
|
return logger;
|
|
3381
4360
|
}
|
|
3382
4361
|
function constructLogs3Data(items) {
|
|
3383
|
-
return `{"rows": ${
|
|
4362
|
+
return `{"rows": ${constructJsonArray(items)}, "api_version": 2}`;
|
|
3384
4363
|
}
|
|
3385
4364
|
function now() {
|
|
3386
4365
|
return (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -3497,7 +4476,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
|
|
|
3497
4476
|
this.queue.clear();
|
|
3498
4477
|
return;
|
|
3499
4478
|
}
|
|
3500
|
-
const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4479
|
+
const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _35 => _35.batchSize]), () => ( this.defaultBatchSize));
|
|
3501
4480
|
const wrappedItems = this.queue.drain();
|
|
3502
4481
|
const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
|
|
3503
4482
|
if (allItems.length === 0) {
|
|
@@ -3506,7 +4485,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
|
|
|
3506
4485
|
const allItemsStr = allItems.map(
|
|
3507
4486
|
(bucket) => bucket.map((item) => JSON.stringify(item))
|
|
3508
4487
|
);
|
|
3509
|
-
const batchSets =
|
|
4488
|
+
const batchSets = batchItems({
|
|
3510
4489
|
items: allItemsStr,
|
|
3511
4490
|
batchMaxNumItems: batchSize,
|
|
3512
4491
|
batchMaxNumBytes: this.maxRequestSize / 2
|
|
@@ -3560,7 +4539,7 @@ var HTTPBackgroundLogger = (_class7 = class _HTTPBackgroundLogger {
|
|
|
3560
4539
|
const items = await Promise.all(wrappedItems.map((x) => x.get()));
|
|
3561
4540
|
const attachments = [];
|
|
3562
4541
|
items.forEach((item) => extractAttachments(item, attachments));
|
|
3563
|
-
let mergedItems =
|
|
4542
|
+
let mergedItems = mergeRowBatch(items);
|
|
3564
4543
|
if (this.maskingFunction) {
|
|
3565
4544
|
mergedItems = mergedItems.map(
|
|
3566
4545
|
(batch) => batch.map((item) => {
|
|
@@ -3746,10 +4725,10 @@ Error: ${errorText}`;
|
|
|
3746
4725
|
} catch (err) {
|
|
3747
4726
|
if (err instanceof AggregateError) {
|
|
3748
4727
|
for (const e of err.errors) {
|
|
3749
|
-
_optionalChain([this, 'access',
|
|
4728
|
+
_optionalChain([this, 'access', _36 => _36.onFlushError, 'optionalCall', _37 => _37(e)]);
|
|
3750
4729
|
}
|
|
3751
4730
|
} else {
|
|
3752
|
-
_optionalChain([this, 'access',
|
|
4731
|
+
_optionalChain([this, 'access', _38 => _38.onFlushError, 'optionalCall', _39 => _39(err)]);
|
|
3753
4732
|
}
|
|
3754
4733
|
this.activeFlushError = err;
|
|
3755
4734
|
} finally {
|
|
@@ -3879,7 +4858,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
3879
4858
|
}
|
|
3880
4859
|
};
|
|
3881
4860
|
if (gitMetadataSettings) {
|
|
3882
|
-
mergedGitMetadataSettings =
|
|
4861
|
+
mergedGitMetadataSettings = mergeGitMetadataSettings(
|
|
3883
4862
|
mergedGitMetadataSettings,
|
|
3884
4863
|
gitMetadataSettings
|
|
3885
4864
|
);
|
|
@@ -4106,7 +5085,7 @@ async function loginToState(options = {}) {
|
|
|
4106
5085
|
return state;
|
|
4107
5086
|
} else {
|
|
4108
5087
|
const resp = await checkResponse(
|
|
4109
|
-
await fetch2(
|
|
5088
|
+
await fetch2(_urljoin(state.appUrl, `/api/apikey/login`), {
|
|
4110
5089
|
method: "POST",
|
|
4111
5090
|
headers: {
|
|
4112
5091
|
"Content-Type": "application/json",
|
|
@@ -4144,23 +5123,25 @@ async function loginToState(options = {}) {
|
|
|
4144
5123
|
return state;
|
|
4145
5124
|
}
|
|
4146
5125
|
function currentExperiment(options) {
|
|
4147
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5126
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.state]), () => ( _globalState));
|
|
4148
5127
|
return state.currentExperiment;
|
|
4149
5128
|
}
|
|
4150
5129
|
function currentLogger(options) {
|
|
4151
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4152
|
-
return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess',
|
|
5130
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.state]), () => ( _globalState));
|
|
5131
|
+
return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _42 => _42.asyncFlush]));
|
|
4153
5132
|
}
|
|
4154
5133
|
function currentSpan(options) {
|
|
4155
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5134
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _43 => _43.state]), () => ( _globalState));
|
|
4156
5135
|
return _nullishCoalesce(state.currentSpan.getStore(), () => ( NOOP_SPAN));
|
|
4157
5136
|
}
|
|
4158
5137
|
function getSpanParentObject(options) {
|
|
4159
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5138
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _44 => _44.state]), () => ( _globalState));
|
|
4160
5139
|
const parentSpan = currentSpan({ state });
|
|
4161
5140
|
if (!Object.is(parentSpan, NOOP_SPAN)) {
|
|
4162
5141
|
return parentSpan;
|
|
4163
5142
|
}
|
|
5143
|
+
const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.parent]), () => ( state.currentParent.getStore()));
|
|
5144
|
+
if (parentStr) return SpanComponentsV3.fromStr(parentStr);
|
|
4164
5145
|
const experiment = currentExperiment();
|
|
4165
5146
|
if (experiment) {
|
|
4166
5147
|
return experiment;
|
|
@@ -4188,7 +5169,7 @@ function traced(callback, args) {
|
|
|
4188
5169
|
const { span, isSyncFlushLogger } = startSpanAndIsLogger(args);
|
|
4189
5170
|
const ret = runCatchFinally(
|
|
4190
5171
|
() => {
|
|
4191
|
-
if (_nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
5172
|
+
if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _46 => _46.setCurrent]), () => ( true))) {
|
|
4192
5173
|
return withCurrent(span, callback);
|
|
4193
5174
|
} else {
|
|
4194
5175
|
return callback(span);
|
|
@@ -4200,7 +5181,7 @@ function traced(callback, args) {
|
|
|
4200
5181
|
},
|
|
4201
5182
|
() => span.end()
|
|
4202
5183
|
);
|
|
4203
|
-
if (_optionalChain([args, 'optionalAccess',
|
|
5184
|
+
if (_optionalChain([args, 'optionalAccess', _47 => _47.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _48 => _48.asyncFlush])) {
|
|
4204
5185
|
return ret;
|
|
4205
5186
|
} else {
|
|
4206
5187
|
return (async () => {
|
|
@@ -4216,40 +5197,40 @@ function startSpan(args) {
|
|
|
4216
5197
|
return startSpanAndIsLogger(args).span;
|
|
4217
5198
|
}
|
|
4218
5199
|
async function flush(options) {
|
|
4219
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5200
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.state]), () => ( _globalState));
|
|
4220
5201
|
return await state.bgLogger().flush();
|
|
4221
5202
|
}
|
|
4222
5203
|
function startSpanAndIsLogger(args) {
|
|
4223
|
-
const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4224
|
-
const
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
5204
|
+
const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _50 => _50.state]), () => ( _globalState));
|
|
5205
|
+
const parentObject = getSpanParentObject({
|
|
5206
|
+
asyncFlush: _optionalChain([args, 'optionalAccess', _51 => _51.asyncFlush]),
|
|
5207
|
+
parent: _optionalChain([args, 'optionalAccess', _52 => _52.parent]),
|
|
5208
|
+
state
|
|
5209
|
+
});
|
|
5210
|
+
if (parentObject instanceof SpanComponentsV3) {
|
|
5211
|
+
const parentSpanIds = parentObject.data.row_id ? {
|
|
5212
|
+
spanId: parentObject.data.span_id,
|
|
5213
|
+
rootSpanId: parentObject.data.root_span_id
|
|
4230
5214
|
} : void 0;
|
|
4231
5215
|
const span = new SpanImpl({
|
|
4232
5216
|
state,
|
|
4233
5217
|
...args,
|
|
4234
|
-
parentObjectType:
|
|
5218
|
+
parentObjectType: parentObject.data.object_type,
|
|
4235
5219
|
parentObjectId: new LazyValue(
|
|
4236
|
-
spanComponentsToObjectIdLambda(state,
|
|
5220
|
+
spanComponentsToObjectIdLambda(state, parentObject)
|
|
4237
5221
|
),
|
|
4238
|
-
parentComputeObjectMetadataArgs: _nullishCoalesce(
|
|
5222
|
+
parentComputeObjectMetadataArgs: _nullishCoalesce(parentObject.data.compute_object_metadata_args, () => ( void 0)),
|
|
4239
5223
|
parentSpanIds,
|
|
4240
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4241
|
-
(_nullishCoalesce(
|
|
5224
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _53 => _53.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5225
|
+
(_nullishCoalesce(parentObject.data.propagated_event, () => ( void 0)))))
|
|
4242
5226
|
});
|
|
4243
5227
|
return {
|
|
4244
5228
|
span,
|
|
4245
|
-
isSyncFlushLogger:
|
|
5229
|
+
isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
|
|
4246
5230
|
// behavior, and therefore propagate along whatever we get from the arguments
|
|
4247
|
-
_optionalChain([args, 'optionalAccess',
|
|
5231
|
+
_optionalChain([args, 'optionalAccess', _54 => _54.asyncFlush]) === false
|
|
4248
5232
|
};
|
|
4249
5233
|
} else {
|
|
4250
|
-
const parentObject = getSpanParentObject({
|
|
4251
|
-
asyncFlush: _optionalChain([args, 'optionalAccess', _43 => _43.asyncFlush])
|
|
4252
|
-
});
|
|
4253
5234
|
const span = parentObject.startSpan(args);
|
|
4254
5235
|
return {
|
|
4255
5236
|
span,
|
|
@@ -4390,10 +5371,10 @@ function extractAttachments(event, attachments) {
|
|
|
4390
5371
|
event[key] = value.reference;
|
|
4391
5372
|
continue;
|
|
4392
5373
|
}
|
|
4393
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
5374
|
+
if (_optionalChain([value, 'optionalAccess', _55 => _55.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
|
|
4394
5375
|
continue;
|
|
4395
5376
|
}
|
|
4396
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
5377
|
+
if (_optionalChain([value, 'optionalAccess', _56 => _56.reference, 'optionalAccess', _57 => _57.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _58 => _58.uploader])) {
|
|
4397
5378
|
const attachment = new Attachment({
|
|
4398
5379
|
data: value.dataDebugString,
|
|
4399
5380
|
filename: value.reference.filename,
|
|
@@ -4531,7 +5512,7 @@ var ObjectFetcher = (_class8 = class {
|
|
|
4531
5512
|
throw new Error("Too many BTQL iterations");
|
|
4532
5513
|
}
|
|
4533
5514
|
}
|
|
4534
|
-
this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess',
|
|
5515
|
+
this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _59 => _59.map, 'call', _60 => _60(this.mutateRecord)]) : data;
|
|
4535
5516
|
}
|
|
4536
5517
|
return this._fetchedData || [];
|
|
4537
5518
|
}
|
|
@@ -4545,7 +5526,7 @@ var ObjectFetcher = (_class8 = class {
|
|
|
4545
5526
|
const fetchedData = await this.fetchedData();
|
|
4546
5527
|
let maxVersion = void 0;
|
|
4547
5528
|
for (const record of fetchedData) {
|
|
4548
|
-
const xactId = String(_nullishCoalesce(record[
|
|
5529
|
+
const xactId = String(_nullishCoalesce(record[TRANSACTION_ID_FIELD], () => ( "0")));
|
|
4549
5530
|
if (maxVersion === void 0 || xactId > maxVersion) {
|
|
4550
5531
|
maxVersion = xactId;
|
|
4551
5532
|
}
|
|
@@ -4588,7 +5569,7 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
4588
5569
|
})();
|
|
4589
5570
|
}
|
|
4590
5571
|
parentObjectType() {
|
|
4591
|
-
return
|
|
5572
|
+
return 1 /* EXPERIMENT */;
|
|
4592
5573
|
}
|
|
4593
5574
|
async getState() {
|
|
4594
5575
|
await this.lazyMetadata.get();
|
|
@@ -4612,7 +5593,7 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
4612
5593
|
* @returns The `id` of the logged event.
|
|
4613
5594
|
*/
|
|
4614
5595
|
log(event, options) {
|
|
4615
|
-
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess',
|
|
5596
|
+
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _61 => _61.allowConcurrentWithSpans])) {
|
|
4616
5597
|
throw new Error(
|
|
4617
5598
|
"Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
|
|
4618
5599
|
);
|
|
@@ -4665,14 +5646,14 @@ var Experiment2 = (_class9 = class extends ObjectFetcher {
|
|
|
4665
5646
|
state: this.state,
|
|
4666
5647
|
...startSpanParentArgs({
|
|
4667
5648
|
state: this.state,
|
|
4668
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
5649
|
+
parent: _optionalChain([args, 'optionalAccess', _62 => _62.parent]),
|
|
4669
5650
|
parentObjectType: this.parentObjectType(),
|
|
4670
5651
|
parentObjectId: this.lazyId,
|
|
4671
5652
|
parentComputeObjectMetadataArgs: void 0,
|
|
4672
5653
|
parentSpanIds: void 0,
|
|
4673
|
-
propagatedEvent: _optionalChain([args, 'optionalAccess',
|
|
5654
|
+
propagatedEvent: _optionalChain([args, 'optionalAccess', _63 => _63.propagatedEvent])
|
|
4674
5655
|
}),
|
|
4675
|
-
defaultRootType:
|
|
5656
|
+
defaultRootType: "eval" /* EVAL */
|
|
4676
5657
|
});
|
|
4677
5658
|
}
|
|
4678
5659
|
async fetchBaseExperiment() {
|
|
@@ -4796,7 +5777,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
4796
5777
|
* See {@link Span.startSpan} for more details.
|
|
4797
5778
|
*/
|
|
4798
5779
|
async export() {
|
|
4799
|
-
return new
|
|
5780
|
+
return new SpanComponentsV3({
|
|
4800
5781
|
object_type: this.parentObjectType(),
|
|
4801
5782
|
object_id: await this.id
|
|
4802
5783
|
}).toStr();
|
|
@@ -4883,7 +5864,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
4883
5864
|
this.parentComputeObjectMetadataArgs = args.parentComputeObjectMetadataArgs;
|
|
4884
5865
|
this.propagatedEvent = args.propagatedEvent;
|
|
4885
5866
|
if (this.propagatedEvent) {
|
|
4886
|
-
|
|
5867
|
+
mergeDicts(rawEvent, this.propagatedEvent);
|
|
4887
5868
|
}
|
|
4888
5869
|
const { id: eventId, ...event } = rawEvent;
|
|
4889
5870
|
const callerLocation = isomorph_default.getCallerLocation();
|
|
@@ -4960,12 +5941,12 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
4960
5941
|
root_span_id: this._rootSpanId,
|
|
4961
5942
|
span_parents: this._spanParents,
|
|
4962
5943
|
...serializableInternalData,
|
|
4963
|
-
[
|
|
5944
|
+
[IS_MERGE_FIELD]: this.isMerge
|
|
4964
5945
|
});
|
|
4965
|
-
if (_optionalChain([partialRecord, 'access',
|
|
4966
|
-
this.loggedEndTime = _optionalChain([partialRecord, 'access',
|
|
5946
|
+
if (_optionalChain([partialRecord, 'access', _64 => _64.metrics, 'optionalAccess', _65 => _65.end])) {
|
|
5947
|
+
this.loggedEndTime = _optionalChain([partialRecord, 'access', _66 => _66.metrics, 'optionalAccess', _67 => _67.end]);
|
|
4967
5948
|
}
|
|
4968
|
-
if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access',
|
|
5949
|
+
if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _68 => _68._spanParents, 'optionalAccess', _69 => _69.length])) {
|
|
4969
5950
|
throw new Error("Tags can only be logged to the root span");
|
|
4970
5951
|
}
|
|
4971
5952
|
const computeRecord = async () => ({
|
|
@@ -4978,7 +5959,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
4978
5959
|
])
|
|
4979
5960
|
)
|
|
4980
5961
|
),
|
|
4981
|
-
...new
|
|
5962
|
+
...new SpanComponentsV3({
|
|
4982
5963
|
object_type: this.parentObjectType,
|
|
4983
5964
|
object_id: await this.parentObjectId.get()
|
|
4984
5965
|
}).objectIdFields()
|
|
@@ -5010,18 +5991,18 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5010
5991
|
);
|
|
5011
5992
|
}
|
|
5012
5993
|
startSpan(args) {
|
|
5013
|
-
const parentSpanIds = _optionalChain([args, 'optionalAccess',
|
|
5994
|
+
const parentSpanIds = _optionalChain([args, 'optionalAccess', _70 => _70.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
|
|
5014
5995
|
return new _SpanImpl({
|
|
5015
5996
|
state: this._state,
|
|
5016
5997
|
...args,
|
|
5017
5998
|
...startSpanParentArgs({
|
|
5018
5999
|
state: this._state,
|
|
5019
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
6000
|
+
parent: _optionalChain([args, 'optionalAccess', _71 => _71.parent]),
|
|
5020
6001
|
parentObjectType: this.parentObjectType,
|
|
5021
6002
|
parentObjectId: this.parentObjectId,
|
|
5022
6003
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
5023
6004
|
parentSpanIds,
|
|
5024
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6005
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _72 => _72.propagatedEvent]), () => ( this.propagatedEvent))
|
|
5025
6006
|
})
|
|
5026
6007
|
});
|
|
5027
6008
|
}
|
|
@@ -5035,12 +6016,12 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5035
6016
|
...args,
|
|
5036
6017
|
...startSpanParentArgs({
|
|
5037
6018
|
state: this._state,
|
|
5038
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
6019
|
+
parent: _optionalChain([args, 'optionalAccess', _73 => _73.parent]),
|
|
5039
6020
|
parentObjectType: this.parentObjectType,
|
|
5040
6021
|
parentObjectId: this.parentObjectId,
|
|
5041
6022
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
5042
6023
|
parentSpanIds,
|
|
5043
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6024
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _74 => _74.propagatedEvent]), () => ( this.propagatedEvent))
|
|
5044
6025
|
}),
|
|
5045
6026
|
spanId
|
|
5046
6027
|
});
|
|
@@ -5049,7 +6030,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5049
6030
|
let endTime;
|
|
5050
6031
|
let internalData = {};
|
|
5051
6032
|
if (!this.loggedEndTime) {
|
|
5052
|
-
endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6033
|
+
endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _75 => _75.endTime]), () => ( getCurrentUnixTimestamp()));
|
|
5053
6034
|
internalData = { metrics: { end: endTime } };
|
|
5054
6035
|
} else {
|
|
5055
6036
|
endTime = this.loggedEndTime;
|
|
@@ -5058,7 +6039,7 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5058
6039
|
return endTime;
|
|
5059
6040
|
}
|
|
5060
6041
|
async export() {
|
|
5061
|
-
return new
|
|
6042
|
+
return new SpanComponentsV3({
|
|
5062
6043
|
object_type: this.parentObjectType,
|
|
5063
6044
|
...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
|
|
5064
6045
|
row_id: this.id,
|
|
@@ -5091,9 +6072,9 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5091
6072
|
const baseUrl = `${appUrl}/app/${orgName}`;
|
|
5092
6073
|
const args = this.parentComputeObjectMetadataArgs;
|
|
5093
6074
|
switch (this.parentObjectType) {
|
|
5094
|
-
case
|
|
5095
|
-
const projectID = _optionalChain([args, 'optionalAccess',
|
|
5096
|
-
const projectName = _optionalChain([args, 'optionalAccess',
|
|
6075
|
+
case 2 /* PROJECT_LOGS */: {
|
|
6076
|
+
const projectID = _optionalChain([args, 'optionalAccess', _76 => _76.project_id]) || this.parentObjectId.getSync().value;
|
|
6077
|
+
const projectName = _optionalChain([args, 'optionalAccess', _77 => _77.project_name]);
|
|
5097
6078
|
if (projectID) {
|
|
5098
6079
|
return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
|
|
5099
6080
|
} else if (projectName) {
|
|
@@ -5102,15 +6083,15 @@ var SpanImpl = (_class10 = class _SpanImpl {
|
|
|
5102
6083
|
return getErrPermlink("provide-project-name-or-id");
|
|
5103
6084
|
}
|
|
5104
6085
|
}
|
|
5105
|
-
case
|
|
5106
|
-
const expID = _optionalChain([args, 'optionalAccess',
|
|
6086
|
+
case 1 /* EXPERIMENT */: {
|
|
6087
|
+
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
6088
|
if (!expID) {
|
|
5108
6089
|
return getErrPermlink("provide-experiment-id");
|
|
5109
6090
|
} else {
|
|
5110
6091
|
return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
|
|
5111
6092
|
}
|
|
5112
6093
|
}
|
|
5113
|
-
case
|
|
6094
|
+
case 3 /* PLAYGROUND_LOGS */: {
|
|
5114
6095
|
return NOOP_SPAN_PERMALINK;
|
|
5115
6096
|
}
|
|
5116
6097
|
default: {
|
|
@@ -5136,8 +6117,8 @@ function splitLoggingData({
|
|
|
5136
6117
|
}) {
|
|
5137
6118
|
const sanitized = validateAndSanitizeExperimentLogPartialArgs(_nullishCoalesce(event, () => ( {})));
|
|
5138
6119
|
const sanitizedAndInternalData = {};
|
|
5139
|
-
|
|
5140
|
-
|
|
6120
|
+
mergeDicts(sanitizedAndInternalData, internalData || {});
|
|
6121
|
+
mergeDicts(sanitizedAndInternalData, sanitized);
|
|
5141
6122
|
const serializableInternalData = {};
|
|
5142
6123
|
const lazyInternalData = {};
|
|
5143
6124
|
for (const [key, value] of Object.entries(sanitizedAndInternalData)) {
|
|
@@ -5162,7 +6143,7 @@ function splitLoggingData({
|
|
|
5162
6143
|
}
|
|
5163
6144
|
var Dataset2 = (_class11 = class extends ObjectFetcher {
|
|
5164
6145
|
constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
|
|
5165
|
-
const isLegacyDataset = _nullishCoalesce(legacy, () => (
|
|
6146
|
+
const isLegacyDataset = _nullishCoalesce(legacy, () => ( DEFAULT_IS_LEGACY_DATASET));
|
|
5166
6147
|
if (isLegacyDataset) {
|
|
5167
6148
|
console.warn(
|
|
5168
6149
|
`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 +6154,7 @@ var Dataset2 = (_class11 = class extends ObjectFetcher {
|
|
|
5173
6154
|
pinnedVersion,
|
|
5174
6155
|
(r) => (
|
|
5175
6156
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5176
|
-
|
|
6157
|
+
ensureDatasetRecord(
|
|
5177
6158
|
enrichAttachments(r, this.state),
|
|
5178
6159
|
isLegacyDataset
|
|
5179
6160
|
)
|
|
@@ -5249,7 +6230,7 @@ var Dataset2 = (_class11 = class extends ObjectFetcher {
|
|
|
5249
6230
|
//if we're merging/updating an event we will not add this ts
|
|
5250
6231
|
metadata,
|
|
5251
6232
|
...!!isMerge ? {
|
|
5252
|
-
[
|
|
6233
|
+
[IS_MERGE_FIELD]: true
|
|
5253
6234
|
} : {}
|
|
5254
6235
|
};
|
|
5255
6236
|
return args;
|
|
@@ -5410,7 +6391,7 @@ function renderMessage(render, message) {
|
|
|
5410
6391
|
case "text":
|
|
5411
6392
|
return { ...c, text: render(c.text) };
|
|
5412
6393
|
case "image_url":
|
|
5413
|
-
if (
|
|
6394
|
+
if (isObject(c.image_url.url)) {
|
|
5414
6395
|
throw new Error(
|
|
5415
6396
|
"Attachments must be replaced with URLs before calling `build()`"
|
|
5416
6397
|
);
|
|
@@ -5469,9 +6450,9 @@ function renderTemplatedObject(obj, args, options) {
|
|
|
5469
6450
|
}
|
|
5470
6451
|
}
|
|
5471
6452
|
});
|
|
5472
|
-
} else if (
|
|
6453
|
+
} else if (isArray(obj)) {
|
|
5473
6454
|
return obj.map((item) => renderTemplatedObject(item, args, options));
|
|
5474
|
-
} else if (
|
|
6455
|
+
} else if (isObject(obj)) {
|
|
5475
6456
|
return Object.fromEntries(
|
|
5476
6457
|
Object.entries(obj).map(([key, value]) => [
|
|
5477
6458
|
key,
|
|
@@ -5529,13 +6510,13 @@ var Prompt2 = (_class12 = class _Prompt {
|
|
|
5529
6510
|
return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
|
|
5530
6511
|
}
|
|
5531
6512
|
get prompt() {
|
|
5532
|
-
return _optionalChain([this, 'access',
|
|
6513
|
+
return _optionalChain([this, 'access', _83 => _83.getParsedPromptData, 'call', _84 => _84(), 'optionalAccess', _85 => _85.prompt]);
|
|
5533
6514
|
}
|
|
5534
6515
|
get version() {
|
|
5535
|
-
return this.metadata[
|
|
6516
|
+
return this.metadata[TRANSACTION_ID_FIELD];
|
|
5536
6517
|
}
|
|
5537
6518
|
get options() {
|
|
5538
|
-
return _optionalChain([this, 'access',
|
|
6519
|
+
return _optionalChain([this, 'access', _86 => _86.getParsedPromptData, 'call', _87 => _87(), 'optionalAccess', _88 => _88.options]) || {};
|
|
5539
6520
|
}
|
|
5540
6521
|
get promptData() {
|
|
5541
6522
|
return this.getParsedPromptData();
|
|
@@ -5686,7 +6667,7 @@ var Prompt2 = (_class12 = class _Prompt {
|
|
|
5686
6667
|
return {
|
|
5687
6668
|
type: "chat",
|
|
5688
6669
|
messages,
|
|
5689
|
-
..._optionalChain([prompt, 'access',
|
|
6670
|
+
..._optionalChain([prompt, 'access', _89 => _89.tools, 'optionalAccess', _90 => _90.trim, 'call', _91 => _91()]) ? {
|
|
5690
6671
|
tools: render(prompt.tools)
|
|
5691
6672
|
} : void 0
|
|
5692
6673
|
};
|
|
@@ -5767,9 +6748,6 @@ function configureNode() {
|
|
|
5767
6748
|
var _express = require('express'); var _express2 = _interopRequireDefault(_express);
|
|
5768
6749
|
var _cors = require('cors'); var _cors2 = _interopRequireDefault(_cors);
|
|
5769
6750
|
|
|
5770
|
-
// src/framework.ts
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
6751
|
// ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
|
|
5774
6752
|
function initialParams(fn) {
|
|
5775
6753
|
return function(...args) {
|
|
@@ -6855,7 +7833,6 @@ var BarProgressReporter = (_class13 = class {
|
|
|
6855
7833
|
|
|
6856
7834
|
var _slugify = require('slugify'); var _slugify2 = _interopRequireDefault(_slugify);
|
|
6857
7835
|
|
|
6858
|
-
|
|
6859
7836
|
var ProjectBuilder = class {
|
|
6860
7837
|
create(opts) {
|
|
6861
7838
|
return new Project2(opts);
|
|
@@ -7089,23 +8066,23 @@ var CodePrompt = class {
|
|
|
7089
8066
|
};
|
|
7090
8067
|
}
|
|
7091
8068
|
};
|
|
7092
|
-
var promptContentsSchema =
|
|
7093
|
-
|
|
7094
|
-
prompt:
|
|
8069
|
+
var promptContentsSchema = _v3.z.union([
|
|
8070
|
+
_v3.z.object({
|
|
8071
|
+
prompt: _v3.z.string()
|
|
7095
8072
|
}),
|
|
7096
|
-
|
|
7097
|
-
messages:
|
|
8073
|
+
_v3.z.object({
|
|
8074
|
+
messages: _v3.z.array(ChatCompletionMessageParam)
|
|
7098
8075
|
})
|
|
7099
8076
|
]);
|
|
7100
8077
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
7101
|
-
|
|
7102
|
-
model:
|
|
8078
|
+
_v3.z.object({
|
|
8079
|
+
model: _v3.z.string(),
|
|
7103
8080
|
params: ModelParams.optional()
|
|
7104
8081
|
})
|
|
7105
8082
|
);
|
|
7106
8083
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
7107
|
-
|
|
7108
|
-
tools:
|
|
8084
|
+
_v3.z.object({
|
|
8085
|
+
tools: _v3.z.array(ToolFunctionDefinition).optional()
|
|
7109
8086
|
})
|
|
7110
8087
|
);
|
|
7111
8088
|
var PromptBuilder = class {
|
|
@@ -7128,7 +8105,7 @@ var PromptBuilder = class {
|
|
|
7128
8105
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
7129
8106
|
const promptRow = {
|
|
7130
8107
|
id: opts.id,
|
|
7131
|
-
_xact_id: opts.version ?
|
|
8108
|
+
_xact_id: opts.version ? loadPrettyXact(opts.version) : void 0,
|
|
7132
8109
|
name: opts.name,
|
|
7133
8110
|
slug,
|
|
7134
8111
|
prompt_data: promptData,
|
|
@@ -7173,7 +8150,7 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
|
|
|
7173
8150
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
|
|
7174
8151
|
project_name: projectName
|
|
7175
8152
|
});
|
|
7176
|
-
const result =
|
|
8153
|
+
const result = _v3.z.object({
|
|
7177
8154
|
project: Project
|
|
7178
8155
|
}).parse(response);
|
|
7179
8156
|
const projectId = result.project.id;
|
|
@@ -7187,7 +8164,7 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
|
|
|
7187
8164
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
|
|
7188
8165
|
id: projectId
|
|
7189
8166
|
});
|
|
7190
|
-
const result =
|
|
8167
|
+
const result = _v3.z.array(Project).nonempty().parse(response);
|
|
7191
8168
|
const projectName = result[0].name;
|
|
7192
8169
|
this.idToName[projectId] = projectName;
|
|
7193
8170
|
this.nameToId[projectName] = projectId;
|
|
@@ -7203,15 +8180,15 @@ var ProjectNameIdMap = (_class17 = class {constructor() { _class17.prototype.__i
|
|
|
7203
8180
|
}, _class17);
|
|
7204
8181
|
|
|
7205
8182
|
// src/eval-parameters.ts
|
|
7206
|
-
var evalParametersSchema =
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
type:
|
|
8183
|
+
var evalParametersSchema = _v3.z.record(
|
|
8184
|
+
_v3.z.string(),
|
|
8185
|
+
_v3.z.union([
|
|
8186
|
+
_v3.z.object({
|
|
8187
|
+
type: _v3.z.literal("prompt"),
|
|
7211
8188
|
default: promptDefinitionWithToolsSchema.optional(),
|
|
7212
|
-
description:
|
|
8189
|
+
description: _v3.z.string().optional()
|
|
7213
8190
|
}),
|
|
7214
|
-
|
|
8191
|
+
_v3.z.instanceof(_v3.z.ZodType)
|
|
7215
8192
|
// For Zod schemas
|
|
7216
8193
|
])
|
|
7217
8194
|
);
|
|
@@ -7491,7 +8468,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7491
8468
|
const baseEvent = {
|
|
7492
8469
|
name: "eval",
|
|
7493
8470
|
spanAttributes: {
|
|
7494
|
-
type:
|
|
8471
|
+
type: "eval" /* EVAL */
|
|
7495
8472
|
},
|
|
7496
8473
|
event: {
|
|
7497
8474
|
input: datum.input,
|
|
@@ -7529,10 +8506,10 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7529
8506
|
span,
|
|
7530
8507
|
parameters: _nullishCoalesce(parameters, () => ( {})),
|
|
7531
8508
|
reportProgress: (event) => {
|
|
7532
|
-
_optionalChain([stream, 'optionalCall',
|
|
8509
|
+
_optionalChain([stream, 'optionalCall', _92 => _92({
|
|
7533
8510
|
...event,
|
|
7534
8511
|
id: rootSpan.id,
|
|
7535
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8512
|
+
origin: _optionalChain([baseEvent, 'access', _93 => _93.event, 'optionalAccess', _94 => _94.origin]),
|
|
7536
8513
|
name: evaluator.evalName,
|
|
7537
8514
|
object_type: "task"
|
|
7538
8515
|
})]);
|
|
@@ -7551,7 +8528,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7551
8528
|
},
|
|
7552
8529
|
{
|
|
7553
8530
|
name: "task",
|
|
7554
|
-
spanAttributes: { type:
|
|
8531
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
7555
8532
|
event: { input: datum.input }
|
|
7556
8533
|
}
|
|
7557
8534
|
);
|
|
@@ -7597,17 +8574,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7597
8574
|
return rest;
|
|
7598
8575
|
};
|
|
7599
8576
|
const resultMetadata = results3.length === 1 ? results3[0].metadata : results3.reduce(
|
|
7600
|
-
(prev, s) =>
|
|
8577
|
+
(prev, s) => mergeDicts(prev, {
|
|
7601
8578
|
[s.name]: s.metadata
|
|
7602
8579
|
}),
|
|
7603
8580
|
{}
|
|
7604
8581
|
);
|
|
7605
8582
|
const resultOutput = results3.length === 1 ? getOtherFields(results3[0]) : results3.reduce(
|
|
7606
|
-
(prev, s) =>
|
|
8583
|
+
(prev, s) => mergeDicts(prev, { [s.name]: getOtherFields(s) }),
|
|
7607
8584
|
{}
|
|
7608
8585
|
);
|
|
7609
8586
|
const scores2 = results3.reduce(
|
|
7610
|
-
(prev, s) =>
|
|
8587
|
+
(prev, s) => mergeDicts(prev, { [s.name]: s.score }),
|
|
7611
8588
|
{}
|
|
7612
8589
|
);
|
|
7613
8590
|
span.log({
|
|
@@ -7620,7 +8597,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7620
8597
|
const results2 = await rootSpan.traced(runScorer, {
|
|
7621
8598
|
name: scorerNames[score_idx],
|
|
7622
8599
|
spanAttributes: {
|
|
7623
|
-
type:
|
|
8600
|
+
type: "score" /* SCORE */
|
|
7624
8601
|
},
|
|
7625
8602
|
event: { input: scoringArgs }
|
|
7626
8603
|
});
|
|
@@ -7682,7 +8659,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7682
8659
|
...scores
|
|
7683
8660
|
},
|
|
7684
8661
|
error: error2,
|
|
7685
|
-
origin: _optionalChain([baseEvent, 'access',
|
|
8662
|
+
origin: _optionalChain([baseEvent, 'access', _95 => _95.event, 'optionalAccess', _96 => _96.origin])
|
|
7686
8663
|
});
|
|
7687
8664
|
};
|
|
7688
8665
|
if (!experiment) {
|
|
@@ -7849,7 +8826,7 @@ var errorHandler = (err, req, res, next) => {
|
|
|
7849
8826
|
});
|
|
7850
8827
|
return;
|
|
7851
8828
|
}
|
|
7852
|
-
if (err instanceof
|
|
8829
|
+
if (err instanceof _v3.z.ZodError) {
|
|
7853
8830
|
res.status(400).json({
|
|
7854
8831
|
error: {
|
|
7855
8832
|
message: "Invalid request",
|
|
@@ -7873,7 +8850,8 @@ function authorizeRequest(req, res, next) {
|
|
|
7873
8850
|
try {
|
|
7874
8851
|
const ctx = {
|
|
7875
8852
|
appOrigin: extractAllowedOrigin(req.headers[ORIGIN_HEADER]),
|
|
7876
|
-
token: void 0
|
|
8853
|
+
token: void 0,
|
|
8854
|
+
state: void 0
|
|
7877
8855
|
};
|
|
7878
8856
|
if (req.headers.authorization || req.headers[BRAINTRUST_AUTH_TOKEN_HEADER]) {
|
|
7879
8857
|
const tokenText = parseBraintrustAuthHeader(req.headers);
|
|
@@ -7888,11 +8866,37 @@ function authorizeRequest(req, res, next) {
|
|
|
7888
8866
|
next(e);
|
|
7889
8867
|
}
|
|
7890
8868
|
}
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
8869
|
+
var loginCache = new LRUCache({
|
|
8870
|
+
max: 32
|
|
8871
|
+
// TODO: Make this configurable
|
|
8872
|
+
});
|
|
8873
|
+
async function cachedLogin(options) {
|
|
8874
|
+
const key = JSON.stringify(options);
|
|
8875
|
+
const cached = loginCache.get(key);
|
|
8876
|
+
if (cached) {
|
|
8877
|
+
return cached;
|
|
7894
8878
|
}
|
|
7895
|
-
|
|
8879
|
+
const state = await loginToState(options);
|
|
8880
|
+
loginCache.set(key, state);
|
|
8881
|
+
return state;
|
|
8882
|
+
}
|
|
8883
|
+
function makeCheckAuthorized(allowedOrgName) {
|
|
8884
|
+
return async (req, _res, next) => {
|
|
8885
|
+
if (!_optionalChain([req, 'access', _97 => _97.ctx, 'optionalAccess', _98 => _98.token])) {
|
|
8886
|
+
return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
|
|
8887
|
+
}
|
|
8888
|
+
try {
|
|
8889
|
+
const state = await cachedLogin({
|
|
8890
|
+
apiKey: _optionalChain([req, 'access', _99 => _99.ctx, 'optionalAccess', _100 => _100.token]),
|
|
8891
|
+
orgName: allowedOrgName
|
|
8892
|
+
});
|
|
8893
|
+
req.ctx.state = state;
|
|
8894
|
+
next();
|
|
8895
|
+
} catch (e) {
|
|
8896
|
+
console.error("Authorization error:", e);
|
|
8897
|
+
return next(_httperrors2.default.call(void 0, 401, "Unauthorized"));
|
|
8898
|
+
}
|
|
8899
|
+
};
|
|
7896
8900
|
}
|
|
7897
8901
|
function parseBraintrustAuthHeader(headers) {
|
|
7898
8902
|
const tokenString = parseHeader(headers, BRAINTRUST_AUTH_TOKEN_HEADER);
|
|
@@ -7977,13 +8981,6 @@ var baseAllowedHeaders = [
|
|
|
7977
8981
|
"x-stainless-arch"
|
|
7978
8982
|
];
|
|
7979
8983
|
|
|
7980
|
-
// dev/server.ts
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
8984
|
// dev/stream.ts
|
|
7988
8985
|
function serializeSSEEvent(event) {
|
|
7989
8986
|
return Object.entries(event).filter(([_key, value]) => value !== void 0).map(([key, value]) => `${key}: ${value}`).join("\n") + "\n\n";
|
|
@@ -7991,43 +8988,43 @@ function serializeSSEEvent(event) {
|
|
|
7991
8988
|
|
|
7992
8989
|
// dev/types.ts
|
|
7993
8990
|
|
|
7994
|
-
var evalBodySchema =
|
|
7995
|
-
name:
|
|
7996
|
-
parameters:
|
|
8991
|
+
var evalBodySchema = _v3.z.object({
|
|
8992
|
+
name: _v3.z.string(),
|
|
8993
|
+
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
7997
8994
|
data: RunEval.shape.data,
|
|
7998
|
-
scores:
|
|
7999
|
-
|
|
8995
|
+
scores: _v3.z.array(
|
|
8996
|
+
_v3.z.object({
|
|
8000
8997
|
function_id: FunctionId,
|
|
8001
|
-
name:
|
|
8998
|
+
name: _v3.z.string()
|
|
8002
8999
|
})
|
|
8003
9000
|
).nullish(),
|
|
8004
|
-
experiment_name:
|
|
8005
|
-
project_id:
|
|
9001
|
+
experiment_name: _v3.z.string().nullish(),
|
|
9002
|
+
project_id: _v3.z.string().nullish(),
|
|
8006
9003
|
parent: InvokeParent.optional(),
|
|
8007
|
-
stream:
|
|
9004
|
+
stream: _v3.z.boolean().optional()
|
|
8008
9005
|
});
|
|
8009
|
-
var evalParametersSerializedSchema =
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
type:
|
|
9006
|
+
var evalParametersSerializedSchema = _v3.z.record(
|
|
9007
|
+
_v3.z.string(),
|
|
9008
|
+
_v3.z.union([
|
|
9009
|
+
_v3.z.object({
|
|
9010
|
+
type: _v3.z.literal("prompt"),
|
|
8014
9011
|
default: PromptData.optional(),
|
|
8015
|
-
description:
|
|
9012
|
+
description: _v3.z.string().optional()
|
|
8016
9013
|
}),
|
|
8017
|
-
|
|
8018
|
-
type:
|
|
8019
|
-
schema:
|
|
9014
|
+
_v3.z.object({
|
|
9015
|
+
type: _v3.z.literal("data"),
|
|
9016
|
+
schema: _v3.z.record(_v3.z.unknown()),
|
|
8020
9017
|
// JSON Schema
|
|
8021
|
-
default:
|
|
8022
|
-
description:
|
|
9018
|
+
default: _v3.z.unknown().optional(),
|
|
9019
|
+
description: _v3.z.string().optional()
|
|
8023
9020
|
})
|
|
8024
9021
|
])
|
|
8025
9022
|
);
|
|
8026
|
-
var evaluatorDefinitionSchema =
|
|
9023
|
+
var evaluatorDefinitionSchema = _v3.z.object({
|
|
8027
9024
|
parameters: evalParametersSerializedSchema.optional()
|
|
8028
9025
|
});
|
|
8029
|
-
var evaluatorDefinitionsSchema =
|
|
8030
|
-
|
|
9026
|
+
var evaluatorDefinitionsSchema = _v3.z.record(
|
|
9027
|
+
_v3.z.string(),
|
|
8031
9028
|
evaluatorDefinitionSchema
|
|
8032
9029
|
);
|
|
8033
9030
|
|
|
@@ -8048,6 +9045,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8048
9045
|
}
|
|
8049
9046
|
next();
|
|
8050
9047
|
});
|
|
9048
|
+
const checkAuthorized = makeCheckAuthorized(opts.orgName);
|
|
8051
9049
|
app.use(
|
|
8052
9050
|
_cors2.default.call(void 0, {
|
|
8053
9051
|
origin: checkOrigin,
|
|
@@ -8055,8 +9053,8 @@ function runDevServer(evaluators, opts) {
|
|
|
8055
9053
|
allowedHeaders: baseAllowedHeaders,
|
|
8056
9054
|
credentials: true,
|
|
8057
9055
|
exposedHeaders: [
|
|
8058
|
-
|
|
8059
|
-
|
|
9056
|
+
BT_CURSOR_HEADER,
|
|
9057
|
+
BT_FOUND_EXISTING_HEADER,
|
|
8060
9058
|
"x-bt-span-id",
|
|
8061
9059
|
"x-bt-span-export"
|
|
8062
9060
|
],
|
|
@@ -8067,7 +9065,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8067
9065
|
app.get("/", (req, res) => {
|
|
8068
9066
|
res.send("Hello, world!");
|
|
8069
9067
|
});
|
|
8070
|
-
app.get("/list", (req, res) => {
|
|
9068
|
+
app.get("/list", checkAuthorized, (req, res) => {
|
|
8071
9069
|
const evalDefs = Object.fromEntries(
|
|
8072
9070
|
Object.entries(allEvaluators).map(([name, evaluator]) => [
|
|
8073
9071
|
name,
|
|
@@ -8095,7 +9093,11 @@ function runDevServer(evaluators, opts) {
|
|
|
8095
9093
|
scores,
|
|
8096
9094
|
stream
|
|
8097
9095
|
} = evalBodySchema.parse(req.body);
|
|
8098
|
-
|
|
9096
|
+
if (!_optionalChain([req, 'access', _101 => _101.ctx, 'optionalAccess', _102 => _102.state])) {
|
|
9097
|
+
res.status(500).json({ error: "Braintrust state not initialized in request" });
|
|
9098
|
+
return;
|
|
9099
|
+
}
|
|
9100
|
+
const state = req.ctx.state;
|
|
8099
9101
|
const evaluator = allEvaluators[name];
|
|
8100
9102
|
if (!evaluator) {
|
|
8101
9103
|
res.status(404).json({ error: `Evaluator '${name}' not found` });
|
|
@@ -8112,7 +9114,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8112
9114
|
validateParameters(_nullishCoalesce(parameters, () => ( {})), evaluator.parameters);
|
|
8113
9115
|
} catch (e) {
|
|
8114
9116
|
console.error("Error validating parameters", e);
|
|
8115
|
-
if (e instanceof
|
|
9117
|
+
if (e instanceof _v3.z.ZodError || e instanceof Error) {
|
|
8116
9118
|
res.status(400).json({
|
|
8117
9119
|
error: e.message
|
|
8118
9120
|
});
|
|
@@ -8148,7 +9150,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8148
9150
|
...evaluator,
|
|
8149
9151
|
data: evalData.data,
|
|
8150
9152
|
scores: evaluator.scores.concat(
|
|
8151
|
-
_nullishCoalesce(_optionalChain([scores, 'optionalAccess',
|
|
9153
|
+
_nullishCoalesce(_optionalChain([scores, 'optionalAccess', _103 => _103.map, 'call', _104 => _104(
|
|
8152
9154
|
(score) => makeScorer(state, score.name, score.function_id)
|
|
8153
9155
|
)]), () => ( []))
|
|
8154
9156
|
),
|
|
@@ -8188,7 +9190,7 @@ function runDevServer(evaluators, opts) {
|
|
|
8188
9190
|
);
|
|
8189
9191
|
}
|
|
8190
9192
|
},
|
|
8191
|
-
parent:
|
|
9193
|
+
parent: parseParent(parent),
|
|
8192
9194
|
parameters: _nullishCoalesce(parameters, () => ( {}))
|
|
8193
9195
|
}
|
|
8194
9196
|
);
|
|
@@ -8233,20 +9235,6 @@ function runDevServer(evaluators, opts) {
|
|
|
8233
9235
|
var asyncHandler = (fn) => (req, res, next) => {
|
|
8234
9236
|
Promise.resolve(fn(req, res, next)).catch(next);
|
|
8235
9237
|
};
|
|
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
9238
|
async function getDataset(state, data) {
|
|
8251
9239
|
if ("project_name" in data) {
|
|
8252
9240
|
return initDataset({
|
|
@@ -8270,9 +9258,9 @@ async function getDataset(state, data) {
|
|
|
8270
9258
|
return data.data;
|
|
8271
9259
|
}
|
|
8272
9260
|
}
|
|
8273
|
-
var datasetFetchSchema =
|
|
8274
|
-
project_id:
|
|
8275
|
-
name:
|
|
9261
|
+
var datasetFetchSchema = _v3.z.object({
|
|
9262
|
+
project_id: _v3.z.string(),
|
|
9263
|
+
name: _v3.z.string()
|
|
8276
9264
|
});
|
|
8277
9265
|
async function getDatasetById({
|
|
8278
9266
|
state,
|
|
@@ -8281,7 +9269,7 @@ async function getDatasetById({
|
|
|
8281
9269
|
const dataset = await state.appConn().post_json("api/dataset/get", {
|
|
8282
9270
|
id: datasetId
|
|
8283
9271
|
});
|
|
8284
|
-
const parsed =
|
|
9272
|
+
const parsed = _v3.z.array(datasetFetchSchema).parse(dataset);
|
|
8285
9273
|
if (parsed.length === 0) {
|
|
8286
9274
|
throw new Error(`Dataset '${datasetId}' not found`);
|
|
8287
9275
|
}
|