braintrust 0.2.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 +2157 -1169
- package/dist/browser.mjs +2099 -1111
- package/dist/cli.js +2191 -1159
- package/dist/index.d.mts +356 -28
- package/dist/index.d.ts +356 -28
- package/dist/index.js +2642 -1286
- package/dist/index.mjs +2562 -1206
- package/package.json +13 -8
- package/util/dist/index.d.mts +5229 -0
- package/util/dist/index.d.ts +5229 -0
- package/util/dist/index.js +1264 -0
- package/util/dist/index.mjs +1264 -0
package/dist/index.mjs
CHANGED
|
@@ -481,15 +481,15 @@ function mergeTwoObjects(one, two, level = 0, objects) {
|
|
|
481
481
|
for (let i = 0, j = two.length; i < j; i++) {
|
|
482
482
|
result.push(takeValue(two[i]));
|
|
483
483
|
}
|
|
484
|
-
} else if (
|
|
484
|
+
} else if (isObject2(two)) {
|
|
485
485
|
const keys = Object.keys(two);
|
|
486
486
|
for (let i = 0, j = keys.length; i < j; i++) {
|
|
487
487
|
const key = keys[i];
|
|
488
488
|
result[key] = takeValue(two[key]);
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
|
-
} else if (
|
|
492
|
-
if (
|
|
491
|
+
} else if (isObject2(one)) {
|
|
492
|
+
if (isObject2(two)) {
|
|
493
493
|
if (!shouldMerge(one, two)) {
|
|
494
494
|
return two;
|
|
495
495
|
}
|
|
@@ -510,7 +510,7 @@ function mergeTwoObjects(one, two, level = 0, objects) {
|
|
|
510
510
|
if (wasObjectReferenced(one, key, objects) || wasObjectReferenced(two, key, objects)) {
|
|
511
511
|
delete result[key];
|
|
512
512
|
} else {
|
|
513
|
-
if (
|
|
513
|
+
if (isObject2(obj1) && isObject2(obj2)) {
|
|
514
514
|
const arr1 = objects.get(obj1) || [];
|
|
515
515
|
const arr2 = objects.get(obj2) || [];
|
|
516
516
|
arr1.push({ obj: one, key });
|
|
@@ -544,7 +544,7 @@ function isArray2(value) {
|
|
|
544
544
|
function isFunction(value) {
|
|
545
545
|
return typeof value === "function";
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function isObject2(value) {
|
|
548
548
|
return !isPrimitive(value) && !isArray2(value) && !isFunction(value) && typeof value === "object";
|
|
549
549
|
}
|
|
550
550
|
function isPrimitive(value) {
|
|
@@ -3498,33 +3498,999 @@ var Queue = class {
|
|
|
3498
3498
|
}
|
|
3499
3499
|
};
|
|
3500
3500
|
|
|
3501
|
-
//
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3501
|
+
// util/db_fields.ts
|
|
3502
|
+
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
3503
|
+
var IS_MERGE_FIELD = "_is_merge";
|
|
3504
|
+
var AUDIT_SOURCE_FIELD = "_audit_source";
|
|
3505
|
+
var AUDIT_METADATA_FIELD = "_audit_metadata";
|
|
3506
|
+
var VALID_SOURCES = ["app", "api", "external"];
|
|
3507
|
+
var PARENT_ID_FIELD = "_parent_id";
|
|
3508
|
+
|
|
3509
|
+
// util/span_identifier_v3.ts
|
|
3510
|
+
import * as uuid3 from "uuid";
|
|
3511
|
+
|
|
3512
|
+
// util/span_identifier_v2.ts
|
|
3513
|
+
import * as uuid2 from "uuid";
|
|
3514
|
+
|
|
3515
|
+
// util/span_identifier_v1.ts
|
|
3516
|
+
import * as uuid from "uuid";
|
|
3517
|
+
import { z } from "zod/v3";
|
|
3518
|
+
function tryMakeUuid(s) {
|
|
3519
|
+
try {
|
|
3520
|
+
const ret = uuid.parse(s);
|
|
3521
|
+
if (ret.length !== 16) {
|
|
3522
|
+
throw new Error();
|
|
3523
|
+
}
|
|
3524
|
+
return { bytes: Buffer.from(ret), isUUID: true };
|
|
3525
|
+
} catch (e) {
|
|
3526
|
+
return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
var ENCODING_VERSION_NUMBER = 1;
|
|
3530
|
+
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";
|
|
3531
|
+
var SpanObjectTypeV1 = /* @__PURE__ */ ((SpanObjectTypeV12) => {
|
|
3532
|
+
SpanObjectTypeV12[SpanObjectTypeV12["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
3533
|
+
SpanObjectTypeV12[SpanObjectTypeV12["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
3534
|
+
return SpanObjectTypeV12;
|
|
3535
|
+
})(SpanObjectTypeV1 || {});
|
|
3536
|
+
var SpanObjectTypeV1EnumSchema = z.nativeEnum(SpanObjectTypeV1);
|
|
3537
|
+
var SpanRowIdsV1 = class {
|
|
3538
|
+
rowId;
|
|
3539
|
+
spanId;
|
|
3540
|
+
rootSpanId;
|
|
3541
|
+
constructor(args) {
|
|
3542
|
+
this.rowId = args.rowId;
|
|
3543
|
+
this.spanId = args.spanId;
|
|
3544
|
+
this.rootSpanId = args.rootSpanId;
|
|
3545
|
+
if (!this.rowId) {
|
|
3546
|
+
throw new Error("rowId must be nonempty string");
|
|
3547
|
+
}
|
|
3548
|
+
if (!this.spanId) {
|
|
3549
|
+
throw new Error("spanId must be nonempty string");
|
|
3550
|
+
}
|
|
3551
|
+
if (!this.rootSpanId) {
|
|
3552
|
+
throw new Error("rootSpanId must be nonempty string");
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
toObject() {
|
|
3556
|
+
return {
|
|
3557
|
+
rowId: this.rowId,
|
|
3558
|
+
spanId: this.spanId,
|
|
3559
|
+
rootSpanId: this.rootSpanId
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3562
|
+
};
|
|
3563
|
+
var SpanComponentsV1 = class _SpanComponentsV1 {
|
|
3564
|
+
objectType;
|
|
3565
|
+
objectId;
|
|
3566
|
+
rowIds;
|
|
3567
|
+
constructor(args) {
|
|
3568
|
+
this.objectType = args.objectType;
|
|
3569
|
+
this.objectId = args.objectId;
|
|
3570
|
+
this.rowIds = args.rowIds;
|
|
3571
|
+
}
|
|
3572
|
+
toStr() {
|
|
3573
|
+
const allBuffers = [];
|
|
3574
|
+
const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
|
|
3575
|
+
allBuffers.push(
|
|
3576
|
+
Buffer.from([
|
|
3577
|
+
ENCODING_VERSION_NUMBER,
|
|
3578
|
+
this.objectType,
|
|
3579
|
+
this.rowIds ? 1 : 0,
|
|
3580
|
+
rowIdIsUUID ? 1 : 0
|
|
3581
|
+
])
|
|
3582
|
+
);
|
|
3583
|
+
const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid(
|
|
3584
|
+
this.objectId
|
|
3585
|
+
);
|
|
3586
|
+
if (!objectIdIsUUID) {
|
|
3587
|
+
throw new Error("object_id component must be a valid UUID");
|
|
3588
|
+
}
|
|
3589
|
+
allBuffers.push(objectIdBytes);
|
|
3590
|
+
if (this.rowIds) {
|
|
3591
|
+
const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid(
|
|
3592
|
+
this.rowIds.spanId
|
|
3593
|
+
);
|
|
3594
|
+
if (!spanIdIsUUID) {
|
|
3595
|
+
throw new Error("span_id component must be a valid UUID");
|
|
3596
|
+
}
|
|
3597
|
+
const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid(
|
|
3598
|
+
this.rowIds.rootSpanId
|
|
3599
|
+
);
|
|
3600
|
+
if (!rootSpanIdIsUUID) {
|
|
3601
|
+
throw new Error("root_span_id component must be a valid UUID");
|
|
3602
|
+
}
|
|
3603
|
+
allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
|
|
3604
|
+
}
|
|
3605
|
+
return Buffer.concat(allBuffers).toString("base64");
|
|
3606
|
+
}
|
|
3607
|
+
static fromStr(s) {
|
|
3608
|
+
try {
|
|
3609
|
+
const rawBytes = Buffer.from(s, "base64");
|
|
3610
|
+
if (rawBytes[0] !== ENCODING_VERSION_NUMBER) {
|
|
3611
|
+
throw new Error();
|
|
3612
|
+
}
|
|
3613
|
+
const objectType = SpanObjectTypeV1EnumSchema.parse(rawBytes[1]);
|
|
3614
|
+
if (![0, 1].includes(rawBytes[2])) {
|
|
3615
|
+
throw new Error();
|
|
3616
|
+
}
|
|
3617
|
+
if (![0, 1].includes(rawBytes[3])) {
|
|
3618
|
+
throw new Error();
|
|
3619
|
+
}
|
|
3620
|
+
const hasRowId = rawBytes[2] == 1;
|
|
3621
|
+
const rowIdIsUUID = rawBytes[3] == 1;
|
|
3622
|
+
const objectId = uuid.stringify(rawBytes.subarray(4, 20));
|
|
3623
|
+
const rowIds = (() => {
|
|
3624
|
+
if (!hasRowId) {
|
|
3625
|
+
return void 0;
|
|
3626
|
+
}
|
|
3627
|
+
const spanId = uuid.stringify(rawBytes.subarray(20, 36));
|
|
3628
|
+
const rootSpanId = uuid.stringify(rawBytes.subarray(36, 52));
|
|
3629
|
+
const rowId = rowIdIsUUID ? uuid.stringify(rawBytes.subarray(52)) : rawBytes.subarray(52).toString("utf-8");
|
|
3630
|
+
return new SpanRowIdsV1({ rowId, spanId, rootSpanId });
|
|
3631
|
+
})();
|
|
3632
|
+
return new _SpanComponentsV1({ objectType, objectId, rowIds });
|
|
3633
|
+
} catch (e) {
|
|
3634
|
+
throw new Error(INVALID_ENCODING_ERRMSG);
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
objectIdFields() {
|
|
3638
|
+
switch (this.objectType) {
|
|
3639
|
+
case 1 /* EXPERIMENT */:
|
|
3640
|
+
return { experiment_id: this.objectId };
|
|
3641
|
+
case 2 /* PROJECT_LOGS */:
|
|
3642
|
+
return { project_id: this.objectId, log_id: "g" };
|
|
3643
|
+
default:
|
|
3644
|
+
throw new Error("Impossible");
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
toObject() {
|
|
3648
|
+
return {
|
|
3649
|
+
objectType: this.objectType,
|
|
3650
|
+
objectId: this.objectId,
|
|
3651
|
+
rowIds: this.rowIds?.toObject()
|
|
3652
|
+
};
|
|
3653
|
+
}
|
|
3654
|
+
};
|
|
3655
|
+
|
|
3656
|
+
// util/span_identifier_v2.ts
|
|
3657
|
+
import { z as z2 } from "zod/v3";
|
|
3658
|
+
function tryMakeUuid2(s) {
|
|
3659
|
+
try {
|
|
3660
|
+
const ret = uuid2.parse(s);
|
|
3661
|
+
if (ret.length !== 16) {
|
|
3662
|
+
throw new Error();
|
|
3663
|
+
}
|
|
3664
|
+
return { bytes: Buffer.from(ret), isUUID: true };
|
|
3665
|
+
} catch (e) {
|
|
3666
|
+
return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
|
|
3667
|
+
}
|
|
3668
|
+
}
|
|
3669
|
+
var ENCODING_VERSION_NUMBER2 = 2;
|
|
3670
|
+
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.`;
|
|
3671
|
+
var INTEGER_ENCODING_NUM_BYTES = 4;
|
|
3672
|
+
var SpanObjectTypeV2 = /* @__PURE__ */ ((SpanObjectTypeV22) => {
|
|
3673
|
+
SpanObjectTypeV22[SpanObjectTypeV22["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
3674
|
+
SpanObjectTypeV22[SpanObjectTypeV22["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
3675
|
+
return SpanObjectTypeV22;
|
|
3676
|
+
})(SpanObjectTypeV2 || {});
|
|
3677
|
+
var SpanObjectTypeV2EnumSchema = z2.nativeEnum(SpanObjectTypeV2);
|
|
3678
|
+
var SpanRowIdsV2 = class {
|
|
3679
|
+
rowId;
|
|
3680
|
+
spanId;
|
|
3681
|
+
rootSpanId;
|
|
3682
|
+
constructor(args) {
|
|
3683
|
+
this.rowId = args.rowId;
|
|
3684
|
+
this.spanId = args.spanId;
|
|
3685
|
+
this.rootSpanId = args.rootSpanId;
|
|
3686
|
+
if (!this.rowId) {
|
|
3687
|
+
throw new Error("rowId must be nonempty string");
|
|
3688
|
+
}
|
|
3689
|
+
if (!this.spanId) {
|
|
3690
|
+
throw new Error("spanId must be nonempty string");
|
|
3691
|
+
}
|
|
3692
|
+
if (!this.rootSpanId) {
|
|
3693
|
+
throw new Error("rootSpanId must be nonempty string");
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
toObject() {
|
|
3697
|
+
return {
|
|
3698
|
+
rowId: this.rowId,
|
|
3699
|
+
spanId: this.spanId,
|
|
3700
|
+
rootSpanId: this.rootSpanId
|
|
3701
|
+
};
|
|
3702
|
+
}
|
|
3703
|
+
};
|
|
3704
|
+
var SpanComponentsV2 = class _SpanComponentsV2 {
|
|
3705
|
+
objectType;
|
|
3706
|
+
objectId;
|
|
3707
|
+
computeObjectMetadataArgs;
|
|
3708
|
+
rowIds;
|
|
3709
|
+
constructor(args) {
|
|
3710
|
+
this.objectType = args.objectType;
|
|
3711
|
+
this.objectId = args.objectId;
|
|
3712
|
+
this.computeObjectMetadataArgs = args.computeObjectMetadataArgs;
|
|
3713
|
+
this.rowIds = args.rowIds;
|
|
3714
|
+
if (!(this.objectId || this.computeObjectMetadataArgs)) {
|
|
3715
|
+
throw new Error(
|
|
3716
|
+
"Must provide either objectId or computeObjectMetadataArgs"
|
|
3717
|
+
);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
toStr() {
|
|
3721
|
+
const allBuffers = [];
|
|
3722
|
+
const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid2(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
|
|
3723
|
+
allBuffers.push(
|
|
3724
|
+
Buffer.from([
|
|
3725
|
+
ENCODING_VERSION_NUMBER2,
|
|
3726
|
+
this.objectType,
|
|
3727
|
+
this.objectId ? 1 : 0,
|
|
3728
|
+
this.computeObjectMetadataArgs ? 1 : 0,
|
|
3729
|
+
this.rowIds ? 1 : 0,
|
|
3730
|
+
rowIdIsUUID ? 1 : 0
|
|
3731
|
+
])
|
|
3732
|
+
);
|
|
3733
|
+
if (this.objectId) {
|
|
3734
|
+
const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid2(
|
|
3735
|
+
this.objectId
|
|
3736
|
+
);
|
|
3737
|
+
if (!objectIdIsUUID) {
|
|
3738
|
+
throw new Error("object_id component must be a valid UUID");
|
|
3739
|
+
}
|
|
3740
|
+
allBuffers.push(objectIdBytes);
|
|
3741
|
+
}
|
|
3742
|
+
if (this.computeObjectMetadataArgs) {
|
|
3743
|
+
const computeObjectMetadataBytes = Buffer.from(
|
|
3744
|
+
JSON.stringify(this.computeObjectMetadataArgs),
|
|
3745
|
+
"utf-8"
|
|
3746
|
+
);
|
|
3747
|
+
const serializedLenBytes = Buffer.alloc(INTEGER_ENCODING_NUM_BYTES);
|
|
3748
|
+
serializedLenBytes.writeInt32BE(computeObjectMetadataBytes.length);
|
|
3749
|
+
allBuffers.push(serializedLenBytes, computeObjectMetadataBytes);
|
|
3750
|
+
}
|
|
3751
|
+
if (this.rowIds) {
|
|
3752
|
+
const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid2(
|
|
3753
|
+
this.rowIds.spanId
|
|
3754
|
+
);
|
|
3755
|
+
if (!spanIdIsUUID) {
|
|
3756
|
+
throw new Error("span_id component must be a valid UUID");
|
|
3757
|
+
}
|
|
3758
|
+
const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid2(
|
|
3759
|
+
this.rowIds.rootSpanId
|
|
3760
|
+
);
|
|
3761
|
+
if (!rootSpanIdIsUUID) {
|
|
3762
|
+
throw new Error("root_span_id component must be a valid UUID");
|
|
3763
|
+
}
|
|
3764
|
+
allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
|
|
3765
|
+
}
|
|
3766
|
+
return Buffer.concat(allBuffers).toString("base64");
|
|
3767
|
+
}
|
|
3768
|
+
static fromStr(s) {
|
|
3769
|
+
try {
|
|
3770
|
+
const rawBytes = Buffer.from(s, "base64");
|
|
3771
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER2) {
|
|
3772
|
+
const spanComponentsOld = SpanComponentsV1.fromStr(s);
|
|
3773
|
+
return new _SpanComponentsV2({
|
|
3774
|
+
objectType: SpanObjectTypeV2EnumSchema.parse(
|
|
3775
|
+
spanComponentsOld.objectType
|
|
3776
|
+
),
|
|
3777
|
+
objectId: spanComponentsOld.objectId,
|
|
3778
|
+
rowIds: spanComponentsOld.rowIds ? new SpanRowIdsV2({
|
|
3779
|
+
rowId: spanComponentsOld.rowIds.rowId,
|
|
3780
|
+
spanId: spanComponentsOld.rowIds.spanId,
|
|
3781
|
+
rootSpanId: spanComponentsOld.rowIds.rootSpanId
|
|
3782
|
+
}) : void 0
|
|
3783
|
+
});
|
|
3784
|
+
}
|
|
3785
|
+
if (rawBytes[0] !== ENCODING_VERSION_NUMBER2) {
|
|
3786
|
+
throw new Error();
|
|
3787
|
+
}
|
|
3788
|
+
const objectType = SpanObjectTypeV2EnumSchema.parse(rawBytes[1]);
|
|
3789
|
+
for (let i = 2; i < 6; ++i) {
|
|
3790
|
+
if (![0, 1].includes(rawBytes[i])) {
|
|
3791
|
+
throw new Error();
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
const hasObjectId = rawBytes[2] == 1;
|
|
3795
|
+
const hasComputeObjectMetadataArgs = rawBytes[3] == 1;
|
|
3796
|
+
const hasRowId = rawBytes[4] == 1;
|
|
3797
|
+
const rowIdIsUUID = rawBytes[5] == 1;
|
|
3798
|
+
let byteCursor = 6;
|
|
3799
|
+
let objectId = void 0;
|
|
3800
|
+
if (hasObjectId) {
|
|
3801
|
+
const nextByteCursor = byteCursor + 16;
|
|
3802
|
+
objectId = uuid2.stringify(
|
|
3803
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
3804
|
+
);
|
|
3805
|
+
byteCursor = nextByteCursor;
|
|
3806
|
+
}
|
|
3807
|
+
let computeObjectMetadataArgs;
|
|
3808
|
+
if (hasComputeObjectMetadataArgs) {
|
|
3809
|
+
let nextByteCursor = byteCursor + INTEGER_ENCODING_NUM_BYTES;
|
|
3810
|
+
const serializedLenBytes = rawBytes.readInt32BE(byteCursor);
|
|
3811
|
+
byteCursor = nextByteCursor;
|
|
3812
|
+
nextByteCursor = byteCursor + serializedLenBytes;
|
|
3813
|
+
computeObjectMetadataArgs = JSON.parse(
|
|
3814
|
+
rawBytes.subarray(byteCursor, nextByteCursor).toString("utf-8")
|
|
3815
|
+
);
|
|
3816
|
+
byteCursor = nextByteCursor;
|
|
3817
|
+
}
|
|
3818
|
+
const rowIds = (() => {
|
|
3819
|
+
if (!hasRowId) {
|
|
3820
|
+
return void 0;
|
|
3821
|
+
}
|
|
3822
|
+
let nextByteCursor = byteCursor + 16;
|
|
3823
|
+
const spanId = uuid2.stringify(
|
|
3824
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
3825
|
+
);
|
|
3826
|
+
byteCursor = nextByteCursor;
|
|
3827
|
+
nextByteCursor = byteCursor + 16;
|
|
3828
|
+
const rootSpanId = uuid2.stringify(
|
|
3829
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
3830
|
+
);
|
|
3831
|
+
byteCursor = nextByteCursor;
|
|
3832
|
+
const rowId = rowIdIsUUID ? uuid2.stringify(rawBytes.subarray(byteCursor)) : rawBytes.subarray(byteCursor).toString("utf-8");
|
|
3833
|
+
return new SpanRowIdsV2({ rowId, spanId, rootSpanId });
|
|
3834
|
+
})();
|
|
3835
|
+
return new _SpanComponentsV2({
|
|
3836
|
+
objectType,
|
|
3837
|
+
objectId,
|
|
3838
|
+
computeObjectMetadataArgs,
|
|
3839
|
+
rowIds
|
|
3840
|
+
});
|
|
3841
|
+
} catch (e) {
|
|
3842
|
+
throw new Error(INVALID_ENCODING_ERRMSG2);
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
objectIdFields() {
|
|
3846
|
+
if (!this.objectId) {
|
|
3847
|
+
throw new Error(
|
|
3848
|
+
"Impossible: cannot invoke `object_id_fields` unless SpanComponentsV2 is initialized with an `object_id`"
|
|
3849
|
+
);
|
|
3850
|
+
}
|
|
3851
|
+
switch (this.objectType) {
|
|
3852
|
+
case 1 /* EXPERIMENT */:
|
|
3853
|
+
return { experiment_id: this.objectId };
|
|
3854
|
+
case 2 /* PROJECT_LOGS */:
|
|
3855
|
+
return { project_id: this.objectId, log_id: "g" };
|
|
3856
|
+
default:
|
|
3857
|
+
throw new Error("Impossible");
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
toObject() {
|
|
3861
|
+
return {
|
|
3862
|
+
objectType: this.objectType,
|
|
3863
|
+
objectId: this.objectId,
|
|
3864
|
+
computeObjectMetadataArgs: this.computeObjectMetadataArgs,
|
|
3865
|
+
rowIds: this.rowIds?.toObject()
|
|
3866
|
+
};
|
|
3867
|
+
}
|
|
3868
|
+
};
|
|
3869
|
+
|
|
3870
|
+
// util/span_identifier_v3.ts
|
|
3871
|
+
import { z as z3 } from "zod/v3";
|
|
3872
|
+
|
|
3873
|
+
// util/bytes.ts
|
|
3874
|
+
function concatUint8Arrays(...arrays) {
|
|
3875
|
+
const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
|
|
3876
|
+
const result = new Uint8Array(totalLength);
|
|
3877
|
+
let offset = 0;
|
|
3878
|
+
for (const arr of arrays) {
|
|
3879
|
+
result.set(arr, offset);
|
|
3880
|
+
offset += arr.length;
|
|
3881
|
+
}
|
|
3882
|
+
return result;
|
|
3883
|
+
}
|
|
3884
|
+
function uint8ArrayToBase64(uint8Array) {
|
|
3885
|
+
let binary = "";
|
|
3886
|
+
for (let i = 0; i < uint8Array.length; i++) {
|
|
3887
|
+
binary += String.fromCharCode(uint8Array[i]);
|
|
3888
|
+
}
|
|
3889
|
+
return btoa(binary);
|
|
3890
|
+
}
|
|
3891
|
+
function base64ToUint8Array(base64) {
|
|
3892
|
+
const binary = atob(base64);
|
|
3893
|
+
const uint8Array = new Uint8Array(binary.length);
|
|
3894
|
+
for (let i = 0; i < binary.length; i++) {
|
|
3895
|
+
uint8Array[i] = binary.charCodeAt(i);
|
|
3896
|
+
}
|
|
3897
|
+
return uint8Array;
|
|
3898
|
+
}
|
|
3899
|
+
function uint8ArrayToString(uint8Array) {
|
|
3900
|
+
const decoder = new TextDecoder("utf-8");
|
|
3901
|
+
return decoder.decode(uint8Array);
|
|
3902
|
+
}
|
|
3903
|
+
function stringToUint8Array(str) {
|
|
3904
|
+
const encoder = new TextEncoder();
|
|
3905
|
+
return encoder.encode(str);
|
|
3906
|
+
}
|
|
3907
|
+
|
|
3908
|
+
// util/span_identifier_v3.ts
|
|
3909
|
+
function tryMakeUuid3(s) {
|
|
3910
|
+
try {
|
|
3911
|
+
const ret = uuid3.parse(s);
|
|
3912
|
+
if (ret.length !== 16) {
|
|
3913
|
+
throw new Error();
|
|
3914
|
+
}
|
|
3915
|
+
return { bytes: new Uint8Array(ret), isUUID: true };
|
|
3916
|
+
} catch {
|
|
3917
|
+
return { bytes: void 0, isUUID: false };
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
var ENCODING_VERSION_NUMBER3 = 3;
|
|
3921
|
+
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.`;
|
|
3922
|
+
var SpanObjectTypeV3 = /* @__PURE__ */ ((SpanObjectTypeV32) => {
|
|
3923
|
+
SpanObjectTypeV32[SpanObjectTypeV32["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
3924
|
+
SpanObjectTypeV32[SpanObjectTypeV32["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
3925
|
+
SpanObjectTypeV32[SpanObjectTypeV32["PLAYGROUND_LOGS"] = 3] = "PLAYGROUND_LOGS";
|
|
3926
|
+
return SpanObjectTypeV32;
|
|
3927
|
+
})(SpanObjectTypeV3 || {});
|
|
3928
|
+
var spanObjectTypeV3EnumSchema = z3.nativeEnum(SpanObjectTypeV3);
|
|
3929
|
+
function spanObjectTypeV3ToString(objectType) {
|
|
3930
|
+
switch (objectType) {
|
|
3931
|
+
case 1 /* EXPERIMENT */:
|
|
3932
|
+
return "experiment";
|
|
3933
|
+
case 2 /* PROJECT_LOGS */:
|
|
3934
|
+
return "project_logs";
|
|
3935
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
3936
|
+
return "playground_logs";
|
|
3937
|
+
default:
|
|
3938
|
+
const x = objectType;
|
|
3939
|
+
throw new Error(`Unknown SpanObjectTypeV3: ${x}`);
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
var InternalSpanComponentUUIDFields = /* @__PURE__ */ ((InternalSpanComponentUUIDFields2) => {
|
|
3943
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["OBJECT_ID"] = 1] = "OBJECT_ID";
|
|
3944
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROW_ID"] = 2] = "ROW_ID";
|
|
3945
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["SPAN_ID"] = 3] = "SPAN_ID";
|
|
3946
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROOT_SPAN_ID"] = 4] = "ROOT_SPAN_ID";
|
|
3947
|
+
return InternalSpanComponentUUIDFields2;
|
|
3948
|
+
})(InternalSpanComponentUUIDFields || {});
|
|
3949
|
+
var internalSpanComponentUUIDFieldsEnumSchema = z3.nativeEnum(
|
|
3950
|
+
InternalSpanComponentUUIDFields
|
|
3951
|
+
);
|
|
3952
|
+
var _INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME = {
|
|
3953
|
+
[1 /* OBJECT_ID */]: "object_id",
|
|
3954
|
+
[2 /* ROW_ID */]: "row_id",
|
|
3955
|
+
[3 /* SPAN_ID */]: "span_id",
|
|
3956
|
+
[4 /* ROOT_SPAN_ID */]: "root_span_id"
|
|
3957
|
+
};
|
|
3958
|
+
var spanComponentsV3Schema = z3.object({
|
|
3959
|
+
object_type: spanObjectTypeV3EnumSchema,
|
|
3960
|
+
// TODO(manu): We should have a more elaborate zod schema for
|
|
3961
|
+
// `propagated_event`. This will required zod-ifying the contents of
|
|
3962
|
+
// sdk/js/util/object.ts.
|
|
3963
|
+
propagated_event: z3.record(z3.unknown()).nullish()
|
|
3964
|
+
}).and(
|
|
3965
|
+
z3.union([
|
|
3966
|
+
// Must provide one or the other.
|
|
3967
|
+
z3.object({
|
|
3968
|
+
object_id: z3.string().nullish(),
|
|
3969
|
+
compute_object_metadata_args: z3.optional(z3.null())
|
|
3970
|
+
}),
|
|
3971
|
+
z3.object({
|
|
3972
|
+
object_id: z3.optional(z3.null()),
|
|
3973
|
+
compute_object_metadata_args: z3.record(z3.unknown())
|
|
3974
|
+
})
|
|
3975
|
+
])
|
|
3976
|
+
).and(
|
|
3977
|
+
z3.union([
|
|
3978
|
+
// Either all of these must be provided or none.
|
|
3979
|
+
z3.object({
|
|
3980
|
+
row_id: z3.string(),
|
|
3981
|
+
span_id: z3.string(),
|
|
3982
|
+
root_span_id: z3.string()
|
|
3983
|
+
}),
|
|
3984
|
+
z3.object({
|
|
3985
|
+
row_id: z3.optional(z3.null()),
|
|
3986
|
+
span_id: z3.optional(z3.null()),
|
|
3987
|
+
root_span_id: z3.optional(z3.null())
|
|
3988
|
+
})
|
|
3989
|
+
])
|
|
3990
|
+
);
|
|
3991
|
+
var SpanComponentsV3 = class _SpanComponentsV3 {
|
|
3992
|
+
constructor(data) {
|
|
3993
|
+
this.data = data;
|
|
3994
|
+
}
|
|
3995
|
+
toStr() {
|
|
3996
|
+
const jsonObj = {
|
|
3997
|
+
compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
|
|
3998
|
+
propagated_event: this.data.propagated_event || void 0
|
|
3999
|
+
};
|
|
4000
|
+
const allBuffers = [];
|
|
4001
|
+
allBuffers.push(
|
|
4002
|
+
new Uint8Array([ENCODING_VERSION_NUMBER3, this.data.object_type])
|
|
4003
|
+
);
|
|
4004
|
+
const uuidEntries = [];
|
|
4005
|
+
function addUuidField(origVal, fieldId) {
|
|
4006
|
+
const ret = tryMakeUuid3(origVal);
|
|
4007
|
+
if (ret.isUUID) {
|
|
4008
|
+
uuidEntries.push(
|
|
4009
|
+
concatUint8Arrays(new Uint8Array([fieldId]), ret.bytes)
|
|
4010
|
+
);
|
|
4011
|
+
} else {
|
|
4012
|
+
jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = origVal;
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
if (this.data.object_id) {
|
|
4016
|
+
addUuidField(
|
|
4017
|
+
this.data.object_id,
|
|
4018
|
+
1 /* OBJECT_ID */
|
|
4019
|
+
);
|
|
4020
|
+
}
|
|
4021
|
+
if (this.data.row_id) {
|
|
4022
|
+
addUuidField(this.data.row_id, 2 /* ROW_ID */);
|
|
4023
|
+
}
|
|
4024
|
+
if (this.data.span_id) {
|
|
4025
|
+
addUuidField(this.data.span_id, 3 /* SPAN_ID */);
|
|
4026
|
+
}
|
|
4027
|
+
if (this.data.root_span_id) {
|
|
4028
|
+
addUuidField(
|
|
4029
|
+
this.data.root_span_id,
|
|
4030
|
+
4 /* ROOT_SPAN_ID */
|
|
4031
|
+
);
|
|
4032
|
+
}
|
|
4033
|
+
if (uuidEntries.length > 255) {
|
|
4034
|
+
throw new Error("Impossible: too many UUID entries to encode");
|
|
4035
|
+
}
|
|
4036
|
+
allBuffers.push(new Uint8Array([uuidEntries.length]));
|
|
4037
|
+
allBuffers.push(...uuidEntries);
|
|
4038
|
+
if (Object.keys(jsonObj).length > 0) {
|
|
4039
|
+
allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
|
|
4040
|
+
}
|
|
4041
|
+
return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
|
|
4042
|
+
}
|
|
4043
|
+
static fromStr(s) {
|
|
4044
|
+
try {
|
|
4045
|
+
const rawBytes = base64ToUint8Array(s);
|
|
4046
|
+
const jsonObj = {};
|
|
4047
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER3) {
|
|
4048
|
+
const spanComponentsOld = SpanComponentsV2.fromStr(s);
|
|
4049
|
+
jsonObj["object_type"] = spanComponentsOld.objectType;
|
|
4050
|
+
jsonObj["object_id"] = spanComponentsOld.objectId;
|
|
4051
|
+
jsonObj["compute_object_metadata_args"] = spanComponentsOld.computeObjectMetadataArgs;
|
|
4052
|
+
if (spanComponentsOld.rowIds) {
|
|
4053
|
+
jsonObj["row_id"] = spanComponentsOld.rowIds.rowId;
|
|
4054
|
+
jsonObj["span_id"] = spanComponentsOld.rowIds.spanId;
|
|
4055
|
+
jsonObj["root_span_id"] = spanComponentsOld.rowIds.rootSpanId;
|
|
4056
|
+
}
|
|
4057
|
+
} else {
|
|
4058
|
+
jsonObj["object_type"] = rawBytes[1];
|
|
4059
|
+
const numUuidEntries = rawBytes[2];
|
|
4060
|
+
let byteOffset = 3;
|
|
4061
|
+
for (let i = 0; i < numUuidEntries; ++i) {
|
|
4062
|
+
const fieldId = internalSpanComponentUUIDFieldsEnumSchema.parse(
|
|
4063
|
+
rawBytes[byteOffset]
|
|
4064
|
+
);
|
|
4065
|
+
const fieldBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
|
|
4066
|
+
byteOffset += 17;
|
|
4067
|
+
jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = uuid3.stringify(fieldBytes);
|
|
4068
|
+
}
|
|
4069
|
+
if (byteOffset < rawBytes.length) {
|
|
4070
|
+
const remainingJsonObj = JSON.parse(
|
|
4071
|
+
uint8ArrayToString(rawBytes.subarray(byteOffset))
|
|
4072
|
+
);
|
|
4073
|
+
Object.assign(jsonObj, remainingJsonObj);
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
return _SpanComponentsV3.fromJsonObj(jsonObj);
|
|
4077
|
+
} catch {
|
|
4078
|
+
throw new Error(INVALID_ENCODING_ERRMSG3);
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
objectIdFields() {
|
|
4082
|
+
if (!this.data.object_id) {
|
|
4083
|
+
throw new Error(
|
|
4084
|
+
"Impossible: cannot invoke `objectIdFields` unless SpanComponentsV3 is initialized with an `object_id`"
|
|
4085
|
+
);
|
|
4086
|
+
}
|
|
4087
|
+
switch (this.data.object_type) {
|
|
4088
|
+
case 1 /* EXPERIMENT */:
|
|
4089
|
+
return { experiment_id: this.data.object_id };
|
|
4090
|
+
case 2 /* PROJECT_LOGS */:
|
|
4091
|
+
return { project_id: this.data.object_id, log_id: "g" };
|
|
4092
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
4093
|
+
return { prompt_session_id: this.data.object_id, log_id: "x" };
|
|
4094
|
+
default:
|
|
4095
|
+
const _ = this.data.object_type;
|
|
4096
|
+
throw new Error("Impossible");
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
async export() {
|
|
4100
|
+
return this.toStr();
|
|
4101
|
+
}
|
|
4102
|
+
static fromJsonObj(jsonObj) {
|
|
4103
|
+
return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
|
|
4104
|
+
}
|
|
4105
|
+
};
|
|
4106
|
+
|
|
4107
|
+
// util/type_util.ts
|
|
4108
|
+
function isObject(value) {
|
|
4109
|
+
return value instanceof Object && !(value instanceof Array);
|
|
4110
|
+
}
|
|
4111
|
+
function isArray(value) {
|
|
4112
|
+
return value instanceof Array;
|
|
4113
|
+
}
|
|
4114
|
+
function isObjectOrArray(value) {
|
|
4115
|
+
return value instanceof Object;
|
|
4116
|
+
}
|
|
4117
|
+
|
|
4118
|
+
// util/object_util.ts
|
|
4119
|
+
function mergeDictsWithPaths({
|
|
4120
|
+
mergeInto,
|
|
4121
|
+
mergeFrom,
|
|
4122
|
+
mergePaths
|
|
4123
|
+
}) {
|
|
4124
|
+
const mergePathsSerialized = new Set(
|
|
4125
|
+
mergePaths.map((p) => JSON.stringify(p))
|
|
4126
|
+
);
|
|
4127
|
+
return mergeDictsWithPathsHelper({
|
|
4128
|
+
mergeInto,
|
|
4129
|
+
mergeFrom,
|
|
4130
|
+
path: [],
|
|
4131
|
+
mergePaths: mergePathsSerialized
|
|
4132
|
+
});
|
|
4133
|
+
}
|
|
4134
|
+
function mergeDictsWithPathsHelper({
|
|
4135
|
+
mergeInto,
|
|
4136
|
+
mergeFrom,
|
|
4137
|
+
path: path3,
|
|
4138
|
+
mergePaths
|
|
4139
|
+
}) {
|
|
4140
|
+
Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
|
|
4141
|
+
const fullPath = path3.concat([k]);
|
|
4142
|
+
const fullPathSerialized = JSON.stringify(fullPath);
|
|
4143
|
+
const mergeIntoV = recordFind(mergeInto, k);
|
|
4144
|
+
if (isObject(mergeIntoV) && isObject(mergeFromV) && !mergePaths.has(fullPathSerialized)) {
|
|
4145
|
+
mergeDictsWithPathsHelper({
|
|
4146
|
+
mergeInto: mergeIntoV,
|
|
4147
|
+
mergeFrom: mergeFromV,
|
|
4148
|
+
path: fullPath,
|
|
4149
|
+
mergePaths
|
|
4150
|
+
});
|
|
4151
|
+
} else {
|
|
4152
|
+
mergeInto[k] = mergeFromV;
|
|
4153
|
+
}
|
|
4154
|
+
});
|
|
4155
|
+
return mergeInto;
|
|
4156
|
+
}
|
|
4157
|
+
function mergeDicts(mergeInto, mergeFrom) {
|
|
4158
|
+
return mergeDictsWithPaths({ mergeInto, mergeFrom, mergePaths: [] });
|
|
4159
|
+
}
|
|
4160
|
+
function mapAt(m, k) {
|
|
4161
|
+
const ret = m.get(k);
|
|
4162
|
+
if (ret === void 0) {
|
|
4163
|
+
throw new Error(`Map does not contain key ${k}`);
|
|
4164
|
+
}
|
|
4165
|
+
return ret;
|
|
4166
|
+
}
|
|
4167
|
+
function recordFind(m, k) {
|
|
4168
|
+
return m[k];
|
|
4169
|
+
}
|
|
4170
|
+
function getObjValueByPath(row, path3) {
|
|
4171
|
+
let curr = row;
|
|
4172
|
+
for (const p of path3) {
|
|
4173
|
+
if (!isObjectOrArray(curr)) {
|
|
4174
|
+
return null;
|
|
4175
|
+
}
|
|
4176
|
+
curr = curr[p];
|
|
4177
|
+
}
|
|
4178
|
+
return curr;
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
// util/graph_util.ts
|
|
4182
|
+
function depthFirstSearch(args) {
|
|
4183
|
+
const { graph, firstVisitF, lastVisitF } = args;
|
|
4184
|
+
for (const vs of graph.values()) {
|
|
4185
|
+
for (const v of vs.values()) {
|
|
4186
|
+
if (!graph.has(v)) {
|
|
4187
|
+
throw new Error(`Outgoing vertex ${v} must be a key in the graph`);
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
const firstVisitedVertices = /* @__PURE__ */ new Set();
|
|
4192
|
+
const visitationOrder = args.visitationOrder ?? [...graph.keys()];
|
|
4193
|
+
const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
|
|
4194
|
+
while (events.length) {
|
|
4195
|
+
const { eventType, vertex, extras } = events.pop();
|
|
4196
|
+
if (eventType === "last") {
|
|
4197
|
+
lastVisitF?.(vertex);
|
|
4198
|
+
continue;
|
|
4199
|
+
}
|
|
4200
|
+
if (firstVisitedVertices.has(vertex)) {
|
|
4201
|
+
continue;
|
|
4202
|
+
}
|
|
4203
|
+
firstVisitedVertices.add(vertex);
|
|
4204
|
+
firstVisitF?.(vertex, { parentVertex: extras.parentVertex });
|
|
4205
|
+
events.push({ eventType: "last", vertex, extras: {} });
|
|
4206
|
+
mapAt(graph, vertex).forEach((child) => {
|
|
4207
|
+
events.push({
|
|
4208
|
+
eventType: "first",
|
|
4209
|
+
vertex: child,
|
|
4210
|
+
extras: { parentVertex: vertex }
|
|
4211
|
+
});
|
|
4212
|
+
});
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
function undirectedConnectedComponents(graph) {
|
|
4216
|
+
const directedGraph = new Map(
|
|
4217
|
+
[...graph.vertices].map((v) => [v, /* @__PURE__ */ new Set()])
|
|
4218
|
+
);
|
|
4219
|
+
for (const [i, j] of graph.edges) {
|
|
4220
|
+
mapAt(directedGraph, i).add(j);
|
|
4221
|
+
mapAt(directedGraph, j).add(i);
|
|
4222
|
+
}
|
|
4223
|
+
let labelCounter = 0;
|
|
4224
|
+
const vertexLabels = /* @__PURE__ */ new Map();
|
|
4225
|
+
const firstVisitF = (vertex, args) => {
|
|
4226
|
+
const label = args?.parentVertex !== void 0 ? mapAt(vertexLabels, args?.parentVertex) : labelCounter++;
|
|
4227
|
+
vertexLabels.set(vertex, label);
|
|
4228
|
+
};
|
|
4229
|
+
depthFirstSearch({ graph: directedGraph, firstVisitF });
|
|
4230
|
+
const output = Array.from({ length: labelCounter }).map(() => []);
|
|
4231
|
+
for (const [vertex, label] of vertexLabels.entries()) {
|
|
4232
|
+
output[label].push(vertex);
|
|
4233
|
+
}
|
|
4234
|
+
return output;
|
|
4235
|
+
}
|
|
4236
|
+
function topologicalSort(graph, visitationOrder) {
|
|
4237
|
+
const reverseOrdering = [];
|
|
4238
|
+
const lastVisitF = (vertex) => {
|
|
4239
|
+
reverseOrdering.push(vertex);
|
|
4240
|
+
};
|
|
4241
|
+
depthFirstSearch({ graph, lastVisitF, visitationOrder });
|
|
4242
|
+
return reverseOrdering.reverse();
|
|
4243
|
+
}
|
|
4244
|
+
|
|
4245
|
+
// util/merge_row_batch.ts
|
|
4246
|
+
function generateMergedRowKey(row, useParentIdForId) {
|
|
4247
|
+
return JSON.stringify(
|
|
4248
|
+
[
|
|
4249
|
+
"org_id",
|
|
4250
|
+
"project_id",
|
|
4251
|
+
"experiment_id",
|
|
4252
|
+
"dataset_id",
|
|
4253
|
+
"prompt_session_id",
|
|
4254
|
+
"log_id",
|
|
4255
|
+
useParentIdForId ?? false ? PARENT_ID_FIELD : "id"
|
|
4256
|
+
].map((k) => row[k])
|
|
4257
|
+
);
|
|
4258
|
+
}
|
|
4259
|
+
var MERGE_ROW_SKIP_FIELDS = [
|
|
4260
|
+
"created",
|
|
4261
|
+
"span_id",
|
|
4262
|
+
"root_span_id",
|
|
4263
|
+
"span_parents",
|
|
4264
|
+
"_parent_id"
|
|
4265
|
+
// TODO: handle merge paths.
|
|
4266
|
+
];
|
|
4267
|
+
function popMergeRowSkipFields(row) {
|
|
4268
|
+
const popped = {};
|
|
4269
|
+
for (const field of MERGE_ROW_SKIP_FIELDS) {
|
|
4270
|
+
if (field in row) {
|
|
4271
|
+
popped[field] = row[field];
|
|
4272
|
+
delete row[field];
|
|
4273
|
+
}
|
|
4274
|
+
}
|
|
4275
|
+
return popped;
|
|
4276
|
+
}
|
|
4277
|
+
function restoreMergeRowSkipFields(row, skipFields) {
|
|
4278
|
+
for (const field of MERGE_ROW_SKIP_FIELDS) {
|
|
4279
|
+
delete row[field];
|
|
4280
|
+
if (field in skipFields) {
|
|
4281
|
+
row[field] = skipFields[field];
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
}
|
|
4285
|
+
function mergeRowBatch(rows) {
|
|
4286
|
+
for (const row of rows) {
|
|
4287
|
+
if (row.id === void 0) {
|
|
4288
|
+
throw new Error(
|
|
4289
|
+
"Logged row is missing an id. This is an internal braintrust error. Please contact us at info@braintrust.dev for help"
|
|
4290
|
+
);
|
|
4291
|
+
}
|
|
4292
|
+
}
|
|
4293
|
+
const rowGroups = /* @__PURE__ */ new Map();
|
|
4294
|
+
for (const row of rows) {
|
|
4295
|
+
const key = generateMergedRowKey(row);
|
|
4296
|
+
const existingRow = rowGroups.get(key);
|
|
4297
|
+
if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
|
|
4298
|
+
const skipFields = popMergeRowSkipFields(existingRow);
|
|
4299
|
+
const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
|
|
4300
|
+
mergeDicts(existingRow, row);
|
|
4301
|
+
restoreMergeRowSkipFields(existingRow, skipFields);
|
|
4302
|
+
if (preserveNoMerge) {
|
|
4303
|
+
delete existingRow[IS_MERGE_FIELD];
|
|
4304
|
+
}
|
|
4305
|
+
} else {
|
|
4306
|
+
rowGroups.set(key, row);
|
|
4307
|
+
}
|
|
4308
|
+
}
|
|
4309
|
+
const merged = [...rowGroups.values()];
|
|
4310
|
+
const rowToLabel = new Map(
|
|
4311
|
+
merged.map((r, i) => [generateMergedRowKey(r), i])
|
|
4312
|
+
);
|
|
4313
|
+
const graph = new Map(
|
|
4314
|
+
Array.from({ length: merged.length }).map((_, i) => [i, /* @__PURE__ */ new Set()])
|
|
4315
|
+
);
|
|
4316
|
+
merged.forEach((r, i) => {
|
|
4317
|
+
const parentId = r[PARENT_ID_FIELD];
|
|
4318
|
+
if (!parentId) {
|
|
4319
|
+
return;
|
|
4320
|
+
}
|
|
4321
|
+
const parentRowKey = generateMergedRowKey(
|
|
4322
|
+
r,
|
|
4323
|
+
true
|
|
4324
|
+
/* useParentIdForId */
|
|
4325
|
+
);
|
|
4326
|
+
const parentLabel = rowToLabel.get(parentRowKey);
|
|
4327
|
+
if (parentLabel !== void 0) {
|
|
4328
|
+
mapAt(graph, parentLabel).add(i);
|
|
4329
|
+
}
|
|
4330
|
+
});
|
|
4331
|
+
const connectedComponents = undirectedConnectedComponents({
|
|
4332
|
+
vertices: new Set(graph.keys()),
|
|
4333
|
+
edges: new Set(
|
|
4334
|
+
[...graph.entries()].flatMap(
|
|
4335
|
+
([k, vs]) => [...vs].map((v) => {
|
|
4336
|
+
const ret = [k, v];
|
|
4337
|
+
return ret;
|
|
4338
|
+
})
|
|
4339
|
+
)
|
|
4340
|
+
)
|
|
4341
|
+
});
|
|
4342
|
+
const buckets = connectedComponents.map(
|
|
4343
|
+
(cc) => topologicalSort(
|
|
4344
|
+
graph,
|
|
4345
|
+
cc
|
|
4346
|
+
/* visitationOrder */
|
|
4347
|
+
)
|
|
4348
|
+
);
|
|
4349
|
+
return buckets.map((bucket) => bucket.map((i) => merged[i]));
|
|
4350
|
+
}
|
|
4351
|
+
function batchItems(args) {
|
|
4352
|
+
let { items } = args;
|
|
4353
|
+
const batchMaxNumItems = args.batchMaxNumItems ?? Number.POSITIVE_INFINITY;
|
|
4354
|
+
const batchMaxNumBytes = args.batchMaxNumBytes ?? Number.POSITIVE_INFINITY;
|
|
4355
|
+
const output = [];
|
|
4356
|
+
let nextItems = [];
|
|
4357
|
+
let batchSet = [];
|
|
4358
|
+
let batch = [];
|
|
4359
|
+
let batchLen = 0;
|
|
4360
|
+
function addToBatch(item) {
|
|
4361
|
+
batch.push(item);
|
|
4362
|
+
batchLen += item.length;
|
|
4363
|
+
}
|
|
4364
|
+
function flushBatch() {
|
|
4365
|
+
batchSet.push(batch);
|
|
4366
|
+
batch = [];
|
|
4367
|
+
batchLen = 0;
|
|
4368
|
+
}
|
|
4369
|
+
while (items.length) {
|
|
4370
|
+
for (const bucket of items) {
|
|
4371
|
+
let i = 0;
|
|
4372
|
+
for (const item of bucket) {
|
|
4373
|
+
if (batch.length === 0 || item.length + batchLen < batchMaxNumBytes && batch.length < batchMaxNumItems) {
|
|
4374
|
+
addToBatch(item);
|
|
4375
|
+
} else if (i === 0) {
|
|
4376
|
+
flushBatch();
|
|
4377
|
+
addToBatch(item);
|
|
4378
|
+
} else {
|
|
4379
|
+
break;
|
|
4380
|
+
}
|
|
4381
|
+
++i;
|
|
4382
|
+
}
|
|
4383
|
+
if (i < bucket.length) {
|
|
4384
|
+
nextItems.push(bucket.slice(i));
|
|
4385
|
+
}
|
|
4386
|
+
if (batchLen >= batchMaxNumBytes || batch.length > batchMaxNumItems) {
|
|
4387
|
+
flushBatch();
|
|
4388
|
+
}
|
|
4389
|
+
}
|
|
4390
|
+
if (batch.length) {
|
|
4391
|
+
flushBatch();
|
|
4392
|
+
}
|
|
4393
|
+
if (batchSet.length) {
|
|
4394
|
+
output.push(batchSet);
|
|
4395
|
+
batchSet = [];
|
|
4396
|
+
}
|
|
4397
|
+
items = nextItems;
|
|
4398
|
+
nextItems = [];
|
|
4399
|
+
}
|
|
4400
|
+
return output;
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4403
|
+
// util/object.ts
|
|
4404
|
+
var DEFAULT_IS_LEGACY_DATASET = false;
|
|
4405
|
+
function ensureDatasetRecord(r, legacy) {
|
|
4406
|
+
if (legacy) {
|
|
4407
|
+
return ensureLegacyDatasetRecord(r);
|
|
4408
|
+
} else {
|
|
4409
|
+
return ensureNewDatasetRecord(r);
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
function ensureLegacyDatasetRecord(r) {
|
|
4413
|
+
if ("output" in r) {
|
|
4414
|
+
return r;
|
|
4415
|
+
}
|
|
4416
|
+
const row = {
|
|
4417
|
+
...r,
|
|
4418
|
+
output: r.expected
|
|
4419
|
+
};
|
|
4420
|
+
delete row.expected;
|
|
4421
|
+
return row;
|
|
4422
|
+
}
|
|
4423
|
+
function ensureNewDatasetRecord(r) {
|
|
4424
|
+
if ("expected" in r) {
|
|
4425
|
+
return r;
|
|
4426
|
+
}
|
|
4427
|
+
const row = {
|
|
4428
|
+
...r,
|
|
4429
|
+
tags: null,
|
|
4430
|
+
expected: r.output
|
|
4431
|
+
};
|
|
4432
|
+
delete row.output;
|
|
4433
|
+
return row;
|
|
4434
|
+
}
|
|
4435
|
+
|
|
4436
|
+
// util/json_util.ts
|
|
4437
|
+
function constructJsonArray(items) {
|
|
4438
|
+
return `[${items.join(",")}]`;
|
|
4439
|
+
}
|
|
4440
|
+
|
|
4441
|
+
// util/string_util.ts
|
|
4442
|
+
function _urljoin(...parts) {
|
|
4443
|
+
return parts.map(
|
|
4444
|
+
(x, i) => x.replace(/^\//, "").replace(i < parts.length - 1 ? /\/$/ : "", "")
|
|
4445
|
+
).filter((x) => x.trim() !== "").join("/");
|
|
4446
|
+
}
|
|
4447
|
+
|
|
4448
|
+
// util/git_fields.ts
|
|
4449
|
+
function mergeGitMetadataSettings(s1, s2) {
|
|
4450
|
+
if (s1.collect === "all") {
|
|
4451
|
+
return s2;
|
|
4452
|
+
} else if (s2.collect === "all") {
|
|
4453
|
+
return s1;
|
|
4454
|
+
} else if (s1.collect === "none") {
|
|
4455
|
+
return s1;
|
|
4456
|
+
} else if (s2.collect === "none") {
|
|
4457
|
+
return s2;
|
|
4458
|
+
}
|
|
4459
|
+
const fields = (s1.fields ?? []).filter((f) => (s2.fields ?? []).includes(f));
|
|
4460
|
+
const collect = fields.length > 0 ? "some" : "none";
|
|
4461
|
+
return { collect, fields };
|
|
4462
|
+
}
|
|
4463
|
+
|
|
4464
|
+
// util/xact-ids.ts
|
|
4465
|
+
var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
|
|
4466
|
+
var MOD = BigInt(1) << BigInt(64);
|
|
4467
|
+
var COPRIME = BigInt("205891132094649");
|
|
4468
|
+
var COPRIME_INVERSE = BigInt("1522336535492693385");
|
|
4469
|
+
function modularMultiply(value, prime) {
|
|
4470
|
+
return value * prime % MOD;
|
|
4471
|
+
}
|
|
4472
|
+
function prettifyXact(valueString) {
|
|
4473
|
+
const value = BigInt(valueString);
|
|
4474
|
+
const encoded = modularMultiply(value, COPRIME);
|
|
4475
|
+
return encoded.toString(16).padStart(16, "0");
|
|
4476
|
+
}
|
|
4477
|
+
function loadPrettyXact(encodedHex) {
|
|
4478
|
+
if (encodedHex.length !== 16) {
|
|
4479
|
+
return encodedHex;
|
|
4480
|
+
}
|
|
4481
|
+
const value = BigInt(`0x${encodedHex}`);
|
|
4482
|
+
const multipliedInverse = modularMultiply(value, COPRIME_INVERSE);
|
|
4483
|
+
const withTopBits = TOP_BITS | multipliedInverse;
|
|
4484
|
+
return withTopBits.toString();
|
|
4485
|
+
}
|
|
4486
|
+
|
|
4487
|
+
// util/zod_util.ts
|
|
4488
|
+
import { z as z4 } from "zod/v3";
|
|
3523
4489
|
|
|
3524
4490
|
// src/generated_types.ts
|
|
3525
|
-
import { z } from "zod";
|
|
3526
|
-
var AclObjectType =
|
|
3527
|
-
|
|
4491
|
+
import { z as z5 } from "zod/v3";
|
|
4492
|
+
var AclObjectType = z5.union([
|
|
4493
|
+
z5.enum([
|
|
3528
4494
|
"organization",
|
|
3529
4495
|
"project",
|
|
3530
4496
|
"experiment",
|
|
@@ -3537,9 +4503,9 @@ var AclObjectType = z.union([
|
|
|
3537
4503
|
"project_log",
|
|
3538
4504
|
"org_project"
|
|
3539
4505
|
]),
|
|
3540
|
-
|
|
4506
|
+
z5.null()
|
|
3541
4507
|
]);
|
|
3542
|
-
var Permission =
|
|
4508
|
+
var Permission = z5.enum([
|
|
3543
4509
|
"create",
|
|
3544
4510
|
"read",
|
|
3545
4511
|
"update",
|
|
@@ -3549,310 +4515,310 @@ var Permission = z.enum([
|
|
|
3549
4515
|
"update_acls",
|
|
3550
4516
|
"delete_acls"
|
|
3551
4517
|
]);
|
|
3552
|
-
var Acl =
|
|
3553
|
-
id:
|
|
3554
|
-
object_type: AclObjectType.and(
|
|
3555
|
-
object_id:
|
|
3556
|
-
user_id:
|
|
3557
|
-
group_id:
|
|
3558
|
-
permission: Permission.and(
|
|
3559
|
-
restrict_object_type: AclObjectType.and(
|
|
3560
|
-
role_id:
|
|
3561
|
-
_object_org_id:
|
|
3562
|
-
created:
|
|
3563
|
-
});
|
|
3564
|
-
var AISecret =
|
|
3565
|
-
id:
|
|
3566
|
-
created:
|
|
3567
|
-
updated_at:
|
|
3568
|
-
org_id:
|
|
3569
|
-
name:
|
|
3570
|
-
type:
|
|
3571
|
-
metadata:
|
|
3572
|
-
preview_secret:
|
|
3573
|
-
});
|
|
3574
|
-
var ResponseFormatJsonSchema =
|
|
3575
|
-
name:
|
|
3576
|
-
description:
|
|
3577
|
-
schema:
|
|
3578
|
-
strict:
|
|
3579
|
-
});
|
|
3580
|
-
var ResponseFormatNullish =
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
type:
|
|
4518
|
+
var Acl = z5.object({
|
|
4519
|
+
id: z5.string().uuid(),
|
|
4520
|
+
object_type: AclObjectType.and(z5.string()),
|
|
4521
|
+
object_id: z5.string().uuid(),
|
|
4522
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4523
|
+
group_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4524
|
+
permission: Permission.and(z5.union([z5.string(), z5.null()])).optional(),
|
|
4525
|
+
restrict_object_type: AclObjectType.and(z5.unknown()).optional(),
|
|
4526
|
+
role_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4527
|
+
_object_org_id: z5.string().uuid(),
|
|
4528
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
4529
|
+
});
|
|
4530
|
+
var AISecret = z5.object({
|
|
4531
|
+
id: z5.string().uuid(),
|
|
4532
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
4533
|
+
updated_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
4534
|
+
org_id: z5.string().uuid(),
|
|
4535
|
+
name: z5.string(),
|
|
4536
|
+
type: z5.union([z5.string(), z5.null()]).optional(),
|
|
4537
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
|
|
4538
|
+
preview_secret: z5.union([z5.string(), z5.null()]).optional()
|
|
4539
|
+
});
|
|
4540
|
+
var ResponseFormatJsonSchema = z5.object({
|
|
4541
|
+
name: z5.string(),
|
|
4542
|
+
description: z5.string().optional(),
|
|
4543
|
+
schema: z5.union([z5.object({}).partial().passthrough(), z5.string()]).optional(),
|
|
4544
|
+
strict: z5.union([z5.boolean(), z5.null()]).optional()
|
|
4545
|
+
});
|
|
4546
|
+
var ResponseFormatNullish = z5.union([
|
|
4547
|
+
z5.object({ type: z5.literal("json_object") }),
|
|
4548
|
+
z5.object({
|
|
4549
|
+
type: z5.literal("json_schema"),
|
|
3584
4550
|
json_schema: ResponseFormatJsonSchema
|
|
3585
4551
|
}),
|
|
3586
|
-
|
|
3587
|
-
|
|
4552
|
+
z5.object({ type: z5.literal("text") }),
|
|
4553
|
+
z5.null()
|
|
3588
4554
|
]);
|
|
3589
|
-
var AnyModelParams =
|
|
3590
|
-
temperature:
|
|
3591
|
-
top_p:
|
|
3592
|
-
max_tokens:
|
|
3593
|
-
max_completion_tokens:
|
|
3594
|
-
frequency_penalty:
|
|
3595
|
-
presence_penalty:
|
|
4555
|
+
var AnyModelParams = z5.object({
|
|
4556
|
+
temperature: z5.number().optional(),
|
|
4557
|
+
top_p: z5.number().optional(),
|
|
4558
|
+
max_tokens: z5.number(),
|
|
4559
|
+
max_completion_tokens: z5.number().optional(),
|
|
4560
|
+
frequency_penalty: z5.number().optional(),
|
|
4561
|
+
presence_penalty: z5.number().optional(),
|
|
3596
4562
|
response_format: ResponseFormatNullish.optional(),
|
|
3597
|
-
tool_choice:
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
type:
|
|
3603
|
-
function:
|
|
4563
|
+
tool_choice: z5.union([
|
|
4564
|
+
z5.literal("auto"),
|
|
4565
|
+
z5.literal("none"),
|
|
4566
|
+
z5.literal("required"),
|
|
4567
|
+
z5.object({
|
|
4568
|
+
type: z5.literal("function"),
|
|
4569
|
+
function: z5.object({ name: z5.string() })
|
|
3604
4570
|
})
|
|
3605
4571
|
]).optional(),
|
|
3606
|
-
function_call:
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
4572
|
+
function_call: z5.union([
|
|
4573
|
+
z5.literal("auto"),
|
|
4574
|
+
z5.literal("none"),
|
|
4575
|
+
z5.object({ name: z5.string() })
|
|
3610
4576
|
]).optional(),
|
|
3611
|
-
n:
|
|
3612
|
-
stop:
|
|
3613
|
-
reasoning_effort:
|
|
3614
|
-
verbosity:
|
|
3615
|
-
top_k:
|
|
3616
|
-
stop_sequences:
|
|
3617
|
-
max_tokens_to_sample:
|
|
3618
|
-
maxOutputTokens:
|
|
3619
|
-
topP:
|
|
3620
|
-
topK:
|
|
3621
|
-
use_cache:
|
|
3622
|
-
});
|
|
3623
|
-
var ApiKey =
|
|
3624
|
-
id:
|
|
3625
|
-
created:
|
|
3626
|
-
name:
|
|
3627
|
-
preview_name:
|
|
3628
|
-
user_id:
|
|
3629
|
-
user_email:
|
|
3630
|
-
user_given_name:
|
|
3631
|
-
user_family_name:
|
|
3632
|
-
org_id:
|
|
3633
|
-
});
|
|
3634
|
-
var AsyncScoringState =
|
|
3635
|
-
|
|
3636
|
-
status:
|
|
3637
|
-
token:
|
|
3638
|
-
function_ids:
|
|
3639
|
-
skip_logging:
|
|
4577
|
+
n: z5.number().optional(),
|
|
4578
|
+
stop: z5.array(z5.string()).optional(),
|
|
4579
|
+
reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
4580
|
+
verbosity: z5.enum(["low", "medium", "high"]).optional(),
|
|
4581
|
+
top_k: z5.number().optional(),
|
|
4582
|
+
stop_sequences: z5.array(z5.string()).optional(),
|
|
4583
|
+
max_tokens_to_sample: z5.number().optional(),
|
|
4584
|
+
maxOutputTokens: z5.number().optional(),
|
|
4585
|
+
topP: z5.number().optional(),
|
|
4586
|
+
topK: z5.number().optional(),
|
|
4587
|
+
use_cache: z5.boolean().optional()
|
|
4588
|
+
});
|
|
4589
|
+
var ApiKey = z5.object({
|
|
4590
|
+
id: z5.string().uuid(),
|
|
4591
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
4592
|
+
name: z5.string(),
|
|
4593
|
+
preview_name: z5.string(),
|
|
4594
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4595
|
+
user_email: z5.union([z5.string(), z5.null()]).optional(),
|
|
4596
|
+
user_given_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
4597
|
+
user_family_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
4598
|
+
org_id: z5.union([z5.string(), z5.null()]).optional()
|
|
4599
|
+
});
|
|
4600
|
+
var AsyncScoringState = z5.union([
|
|
4601
|
+
z5.object({
|
|
4602
|
+
status: z5.literal("enabled"),
|
|
4603
|
+
token: z5.string(),
|
|
4604
|
+
function_ids: z5.array(z5.unknown()).min(1),
|
|
4605
|
+
skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
|
|
3640
4606
|
}),
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
4607
|
+
z5.object({ status: z5.literal("disabled") }),
|
|
4608
|
+
z5.null(),
|
|
4609
|
+
z5.null()
|
|
3644
4610
|
]);
|
|
3645
|
-
var AsyncScoringControl =
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
4611
|
+
var AsyncScoringControl = z5.union([
|
|
4612
|
+
z5.object({ kind: z5.literal("score_update"), token: z5.string() }),
|
|
4613
|
+
z5.object({ kind: z5.literal("state_override"), state: AsyncScoringState }),
|
|
4614
|
+
z5.object({ kind: z5.literal("state_force_reselect") }),
|
|
4615
|
+
z5.object({ kind: z5.literal("state_enabled_force_rescore") })
|
|
3650
4616
|
]);
|
|
3651
|
-
var BraintrustAttachmentReference =
|
|
3652
|
-
type:
|
|
3653
|
-
filename:
|
|
3654
|
-
content_type:
|
|
3655
|
-
key:
|
|
3656
|
-
});
|
|
3657
|
-
var ExternalAttachmentReference =
|
|
3658
|
-
type:
|
|
3659
|
-
filename:
|
|
3660
|
-
content_type:
|
|
3661
|
-
url:
|
|
3662
|
-
});
|
|
3663
|
-
var AttachmentReference =
|
|
4617
|
+
var BraintrustAttachmentReference = z5.object({
|
|
4618
|
+
type: z5.literal("braintrust_attachment"),
|
|
4619
|
+
filename: z5.string().min(1),
|
|
4620
|
+
content_type: z5.string().min(1),
|
|
4621
|
+
key: z5.string().min(1)
|
|
4622
|
+
});
|
|
4623
|
+
var ExternalAttachmentReference = z5.object({
|
|
4624
|
+
type: z5.literal("external_attachment"),
|
|
4625
|
+
filename: z5.string().min(1),
|
|
4626
|
+
content_type: z5.string().min(1),
|
|
4627
|
+
url: z5.string().min(1)
|
|
4628
|
+
});
|
|
4629
|
+
var AttachmentReference = z5.discriminatedUnion("type", [
|
|
3664
4630
|
BraintrustAttachmentReference,
|
|
3665
4631
|
ExternalAttachmentReference
|
|
3666
4632
|
]);
|
|
3667
|
-
var UploadStatus =
|
|
3668
|
-
var AttachmentStatus =
|
|
4633
|
+
var UploadStatus = z5.enum(["uploading", "done", "error"]);
|
|
4634
|
+
var AttachmentStatus = z5.object({
|
|
3669
4635
|
upload_status: UploadStatus,
|
|
3670
|
-
error_message:
|
|
3671
|
-
});
|
|
3672
|
-
var BraintrustModelParams =
|
|
3673
|
-
var CallEvent =
|
|
3674
|
-
|
|
3675
|
-
id:
|
|
3676
|
-
data:
|
|
3677
|
-
event:
|
|
4636
|
+
error_message: z5.string().optional()
|
|
4637
|
+
});
|
|
4638
|
+
var BraintrustModelParams = z5.object({ use_cache: z5.boolean() }).partial();
|
|
4639
|
+
var CallEvent = z5.union([
|
|
4640
|
+
z5.object({
|
|
4641
|
+
id: z5.string().optional(),
|
|
4642
|
+
data: z5.string(),
|
|
4643
|
+
event: z5.literal("text_delta")
|
|
3678
4644
|
}),
|
|
3679
|
-
|
|
3680
|
-
id:
|
|
3681
|
-
data:
|
|
3682
|
-
event:
|
|
4645
|
+
z5.object({
|
|
4646
|
+
id: z5.string().optional(),
|
|
4647
|
+
data: z5.string(),
|
|
4648
|
+
event: z5.literal("reasoning_delta")
|
|
3683
4649
|
}),
|
|
3684
|
-
|
|
3685
|
-
id:
|
|
3686
|
-
data:
|
|
3687
|
-
event:
|
|
4650
|
+
z5.object({
|
|
4651
|
+
id: z5.string().optional(),
|
|
4652
|
+
data: z5.string(),
|
|
4653
|
+
event: z5.literal("json_delta")
|
|
3688
4654
|
}),
|
|
3689
|
-
|
|
3690
|
-
id:
|
|
3691
|
-
data:
|
|
3692
|
-
event:
|
|
4655
|
+
z5.object({
|
|
4656
|
+
id: z5.string().optional(),
|
|
4657
|
+
data: z5.string(),
|
|
4658
|
+
event: z5.literal("progress")
|
|
3693
4659
|
}),
|
|
3694
|
-
|
|
3695
|
-
id:
|
|
3696
|
-
data:
|
|
3697
|
-
event:
|
|
4660
|
+
z5.object({
|
|
4661
|
+
id: z5.string().optional(),
|
|
4662
|
+
data: z5.string(),
|
|
4663
|
+
event: z5.literal("error")
|
|
3698
4664
|
}),
|
|
3699
|
-
|
|
3700
|
-
id:
|
|
3701
|
-
data:
|
|
3702
|
-
event:
|
|
4665
|
+
z5.object({
|
|
4666
|
+
id: z5.string().optional(),
|
|
4667
|
+
data: z5.string(),
|
|
4668
|
+
event: z5.literal("console")
|
|
3703
4669
|
}),
|
|
3704
|
-
|
|
3705
|
-
id:
|
|
3706
|
-
event:
|
|
3707
|
-
data:
|
|
4670
|
+
z5.object({
|
|
4671
|
+
id: z5.string().optional(),
|
|
4672
|
+
event: z5.literal("start"),
|
|
4673
|
+
data: z5.literal("")
|
|
3708
4674
|
}),
|
|
3709
|
-
|
|
3710
|
-
id:
|
|
3711
|
-
event:
|
|
3712
|
-
data:
|
|
4675
|
+
z5.object({
|
|
4676
|
+
id: z5.string().optional(),
|
|
4677
|
+
event: z5.literal("done"),
|
|
4678
|
+
data: z5.literal("")
|
|
3713
4679
|
})
|
|
3714
4680
|
]);
|
|
3715
|
-
var ChatCompletionContentPartTextWithTitle =
|
|
3716
|
-
text:
|
|
3717
|
-
type:
|
|
3718
|
-
cache_control:
|
|
3719
|
-
});
|
|
3720
|
-
var ChatCompletionContentPartImageWithTitle =
|
|
3721
|
-
image_url:
|
|
3722
|
-
url:
|
|
3723
|
-
detail:
|
|
4681
|
+
var ChatCompletionContentPartTextWithTitle = z5.object({
|
|
4682
|
+
text: z5.string().default(""),
|
|
4683
|
+
type: z5.literal("text"),
|
|
4684
|
+
cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
|
|
4685
|
+
});
|
|
4686
|
+
var ChatCompletionContentPartImageWithTitle = z5.object({
|
|
4687
|
+
image_url: z5.object({
|
|
4688
|
+
url: z5.string(),
|
|
4689
|
+
detail: z5.union([z5.literal("auto"), z5.literal("low"), z5.literal("high")]).optional()
|
|
3724
4690
|
}),
|
|
3725
|
-
type:
|
|
4691
|
+
type: z5.literal("image_url")
|
|
3726
4692
|
});
|
|
3727
|
-
var ChatCompletionContentPart =
|
|
4693
|
+
var ChatCompletionContentPart = z5.union([
|
|
3728
4694
|
ChatCompletionContentPartTextWithTitle,
|
|
3729
4695
|
ChatCompletionContentPartImageWithTitle
|
|
3730
4696
|
]);
|
|
3731
|
-
var ChatCompletionContentPartText =
|
|
3732
|
-
text:
|
|
3733
|
-
type:
|
|
3734
|
-
cache_control:
|
|
3735
|
-
});
|
|
3736
|
-
var ChatCompletionMessageToolCall =
|
|
3737
|
-
id:
|
|
3738
|
-
function:
|
|
3739
|
-
type:
|
|
3740
|
-
});
|
|
3741
|
-
var ChatCompletionMessageReasoning =
|
|
3742
|
-
var ChatCompletionMessageParam =
|
|
3743
|
-
|
|
3744
|
-
content:
|
|
3745
|
-
role:
|
|
3746
|
-
name:
|
|
4697
|
+
var ChatCompletionContentPartText = z5.object({
|
|
4698
|
+
text: z5.string().default(""),
|
|
4699
|
+
type: z5.literal("text"),
|
|
4700
|
+
cache_control: z5.object({ type: z5.literal("ephemeral") }).optional()
|
|
4701
|
+
});
|
|
4702
|
+
var ChatCompletionMessageToolCall = z5.object({
|
|
4703
|
+
id: z5.string(),
|
|
4704
|
+
function: z5.object({ arguments: z5.string(), name: z5.string() }),
|
|
4705
|
+
type: z5.literal("function")
|
|
4706
|
+
});
|
|
4707
|
+
var ChatCompletionMessageReasoning = z5.object({ id: z5.string(), content: z5.string() }).partial();
|
|
4708
|
+
var ChatCompletionMessageParam = z5.union([
|
|
4709
|
+
z5.object({
|
|
4710
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
4711
|
+
role: z5.literal("system"),
|
|
4712
|
+
name: z5.string().optional()
|
|
3747
4713
|
}),
|
|
3748
|
-
|
|
3749
|
-
content:
|
|
3750
|
-
role:
|
|
3751
|
-
name:
|
|
4714
|
+
z5.object({
|
|
4715
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
|
|
4716
|
+
role: z5.literal("user"),
|
|
4717
|
+
name: z5.string().optional()
|
|
3752
4718
|
}),
|
|
3753
|
-
|
|
3754
|
-
role:
|
|
3755
|
-
content:
|
|
3756
|
-
function_call:
|
|
3757
|
-
name:
|
|
3758
|
-
tool_calls:
|
|
3759
|
-
reasoning:
|
|
4719
|
+
z5.object({
|
|
4720
|
+
role: z5.literal("assistant"),
|
|
4721
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
|
|
4722
|
+
function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
|
|
4723
|
+
name: z5.string().optional(),
|
|
4724
|
+
tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
|
|
4725
|
+
reasoning: z5.array(ChatCompletionMessageReasoning).optional()
|
|
3760
4726
|
}),
|
|
3761
|
-
|
|
3762
|
-
content:
|
|
3763
|
-
role:
|
|
3764
|
-
tool_call_id:
|
|
4727
|
+
z5.object({
|
|
4728
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
4729
|
+
role: z5.literal("tool"),
|
|
4730
|
+
tool_call_id: z5.string().default("")
|
|
3765
4731
|
}),
|
|
3766
|
-
|
|
3767
|
-
content:
|
|
3768
|
-
name:
|
|
3769
|
-
role:
|
|
4732
|
+
z5.object({
|
|
4733
|
+
content: z5.union([z5.string(), z5.null()]),
|
|
4734
|
+
name: z5.string(),
|
|
4735
|
+
role: z5.literal("function")
|
|
3770
4736
|
}),
|
|
3771
|
-
|
|
3772
|
-
content:
|
|
3773
|
-
role:
|
|
3774
|
-
name:
|
|
4737
|
+
z5.object({
|
|
4738
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
4739
|
+
role: z5.literal("developer"),
|
|
4740
|
+
name: z5.string().optional()
|
|
3775
4741
|
}),
|
|
3776
|
-
|
|
3777
|
-
role:
|
|
3778
|
-
content:
|
|
4742
|
+
z5.object({
|
|
4743
|
+
role: z5.literal("model"),
|
|
4744
|
+
content: z5.union([z5.string(), z5.null()]).optional()
|
|
3779
4745
|
})
|
|
3780
4746
|
]);
|
|
3781
|
-
var ChatCompletionOpenAIMessageParam =
|
|
3782
|
-
|
|
3783
|
-
content:
|
|
3784
|
-
role:
|
|
3785
|
-
name:
|
|
4747
|
+
var ChatCompletionOpenAIMessageParam = z5.union([
|
|
4748
|
+
z5.object({
|
|
4749
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
4750
|
+
role: z5.literal("system"),
|
|
4751
|
+
name: z5.string().optional()
|
|
3786
4752
|
}),
|
|
3787
|
-
|
|
3788
|
-
content:
|
|
3789
|
-
role:
|
|
3790
|
-
name:
|
|
4753
|
+
z5.object({
|
|
4754
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPart)]),
|
|
4755
|
+
role: z5.literal("user"),
|
|
4756
|
+
name: z5.string().optional()
|
|
3791
4757
|
}),
|
|
3792
|
-
|
|
3793
|
-
role:
|
|
3794
|
-
content:
|
|
3795
|
-
function_call:
|
|
3796
|
-
name:
|
|
3797
|
-
tool_calls:
|
|
3798
|
-
reasoning:
|
|
4758
|
+
z5.object({
|
|
4759
|
+
role: z5.literal("assistant"),
|
|
4760
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText), z5.null()]).optional(),
|
|
4761
|
+
function_call: z5.object({ arguments: z5.string(), name: z5.string() }).optional(),
|
|
4762
|
+
name: z5.string().optional(),
|
|
4763
|
+
tool_calls: z5.array(ChatCompletionMessageToolCall).optional(),
|
|
4764
|
+
reasoning: z5.array(ChatCompletionMessageReasoning).optional()
|
|
3799
4765
|
}),
|
|
3800
|
-
|
|
3801
|
-
content:
|
|
3802
|
-
role:
|
|
3803
|
-
tool_call_id:
|
|
4766
|
+
z5.object({
|
|
4767
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
4768
|
+
role: z5.literal("tool"),
|
|
4769
|
+
tool_call_id: z5.string().default("")
|
|
3804
4770
|
}),
|
|
3805
|
-
|
|
3806
|
-
content:
|
|
3807
|
-
name:
|
|
3808
|
-
role:
|
|
4771
|
+
z5.object({
|
|
4772
|
+
content: z5.union([z5.string(), z5.null()]),
|
|
4773
|
+
name: z5.string(),
|
|
4774
|
+
role: z5.literal("function")
|
|
3809
4775
|
}),
|
|
3810
|
-
|
|
3811
|
-
content:
|
|
3812
|
-
role:
|
|
3813
|
-
name:
|
|
4776
|
+
z5.object({
|
|
4777
|
+
content: z5.union([z5.string(), z5.array(ChatCompletionContentPartText)]),
|
|
4778
|
+
role: z5.literal("developer"),
|
|
4779
|
+
name: z5.string().optional()
|
|
3814
4780
|
})
|
|
3815
4781
|
]);
|
|
3816
|
-
var ChatCompletionTool =
|
|
3817
|
-
function:
|
|
3818
|
-
name:
|
|
3819
|
-
description:
|
|
3820
|
-
parameters:
|
|
4782
|
+
var ChatCompletionTool = z5.object({
|
|
4783
|
+
function: z5.object({
|
|
4784
|
+
name: z5.string(),
|
|
4785
|
+
description: z5.string().optional(),
|
|
4786
|
+
parameters: z5.object({}).partial().passthrough().optional()
|
|
3821
4787
|
}),
|
|
3822
|
-
type:
|
|
4788
|
+
type: z5.literal("function")
|
|
3823
4789
|
});
|
|
3824
|
-
var CodeBundle =
|
|
3825
|
-
runtime_context:
|
|
3826
|
-
runtime:
|
|
3827
|
-
version:
|
|
4790
|
+
var CodeBundle = z5.object({
|
|
4791
|
+
runtime_context: z5.object({
|
|
4792
|
+
runtime: z5.enum(["node", "python"]),
|
|
4793
|
+
version: z5.string()
|
|
3828
4794
|
}),
|
|
3829
|
-
location:
|
|
3830
|
-
|
|
3831
|
-
type:
|
|
3832
|
-
eval_name:
|
|
3833
|
-
position:
|
|
3834
|
-
|
|
3835
|
-
|
|
4795
|
+
location: z5.union([
|
|
4796
|
+
z5.object({
|
|
4797
|
+
type: z5.literal("experiment"),
|
|
4798
|
+
eval_name: z5.string(),
|
|
4799
|
+
position: z5.union([
|
|
4800
|
+
z5.object({ type: z5.literal("task") }),
|
|
4801
|
+
z5.object({ type: z5.literal("scorer"), index: z5.number().int().gte(0) })
|
|
3836
4802
|
])
|
|
3837
4803
|
}),
|
|
3838
|
-
|
|
4804
|
+
z5.object({ type: z5.literal("function"), index: z5.number().int().gte(0) })
|
|
3839
4805
|
]),
|
|
3840
|
-
bundle_id:
|
|
3841
|
-
preview:
|
|
3842
|
-
});
|
|
3843
|
-
var Dataset =
|
|
3844
|
-
id:
|
|
3845
|
-
project_id:
|
|
3846
|
-
name:
|
|
3847
|
-
description:
|
|
3848
|
-
created:
|
|
3849
|
-
deleted_at:
|
|
3850
|
-
user_id:
|
|
3851
|
-
metadata:
|
|
3852
|
-
});
|
|
3853
|
-
var ObjectReferenceNullish =
|
|
3854
|
-
|
|
3855
|
-
object_type:
|
|
4806
|
+
bundle_id: z5.string(),
|
|
4807
|
+
preview: z5.union([z5.string(), z5.null()]).optional()
|
|
4808
|
+
});
|
|
4809
|
+
var Dataset = z5.object({
|
|
4810
|
+
id: z5.string().uuid(),
|
|
4811
|
+
project_id: z5.string().uuid(),
|
|
4812
|
+
name: z5.string(),
|
|
4813
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
4814
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
4815
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
4816
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4817
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
|
|
4818
|
+
});
|
|
4819
|
+
var ObjectReferenceNullish = z5.union([
|
|
4820
|
+
z5.object({
|
|
4821
|
+
object_type: z5.enum([
|
|
3856
4822
|
"project_logs",
|
|
3857
4823
|
"experiment",
|
|
3858
4824
|
"dataset",
|
|
@@ -3860,399 +4826,399 @@ var ObjectReferenceNullish = z.union([
|
|
|
3860
4826
|
"function",
|
|
3861
4827
|
"prompt_session"
|
|
3862
4828
|
]),
|
|
3863
|
-
object_id:
|
|
3864
|
-
id:
|
|
3865
|
-
_xact_id:
|
|
3866
|
-
created:
|
|
4829
|
+
object_id: z5.string().uuid(),
|
|
4830
|
+
id: z5.string(),
|
|
4831
|
+
_xact_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4832
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
3867
4833
|
}),
|
|
3868
|
-
|
|
4834
|
+
z5.null()
|
|
3869
4835
|
]);
|
|
3870
|
-
var DatasetEvent =
|
|
3871
|
-
id:
|
|
3872
|
-
_xact_id:
|
|
3873
|
-
created:
|
|
3874
|
-
_pagination_key:
|
|
3875
|
-
project_id:
|
|
3876
|
-
dataset_id:
|
|
3877
|
-
input:
|
|
3878
|
-
expected:
|
|
3879
|
-
metadata:
|
|
3880
|
-
|
|
3881
|
-
|
|
4836
|
+
var DatasetEvent = z5.object({
|
|
4837
|
+
id: z5.string(),
|
|
4838
|
+
_xact_id: z5.string(),
|
|
4839
|
+
created: z5.string().datetime({ offset: true }),
|
|
4840
|
+
_pagination_key: z5.union([z5.string(), z5.null()]).optional(),
|
|
4841
|
+
project_id: z5.string().uuid(),
|
|
4842
|
+
dataset_id: z5.string().uuid(),
|
|
4843
|
+
input: z5.unknown().optional(),
|
|
4844
|
+
expected: z5.unknown().optional(),
|
|
4845
|
+
metadata: z5.union([
|
|
4846
|
+
z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
|
|
4847
|
+
z5.null()
|
|
3882
4848
|
]).optional(),
|
|
3883
|
-
tags:
|
|
3884
|
-
span_id:
|
|
3885
|
-
root_span_id:
|
|
3886
|
-
is_root:
|
|
4849
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
4850
|
+
span_id: z5.string(),
|
|
4851
|
+
root_span_id: z5.string(),
|
|
4852
|
+
is_root: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
3887
4853
|
origin: ObjectReferenceNullish.optional()
|
|
3888
4854
|
});
|
|
3889
|
-
var EnvVar =
|
|
3890
|
-
id:
|
|
3891
|
-
object_type:
|
|
3892
|
-
object_id:
|
|
3893
|
-
name:
|
|
3894
|
-
created:
|
|
3895
|
-
used:
|
|
3896
|
-
});
|
|
3897
|
-
var RepoInfo =
|
|
3898
|
-
|
|
3899
|
-
commit:
|
|
3900
|
-
branch:
|
|
3901
|
-
tag:
|
|
3902
|
-
dirty:
|
|
3903
|
-
author_name:
|
|
3904
|
-
author_email:
|
|
3905
|
-
commit_message:
|
|
3906
|
-
commit_time:
|
|
3907
|
-
git_diff:
|
|
4855
|
+
var EnvVar = z5.object({
|
|
4856
|
+
id: z5.string().uuid(),
|
|
4857
|
+
object_type: z5.enum(["organization", "project", "function"]),
|
|
4858
|
+
object_id: z5.string().uuid(),
|
|
4859
|
+
name: z5.string(),
|
|
4860
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
4861
|
+
used: z5.union([z5.string(), z5.null()]).optional()
|
|
4862
|
+
});
|
|
4863
|
+
var RepoInfo = z5.union([
|
|
4864
|
+
z5.object({
|
|
4865
|
+
commit: z5.union([z5.string(), z5.null()]),
|
|
4866
|
+
branch: z5.union([z5.string(), z5.null()]),
|
|
4867
|
+
tag: z5.union([z5.string(), z5.null()]),
|
|
4868
|
+
dirty: z5.union([z5.boolean(), z5.null()]),
|
|
4869
|
+
author_name: z5.union([z5.string(), z5.null()]),
|
|
4870
|
+
author_email: z5.union([z5.string(), z5.null()]),
|
|
4871
|
+
commit_message: z5.union([z5.string(), z5.null()]),
|
|
4872
|
+
commit_time: z5.union([z5.string(), z5.null()]),
|
|
4873
|
+
git_diff: z5.union([z5.string(), z5.null()])
|
|
3908
4874
|
}).partial(),
|
|
3909
|
-
|
|
4875
|
+
z5.null()
|
|
3910
4876
|
]);
|
|
3911
|
-
var Experiment =
|
|
3912
|
-
id:
|
|
3913
|
-
project_id:
|
|
3914
|
-
name:
|
|
3915
|
-
description:
|
|
3916
|
-
created:
|
|
4877
|
+
var Experiment = z5.object({
|
|
4878
|
+
id: z5.string().uuid(),
|
|
4879
|
+
project_id: z5.string().uuid(),
|
|
4880
|
+
name: z5.string(),
|
|
4881
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
4882
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
3917
4883
|
repo_info: RepoInfo.optional(),
|
|
3918
|
-
commit:
|
|
3919
|
-
base_exp_id:
|
|
3920
|
-
deleted_at:
|
|
3921
|
-
dataset_id:
|
|
3922
|
-
dataset_version:
|
|
3923
|
-
public:
|
|
3924
|
-
user_id:
|
|
3925
|
-
metadata:
|
|
3926
|
-
tags:
|
|
3927
|
-
});
|
|
3928
|
-
var SpanType =
|
|
3929
|
-
|
|
3930
|
-
|
|
4884
|
+
commit: z5.union([z5.string(), z5.null()]).optional(),
|
|
4885
|
+
base_exp_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4886
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
4887
|
+
dataset_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4888
|
+
dataset_version: z5.union([z5.string(), z5.null()]).optional(),
|
|
4889
|
+
public: z5.boolean(),
|
|
4890
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4891
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
|
|
4892
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
|
|
4893
|
+
});
|
|
4894
|
+
var SpanType = z5.union([
|
|
4895
|
+
z5.enum(["llm", "score", "function", "eval", "task", "tool"]),
|
|
4896
|
+
z5.null()
|
|
3931
4897
|
]);
|
|
3932
|
-
var SpanAttributes =
|
|
3933
|
-
|
|
3934
|
-
|
|
4898
|
+
var SpanAttributes = z5.union([
|
|
4899
|
+
z5.object({ name: z5.union([z5.string(), z5.null()]), type: SpanType }).partial().passthrough(),
|
|
4900
|
+
z5.null()
|
|
3935
4901
|
]);
|
|
3936
|
-
var ExperimentEvent =
|
|
3937
|
-
id:
|
|
3938
|
-
_xact_id:
|
|
3939
|
-
created:
|
|
3940
|
-
_pagination_key:
|
|
3941
|
-
project_id:
|
|
3942
|
-
experiment_id:
|
|
3943
|
-
input:
|
|
3944
|
-
output:
|
|
3945
|
-
expected:
|
|
3946
|
-
error:
|
|
3947
|
-
scores:
|
|
3948
|
-
metadata:
|
|
3949
|
-
|
|
3950
|
-
|
|
4902
|
+
var ExperimentEvent = z5.object({
|
|
4903
|
+
id: z5.string(),
|
|
4904
|
+
_xact_id: z5.string(),
|
|
4905
|
+
created: z5.string().datetime({ offset: true }),
|
|
4906
|
+
_pagination_key: z5.union([z5.string(), z5.null()]).optional(),
|
|
4907
|
+
project_id: z5.string().uuid(),
|
|
4908
|
+
experiment_id: z5.string().uuid(),
|
|
4909
|
+
input: z5.unknown().optional(),
|
|
4910
|
+
output: z5.unknown().optional(),
|
|
4911
|
+
expected: z5.unknown().optional(),
|
|
4912
|
+
error: z5.unknown().optional(),
|
|
4913
|
+
scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
|
|
4914
|
+
metadata: z5.union([
|
|
4915
|
+
z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
|
|
4916
|
+
z5.null()
|
|
3951
4917
|
]).optional(),
|
|
3952
|
-
tags:
|
|
3953
|
-
metrics:
|
|
3954
|
-
context:
|
|
3955
|
-
|
|
3956
|
-
caller_functionname:
|
|
3957
|
-
caller_filename:
|
|
3958
|
-
caller_lineno:
|
|
4918
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
4919
|
+
metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
|
|
4920
|
+
context: z5.union([
|
|
4921
|
+
z5.object({
|
|
4922
|
+
caller_functionname: z5.union([z5.string(), z5.null()]),
|
|
4923
|
+
caller_filename: z5.union([z5.string(), z5.null()]),
|
|
4924
|
+
caller_lineno: z5.union([z5.number(), z5.null()])
|
|
3959
4925
|
}).partial().passthrough(),
|
|
3960
|
-
|
|
4926
|
+
z5.null()
|
|
3961
4927
|
]).optional(),
|
|
3962
|
-
span_id:
|
|
3963
|
-
span_parents:
|
|
3964
|
-
root_span_id:
|
|
4928
|
+
span_id: z5.string(),
|
|
4929
|
+
span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
4930
|
+
root_span_id: z5.string(),
|
|
3965
4931
|
span_attributes: SpanAttributes.optional(),
|
|
3966
|
-
is_root:
|
|
4932
|
+
is_root: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
3967
4933
|
origin: ObjectReferenceNullish.optional()
|
|
3968
4934
|
});
|
|
3969
|
-
var ExtendedSavedFunctionId =
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
type:
|
|
3974
|
-
project_id:
|
|
3975
|
-
slug:
|
|
4935
|
+
var ExtendedSavedFunctionId = z5.union([
|
|
4936
|
+
z5.object({ type: z5.literal("function"), id: z5.string() }),
|
|
4937
|
+
z5.object({ type: z5.literal("global"), name: z5.string() }),
|
|
4938
|
+
z5.object({
|
|
4939
|
+
type: z5.literal("slug"),
|
|
4940
|
+
project_id: z5.string(),
|
|
4941
|
+
slug: z5.string()
|
|
3976
4942
|
})
|
|
3977
4943
|
]);
|
|
3978
|
-
var PromptBlockDataNullish =
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
type:
|
|
3982
|
-
messages:
|
|
3983
|
-
tools:
|
|
4944
|
+
var PromptBlockDataNullish = z5.union([
|
|
4945
|
+
z5.object({ type: z5.literal("completion"), content: z5.string() }),
|
|
4946
|
+
z5.object({
|
|
4947
|
+
type: z5.literal("chat"),
|
|
4948
|
+
messages: z5.array(ChatCompletionMessageParam),
|
|
4949
|
+
tools: z5.string().optional()
|
|
3984
4950
|
}),
|
|
3985
|
-
|
|
4951
|
+
z5.null()
|
|
3986
4952
|
]);
|
|
3987
|
-
var ModelParams =
|
|
3988
|
-
|
|
3989
|
-
use_cache:
|
|
3990
|
-
temperature:
|
|
3991
|
-
top_p:
|
|
3992
|
-
max_tokens:
|
|
3993
|
-
max_completion_tokens:
|
|
3994
|
-
frequency_penalty:
|
|
3995
|
-
presence_penalty:
|
|
4953
|
+
var ModelParams = z5.union([
|
|
4954
|
+
z5.object({
|
|
4955
|
+
use_cache: z5.boolean(),
|
|
4956
|
+
temperature: z5.number(),
|
|
4957
|
+
top_p: z5.number(),
|
|
4958
|
+
max_tokens: z5.number(),
|
|
4959
|
+
max_completion_tokens: z5.number(),
|
|
4960
|
+
frequency_penalty: z5.number(),
|
|
4961
|
+
presence_penalty: z5.number(),
|
|
3996
4962
|
response_format: ResponseFormatNullish,
|
|
3997
|
-
tool_choice:
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
type:
|
|
4003
|
-
function:
|
|
4963
|
+
tool_choice: z5.union([
|
|
4964
|
+
z5.literal("auto"),
|
|
4965
|
+
z5.literal("none"),
|
|
4966
|
+
z5.literal("required"),
|
|
4967
|
+
z5.object({
|
|
4968
|
+
type: z5.literal("function"),
|
|
4969
|
+
function: z5.object({ name: z5.string() })
|
|
4004
4970
|
})
|
|
4005
4971
|
]),
|
|
4006
|
-
function_call:
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4972
|
+
function_call: z5.union([
|
|
4973
|
+
z5.literal("auto"),
|
|
4974
|
+
z5.literal("none"),
|
|
4975
|
+
z5.object({ name: z5.string() })
|
|
4010
4976
|
]),
|
|
4011
|
-
n:
|
|
4012
|
-
stop:
|
|
4013
|
-
reasoning_effort:
|
|
4014
|
-
verbosity:
|
|
4977
|
+
n: z5.number(),
|
|
4978
|
+
stop: z5.array(z5.string()),
|
|
4979
|
+
reasoning_effort: z5.enum(["minimal", "low", "medium", "high"]),
|
|
4980
|
+
verbosity: z5.enum(["low", "medium", "high"])
|
|
4015
4981
|
}).partial().passthrough(),
|
|
4016
|
-
|
|
4017
|
-
use_cache:
|
|
4018
|
-
max_tokens:
|
|
4019
|
-
temperature:
|
|
4020
|
-
top_p:
|
|
4021
|
-
top_k:
|
|
4022
|
-
stop_sequences:
|
|
4023
|
-
max_tokens_to_sample:
|
|
4982
|
+
z5.object({
|
|
4983
|
+
use_cache: z5.boolean().optional(),
|
|
4984
|
+
max_tokens: z5.number(),
|
|
4985
|
+
temperature: z5.number(),
|
|
4986
|
+
top_p: z5.number().optional(),
|
|
4987
|
+
top_k: z5.number().optional(),
|
|
4988
|
+
stop_sequences: z5.array(z5.string()).optional(),
|
|
4989
|
+
max_tokens_to_sample: z5.number().optional()
|
|
4024
4990
|
}).passthrough(),
|
|
4025
|
-
|
|
4026
|
-
use_cache:
|
|
4027
|
-
temperature:
|
|
4028
|
-
maxOutputTokens:
|
|
4029
|
-
topP:
|
|
4030
|
-
topK:
|
|
4991
|
+
z5.object({
|
|
4992
|
+
use_cache: z5.boolean(),
|
|
4993
|
+
temperature: z5.number(),
|
|
4994
|
+
maxOutputTokens: z5.number(),
|
|
4995
|
+
topP: z5.number(),
|
|
4996
|
+
topK: z5.number()
|
|
4031
4997
|
}).partial().passthrough(),
|
|
4032
|
-
|
|
4033
|
-
use_cache:
|
|
4034
|
-
temperature:
|
|
4035
|
-
topK:
|
|
4998
|
+
z5.object({
|
|
4999
|
+
use_cache: z5.boolean(),
|
|
5000
|
+
temperature: z5.number(),
|
|
5001
|
+
topK: z5.number()
|
|
4036
5002
|
}).partial().passthrough(),
|
|
4037
|
-
|
|
5003
|
+
z5.object({ use_cache: z5.boolean() }).partial().passthrough()
|
|
4038
5004
|
]);
|
|
4039
|
-
var PromptOptionsNullish =
|
|
4040
|
-
|
|
4041
|
-
|
|
5005
|
+
var PromptOptionsNullish = z5.union([
|
|
5006
|
+
z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial(),
|
|
5007
|
+
z5.null()
|
|
4042
5008
|
]);
|
|
4043
|
-
var PromptParserNullish =
|
|
4044
|
-
|
|
4045
|
-
type:
|
|
4046
|
-
use_cot:
|
|
4047
|
-
choice_scores:
|
|
5009
|
+
var PromptParserNullish = z5.union([
|
|
5010
|
+
z5.object({
|
|
5011
|
+
type: z5.literal("llm_classifier"),
|
|
5012
|
+
use_cot: z5.boolean(),
|
|
5013
|
+
choice_scores: z5.record(z5.number().gte(0).lte(1))
|
|
4048
5014
|
}),
|
|
4049
|
-
|
|
5015
|
+
z5.null()
|
|
4050
5016
|
]);
|
|
4051
|
-
var SavedFunctionId =
|
|
4052
|
-
|
|
4053
|
-
|
|
5017
|
+
var SavedFunctionId = z5.union([
|
|
5018
|
+
z5.object({ type: z5.literal("function"), id: z5.string() }),
|
|
5019
|
+
z5.object({ type: z5.literal("global"), name: z5.string() })
|
|
4054
5020
|
]);
|
|
4055
|
-
var PromptDataNullish =
|
|
4056
|
-
|
|
5021
|
+
var PromptDataNullish = z5.union([
|
|
5022
|
+
z5.object({
|
|
4057
5023
|
prompt: PromptBlockDataNullish,
|
|
4058
5024
|
options: PromptOptionsNullish,
|
|
4059
5025
|
parser: PromptParserNullish,
|
|
4060
|
-
tool_functions:
|
|
4061
|
-
origin:
|
|
4062
|
-
|
|
4063
|
-
prompt_id:
|
|
4064
|
-
project_id:
|
|
4065
|
-
prompt_version:
|
|
5026
|
+
tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
|
|
5027
|
+
origin: z5.union([
|
|
5028
|
+
z5.object({
|
|
5029
|
+
prompt_id: z5.string(),
|
|
5030
|
+
project_id: z5.string(),
|
|
5031
|
+
prompt_version: z5.string()
|
|
4066
5032
|
}).partial(),
|
|
4067
|
-
|
|
5033
|
+
z5.null()
|
|
4068
5034
|
])
|
|
4069
5035
|
}).partial(),
|
|
4070
|
-
|
|
5036
|
+
z5.null()
|
|
4071
5037
|
]);
|
|
4072
|
-
var FunctionTypeEnumNullish =
|
|
4073
|
-
|
|
4074
|
-
|
|
5038
|
+
var FunctionTypeEnumNullish = z5.union([
|
|
5039
|
+
z5.enum(["llm", "scorer", "task", "tool"]),
|
|
5040
|
+
z5.null()
|
|
4075
5041
|
]);
|
|
4076
|
-
var FunctionIdRef =
|
|
4077
|
-
var PromptBlockData =
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
type:
|
|
4081
|
-
messages:
|
|
4082
|
-
tools:
|
|
5042
|
+
var FunctionIdRef = z5.object({}).partial().passthrough();
|
|
5043
|
+
var PromptBlockData = z5.union([
|
|
5044
|
+
z5.object({ type: z5.literal("completion"), content: z5.string() }),
|
|
5045
|
+
z5.object({
|
|
5046
|
+
type: z5.literal("chat"),
|
|
5047
|
+
messages: z5.array(ChatCompletionMessageParam),
|
|
5048
|
+
tools: z5.string().optional()
|
|
4083
5049
|
})
|
|
4084
5050
|
]);
|
|
4085
|
-
var GraphNode =
|
|
4086
|
-
|
|
4087
|
-
description:
|
|
4088
|
-
position:
|
|
4089
|
-
type:
|
|
5051
|
+
var GraphNode = z5.union([
|
|
5052
|
+
z5.object({
|
|
5053
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5054
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
5055
|
+
type: z5.literal("function"),
|
|
4090
5056
|
function: FunctionIdRef
|
|
4091
5057
|
}),
|
|
4092
|
-
|
|
4093
|
-
description:
|
|
4094
|
-
position:
|
|
4095
|
-
type:
|
|
5058
|
+
z5.object({
|
|
5059
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5060
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
5061
|
+
type: z5.literal("input")
|
|
4096
5062
|
}),
|
|
4097
|
-
|
|
4098
|
-
description:
|
|
4099
|
-
position:
|
|
4100
|
-
type:
|
|
5063
|
+
z5.object({
|
|
5064
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5065
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
5066
|
+
type: z5.literal("output")
|
|
4101
5067
|
}),
|
|
4102
|
-
|
|
4103
|
-
description:
|
|
4104
|
-
position:
|
|
4105
|
-
type:
|
|
4106
|
-
value:
|
|
5068
|
+
z5.object({
|
|
5069
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5070
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
5071
|
+
type: z5.literal("literal"),
|
|
5072
|
+
value: z5.unknown().optional()
|
|
4107
5073
|
}),
|
|
4108
|
-
|
|
4109
|
-
description:
|
|
4110
|
-
position:
|
|
4111
|
-
type:
|
|
4112
|
-
expr:
|
|
5074
|
+
z5.object({
|
|
5075
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5076
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
5077
|
+
type: z5.literal("btql"),
|
|
5078
|
+
expr: z5.string()
|
|
4113
5079
|
}),
|
|
4114
|
-
|
|
4115
|
-
description:
|
|
4116
|
-
position:
|
|
4117
|
-
type:
|
|
4118
|
-
condition:
|
|
5080
|
+
z5.object({
|
|
5081
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5082
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
5083
|
+
type: z5.literal("gate"),
|
|
5084
|
+
condition: z5.union([z5.string(), z5.null()]).optional()
|
|
4119
5085
|
}),
|
|
4120
|
-
|
|
4121
|
-
description:
|
|
4122
|
-
position:
|
|
4123
|
-
type:
|
|
5086
|
+
z5.object({
|
|
5087
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5088
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
5089
|
+
type: z5.literal("aggregator")
|
|
4124
5090
|
}),
|
|
4125
|
-
|
|
4126
|
-
description:
|
|
4127
|
-
position:
|
|
4128
|
-
type:
|
|
5091
|
+
z5.object({
|
|
5092
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5093
|
+
position: z5.union([z5.object({ x: z5.number(), y: z5.number() }), z5.null()]).optional(),
|
|
5094
|
+
type: z5.literal("prompt_template"),
|
|
4129
5095
|
prompt: PromptBlockData
|
|
4130
5096
|
})
|
|
4131
5097
|
]);
|
|
4132
|
-
var GraphEdge =
|
|
4133
|
-
source:
|
|
4134
|
-
target:
|
|
4135
|
-
purpose:
|
|
4136
|
-
});
|
|
4137
|
-
var GraphData =
|
|
4138
|
-
type:
|
|
4139
|
-
nodes:
|
|
4140
|
-
edges:
|
|
4141
|
-
});
|
|
4142
|
-
var FunctionData =
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
type:
|
|
4146
|
-
data:
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
type:
|
|
4150
|
-
runtime_context:
|
|
4151
|
-
runtime:
|
|
4152
|
-
version:
|
|
5098
|
+
var GraphEdge = z5.object({
|
|
5099
|
+
source: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
|
|
5100
|
+
target: z5.object({ node: z5.string().max(1024), variable: z5.string() }),
|
|
5101
|
+
purpose: z5.enum(["control", "data", "messages"])
|
|
5102
|
+
});
|
|
5103
|
+
var GraphData = z5.object({
|
|
5104
|
+
type: z5.literal("graph"),
|
|
5105
|
+
nodes: z5.record(GraphNode),
|
|
5106
|
+
edges: z5.record(GraphEdge)
|
|
5107
|
+
});
|
|
5108
|
+
var FunctionData = z5.union([
|
|
5109
|
+
z5.object({ type: z5.literal("prompt") }),
|
|
5110
|
+
z5.object({
|
|
5111
|
+
type: z5.literal("code"),
|
|
5112
|
+
data: z5.union([
|
|
5113
|
+
z5.object({ type: z5.literal("bundle") }).and(CodeBundle),
|
|
5114
|
+
z5.object({
|
|
5115
|
+
type: z5.literal("inline"),
|
|
5116
|
+
runtime_context: z5.object({
|
|
5117
|
+
runtime: z5.enum(["node", "python"]),
|
|
5118
|
+
version: z5.string()
|
|
4153
5119
|
}),
|
|
4154
|
-
code:
|
|
5120
|
+
code: z5.string()
|
|
4155
5121
|
})
|
|
4156
5122
|
])
|
|
4157
5123
|
}),
|
|
4158
5124
|
GraphData,
|
|
4159
|
-
|
|
4160
|
-
type:
|
|
4161
|
-
endpoint:
|
|
4162
|
-
eval_name:
|
|
4163
|
-
parameters:
|
|
5125
|
+
z5.object({
|
|
5126
|
+
type: z5.literal("remote_eval"),
|
|
5127
|
+
endpoint: z5.string(),
|
|
5128
|
+
eval_name: z5.string(),
|
|
5129
|
+
parameters: z5.object({}).partial().passthrough()
|
|
4164
5130
|
}),
|
|
4165
|
-
|
|
5131
|
+
z5.object({ type: z5.literal("global"), name: z5.string() })
|
|
4166
5132
|
]);
|
|
4167
|
-
var Function2 =
|
|
4168
|
-
id:
|
|
4169
|
-
_xact_id:
|
|
4170
|
-
project_id:
|
|
4171
|
-
log_id:
|
|
4172
|
-
org_id:
|
|
4173
|
-
name:
|
|
4174
|
-
slug:
|
|
4175
|
-
description:
|
|
4176
|
-
created:
|
|
5133
|
+
var Function2 = z5.object({
|
|
5134
|
+
id: z5.string().uuid(),
|
|
5135
|
+
_xact_id: z5.string(),
|
|
5136
|
+
project_id: z5.string().uuid(),
|
|
5137
|
+
log_id: z5.literal("p"),
|
|
5138
|
+
org_id: z5.string().uuid(),
|
|
5139
|
+
name: z5.string(),
|
|
5140
|
+
slug: z5.string(),
|
|
5141
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5142
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
4177
5143
|
prompt_data: PromptDataNullish.optional(),
|
|
4178
|
-
tags:
|
|
4179
|
-
metadata:
|
|
5144
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
5145
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
|
|
4180
5146
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
4181
5147
|
function_data: FunctionData,
|
|
4182
|
-
origin:
|
|
4183
|
-
|
|
4184
|
-
object_type: AclObjectType.and(
|
|
4185
|
-
object_id:
|
|
4186
|
-
internal:
|
|
5148
|
+
origin: z5.union([
|
|
5149
|
+
z5.object({
|
|
5150
|
+
object_type: AclObjectType.and(z5.string()),
|
|
5151
|
+
object_id: z5.string().uuid(),
|
|
5152
|
+
internal: z5.union([z5.boolean(), z5.null()]).optional()
|
|
4187
5153
|
}),
|
|
4188
|
-
|
|
5154
|
+
z5.null()
|
|
4189
5155
|
]).optional(),
|
|
4190
|
-
function_schema:
|
|
4191
|
-
|
|
4192
|
-
|
|
5156
|
+
function_schema: z5.union([
|
|
5157
|
+
z5.object({ parameters: z5.unknown(), returns: z5.unknown() }).partial(),
|
|
5158
|
+
z5.null()
|
|
4193
5159
|
]).optional()
|
|
4194
5160
|
});
|
|
4195
|
-
var FunctionFormat =
|
|
4196
|
-
var PromptData =
|
|
5161
|
+
var FunctionFormat = z5.enum(["llm", "code", "global", "graph"]);
|
|
5162
|
+
var PromptData = z5.object({
|
|
4197
5163
|
prompt: PromptBlockDataNullish,
|
|
4198
5164
|
options: PromptOptionsNullish,
|
|
4199
5165
|
parser: PromptParserNullish,
|
|
4200
|
-
tool_functions:
|
|
4201
|
-
origin:
|
|
4202
|
-
|
|
4203
|
-
prompt_id:
|
|
4204
|
-
project_id:
|
|
4205
|
-
prompt_version:
|
|
5166
|
+
tool_functions: z5.union([z5.array(SavedFunctionId), z5.null()]),
|
|
5167
|
+
origin: z5.union([
|
|
5168
|
+
z5.object({
|
|
5169
|
+
prompt_id: z5.string(),
|
|
5170
|
+
project_id: z5.string(),
|
|
5171
|
+
prompt_version: z5.string()
|
|
4206
5172
|
}).partial(),
|
|
4207
|
-
|
|
5173
|
+
z5.null()
|
|
4208
5174
|
])
|
|
4209
5175
|
}).partial();
|
|
4210
|
-
var FunctionTypeEnum =
|
|
4211
|
-
var FunctionId =
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
project_name:
|
|
4215
|
-
slug:
|
|
4216
|
-
version:
|
|
5176
|
+
var FunctionTypeEnum = z5.enum(["llm", "scorer", "task", "tool"]);
|
|
5177
|
+
var FunctionId = z5.union([
|
|
5178
|
+
z5.object({ function_id: z5.string(), version: z5.string().optional() }),
|
|
5179
|
+
z5.object({
|
|
5180
|
+
project_name: z5.string(),
|
|
5181
|
+
slug: z5.string(),
|
|
5182
|
+
version: z5.string().optional()
|
|
4217
5183
|
}),
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
prompt_session_id:
|
|
4221
|
-
prompt_session_function_id:
|
|
4222
|
-
version:
|
|
5184
|
+
z5.object({ global_function: z5.string() }),
|
|
5185
|
+
z5.object({
|
|
5186
|
+
prompt_session_id: z5.string(),
|
|
5187
|
+
prompt_session_function_id: z5.string(),
|
|
5188
|
+
version: z5.string().optional()
|
|
4223
5189
|
}),
|
|
4224
|
-
|
|
4225
|
-
inline_context:
|
|
4226
|
-
runtime:
|
|
4227
|
-
version:
|
|
5190
|
+
z5.object({
|
|
5191
|
+
inline_context: z5.object({
|
|
5192
|
+
runtime: z5.enum(["node", "python"]),
|
|
5193
|
+
version: z5.string()
|
|
4228
5194
|
}),
|
|
4229
|
-
code:
|
|
4230
|
-
name:
|
|
5195
|
+
code: z5.string(),
|
|
5196
|
+
name: z5.union([z5.string(), z5.null()]).optional()
|
|
4231
5197
|
}),
|
|
4232
|
-
|
|
5198
|
+
z5.object({
|
|
4233
5199
|
inline_prompt: PromptData.optional(),
|
|
4234
|
-
inline_function:
|
|
5200
|
+
inline_function: z5.object({}).partial().passthrough(),
|
|
4235
5201
|
function_type: FunctionTypeEnum.optional(),
|
|
4236
|
-
name:
|
|
5202
|
+
name: z5.union([z5.string(), z5.null()]).optional()
|
|
4237
5203
|
}),
|
|
4238
|
-
|
|
5204
|
+
z5.object({
|
|
4239
5205
|
inline_prompt: PromptData,
|
|
4240
5206
|
function_type: FunctionTypeEnum.optional(),
|
|
4241
|
-
name:
|
|
5207
|
+
name: z5.union([z5.string(), z5.null()]).optional()
|
|
4242
5208
|
})
|
|
4243
5209
|
]);
|
|
4244
|
-
var FunctionObjectType =
|
|
5210
|
+
var FunctionObjectType = z5.enum([
|
|
4245
5211
|
"prompt",
|
|
4246
5212
|
"tool",
|
|
4247
5213
|
"scorer",
|
|
4248
5214
|
"task",
|
|
4249
5215
|
"agent"
|
|
4250
5216
|
]);
|
|
4251
|
-
var FunctionOutputType =
|
|
4252
|
-
var GitMetadataSettings =
|
|
4253
|
-
collect:
|
|
4254
|
-
fields:
|
|
4255
|
-
|
|
5217
|
+
var FunctionOutputType = z5.enum(["completion", "score", "any"]);
|
|
5218
|
+
var GitMetadataSettings = z5.object({
|
|
5219
|
+
collect: z5.enum(["all", "none", "some"]),
|
|
5220
|
+
fields: z5.array(
|
|
5221
|
+
z5.enum([
|
|
4256
5222
|
"commit",
|
|
4257
5223
|
"branch",
|
|
4258
5224
|
"tag",
|
|
@@ -4265,49 +5231,49 @@ var GitMetadataSettings = z.object({
|
|
|
4265
5231
|
])
|
|
4266
5232
|
).optional()
|
|
4267
5233
|
});
|
|
4268
|
-
var Group =
|
|
4269
|
-
id:
|
|
4270
|
-
org_id:
|
|
4271
|
-
user_id:
|
|
4272
|
-
created:
|
|
4273
|
-
name:
|
|
4274
|
-
description:
|
|
4275
|
-
deleted_at:
|
|
4276
|
-
member_users:
|
|
4277
|
-
member_groups:
|
|
4278
|
-
});
|
|
4279
|
-
var IfExists =
|
|
4280
|
-
var InvokeParent =
|
|
4281
|
-
|
|
4282
|
-
object_type:
|
|
4283
|
-
object_id:
|
|
4284
|
-
row_ids:
|
|
4285
|
-
|
|
4286
|
-
id:
|
|
4287
|
-
span_id:
|
|
4288
|
-
root_span_id:
|
|
5234
|
+
var Group = z5.object({
|
|
5235
|
+
id: z5.string().uuid(),
|
|
5236
|
+
org_id: z5.string().uuid(),
|
|
5237
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
5238
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
5239
|
+
name: z5.string(),
|
|
5240
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5241
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
5242
|
+
member_users: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional(),
|
|
5243
|
+
member_groups: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
|
|
5244
|
+
});
|
|
5245
|
+
var IfExists = z5.enum(["error", "ignore", "replace"]);
|
|
5246
|
+
var InvokeParent = z5.union([
|
|
5247
|
+
z5.object({
|
|
5248
|
+
object_type: z5.enum(["project_logs", "experiment", "playground_logs"]),
|
|
5249
|
+
object_id: z5.string(),
|
|
5250
|
+
row_ids: z5.union([
|
|
5251
|
+
z5.object({
|
|
5252
|
+
id: z5.string(),
|
|
5253
|
+
span_id: z5.string(),
|
|
5254
|
+
root_span_id: z5.string()
|
|
4289
5255
|
}),
|
|
4290
|
-
|
|
5256
|
+
z5.null()
|
|
4291
5257
|
]).optional(),
|
|
4292
|
-
propagated_event:
|
|
5258
|
+
propagated_event: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
|
|
4293
5259
|
}),
|
|
4294
|
-
|
|
5260
|
+
z5.string()
|
|
4295
5261
|
]);
|
|
4296
|
-
var StreamingMode =
|
|
5262
|
+
var StreamingMode = z5.union([z5.enum(["auto", "parallel"]), z5.null()]);
|
|
4297
5263
|
var InvokeFunction = FunctionId.and(
|
|
4298
|
-
|
|
4299
|
-
input:
|
|
4300
|
-
expected:
|
|
4301
|
-
metadata:
|
|
4302
|
-
tags:
|
|
4303
|
-
messages:
|
|
5264
|
+
z5.object({
|
|
5265
|
+
input: z5.unknown(),
|
|
5266
|
+
expected: z5.unknown(),
|
|
5267
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]),
|
|
5268
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]),
|
|
5269
|
+
messages: z5.array(ChatCompletionMessageParam),
|
|
4304
5270
|
parent: InvokeParent,
|
|
4305
|
-
stream:
|
|
5271
|
+
stream: z5.union([z5.boolean(), z5.null()]),
|
|
4306
5272
|
mode: StreamingMode,
|
|
4307
|
-
strict:
|
|
5273
|
+
strict: z5.union([z5.boolean(), z5.null()])
|
|
4308
5274
|
}).partial()
|
|
4309
5275
|
);
|
|
4310
|
-
var MessageRole =
|
|
5276
|
+
var MessageRole = z5.enum([
|
|
4311
5277
|
"system",
|
|
4312
5278
|
"user",
|
|
4313
5279
|
"assistant",
|
|
@@ -4316,8 +5282,8 @@ var MessageRole = z.enum([
|
|
|
4316
5282
|
"model",
|
|
4317
5283
|
"developer"
|
|
4318
5284
|
]);
|
|
4319
|
-
var ObjectReference =
|
|
4320
|
-
object_type:
|
|
5285
|
+
var ObjectReference = z5.object({
|
|
5286
|
+
object_type: z5.enum([
|
|
4321
5287
|
"project_logs",
|
|
4322
5288
|
"experiment",
|
|
4323
5289
|
"dataset",
|
|
@@ -4325,146 +5291,146 @@ var ObjectReference = z.object({
|
|
|
4325
5291
|
"function",
|
|
4326
5292
|
"prompt_session"
|
|
4327
5293
|
]),
|
|
4328
|
-
object_id:
|
|
4329
|
-
id:
|
|
4330
|
-
_xact_id:
|
|
4331
|
-
created:
|
|
4332
|
-
});
|
|
4333
|
-
var OnlineScoreConfig =
|
|
4334
|
-
|
|
4335
|
-
sampling_rate:
|
|
4336
|
-
scorers:
|
|
4337
|
-
btql_filter:
|
|
4338
|
-
apply_to_root_span:
|
|
4339
|
-
apply_to_span_names:
|
|
4340
|
-
skip_logging:
|
|
5294
|
+
object_id: z5.string().uuid(),
|
|
5295
|
+
id: z5.string(),
|
|
5296
|
+
_xact_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
5297
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
5298
|
+
});
|
|
5299
|
+
var OnlineScoreConfig = z5.union([
|
|
5300
|
+
z5.object({
|
|
5301
|
+
sampling_rate: z5.number().gte(0).lte(1),
|
|
5302
|
+
scorers: z5.array(SavedFunctionId),
|
|
5303
|
+
btql_filter: z5.union([z5.string(), z5.null()]).optional(),
|
|
5304
|
+
apply_to_root_span: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
5305
|
+
apply_to_span_names: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
5306
|
+
skip_logging: z5.union([z5.boolean(), z5.null()]).optional()
|
|
4341
5307
|
}),
|
|
4342
|
-
|
|
5308
|
+
z5.null()
|
|
4343
5309
|
]);
|
|
4344
|
-
var Organization =
|
|
4345
|
-
id:
|
|
4346
|
-
name:
|
|
4347
|
-
api_url:
|
|
4348
|
-
is_universal_api:
|
|
4349
|
-
proxy_url:
|
|
4350
|
-
realtime_url:
|
|
4351
|
-
created:
|
|
4352
|
-
});
|
|
4353
|
-
var ProjectSettings =
|
|
4354
|
-
|
|
4355
|
-
comparison_key:
|
|
4356
|
-
baseline_experiment_id:
|
|
4357
|
-
spanFieldOrder:
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
object_type:
|
|
4361
|
-
column_id:
|
|
4362
|
-
position:
|
|
4363
|
-
layout:
|
|
5310
|
+
var Organization = z5.object({
|
|
5311
|
+
id: z5.string().uuid(),
|
|
5312
|
+
name: z5.string(),
|
|
5313
|
+
api_url: z5.union([z5.string(), z5.null()]).optional(),
|
|
5314
|
+
is_universal_api: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
5315
|
+
proxy_url: z5.union([z5.string(), z5.null()]).optional(),
|
|
5316
|
+
realtime_url: z5.union([z5.string(), z5.null()]).optional(),
|
|
5317
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
5318
|
+
});
|
|
5319
|
+
var ProjectSettings = z5.union([
|
|
5320
|
+
z5.object({
|
|
5321
|
+
comparison_key: z5.union([z5.string(), z5.null()]),
|
|
5322
|
+
baseline_experiment_id: z5.union([z5.string(), z5.null()]),
|
|
5323
|
+
spanFieldOrder: z5.union([
|
|
5324
|
+
z5.array(
|
|
5325
|
+
z5.object({
|
|
5326
|
+
object_type: z5.string(),
|
|
5327
|
+
column_id: z5.string(),
|
|
5328
|
+
position: z5.string(),
|
|
5329
|
+
layout: z5.union([z5.literal("full"), z5.literal("two_column"), z5.null()]).optional()
|
|
4364
5330
|
})
|
|
4365
5331
|
),
|
|
4366
|
-
|
|
5332
|
+
z5.null()
|
|
4367
5333
|
]),
|
|
4368
|
-
remote_eval_sources:
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
url:
|
|
4372
|
-
name:
|
|
4373
|
-
description:
|
|
5334
|
+
remote_eval_sources: z5.union([
|
|
5335
|
+
z5.array(
|
|
5336
|
+
z5.object({
|
|
5337
|
+
url: z5.string(),
|
|
5338
|
+
name: z5.string(),
|
|
5339
|
+
description: z5.union([z5.string(), z5.null()]).optional()
|
|
4374
5340
|
})
|
|
4375
5341
|
),
|
|
4376
|
-
|
|
5342
|
+
z5.null()
|
|
4377
5343
|
])
|
|
4378
5344
|
}).partial(),
|
|
4379
|
-
|
|
5345
|
+
z5.null()
|
|
4380
5346
|
]);
|
|
4381
|
-
var Project =
|
|
4382
|
-
id:
|
|
4383
|
-
org_id:
|
|
4384
|
-
name:
|
|
4385
|
-
created:
|
|
4386
|
-
deleted_at:
|
|
4387
|
-
user_id:
|
|
5347
|
+
var Project = z5.object({
|
|
5348
|
+
id: z5.string().uuid(),
|
|
5349
|
+
org_id: z5.string().uuid(),
|
|
5350
|
+
name: z5.string(),
|
|
5351
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
5352
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
5353
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4388
5354
|
settings: ProjectSettings.optional()
|
|
4389
5355
|
});
|
|
4390
|
-
var RetentionObjectType =
|
|
5356
|
+
var RetentionObjectType = z5.enum([
|
|
4391
5357
|
"project_logs",
|
|
4392
5358
|
"experiment",
|
|
4393
5359
|
"dataset"
|
|
4394
5360
|
]);
|
|
4395
|
-
var ProjectAutomation =
|
|
4396
|
-
id:
|
|
4397
|
-
project_id:
|
|
4398
|
-
user_id:
|
|
4399
|
-
created:
|
|
4400
|
-
name:
|
|
4401
|
-
description:
|
|
4402
|
-
config:
|
|
4403
|
-
|
|
4404
|
-
event_type:
|
|
4405
|
-
btql_filter:
|
|
4406
|
-
interval_seconds:
|
|
4407
|
-
action:
|
|
5361
|
+
var ProjectAutomation = z5.object({
|
|
5362
|
+
id: z5.string().uuid(),
|
|
5363
|
+
project_id: z5.string().uuid(),
|
|
5364
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
5365
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
5366
|
+
name: z5.string(),
|
|
5367
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5368
|
+
config: z5.union([
|
|
5369
|
+
z5.object({
|
|
5370
|
+
event_type: z5.literal("logs"),
|
|
5371
|
+
btql_filter: z5.string(),
|
|
5372
|
+
interval_seconds: z5.number().gte(1).lte(2592e3),
|
|
5373
|
+
action: z5.object({ type: z5.literal("webhook"), url: z5.string() })
|
|
4408
5374
|
}),
|
|
4409
|
-
|
|
4410
|
-
event_type:
|
|
4411
|
-
export_definition:
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
5375
|
+
z5.object({
|
|
5376
|
+
event_type: z5.literal("btql_export"),
|
|
5377
|
+
export_definition: z5.union([
|
|
5378
|
+
z5.object({ type: z5.literal("log_traces") }),
|
|
5379
|
+
z5.object({ type: z5.literal("log_spans") }),
|
|
5380
|
+
z5.object({ type: z5.literal("btql_query"), btql_query: z5.string() })
|
|
4415
5381
|
]),
|
|
4416
|
-
export_path:
|
|
4417
|
-
format:
|
|
4418
|
-
interval_seconds:
|
|
4419
|
-
credentials:
|
|
4420
|
-
type:
|
|
4421
|
-
role_arn:
|
|
4422
|
-
external_id:
|
|
5382
|
+
export_path: z5.string(),
|
|
5383
|
+
format: z5.enum(["jsonl", "parquet"]),
|
|
5384
|
+
interval_seconds: z5.number().gte(1).lte(2592e3),
|
|
5385
|
+
credentials: z5.object({
|
|
5386
|
+
type: z5.literal("aws_iam"),
|
|
5387
|
+
role_arn: z5.string(),
|
|
5388
|
+
external_id: z5.string()
|
|
4423
5389
|
}),
|
|
4424
|
-
batch_size:
|
|
5390
|
+
batch_size: z5.union([z5.number(), z5.null()]).optional()
|
|
4425
5391
|
}),
|
|
4426
|
-
|
|
4427
|
-
event_type:
|
|
5392
|
+
z5.object({
|
|
5393
|
+
event_type: z5.literal("retention"),
|
|
4428
5394
|
object_type: RetentionObjectType,
|
|
4429
|
-
retention_days:
|
|
5395
|
+
retention_days: z5.number().gte(0)
|
|
4430
5396
|
})
|
|
4431
5397
|
])
|
|
4432
5398
|
});
|
|
4433
|
-
var ProjectLogsEvent =
|
|
4434
|
-
id:
|
|
4435
|
-
_xact_id:
|
|
4436
|
-
_pagination_key:
|
|
4437
|
-
created:
|
|
4438
|
-
org_id:
|
|
4439
|
-
project_id:
|
|
4440
|
-
log_id:
|
|
4441
|
-
input:
|
|
4442
|
-
output:
|
|
4443
|
-
expected:
|
|
4444
|
-
error:
|
|
4445
|
-
scores:
|
|
4446
|
-
metadata:
|
|
4447
|
-
|
|
4448
|
-
|
|
5399
|
+
var ProjectLogsEvent = z5.object({
|
|
5400
|
+
id: z5.string(),
|
|
5401
|
+
_xact_id: z5.string(),
|
|
5402
|
+
_pagination_key: z5.union([z5.string(), z5.null()]).optional(),
|
|
5403
|
+
created: z5.string().datetime({ offset: true }),
|
|
5404
|
+
org_id: z5.string().uuid(),
|
|
5405
|
+
project_id: z5.string().uuid(),
|
|
5406
|
+
log_id: z5.literal("g"),
|
|
5407
|
+
input: z5.unknown().optional(),
|
|
5408
|
+
output: z5.unknown().optional(),
|
|
5409
|
+
expected: z5.unknown().optional(),
|
|
5410
|
+
error: z5.unknown().optional(),
|
|
5411
|
+
scores: z5.union([z5.record(z5.union([z5.number(), z5.null()])), z5.null()]).optional(),
|
|
5412
|
+
metadata: z5.union([
|
|
5413
|
+
z5.object({ model: z5.union([z5.string(), z5.null()]) }).partial().passthrough(),
|
|
5414
|
+
z5.null()
|
|
4449
5415
|
]).optional(),
|
|
4450
|
-
tags:
|
|
4451
|
-
metrics:
|
|
4452
|
-
context:
|
|
4453
|
-
|
|
4454
|
-
caller_functionname:
|
|
4455
|
-
caller_filename:
|
|
4456
|
-
caller_lineno:
|
|
5416
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
5417
|
+
metrics: z5.union([z5.record(z5.number()), z5.null()]).optional(),
|
|
5418
|
+
context: z5.union([
|
|
5419
|
+
z5.object({
|
|
5420
|
+
caller_functionname: z5.union([z5.string(), z5.null()]),
|
|
5421
|
+
caller_filename: z5.union([z5.string(), z5.null()]),
|
|
5422
|
+
caller_lineno: z5.union([z5.number(), z5.null()])
|
|
4457
5423
|
}).partial().passthrough(),
|
|
4458
|
-
|
|
5424
|
+
z5.null()
|
|
4459
5425
|
]).optional(),
|
|
4460
|
-
span_id:
|
|
4461
|
-
span_parents:
|
|
4462
|
-
root_span_id:
|
|
4463
|
-
is_root:
|
|
5426
|
+
span_id: z5.string(),
|
|
5427
|
+
span_parents: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
5428
|
+
root_span_id: z5.string(),
|
|
5429
|
+
is_root: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
4464
5430
|
span_attributes: SpanAttributes.optional(),
|
|
4465
5431
|
origin: ObjectReferenceNullish.optional()
|
|
4466
5432
|
});
|
|
4467
|
-
var ProjectScoreType =
|
|
5433
|
+
var ProjectScoreType = z5.enum([
|
|
4468
5434
|
"slider",
|
|
4469
5435
|
"categorical",
|
|
4470
5436
|
"weighted",
|
|
@@ -4473,172 +5439,172 @@ var ProjectScoreType = z.enum([
|
|
|
4473
5439
|
"online",
|
|
4474
5440
|
"free-form"
|
|
4475
5441
|
]);
|
|
4476
|
-
var ProjectScoreCategory =
|
|
4477
|
-
name:
|
|
4478
|
-
value:
|
|
4479
|
-
});
|
|
4480
|
-
var ProjectScoreCategories =
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
5442
|
+
var ProjectScoreCategory = z5.object({
|
|
5443
|
+
name: z5.string(),
|
|
5444
|
+
value: z5.number()
|
|
5445
|
+
});
|
|
5446
|
+
var ProjectScoreCategories = z5.union([
|
|
5447
|
+
z5.array(ProjectScoreCategory),
|
|
5448
|
+
z5.record(z5.number()),
|
|
5449
|
+
z5.array(z5.string()),
|
|
5450
|
+
z5.null()
|
|
4485
5451
|
]);
|
|
4486
|
-
var ProjectScoreConfig =
|
|
4487
|
-
|
|
4488
|
-
multi_select:
|
|
4489
|
-
destination:
|
|
5452
|
+
var ProjectScoreConfig = z5.union([
|
|
5453
|
+
z5.object({
|
|
5454
|
+
multi_select: z5.union([z5.boolean(), z5.null()]),
|
|
5455
|
+
destination: z5.union([z5.string(), z5.null()]),
|
|
4490
5456
|
online: OnlineScoreConfig
|
|
4491
5457
|
}).partial(),
|
|
4492
|
-
|
|
5458
|
+
z5.null()
|
|
4493
5459
|
]);
|
|
4494
|
-
var ProjectScore =
|
|
4495
|
-
id:
|
|
4496
|
-
project_id:
|
|
4497
|
-
user_id:
|
|
4498
|
-
created:
|
|
4499
|
-
name:
|
|
4500
|
-
description:
|
|
5460
|
+
var ProjectScore = z5.object({
|
|
5461
|
+
id: z5.string().uuid(),
|
|
5462
|
+
project_id: z5.string().uuid(),
|
|
5463
|
+
user_id: z5.string().uuid(),
|
|
5464
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
5465
|
+
name: z5.string(),
|
|
5466
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
4501
5467
|
score_type: ProjectScoreType,
|
|
4502
5468
|
categories: ProjectScoreCategories.optional(),
|
|
4503
5469
|
config: ProjectScoreConfig.optional(),
|
|
4504
|
-
position:
|
|
4505
|
-
});
|
|
4506
|
-
var ProjectTag =
|
|
4507
|
-
id:
|
|
4508
|
-
project_id:
|
|
4509
|
-
user_id:
|
|
4510
|
-
created:
|
|
4511
|
-
name:
|
|
4512
|
-
description:
|
|
4513
|
-
color:
|
|
4514
|
-
position:
|
|
4515
|
-
});
|
|
4516
|
-
var Prompt =
|
|
4517
|
-
id:
|
|
4518
|
-
_xact_id:
|
|
4519
|
-
project_id:
|
|
4520
|
-
log_id:
|
|
4521
|
-
org_id:
|
|
4522
|
-
name:
|
|
4523
|
-
slug:
|
|
4524
|
-
description:
|
|
4525
|
-
created:
|
|
5470
|
+
position: z5.union([z5.string(), z5.null()]).optional()
|
|
5471
|
+
});
|
|
5472
|
+
var ProjectTag = z5.object({
|
|
5473
|
+
id: z5.string().uuid(),
|
|
5474
|
+
project_id: z5.string().uuid(),
|
|
5475
|
+
user_id: z5.string().uuid(),
|
|
5476
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
5477
|
+
name: z5.string(),
|
|
5478
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5479
|
+
color: z5.union([z5.string(), z5.null()]).optional(),
|
|
5480
|
+
position: z5.union([z5.string(), z5.null()]).optional()
|
|
5481
|
+
});
|
|
5482
|
+
var Prompt = z5.object({
|
|
5483
|
+
id: z5.string().uuid(),
|
|
5484
|
+
_xact_id: z5.string(),
|
|
5485
|
+
project_id: z5.string().uuid(),
|
|
5486
|
+
log_id: z5.literal("p"),
|
|
5487
|
+
org_id: z5.string().uuid(),
|
|
5488
|
+
name: z5.string(),
|
|
5489
|
+
slug: z5.string(),
|
|
5490
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5491
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
4526
5492
|
prompt_data: PromptDataNullish.optional(),
|
|
4527
|
-
tags:
|
|
4528
|
-
metadata:
|
|
5493
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional(),
|
|
5494
|
+
metadata: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional(),
|
|
4529
5495
|
function_type: FunctionTypeEnumNullish.optional()
|
|
4530
5496
|
});
|
|
4531
|
-
var PromptOptions =
|
|
4532
|
-
var PromptSessionEvent =
|
|
4533
|
-
id:
|
|
4534
|
-
_xact_id:
|
|
4535
|
-
created:
|
|
4536
|
-
_pagination_key:
|
|
4537
|
-
project_id:
|
|
4538
|
-
prompt_session_id:
|
|
4539
|
-
prompt_session_data:
|
|
4540
|
-
prompt_data:
|
|
4541
|
-
function_data:
|
|
5497
|
+
var PromptOptions = z5.object({ model: z5.string(), params: ModelParams, position: z5.string() }).partial();
|
|
5498
|
+
var PromptSessionEvent = z5.object({
|
|
5499
|
+
id: z5.string(),
|
|
5500
|
+
_xact_id: z5.string(),
|
|
5501
|
+
created: z5.string().datetime({ offset: true }),
|
|
5502
|
+
_pagination_key: z5.union([z5.string(), z5.null()]).optional(),
|
|
5503
|
+
project_id: z5.string().uuid(),
|
|
5504
|
+
prompt_session_id: z5.string().uuid(),
|
|
5505
|
+
prompt_session_data: z5.unknown().optional(),
|
|
5506
|
+
prompt_data: z5.unknown().optional(),
|
|
5507
|
+
function_data: z5.unknown().optional(),
|
|
4542
5508
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
4543
|
-
object_data:
|
|
4544
|
-
completion:
|
|
4545
|
-
tags:
|
|
4546
|
-
});
|
|
4547
|
-
var ResponseFormat =
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
type:
|
|
5509
|
+
object_data: z5.unknown().optional(),
|
|
5510
|
+
completion: z5.unknown().optional(),
|
|
5511
|
+
tags: z5.union([z5.array(z5.string()), z5.null()]).optional()
|
|
5512
|
+
});
|
|
5513
|
+
var ResponseFormat = z5.union([
|
|
5514
|
+
z5.object({ type: z5.literal("json_object") }),
|
|
5515
|
+
z5.object({
|
|
5516
|
+
type: z5.literal("json_schema"),
|
|
4551
5517
|
json_schema: ResponseFormatJsonSchema
|
|
4552
5518
|
}),
|
|
4553
|
-
|
|
5519
|
+
z5.object({ type: z5.literal("text") })
|
|
4554
5520
|
]);
|
|
4555
|
-
var Role =
|
|
4556
|
-
id:
|
|
4557
|
-
org_id:
|
|
4558
|
-
user_id:
|
|
4559
|
-
created:
|
|
4560
|
-
name:
|
|
4561
|
-
description:
|
|
4562
|
-
deleted_at:
|
|
4563
|
-
member_permissions:
|
|
4564
|
-
|
|
4565
|
-
|
|
5521
|
+
var Role = z5.object({
|
|
5522
|
+
id: z5.string().uuid(),
|
|
5523
|
+
org_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
5524
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
5525
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
5526
|
+
name: z5.string(),
|
|
5527
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5528
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
5529
|
+
member_permissions: z5.union([
|
|
5530
|
+
z5.array(
|
|
5531
|
+
z5.object({
|
|
4566
5532
|
permission: Permission,
|
|
4567
5533
|
restrict_object_type: AclObjectType.optional()
|
|
4568
5534
|
})
|
|
4569
5535
|
),
|
|
4570
|
-
|
|
5536
|
+
z5.null()
|
|
4571
5537
|
]).optional(),
|
|
4572
|
-
member_roles:
|
|
4573
|
-
});
|
|
4574
|
-
var RunEval =
|
|
4575
|
-
project_id:
|
|
4576
|
-
data:
|
|
4577
|
-
|
|
4578
|
-
dataset_id:
|
|
4579
|
-
_internal_btql:
|
|
5538
|
+
member_roles: z5.union([z5.array(z5.string().uuid()), z5.null()]).optional()
|
|
5539
|
+
});
|
|
5540
|
+
var RunEval = z5.object({
|
|
5541
|
+
project_id: z5.string(),
|
|
5542
|
+
data: z5.union([
|
|
5543
|
+
z5.object({
|
|
5544
|
+
dataset_id: z5.string(),
|
|
5545
|
+
_internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
|
|
4580
5546
|
}),
|
|
4581
|
-
|
|
4582
|
-
project_name:
|
|
4583
|
-
dataset_name:
|
|
4584
|
-
_internal_btql:
|
|
5547
|
+
z5.object({
|
|
5548
|
+
project_name: z5.string(),
|
|
5549
|
+
dataset_name: z5.string(),
|
|
5550
|
+
_internal_btql: z5.union([z5.object({}).partial().passthrough(), z5.null()]).optional()
|
|
4585
5551
|
}),
|
|
4586
|
-
|
|
5552
|
+
z5.object({ data: z5.array(z5.unknown()) })
|
|
4587
5553
|
]),
|
|
4588
|
-
task: FunctionId.and(
|
|
4589
|
-
scores:
|
|
4590
|
-
experiment_name:
|
|
4591
|
-
metadata:
|
|
4592
|
-
parent: InvokeParent.and(
|
|
4593
|
-
stream:
|
|
4594
|
-
trial_count:
|
|
4595
|
-
is_public:
|
|
4596
|
-
timeout:
|
|
4597
|
-
max_concurrency:
|
|
4598
|
-
base_experiment_name:
|
|
4599
|
-
base_experiment_id:
|
|
5554
|
+
task: FunctionId.and(z5.unknown()),
|
|
5555
|
+
scores: z5.array(FunctionId),
|
|
5556
|
+
experiment_name: z5.string().optional(),
|
|
5557
|
+
metadata: z5.object({}).partial().passthrough().optional(),
|
|
5558
|
+
parent: InvokeParent.and(z5.unknown()).optional(),
|
|
5559
|
+
stream: z5.boolean().optional(),
|
|
5560
|
+
trial_count: z5.union([z5.number(), z5.null()]).optional(),
|
|
5561
|
+
is_public: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
5562
|
+
timeout: z5.union([z5.number(), z5.null()]).optional(),
|
|
5563
|
+
max_concurrency: z5.union([z5.number(), z5.null()]).optional().default(10),
|
|
5564
|
+
base_experiment_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
5565
|
+
base_experiment_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
4600
5566
|
git_metadata_settings: GitMetadataSettings.and(
|
|
4601
|
-
|
|
5567
|
+
z5.union([z5.object({}).partial(), z5.null()])
|
|
4602
5568
|
).optional(),
|
|
4603
|
-
repo_info: RepoInfo.and(
|
|
4604
|
-
strict:
|
|
4605
|
-
stop_token:
|
|
4606
|
-
extra_messages:
|
|
4607
|
-
tags:
|
|
4608
|
-
});
|
|
4609
|
-
var ServiceToken =
|
|
4610
|
-
id:
|
|
4611
|
-
created:
|
|
4612
|
-
name:
|
|
4613
|
-
preview_name:
|
|
4614
|
-
service_account_id:
|
|
4615
|
-
service_account_email:
|
|
4616
|
-
service_account_name:
|
|
4617
|
-
org_id:
|
|
4618
|
-
});
|
|
4619
|
-
var SpanIFrame =
|
|
4620
|
-
id:
|
|
4621
|
-
project_id:
|
|
4622
|
-
user_id:
|
|
4623
|
-
created:
|
|
4624
|
-
deleted_at:
|
|
4625
|
-
name:
|
|
4626
|
-
description:
|
|
4627
|
-
url:
|
|
4628
|
-
post_message:
|
|
4629
|
-
});
|
|
4630
|
-
var SSEConsoleEventData =
|
|
4631
|
-
stream:
|
|
4632
|
-
message:
|
|
4633
|
-
});
|
|
4634
|
-
var SSEProgressEventData =
|
|
4635
|
-
id:
|
|
5569
|
+
repo_info: RepoInfo.and(z5.unknown()).optional(),
|
|
5570
|
+
strict: z5.union([z5.boolean(), z5.null()]).optional(),
|
|
5571
|
+
stop_token: z5.union([z5.string(), z5.null()]).optional(),
|
|
5572
|
+
extra_messages: z5.string().optional(),
|
|
5573
|
+
tags: z5.array(z5.string()).optional()
|
|
5574
|
+
});
|
|
5575
|
+
var ServiceToken = z5.object({
|
|
5576
|
+
id: z5.string().uuid(),
|
|
5577
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
5578
|
+
name: z5.string(),
|
|
5579
|
+
preview_name: z5.string(),
|
|
5580
|
+
service_account_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
5581
|
+
service_account_email: z5.union([z5.string(), z5.null()]).optional(),
|
|
5582
|
+
service_account_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
5583
|
+
org_id: z5.union([z5.string(), z5.null()]).optional()
|
|
5584
|
+
});
|
|
5585
|
+
var SpanIFrame = z5.object({
|
|
5586
|
+
id: z5.string().uuid(),
|
|
5587
|
+
project_id: z5.string().uuid(),
|
|
5588
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
5589
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
5590
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional(),
|
|
5591
|
+
name: z5.string(),
|
|
5592
|
+
description: z5.union([z5.string(), z5.null()]).optional(),
|
|
5593
|
+
url: z5.string(),
|
|
5594
|
+
post_message: z5.union([z5.boolean(), z5.null()]).optional()
|
|
5595
|
+
});
|
|
5596
|
+
var SSEConsoleEventData = z5.object({
|
|
5597
|
+
stream: z5.enum(["stderr", "stdout"]),
|
|
5598
|
+
message: z5.string()
|
|
5599
|
+
});
|
|
5600
|
+
var SSEProgressEventData = z5.object({
|
|
5601
|
+
id: z5.string(),
|
|
4636
5602
|
object_type: FunctionObjectType,
|
|
4637
|
-
origin: ObjectReferenceNullish.and(
|
|
5603
|
+
origin: ObjectReferenceNullish.and(z5.unknown()).optional(),
|
|
4638
5604
|
format: FunctionFormat,
|
|
4639
5605
|
output_type: FunctionOutputType,
|
|
4640
|
-
name:
|
|
4641
|
-
event:
|
|
5606
|
+
name: z5.string(),
|
|
5607
|
+
event: z5.enum([
|
|
4642
5608
|
"reasoning_delta",
|
|
4643
5609
|
"text_delta",
|
|
4644
5610
|
"json_delta",
|
|
@@ -4648,110 +5614,110 @@ var SSEProgressEventData = z.object({
|
|
|
4648
5614
|
"done",
|
|
4649
5615
|
"progress"
|
|
4650
5616
|
]),
|
|
4651
|
-
data:
|
|
4652
|
-
});
|
|
4653
|
-
var ToolFunctionDefinition =
|
|
4654
|
-
type:
|
|
4655
|
-
function:
|
|
4656
|
-
name:
|
|
4657
|
-
description:
|
|
4658
|
-
parameters:
|
|
4659
|
-
strict:
|
|
5617
|
+
data: z5.string()
|
|
5618
|
+
});
|
|
5619
|
+
var ToolFunctionDefinition = z5.object({
|
|
5620
|
+
type: z5.literal("function"),
|
|
5621
|
+
function: z5.object({
|
|
5622
|
+
name: z5.string(),
|
|
5623
|
+
description: z5.string().optional(),
|
|
5624
|
+
parameters: z5.object({}).partial().passthrough().optional(),
|
|
5625
|
+
strict: z5.union([z5.boolean(), z5.null()]).optional()
|
|
4660
5626
|
})
|
|
4661
5627
|
});
|
|
4662
|
-
var User =
|
|
4663
|
-
id:
|
|
4664
|
-
given_name:
|
|
4665
|
-
family_name:
|
|
4666
|
-
email:
|
|
4667
|
-
avatar_url:
|
|
4668
|
-
created:
|
|
4669
|
-
});
|
|
4670
|
-
var ViewDataSearch =
|
|
4671
|
-
|
|
4672
|
-
filter:
|
|
4673
|
-
tag:
|
|
4674
|
-
match:
|
|
4675
|
-
sort:
|
|
5628
|
+
var User = z5.object({
|
|
5629
|
+
id: z5.string().uuid(),
|
|
5630
|
+
given_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
5631
|
+
family_name: z5.union([z5.string(), z5.null()]).optional(),
|
|
5632
|
+
email: z5.union([z5.string(), z5.null()]).optional(),
|
|
5633
|
+
avatar_url: z5.union([z5.string(), z5.null()]).optional(),
|
|
5634
|
+
created: z5.union([z5.string(), z5.null()]).optional()
|
|
5635
|
+
});
|
|
5636
|
+
var ViewDataSearch = z5.union([
|
|
5637
|
+
z5.object({
|
|
5638
|
+
filter: z5.union([z5.array(z5.unknown()), z5.null()]),
|
|
5639
|
+
tag: z5.union([z5.array(z5.unknown()), z5.null()]),
|
|
5640
|
+
match: z5.union([z5.array(z5.unknown()), z5.null()]),
|
|
5641
|
+
sort: z5.union([z5.array(z5.unknown()), z5.null()])
|
|
4676
5642
|
}).partial(),
|
|
4677
|
-
|
|
5643
|
+
z5.null()
|
|
4678
5644
|
]);
|
|
4679
|
-
var ViewData =
|
|
4680
|
-
|
|
4681
|
-
|
|
5645
|
+
var ViewData = z5.union([
|
|
5646
|
+
z5.object({ search: ViewDataSearch }).partial(),
|
|
5647
|
+
z5.null()
|
|
4682
5648
|
]);
|
|
4683
|
-
var ViewOptions =
|
|
4684
|
-
|
|
4685
|
-
viewType:
|
|
4686
|
-
options:
|
|
4687
|
-
spanType:
|
|
4688
|
-
rangeValue:
|
|
4689
|
-
frameStart:
|
|
4690
|
-
frameEnd:
|
|
4691
|
-
tzUTC:
|
|
4692
|
-
chartVisibility:
|
|
4693
|
-
projectId:
|
|
4694
|
-
type:
|
|
4695
|
-
groupBy:
|
|
5649
|
+
var ViewOptions = z5.union([
|
|
5650
|
+
z5.object({
|
|
5651
|
+
viewType: z5.literal("monitor"),
|
|
5652
|
+
options: z5.object({
|
|
5653
|
+
spanType: z5.union([z5.enum(["range", "frame"]), z5.null()]),
|
|
5654
|
+
rangeValue: z5.union([z5.string(), z5.null()]),
|
|
5655
|
+
frameStart: z5.union([z5.string(), z5.null()]),
|
|
5656
|
+
frameEnd: z5.union([z5.string(), z5.null()]),
|
|
5657
|
+
tzUTC: z5.union([z5.boolean(), z5.null()]),
|
|
5658
|
+
chartVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
|
|
5659
|
+
projectId: z5.union([z5.string(), z5.null()]),
|
|
5660
|
+
type: z5.union([z5.enum(["project", "experiment"]), z5.null()]),
|
|
5661
|
+
groupBy: z5.union([z5.string(), z5.null()])
|
|
4696
5662
|
}).partial()
|
|
4697
5663
|
}),
|
|
4698
|
-
|
|
4699
|
-
columnVisibility:
|
|
4700
|
-
columnOrder:
|
|
4701
|
-
columnSizing:
|
|
4702
|
-
grouping:
|
|
4703
|
-
rowHeight:
|
|
4704
|
-
tallGroupRows:
|
|
4705
|
-
layout:
|
|
4706
|
-
chartHeight:
|
|
4707
|
-
excludedMeasures:
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
type:
|
|
4711
|
-
value:
|
|
5664
|
+
z5.object({
|
|
5665
|
+
columnVisibility: z5.union([z5.record(z5.boolean()), z5.null()]),
|
|
5666
|
+
columnOrder: z5.union([z5.array(z5.string()), z5.null()]),
|
|
5667
|
+
columnSizing: z5.union([z5.record(z5.number()), z5.null()]),
|
|
5668
|
+
grouping: z5.union([z5.string(), z5.null()]),
|
|
5669
|
+
rowHeight: z5.union([z5.string(), z5.null()]),
|
|
5670
|
+
tallGroupRows: z5.union([z5.boolean(), z5.null()]),
|
|
5671
|
+
layout: z5.union([z5.string(), z5.null()]),
|
|
5672
|
+
chartHeight: z5.union([z5.number(), z5.null()]),
|
|
5673
|
+
excludedMeasures: z5.union([
|
|
5674
|
+
z5.array(
|
|
5675
|
+
z5.object({
|
|
5676
|
+
type: z5.enum(["none", "score", "metric", "metadata"]),
|
|
5677
|
+
value: z5.string()
|
|
4712
5678
|
})
|
|
4713
5679
|
),
|
|
4714
|
-
|
|
5680
|
+
z5.null()
|
|
4715
5681
|
]),
|
|
4716
|
-
yMetric:
|
|
4717
|
-
|
|
4718
|
-
type:
|
|
4719
|
-
value:
|
|
5682
|
+
yMetric: z5.union([
|
|
5683
|
+
z5.object({
|
|
5684
|
+
type: z5.enum(["none", "score", "metric", "metadata"]),
|
|
5685
|
+
value: z5.string()
|
|
4720
5686
|
}),
|
|
4721
|
-
|
|
5687
|
+
z5.null()
|
|
4722
5688
|
]),
|
|
4723
|
-
xAxis:
|
|
4724
|
-
|
|
4725
|
-
type:
|
|
4726
|
-
value:
|
|
5689
|
+
xAxis: z5.union([
|
|
5690
|
+
z5.object({
|
|
5691
|
+
type: z5.enum(["none", "score", "metric", "metadata"]),
|
|
5692
|
+
value: z5.string()
|
|
4727
5693
|
}),
|
|
4728
|
-
|
|
5694
|
+
z5.null()
|
|
4729
5695
|
]),
|
|
4730
|
-
symbolGrouping:
|
|
4731
|
-
|
|
4732
|
-
type:
|
|
4733
|
-
value:
|
|
5696
|
+
symbolGrouping: z5.union([
|
|
5697
|
+
z5.object({
|
|
5698
|
+
type: z5.enum(["none", "score", "metric", "metadata"]),
|
|
5699
|
+
value: z5.string()
|
|
4734
5700
|
}),
|
|
4735
|
-
|
|
5701
|
+
z5.null()
|
|
4736
5702
|
]),
|
|
4737
|
-
xAxisAggregation:
|
|
4738
|
-
chartAnnotations:
|
|
4739
|
-
|
|
4740
|
-
|
|
5703
|
+
xAxisAggregation: z5.union([z5.string(), z5.null()]),
|
|
5704
|
+
chartAnnotations: z5.union([
|
|
5705
|
+
z5.array(z5.object({ id: z5.string(), text: z5.string() })),
|
|
5706
|
+
z5.null()
|
|
4741
5707
|
]),
|
|
4742
|
-
timeRangeFilter:
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
5708
|
+
timeRangeFilter: z5.union([
|
|
5709
|
+
z5.string(),
|
|
5710
|
+
z5.object({ from: z5.string(), to: z5.string() }),
|
|
5711
|
+
z5.null()
|
|
4746
5712
|
])
|
|
4747
5713
|
}).partial(),
|
|
4748
|
-
|
|
5714
|
+
z5.null()
|
|
4749
5715
|
]);
|
|
4750
|
-
var View =
|
|
4751
|
-
id:
|
|
4752
|
-
object_type: AclObjectType.and(
|
|
4753
|
-
object_id:
|
|
4754
|
-
view_type:
|
|
5716
|
+
var View = z5.object({
|
|
5717
|
+
id: z5.string().uuid(),
|
|
5718
|
+
object_type: AclObjectType.and(z5.string()),
|
|
5719
|
+
object_id: z5.string().uuid(),
|
|
5720
|
+
view_type: z5.enum([
|
|
4755
5721
|
"projects",
|
|
4756
5722
|
"experiments",
|
|
4757
5723
|
"experiment",
|
|
@@ -4766,56 +5732,56 @@ var View = z.object({
|
|
|
4766
5732
|
"agents",
|
|
4767
5733
|
"monitor"
|
|
4768
5734
|
]),
|
|
4769
|
-
name:
|
|
4770
|
-
created:
|
|
5735
|
+
name: z5.string(),
|
|
5736
|
+
created: z5.union([z5.string(), z5.null()]).optional(),
|
|
4771
5737
|
view_data: ViewData.optional(),
|
|
4772
5738
|
options: ViewOptions.optional(),
|
|
4773
|
-
user_id:
|
|
4774
|
-
deleted_at:
|
|
5739
|
+
user_id: z5.union([z5.string(), z5.null()]).optional(),
|
|
5740
|
+
deleted_at: z5.union([z5.string(), z5.null()]).optional()
|
|
4775
5741
|
});
|
|
4776
5742
|
|
|
4777
5743
|
// src/logger.ts
|
|
4778
5744
|
import { waitUntil } from "@vercel/functions";
|
|
4779
5745
|
import Mustache2 from "mustache";
|
|
4780
|
-
import { z as
|
|
5746
|
+
import { z as z7, ZodError } from "zod";
|
|
4781
5747
|
|
|
4782
5748
|
// src/functions/stream.ts
|
|
4783
5749
|
import {
|
|
4784
5750
|
createParser
|
|
4785
5751
|
} from "eventsource-parser";
|
|
4786
|
-
import { z as
|
|
4787
|
-
var braintrustStreamChunkSchema =
|
|
4788
|
-
|
|
4789
|
-
type:
|
|
4790
|
-
data:
|
|
5752
|
+
import { z as z6 } from "zod/v3";
|
|
5753
|
+
var braintrustStreamChunkSchema = z6.union([
|
|
5754
|
+
z6.object({
|
|
5755
|
+
type: z6.literal("text_delta"),
|
|
5756
|
+
data: z6.string()
|
|
4791
5757
|
}),
|
|
4792
|
-
|
|
4793
|
-
type:
|
|
4794
|
-
data:
|
|
5758
|
+
z6.object({
|
|
5759
|
+
type: z6.literal("reasoning_delta"),
|
|
5760
|
+
data: z6.string()
|
|
4795
5761
|
}),
|
|
4796
|
-
|
|
4797
|
-
type:
|
|
4798
|
-
data:
|
|
5762
|
+
z6.object({
|
|
5763
|
+
type: z6.literal("json_delta"),
|
|
5764
|
+
data: z6.string()
|
|
4799
5765
|
}),
|
|
4800
|
-
|
|
4801
|
-
type:
|
|
4802
|
-
data:
|
|
5766
|
+
z6.object({
|
|
5767
|
+
type: z6.literal("error"),
|
|
5768
|
+
data: z6.string()
|
|
4803
5769
|
}),
|
|
4804
|
-
|
|
4805
|
-
type:
|
|
5770
|
+
z6.object({
|
|
5771
|
+
type: z6.literal("console"),
|
|
4806
5772
|
data: SSEConsoleEventData
|
|
4807
5773
|
}),
|
|
4808
|
-
|
|
4809
|
-
type:
|
|
5774
|
+
z6.object({
|
|
5775
|
+
type: z6.literal("progress"),
|
|
4810
5776
|
data: SSEProgressEventData
|
|
4811
5777
|
}),
|
|
4812
|
-
|
|
4813
|
-
type:
|
|
4814
|
-
data:
|
|
5778
|
+
z6.object({
|
|
5779
|
+
type: z6.literal("start"),
|
|
5780
|
+
data: z6.string()
|
|
4815
5781
|
}),
|
|
4816
|
-
|
|
4817
|
-
type:
|
|
4818
|
-
data:
|
|
5782
|
+
z6.object({
|
|
5783
|
+
type: z6.literal("done"),
|
|
5784
|
+
data: z6.string()
|
|
4819
5785
|
})
|
|
4820
5786
|
]);
|
|
4821
5787
|
var BraintrustStream = class _BraintrustStream {
|
|
@@ -5412,7 +6378,6 @@ function objectIsEmpty(obj) {
|
|
|
5412
6378
|
}
|
|
5413
6379
|
|
|
5414
6380
|
// src/mustache-utils.ts
|
|
5415
|
-
import { getObjValueByPath } from "@braintrust/core";
|
|
5416
6381
|
import Mustache from "mustache";
|
|
5417
6382
|
function lintTemplate(template, context2) {
|
|
5418
6383
|
const variables = getMustacheVars(template);
|
|
@@ -5435,7 +6400,6 @@ function getMustacheVars(prompt) {
|
|
|
5435
6400
|
}
|
|
5436
6401
|
|
|
5437
6402
|
// src/logger.ts
|
|
5438
|
-
import { prettifyXact } from "@braintrust/core";
|
|
5439
6403
|
var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
|
|
5440
6404
|
var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
|
|
5441
6405
|
var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
|
|
@@ -5523,14 +6487,14 @@ var NoopSpan = class {
|
|
|
5523
6487
|
};
|
|
5524
6488
|
var NOOP_SPAN = new NoopSpan();
|
|
5525
6489
|
var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
|
|
5526
|
-
var loginSchema =
|
|
5527
|
-
appUrl:
|
|
5528
|
-
appPublicUrl:
|
|
5529
|
-
orgName:
|
|
5530
|
-
apiUrl:
|
|
5531
|
-
proxyUrl:
|
|
5532
|
-
loginToken:
|
|
5533
|
-
orgId:
|
|
6490
|
+
var loginSchema = z7.strictObject({
|
|
6491
|
+
appUrl: z7.string(),
|
|
6492
|
+
appPublicUrl: z7.string(),
|
|
6493
|
+
orgName: z7.string(),
|
|
6494
|
+
apiUrl: z7.string(),
|
|
6495
|
+
proxyUrl: z7.string(),
|
|
6496
|
+
loginToken: z7.string(),
|
|
6497
|
+
orgId: z7.string().nullish(),
|
|
5534
6498
|
gitMetadataSettings: GitMetadataSettings.nullish()
|
|
5535
6499
|
});
|
|
5536
6500
|
var stateNonce = 0;
|
|
@@ -6007,9 +6971,9 @@ var Attachment = class extends BaseAttachment {
|
|
|
6007
6971
|
let signedUrl;
|
|
6008
6972
|
let headers;
|
|
6009
6973
|
try {
|
|
6010
|
-
({ signedUrl, headers } =
|
|
6011
|
-
signedUrl:
|
|
6012
|
-
headers:
|
|
6974
|
+
({ signedUrl, headers } = z7.object({
|
|
6975
|
+
signedUrl: z7.string().url(),
|
|
6976
|
+
headers: z7.record(z7.string())
|
|
6013
6977
|
}).parse(await metadataResponse.json()));
|
|
6014
6978
|
} catch (error2) {
|
|
6015
6979
|
if (error2 instanceof ZodError) {
|
|
@@ -6164,8 +7128,8 @@ var ExternalAttachment = class extends BaseAttachment {
|
|
|
6164
7128
|
});
|
|
6165
7129
|
}
|
|
6166
7130
|
};
|
|
6167
|
-
var attachmentMetadataSchema =
|
|
6168
|
-
downloadUrl:
|
|
7131
|
+
var attachmentMetadataSchema = z7.object({
|
|
7132
|
+
downloadUrl: z7.string(),
|
|
6169
7133
|
status: AttachmentStatus
|
|
6170
7134
|
});
|
|
6171
7135
|
var ReadonlyAttachment = class {
|
|
@@ -6377,15 +7341,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
6377
7341
|
);
|
|
6378
7342
|
}
|
|
6379
7343
|
switch (components.data.object_type) {
|
|
6380
|
-
case
|
|
7344
|
+
case 1 /* EXPERIMENT */:
|
|
6381
7345
|
throw new Error(
|
|
6382
7346
|
"Impossible: computeObjectMetadataArgs not supported for experiments"
|
|
6383
7347
|
);
|
|
6384
|
-
case
|
|
7348
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
6385
7349
|
throw new Error(
|
|
6386
7350
|
"Impossible: computeObjectMetadataArgs not supported for prompt sessions"
|
|
6387
7351
|
);
|
|
6388
|
-
case
|
|
7352
|
+
case 2 /* PROJECT_LOGS */:
|
|
6389
7353
|
return async () => (await computeLoggerMetadata(state, {
|
|
6390
7354
|
...components.data.compute_object_metadata_args
|
|
6391
7355
|
})).project.id;
|
|
@@ -6537,7 +7501,7 @@ var Logger = class {
|
|
|
6537
7501
|
return (async () => (await this.project).id)();
|
|
6538
7502
|
}
|
|
6539
7503
|
parentObjectType() {
|
|
6540
|
-
return
|
|
7504
|
+
return 2 /* PROJECT_LOGS */;
|
|
6541
7505
|
}
|
|
6542
7506
|
/**
|
|
6543
7507
|
* Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
|
|
@@ -6631,7 +7595,7 @@ var Logger = class {
|
|
|
6631
7595
|
parentSpanIds: args?.parentSpanIds,
|
|
6632
7596
|
propagatedEvent: args?.propagatedEvent
|
|
6633
7597
|
}),
|
|
6634
|
-
defaultRootType:
|
|
7598
|
+
defaultRootType: "task" /* TASK */
|
|
6635
7599
|
});
|
|
6636
7600
|
}
|
|
6637
7601
|
/**
|
|
@@ -7749,6 +8713,8 @@ function getSpanParentObject(options) {
|
|
|
7749
8713
|
if (!Object.is(parentSpan, NOOP_SPAN)) {
|
|
7750
8714
|
return parentSpan;
|
|
7751
8715
|
}
|
|
8716
|
+
const parentStr = options?.parent ?? state.currentParent.getStore();
|
|
8717
|
+
if (parentStr) return SpanComponentsV3.fromStr(parentStr);
|
|
7752
8718
|
const experiment = currentExperiment();
|
|
7753
8719
|
if (experiment) {
|
|
7754
8720
|
return experiment;
|
|
@@ -7965,35 +8931,35 @@ function setFetch(fetch2) {
|
|
|
7965
8931
|
}
|
|
7966
8932
|
function startSpanAndIsLogger(args) {
|
|
7967
8933
|
const state = args?.state ?? _globalState;
|
|
7968
|
-
const
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
8934
|
+
const parentObject = getSpanParentObject({
|
|
8935
|
+
asyncFlush: args?.asyncFlush,
|
|
8936
|
+
parent: args?.parent,
|
|
8937
|
+
state
|
|
8938
|
+
});
|
|
8939
|
+
if (parentObject instanceof SpanComponentsV3) {
|
|
8940
|
+
const parentSpanIds = parentObject.data.row_id ? {
|
|
8941
|
+
spanId: parentObject.data.span_id,
|
|
8942
|
+
rootSpanId: parentObject.data.root_span_id
|
|
7974
8943
|
} : void 0;
|
|
7975
8944
|
const span = new SpanImpl({
|
|
7976
8945
|
state,
|
|
7977
8946
|
...args,
|
|
7978
|
-
parentObjectType:
|
|
8947
|
+
parentObjectType: parentObject.data.object_type,
|
|
7979
8948
|
parentObjectId: new LazyValue(
|
|
7980
|
-
spanComponentsToObjectIdLambda(state,
|
|
8949
|
+
spanComponentsToObjectIdLambda(state, parentObject)
|
|
7981
8950
|
),
|
|
7982
|
-
parentComputeObjectMetadataArgs:
|
|
8951
|
+
parentComputeObjectMetadataArgs: parentObject.data.compute_object_metadata_args ?? void 0,
|
|
7983
8952
|
parentSpanIds,
|
|
7984
8953
|
propagatedEvent: args?.propagatedEvent ?? // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
7985
|
-
(
|
|
8954
|
+
(parentObject.data.propagated_event ?? void 0)
|
|
7986
8955
|
});
|
|
7987
8956
|
return {
|
|
7988
8957
|
span,
|
|
7989
|
-
isSyncFlushLogger:
|
|
8958
|
+
isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
|
|
7990
8959
|
// behavior, and therefore propagate along whatever we get from the arguments
|
|
7991
8960
|
args?.asyncFlush === false
|
|
7992
8961
|
};
|
|
7993
8962
|
} else {
|
|
7994
|
-
const parentObject = getSpanParentObject({
|
|
7995
|
-
asyncFlush: args?.asyncFlush
|
|
7996
|
-
});
|
|
7997
8963
|
const span = parentObject.startSpan(args);
|
|
7998
8964
|
return {
|
|
7999
8965
|
span,
|
|
@@ -8143,7 +9109,7 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
|
|
|
8143
9109
|
function deepCopyEvent(event) {
|
|
8144
9110
|
const attachments = [];
|
|
8145
9111
|
const IDENTIFIER = "_bt_internal_saved_attachment";
|
|
8146
|
-
const savedAttachmentSchema =
|
|
9112
|
+
const savedAttachmentSchema = z7.strictObject({ [IDENTIFIER]: z7.number() });
|
|
8147
9113
|
const serialized = JSON.stringify(event, (_k, v) => {
|
|
8148
9114
|
if (v instanceof SpanImpl || v instanceof NoopSpan) {
|
|
8149
9115
|
return `<span>`;
|
|
@@ -8378,7 +9344,7 @@ var Experiment2 = class extends ObjectFetcher {
|
|
|
8378
9344
|
})();
|
|
8379
9345
|
}
|
|
8380
9346
|
parentObjectType() {
|
|
8381
|
-
return
|
|
9347
|
+
return 1 /* EXPERIMENT */;
|
|
8382
9348
|
}
|
|
8383
9349
|
async getState() {
|
|
8384
9350
|
await this.lazyMetadata.get();
|
|
@@ -8462,7 +9428,7 @@ var Experiment2 = class extends ObjectFetcher {
|
|
|
8462
9428
|
parentSpanIds: void 0,
|
|
8463
9429
|
propagatedEvent: args?.propagatedEvent
|
|
8464
9430
|
}),
|
|
8465
|
-
defaultRootType:
|
|
9431
|
+
defaultRootType: "eval" /* EVAL */
|
|
8466
9432
|
});
|
|
8467
9433
|
}
|
|
8468
9434
|
async fetchBaseExperiment() {
|
|
@@ -8881,7 +9847,7 @@ var SpanImpl = class _SpanImpl {
|
|
|
8881
9847
|
const baseUrl = `${appUrl}/app/${orgName}`;
|
|
8882
9848
|
const args = this.parentComputeObjectMetadataArgs;
|
|
8883
9849
|
switch (this.parentObjectType) {
|
|
8884
|
-
case
|
|
9850
|
+
case 2 /* PROJECT_LOGS */: {
|
|
8885
9851
|
const projectID = args?.project_id || this.parentObjectId.getSync().value;
|
|
8886
9852
|
const projectName = args?.project_name;
|
|
8887
9853
|
if (projectID) {
|
|
@@ -8892,7 +9858,7 @@ var SpanImpl = class _SpanImpl {
|
|
|
8892
9858
|
return getErrPermlink("provide-project-name-or-id");
|
|
8893
9859
|
}
|
|
8894
9860
|
}
|
|
8895
|
-
case
|
|
9861
|
+
case 1 /* EXPERIMENT */: {
|
|
8896
9862
|
const expID = args?.experiment_id || this.parentObjectId?.getSync()?.value;
|
|
8897
9863
|
if (!expID) {
|
|
8898
9864
|
return getErrPermlink("provide-experiment-id");
|
|
@@ -8900,7 +9866,7 @@ var SpanImpl = class _SpanImpl {
|
|
|
8900
9866
|
return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
|
|
8901
9867
|
}
|
|
8902
9868
|
}
|
|
8903
|
-
case
|
|
9869
|
+
case 3 /* PLAYGROUND_LOGS */: {
|
|
8904
9870
|
return NOOP_SPAN_PERMALINK;
|
|
8905
9871
|
}
|
|
8906
9872
|
default: {
|
|
@@ -9148,8 +10114,8 @@ var Dataset2 = class extends ObjectFetcher {
|
|
|
9148
10114
|
)}`;
|
|
9149
10115
|
let dataSummary;
|
|
9150
10116
|
if (summarizeData) {
|
|
9151
|
-
const rawDataSummary =
|
|
9152
|
-
total_records:
|
|
10117
|
+
const rawDataSummary = z7.object({
|
|
10118
|
+
total_records: z7.number()
|
|
9153
10119
|
}).parse(
|
|
9154
10120
|
await state.apiConn().get_json(
|
|
9155
10121
|
"dataset-summary",
|
|
@@ -9272,11 +10238,11 @@ function renderTemplatedObject(obj, args, options) {
|
|
|
9272
10238
|
return obj;
|
|
9273
10239
|
}
|
|
9274
10240
|
function renderPromptParams(params, args, options) {
|
|
9275
|
-
const schemaParsed =
|
|
9276
|
-
response_format:
|
|
9277
|
-
type:
|
|
10241
|
+
const schemaParsed = z7.object({
|
|
10242
|
+
response_format: z7.object({
|
|
10243
|
+
type: z7.literal("json_schema"),
|
|
9278
10244
|
json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
|
|
9279
|
-
schema:
|
|
10245
|
+
schema: z7.unknown()
|
|
9280
10246
|
})
|
|
9281
10247
|
})
|
|
9282
10248
|
}).safeParse(params);
|
|
@@ -9394,7 +10360,7 @@ var Prompt2 = class _Prompt {
|
|
|
9394
10360
|
if (!prompt) {
|
|
9395
10361
|
throw new Error("Empty prompt");
|
|
9396
10362
|
}
|
|
9397
|
-
const dictArgParsed =
|
|
10363
|
+
const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
|
|
9398
10364
|
const variables = {
|
|
9399
10365
|
input: buildArgs,
|
|
9400
10366
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -9449,7 +10415,7 @@ var Prompt2 = class _Prompt {
|
|
|
9449
10415
|
return JSON.stringify(v);
|
|
9450
10416
|
}
|
|
9451
10417
|
};
|
|
9452
|
-
const dictArgParsed =
|
|
10418
|
+
const dictArgParsed = z7.record(z7.unknown()).safeParse(buildArgs);
|
|
9453
10419
|
const variables = {
|
|
9454
10420
|
input: buildArgs,
|
|
9455
10421
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -9725,6 +10691,7 @@ __export(exports_node_exports, {
|
|
|
9725
10691
|
withExperiment: () => withExperiment,
|
|
9726
10692
|
withLogger: () => withLogger,
|
|
9727
10693
|
withParent: () => withParent,
|
|
10694
|
+
wrapAISDK: () => wrapAISDK,
|
|
9728
10695
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
9729
10696
|
wrapAnthropic: () => wrapAnthropic,
|
|
9730
10697
|
wrapOpenAI: () => wrapOpenAI,
|
|
@@ -9820,9 +10787,6 @@ function initFunction({
|
|
|
9820
10787
|
return f;
|
|
9821
10788
|
}
|
|
9822
10789
|
|
|
9823
|
-
// src/framework.ts
|
|
9824
|
-
import { SpanTypeAttribute as SpanTypeAttribute2, mergeDicts as mergeDicts2 } from "@braintrust/core";
|
|
9825
|
-
|
|
9826
10790
|
// ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
|
|
9827
10791
|
function initialParams(fn) {
|
|
9828
10792
|
return function(...args) {
|
|
@@ -10902,13 +11866,12 @@ var BarProgressReporter = class {
|
|
|
10902
11866
|
};
|
|
10903
11867
|
|
|
10904
11868
|
// src/eval-parameters.ts
|
|
10905
|
-
import { z as
|
|
11869
|
+
import { z as z9 } from "zod/v3";
|
|
10906
11870
|
|
|
10907
11871
|
// src/framework2.ts
|
|
10908
11872
|
import path2 from "path";
|
|
10909
11873
|
import slugifyLib from "slugify";
|
|
10910
|
-
import { z as
|
|
10911
|
-
import { loadPrettyXact } from "@braintrust/core";
|
|
11874
|
+
import { z as z8 } from "zod/v3";
|
|
10912
11875
|
var ProjectBuilder = class {
|
|
10913
11876
|
create(opts) {
|
|
10914
11877
|
return new Project2(opts);
|
|
@@ -11142,23 +12105,23 @@ var CodePrompt = class {
|
|
|
11142
12105
|
};
|
|
11143
12106
|
}
|
|
11144
12107
|
};
|
|
11145
|
-
var promptContentsSchema =
|
|
11146
|
-
|
|
11147
|
-
prompt:
|
|
12108
|
+
var promptContentsSchema = z8.union([
|
|
12109
|
+
z8.object({
|
|
12110
|
+
prompt: z8.string()
|
|
11148
12111
|
}),
|
|
11149
|
-
|
|
11150
|
-
messages:
|
|
12112
|
+
z8.object({
|
|
12113
|
+
messages: z8.array(ChatCompletionMessageParam)
|
|
11151
12114
|
})
|
|
11152
12115
|
]);
|
|
11153
12116
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
11154
|
-
|
|
11155
|
-
model:
|
|
12117
|
+
z8.object({
|
|
12118
|
+
model: z8.string(),
|
|
11156
12119
|
params: ModelParams.optional()
|
|
11157
12120
|
})
|
|
11158
12121
|
);
|
|
11159
12122
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
11160
|
-
|
|
11161
|
-
tools:
|
|
12123
|
+
z8.object({
|
|
12124
|
+
tools: z8.array(ToolFunctionDefinition).optional()
|
|
11162
12125
|
})
|
|
11163
12126
|
);
|
|
11164
12127
|
var PromptBuilder = class {
|
|
@@ -11226,7 +12189,7 @@ var ProjectNameIdMap = class {
|
|
|
11226
12189
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
|
|
11227
12190
|
project_name: projectName
|
|
11228
12191
|
});
|
|
11229
|
-
const result =
|
|
12192
|
+
const result = z8.object({
|
|
11230
12193
|
project: Project
|
|
11231
12194
|
}).parse(response);
|
|
11232
12195
|
const projectId = result.project.id;
|
|
@@ -11240,7 +12203,7 @@ var ProjectNameIdMap = class {
|
|
|
11240
12203
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
|
|
11241
12204
|
id: projectId
|
|
11242
12205
|
});
|
|
11243
|
-
const result =
|
|
12206
|
+
const result = z8.array(Project).nonempty().parse(response);
|
|
11244
12207
|
const projectName = result[0].name;
|
|
11245
12208
|
this.idToName[projectId] = projectName;
|
|
11246
12209
|
this.nameToId[projectName] = projectId;
|
|
@@ -11256,15 +12219,15 @@ var ProjectNameIdMap = class {
|
|
|
11256
12219
|
};
|
|
11257
12220
|
|
|
11258
12221
|
// src/eval-parameters.ts
|
|
11259
|
-
var evalParametersSchema =
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
type:
|
|
12222
|
+
var evalParametersSchema = z9.record(
|
|
12223
|
+
z9.string(),
|
|
12224
|
+
z9.union([
|
|
12225
|
+
z9.object({
|
|
12226
|
+
type: z9.literal("prompt"),
|
|
11264
12227
|
default: promptDefinitionWithToolsSchema.optional(),
|
|
11265
|
-
description:
|
|
12228
|
+
description: z9.string().optional()
|
|
11266
12229
|
}),
|
|
11267
|
-
|
|
12230
|
+
z9.instanceof(z9.ZodType)
|
|
11268
12231
|
// For Zod schemas
|
|
11269
12232
|
])
|
|
11270
12233
|
);
|
|
@@ -11566,7 +12529,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
11566
12529
|
const baseEvent = {
|
|
11567
12530
|
name: "eval",
|
|
11568
12531
|
spanAttributes: {
|
|
11569
|
-
type:
|
|
12532
|
+
type: "eval" /* EVAL */
|
|
11570
12533
|
},
|
|
11571
12534
|
event: {
|
|
11572
12535
|
input: datum.input,
|
|
@@ -11626,7 +12589,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
11626
12589
|
},
|
|
11627
12590
|
{
|
|
11628
12591
|
name: "task",
|
|
11629
|
-
spanAttributes: { type:
|
|
12592
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
11630
12593
|
event: { input: datum.input }
|
|
11631
12594
|
}
|
|
11632
12595
|
);
|
|
@@ -11672,17 +12635,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
11672
12635
|
return rest;
|
|
11673
12636
|
};
|
|
11674
12637
|
const resultMetadata = results3.length === 1 ? results3[0].metadata : results3.reduce(
|
|
11675
|
-
(prev, s) =>
|
|
12638
|
+
(prev, s) => mergeDicts(prev, {
|
|
11676
12639
|
[s.name]: s.metadata
|
|
11677
12640
|
}),
|
|
11678
12641
|
{}
|
|
11679
12642
|
);
|
|
11680
12643
|
const resultOutput = results3.length === 1 ? getOtherFields(results3[0]) : results3.reduce(
|
|
11681
|
-
(prev, s) =>
|
|
12644
|
+
(prev, s) => mergeDicts(prev, { [s.name]: getOtherFields(s) }),
|
|
11682
12645
|
{}
|
|
11683
12646
|
);
|
|
11684
12647
|
const scores2 = results3.reduce(
|
|
11685
|
-
(prev, s) =>
|
|
12648
|
+
(prev, s) => mergeDicts(prev, { [s.name]: s.score }),
|
|
11686
12649
|
{}
|
|
11687
12650
|
);
|
|
11688
12651
|
span.log({
|
|
@@ -11695,7 +12658,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
11695
12658
|
const results2 = await rootSpan.traced(runScorer, {
|
|
11696
12659
|
name: scorerNames[score_idx],
|
|
11697
12660
|
spanAttributes: {
|
|
11698
|
-
type:
|
|
12661
|
+
type: "score" /* SCORE */
|
|
11699
12662
|
},
|
|
11700
12663
|
event: { input: scoringArgs }
|
|
11701
12664
|
});
|
|
@@ -12038,11 +13001,11 @@ var GraphBuilder = class {
|
|
|
12038
13001
|
// }
|
|
12039
13002
|
// Helper to generate node IDs
|
|
12040
13003
|
generateId(name) {
|
|
12041
|
-
const
|
|
13004
|
+
const uuid4 = newId();
|
|
12042
13005
|
if (name) {
|
|
12043
|
-
return `${name}-${
|
|
13006
|
+
return `${name}-${uuid4.slice(0, 8)}`;
|
|
12044
13007
|
} else {
|
|
12045
|
-
return
|
|
13008
|
+
return uuid4;
|
|
12046
13009
|
}
|
|
12047
13010
|
}
|
|
12048
13011
|
// Create an input node
|
|
@@ -12195,12 +13158,7 @@ function unescapePath(path3) {
|
|
|
12195
13158
|
}
|
|
12196
13159
|
var graph_framework_default = { createGraph };
|
|
12197
13160
|
|
|
12198
|
-
// src/wrappers/oai.ts
|
|
12199
|
-
import { SpanTypeAttribute as SpanTypeAttribute3 } from "@braintrust/core";
|
|
12200
|
-
import { mergeDicts as mergeDicts3 } from "@braintrust/core";
|
|
12201
|
-
|
|
12202
13161
|
// src/wrappers/oai_responses.ts
|
|
12203
|
-
import { isObject as isObject2 } from "@braintrust/core";
|
|
12204
13162
|
function responsesProxy(openai) {
|
|
12205
13163
|
if (!openai.responses) {
|
|
12206
13164
|
return openai;
|
|
@@ -12228,19 +13186,15 @@ function responsesCreateProxy(target) {
|
|
|
12228
13186
|
return proxyCreate(target, hooks);
|
|
12229
13187
|
}
|
|
12230
13188
|
function parseSpanFromResponseCreateParams(params) {
|
|
12231
|
-
const input = [{ role: "user", content: params.input }];
|
|
12232
|
-
if (params.instructions) {
|
|
12233
|
-
input.push({ role: "system", content: params.instructions });
|
|
12234
|
-
}
|
|
12235
13189
|
const spanArgs = {
|
|
12236
13190
|
name: "openai.responses.create",
|
|
12237
13191
|
spanAttributes: {
|
|
12238
13192
|
type: "llm"
|
|
12239
13193
|
},
|
|
12240
13194
|
event: {
|
|
12241
|
-
input,
|
|
13195
|
+
input: params.input,
|
|
12242
13196
|
metadata: {
|
|
12243
|
-
...filterFrom(params, ["input"
|
|
13197
|
+
...filterFrom(params, ["input"]),
|
|
12244
13198
|
provider: "openai"
|
|
12245
13199
|
}
|
|
12246
13200
|
},
|
|
@@ -12252,25 +13206,29 @@ function parseSpanFromResponseCreateParams(params) {
|
|
|
12252
13206
|
};
|
|
12253
13207
|
}
|
|
12254
13208
|
function parseEventFromResponseCreateResult(result) {
|
|
12255
|
-
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
}
|
|
13209
|
+
const data = {};
|
|
13210
|
+
if (result?.output !== void 0) {
|
|
13211
|
+
data.output = result.output;
|
|
13212
|
+
}
|
|
13213
|
+
if (result) {
|
|
13214
|
+
const { output, usage, ...metadata } = result;
|
|
13215
|
+
if (Object.keys(metadata).length > 0) {
|
|
13216
|
+
data.metadata = metadata;
|
|
13217
|
+
}
|
|
13218
|
+
}
|
|
13219
|
+
data.metrics = parseMetricsFromUsage(result?.usage);
|
|
13220
|
+
return data;
|
|
12259
13221
|
}
|
|
12260
13222
|
function parseSpanFromResponseParseParams(params) {
|
|
12261
|
-
const input = [{ role: "user", content: params.input }];
|
|
12262
|
-
if (params.instructions) {
|
|
12263
|
-
input.push({ role: "system", content: params.instructions });
|
|
12264
|
-
}
|
|
12265
13223
|
const spanArgs = {
|
|
12266
13224
|
name: "openai.responses.parse",
|
|
12267
13225
|
spanAttributes: {
|
|
12268
13226
|
type: "llm"
|
|
12269
13227
|
},
|
|
12270
13228
|
event: {
|
|
12271
|
-
input,
|
|
13229
|
+
input: params.input,
|
|
12272
13230
|
metadata: {
|
|
12273
|
-
...filterFrom(params, ["input"
|
|
13231
|
+
...filterFrom(params, ["input"]),
|
|
12274
13232
|
provider: "openai"
|
|
12275
13233
|
}
|
|
12276
13234
|
},
|
|
@@ -12282,10 +13240,18 @@ function parseSpanFromResponseParseParams(params) {
|
|
|
12282
13240
|
};
|
|
12283
13241
|
}
|
|
12284
13242
|
function parseEventFromResponseParseResult(result) {
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
}
|
|
13243
|
+
const data = {};
|
|
13244
|
+
if (result?.output !== void 0) {
|
|
13245
|
+
data.output = result.output;
|
|
13246
|
+
}
|
|
13247
|
+
if (result) {
|
|
13248
|
+
const { output, usage, ...metadata } = result;
|
|
13249
|
+
if (Object.keys(metadata).length > 0) {
|
|
13250
|
+
data.metadata = metadata;
|
|
13251
|
+
}
|
|
13252
|
+
}
|
|
13253
|
+
data.metrics = parseMetricsFromUsage(result?.usage);
|
|
13254
|
+
return data;
|
|
12289
13255
|
}
|
|
12290
13256
|
function traceResponseCreateStream(stream, timedSpan) {
|
|
12291
13257
|
const span = timedSpan.span;
|
|
@@ -12318,18 +13284,18 @@ function parseLogFromItem(item) {
|
|
|
12318
13284
|
const response = item.response;
|
|
12319
13285
|
switch (item.type) {
|
|
12320
13286
|
case "response.completed":
|
|
12321
|
-
const
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
13287
|
+
const data = {};
|
|
13288
|
+
if (response?.output !== void 0) {
|
|
13289
|
+
data.output = response.output;
|
|
13290
|
+
}
|
|
13291
|
+
if (response) {
|
|
13292
|
+
const { usage, output, ...metadata } = response;
|
|
13293
|
+
if (Object.keys(metadata).length > 0) {
|
|
13294
|
+
data.metadata = metadata;
|
|
12327
13295
|
}
|
|
12328
13296
|
}
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
metrics: parseMetricsFromUsage(response?.usage)
|
|
12332
|
-
};
|
|
13297
|
+
data.metrics = parseMetricsFromUsage(response?.usage);
|
|
13298
|
+
return data;
|
|
12333
13299
|
default:
|
|
12334
13300
|
return {};
|
|
12335
13301
|
}
|
|
@@ -12390,7 +13356,7 @@ function parseMetricsFromUsage(usage) {
|
|
|
12390
13356
|
const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
|
|
12391
13357
|
metrics[metricName] = value;
|
|
12392
13358
|
} else if (oai_name.endsWith("_tokens_details")) {
|
|
12393
|
-
if (!
|
|
13359
|
+
if (!isObject(value)) {
|
|
12394
13360
|
continue;
|
|
12395
13361
|
}
|
|
12396
13362
|
const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
|
|
@@ -12572,11 +13538,11 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
12572
13538
|
return async (allParams) => {
|
|
12573
13539
|
const { span_info: _, ...params } = allParams;
|
|
12574
13540
|
const span = startSpan(
|
|
12575
|
-
|
|
13541
|
+
mergeDicts(
|
|
12576
13542
|
{
|
|
12577
13543
|
name: "Chat Completion",
|
|
12578
13544
|
spanAttributes: {
|
|
12579
|
-
type:
|
|
13545
|
+
type: "llm" /* LLM */
|
|
12580
13546
|
}
|
|
12581
13547
|
},
|
|
12582
13548
|
parseChatCompletionParams(allParams)
|
|
@@ -12596,11 +13562,11 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
12596
13562
|
return (allParams) => {
|
|
12597
13563
|
const { span_info: _, ...params } = allParams;
|
|
12598
13564
|
const span = startSpan(
|
|
12599
|
-
|
|
13565
|
+
mergeDicts(
|
|
12600
13566
|
{
|
|
12601
13567
|
name: "Chat Completion",
|
|
12602
13568
|
spanAttributes: {
|
|
12603
|
-
type:
|
|
13569
|
+
type: "llm" /* LLM */
|
|
12604
13570
|
}
|
|
12605
13571
|
},
|
|
12606
13572
|
parseChatCompletionParams(allParams)
|
|
@@ -12656,55 +13622,83 @@ function logHeaders(response, span) {
|
|
|
12656
13622
|
}
|
|
12657
13623
|
}
|
|
12658
13624
|
function wrapChatCompletion(completion) {
|
|
12659
|
-
return
|
|
13625
|
+
return (allParams, options) => {
|
|
12660
13626
|
const { span_info: _, ...params } = allParams;
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
13627
|
+
let executionPromise = null;
|
|
13628
|
+
let dataPromise = null;
|
|
13629
|
+
const ensureExecuted = () => {
|
|
13630
|
+
if (!executionPromise) {
|
|
13631
|
+
executionPromise = (async () => {
|
|
13632
|
+
const span = startSpan(
|
|
13633
|
+
mergeDicts(
|
|
13634
|
+
{
|
|
13635
|
+
name: "Chat Completion",
|
|
13636
|
+
spanAttributes: {
|
|
13637
|
+
type: "llm" /* LLM */
|
|
13638
|
+
}
|
|
13639
|
+
},
|
|
13640
|
+
parseChatCompletionParams(allParams)
|
|
13641
|
+
)
|
|
13642
|
+
);
|
|
13643
|
+
const startTime = getCurrentUnixTimestamp();
|
|
13644
|
+
if (params.stream) {
|
|
13645
|
+
const { data: ret, response } = await completion(
|
|
13646
|
+
// We could get rid of this type coercion if we could somehow enforce
|
|
13647
|
+
// that `P extends ChatParams` BUT does not have the property
|
|
13648
|
+
// `span_info`.
|
|
13649
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
13650
|
+
params,
|
|
13651
|
+
options
|
|
13652
|
+
).withResponse();
|
|
13653
|
+
logHeaders(response, span);
|
|
13654
|
+
const wrapperStream = new WrapperStream(
|
|
13655
|
+
span,
|
|
13656
|
+
startTime,
|
|
13657
|
+
ret.iterator()
|
|
13658
|
+
);
|
|
13659
|
+
ret.iterator = () => wrapperStream[Symbol.asyncIterator]();
|
|
13660
|
+
return { data: ret, response };
|
|
13661
|
+
} else {
|
|
13662
|
+
try {
|
|
13663
|
+
const completionResponse = completion(
|
|
13664
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
13665
|
+
params,
|
|
13666
|
+
options
|
|
13667
|
+
);
|
|
13668
|
+
const { data: ret, response } = await completionResponse.withResponse();
|
|
13669
|
+
logHeaders(response, span);
|
|
13670
|
+
const { messages, ...rest } = params;
|
|
13671
|
+
span.log({
|
|
13672
|
+
input: messages,
|
|
13673
|
+
metadata: {
|
|
13674
|
+
...rest
|
|
13675
|
+
}
|
|
13676
|
+
});
|
|
13677
|
+
logCompletionResponse(startTime, ret, span);
|
|
13678
|
+
return { data: ret, response };
|
|
13679
|
+
} finally {
|
|
13680
|
+
span.end();
|
|
13681
|
+
}
|
|
12667
13682
|
}
|
|
12668
|
-
}
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
options
|
|
12681
|
-
).withResponse();
|
|
12682
|
-
logHeaders(response, span);
|
|
12683
|
-
const wrapperStream = new WrapperStream(span, startTime, ret.iterator());
|
|
12684
|
-
ret.iterator = () => wrapperStream[Symbol.asyncIterator]();
|
|
12685
|
-
return ret;
|
|
12686
|
-
} else {
|
|
12687
|
-
try {
|
|
12688
|
-
const completionResponse = completion(
|
|
12689
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
12690
|
-
params,
|
|
12691
|
-
options
|
|
12692
|
-
);
|
|
12693
|
-
const { data: ret, response } = await completionResponse.withResponse();
|
|
12694
|
-
logHeaders(response, span);
|
|
12695
|
-
const { messages, ...rest } = params;
|
|
12696
|
-
span.log({
|
|
12697
|
-
input: messages,
|
|
12698
|
-
metadata: {
|
|
12699
|
-
...rest
|
|
13683
|
+
})();
|
|
13684
|
+
}
|
|
13685
|
+
return executionPromise;
|
|
13686
|
+
};
|
|
13687
|
+
return new Proxy({}, {
|
|
13688
|
+
get(target, prop, receiver) {
|
|
13689
|
+
if (prop === "withResponse") {
|
|
13690
|
+
return () => ensureExecuted();
|
|
13691
|
+
}
|
|
13692
|
+
if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
|
|
13693
|
+
if (!dataPromise) {
|
|
13694
|
+
dataPromise = ensureExecuted().then((result) => result.data);
|
|
12700
13695
|
}
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
span.end();
|
|
13696
|
+
const value = Reflect.get(dataPromise, prop, receiver);
|
|
13697
|
+
return typeof value === "function" ? value.bind(dataPromise) : value;
|
|
13698
|
+
}
|
|
13699
|
+
return Reflect.get(target, prop, receiver);
|
|
12706
13700
|
}
|
|
12707
|
-
}
|
|
13701
|
+
});
|
|
12708
13702
|
};
|
|
12709
13703
|
}
|
|
12710
13704
|
function parseBaseParams(allParams, inputField) {
|
|
@@ -12719,7 +13713,7 @@ function parseBaseParams(allParams, inputField) {
|
|
|
12719
13713
|
const input = params[inputField];
|
|
12720
13714
|
const paramsRest = { ...params, provider: "openai" };
|
|
12721
13715
|
delete paramsRest[inputField];
|
|
12722
|
-
return
|
|
13716
|
+
return mergeDicts(ret, { event: { input, metadata: paramsRest } });
|
|
12723
13717
|
}
|
|
12724
13718
|
function createApiWrapper(name, create, processResponse, parseParams) {
|
|
12725
13719
|
return async (allParams, options) => {
|
|
@@ -12734,11 +13728,11 @@ function createApiWrapper(name, create, processResponse, parseParams) {
|
|
|
12734
13728
|
processResponse(result, span);
|
|
12735
13729
|
return result;
|
|
12736
13730
|
},
|
|
12737
|
-
|
|
13731
|
+
mergeDicts(
|
|
12738
13732
|
{
|
|
12739
13733
|
name,
|
|
12740
13734
|
spanAttributes: {
|
|
12741
|
-
type:
|
|
13735
|
+
type: "llm" /* LLM */
|
|
12742
13736
|
}
|
|
12743
13737
|
},
|
|
12744
13738
|
parseParams(allParams)
|
|
@@ -12876,9 +13870,6 @@ var WrapperStream = class {
|
|
|
12876
13870
|
}
|
|
12877
13871
|
};
|
|
12878
13872
|
|
|
12879
|
-
// src/wrappers/ai-sdk-v2.ts
|
|
12880
|
-
import { SpanTypeAttribute as SpanTypeAttribute4 } from "@braintrust/core";
|
|
12881
|
-
|
|
12882
13873
|
// src/wrappers/anthropic-tokens-util.ts
|
|
12883
13874
|
function finalizeAnthropicTokens(metrics) {
|
|
12884
13875
|
const prompt_tokens = (metrics.prompt_tokens || 0) + (metrics.prompt_cached_tokens || 0) + (metrics.prompt_cache_creation_tokens || 0);
|
|
@@ -12899,7 +13890,7 @@ function extractAnthropicCacheTokens(cacheReadTokens = 0, cacheCreationTokens =
|
|
|
12899
13890
|
return cacheTokens;
|
|
12900
13891
|
}
|
|
12901
13892
|
|
|
12902
|
-
// src/wrappers/ai-sdk-
|
|
13893
|
+
// src/wrappers/ai-sdk-shared.ts
|
|
12903
13894
|
function detectProviderFromResult(result) {
|
|
12904
13895
|
if (!result?.providerMetadata) {
|
|
12905
13896
|
return void 0;
|
|
@@ -12919,20 +13910,8 @@ function extractModelFromResult(result) {
|
|
|
12919
13910
|
function camelToSnake(str) {
|
|
12920
13911
|
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
12921
13912
|
}
|
|
12922
|
-
function extractModelParameters(params) {
|
|
13913
|
+
function extractModelParameters(params, excludeKeys) {
|
|
12923
13914
|
const modelParams = {};
|
|
12924
|
-
const excludeKeys = /* @__PURE__ */ new Set([
|
|
12925
|
-
"prompt",
|
|
12926
|
-
// Already captured as input
|
|
12927
|
-
"system",
|
|
12928
|
-
// Already captured as input
|
|
12929
|
-
"messages",
|
|
12930
|
-
// Already captured as input
|
|
12931
|
-
"model",
|
|
12932
|
-
// Already captured in metadata.model
|
|
12933
|
-
"providerOptions"
|
|
12934
|
-
// Internal AI SDK configuration
|
|
12935
|
-
]);
|
|
12936
13915
|
for (const [key, value] of Object.entries(params)) {
|
|
12937
13916
|
if (value !== void 0 && !excludeKeys.has(key)) {
|
|
12938
13917
|
const snakeKey = camelToSnake(key);
|
|
@@ -12988,18 +13967,128 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
12988
13967
|
}
|
|
12989
13968
|
return metrics;
|
|
12990
13969
|
}
|
|
13970
|
+
function normalizeFinishReason(reason) {
|
|
13971
|
+
if (typeof reason !== "string") return void 0;
|
|
13972
|
+
return reason.replace(/-/g, "_");
|
|
13973
|
+
}
|
|
13974
|
+
function extractToolCallsFromSteps(steps) {
|
|
13975
|
+
const toolCalls = [];
|
|
13976
|
+
if (!Array.isArray(steps)) return toolCalls;
|
|
13977
|
+
let idx = 0;
|
|
13978
|
+
for (const step of steps) {
|
|
13979
|
+
const blocks = step?.content;
|
|
13980
|
+
if (!Array.isArray(blocks)) continue;
|
|
13981
|
+
for (const block of blocks) {
|
|
13982
|
+
if (block && typeof block === "object" && block.type === "tool-call") {
|
|
13983
|
+
toolCalls.push({
|
|
13984
|
+
id: block.toolCallId,
|
|
13985
|
+
type: "function",
|
|
13986
|
+
index: idx++,
|
|
13987
|
+
function: {
|
|
13988
|
+
name: block.toolName,
|
|
13989
|
+
arguments: typeof block.input === "string" ? block.input : JSON.stringify(block.input ?? {})
|
|
13990
|
+
}
|
|
13991
|
+
});
|
|
13992
|
+
}
|
|
13993
|
+
}
|
|
13994
|
+
}
|
|
13995
|
+
return toolCalls;
|
|
13996
|
+
}
|
|
13997
|
+
function buildAssistantOutputWithToolCalls(result, toolCalls) {
|
|
13998
|
+
return [
|
|
13999
|
+
{
|
|
14000
|
+
index: 0,
|
|
14001
|
+
logprobs: null,
|
|
14002
|
+
finish_reason: normalizeFinishReason(result?.finishReason) ?? (toolCalls.length ? "tool_calls" : void 0),
|
|
14003
|
+
message: {
|
|
14004
|
+
role: "assistant",
|
|
14005
|
+
tool_calls: toolCalls.length > 0 ? toolCalls : void 0
|
|
14006
|
+
}
|
|
14007
|
+
}
|
|
14008
|
+
];
|
|
14009
|
+
}
|
|
14010
|
+
function extractToolCallsFromBlocks(blocks) {
|
|
14011
|
+
if (!Array.isArray(blocks)) return [];
|
|
14012
|
+
return extractToolCallsFromSteps([{ content: blocks }]);
|
|
14013
|
+
}
|
|
14014
|
+
function wrapTools(tools) {
|
|
14015
|
+
if (!tools) return tools;
|
|
14016
|
+
const inferName = (tool, fallback2) => tool && (tool.name || tool.toolName || tool.id) || fallback2;
|
|
14017
|
+
if (Array.isArray(tools)) {
|
|
14018
|
+
const arr = tools;
|
|
14019
|
+
const out = arr.map((tool, idx) => {
|
|
14020
|
+
if (tool != null && typeof tool === "object" && "execute" in tool && typeof tool.execute === "function") {
|
|
14021
|
+
const name = inferName(tool, `tool[${idx}]`);
|
|
14022
|
+
return {
|
|
14023
|
+
...tool,
|
|
14024
|
+
execute: wrapTraced(tool.execute.bind(tool), {
|
|
14025
|
+
name,
|
|
14026
|
+
type: "tool"
|
|
14027
|
+
})
|
|
14028
|
+
};
|
|
14029
|
+
}
|
|
14030
|
+
return tool;
|
|
14031
|
+
});
|
|
14032
|
+
return out;
|
|
14033
|
+
}
|
|
14034
|
+
const wrappedTools = {};
|
|
14035
|
+
for (const [key, tool] of Object.entries(tools)) {
|
|
14036
|
+
if (tool != null && typeof tool === "object" && "execute" in tool && typeof tool.execute === "function") {
|
|
14037
|
+
wrappedTools[key] = {
|
|
14038
|
+
...tool,
|
|
14039
|
+
execute: wrapTraced(tool.execute.bind(tool), {
|
|
14040
|
+
name: key,
|
|
14041
|
+
type: "tool"
|
|
14042
|
+
})
|
|
14043
|
+
};
|
|
14044
|
+
} else {
|
|
14045
|
+
wrappedTools[key] = tool;
|
|
14046
|
+
}
|
|
14047
|
+
}
|
|
14048
|
+
return wrappedTools;
|
|
14049
|
+
}
|
|
14050
|
+
function extractInput(params) {
|
|
14051
|
+
return params?.prompt ?? params?.messages ?? params?.system;
|
|
14052
|
+
}
|
|
14053
|
+
function wrapStreamObject(iterable, onFirst) {
|
|
14054
|
+
let sawFirst = false;
|
|
14055
|
+
async function* wrapStream() {
|
|
14056
|
+
for await (const chunk of iterable) {
|
|
14057
|
+
if (!sawFirst) {
|
|
14058
|
+
sawFirst = true;
|
|
14059
|
+
onFirst();
|
|
14060
|
+
}
|
|
14061
|
+
yield chunk;
|
|
14062
|
+
}
|
|
14063
|
+
}
|
|
14064
|
+
return wrapStream();
|
|
14065
|
+
}
|
|
14066
|
+
|
|
14067
|
+
// src/wrappers/ai-sdk-v2.ts
|
|
14068
|
+
var V2_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
14069
|
+
"prompt",
|
|
14070
|
+
// Already captured as input
|
|
14071
|
+
"system",
|
|
14072
|
+
// Already captured as input
|
|
14073
|
+
"messages",
|
|
14074
|
+
// Already captured as input
|
|
14075
|
+
"model",
|
|
14076
|
+
// Already captured in metadata.model
|
|
14077
|
+
"providerOptions"
|
|
14078
|
+
// Internal AI SDK configuration
|
|
14079
|
+
]);
|
|
12991
14080
|
function BraintrustMiddleware(config = {}) {
|
|
12992
14081
|
return {
|
|
12993
14082
|
wrapGenerate: async ({ doGenerate, params }) => {
|
|
12994
14083
|
const spanArgs = {
|
|
12995
14084
|
name: "ai-sdk.generateText",
|
|
12996
14085
|
spanAttributes: {
|
|
12997
|
-
type:
|
|
14086
|
+
type: "llm" /* LLM */
|
|
12998
14087
|
},
|
|
12999
14088
|
event: {
|
|
13000
14089
|
input: params.prompt,
|
|
13001
14090
|
metadata: {
|
|
13002
|
-
...extractModelParameters(params)
|
|
14091
|
+
...extractModelParameters(params, V2_EXCLUDE_KEYS)
|
|
13003
14092
|
}
|
|
13004
14093
|
}
|
|
13005
14094
|
};
|
|
@@ -13018,8 +14107,12 @@ function BraintrustMiddleware(config = {}) {
|
|
|
13018
14107
|
if (model !== void 0) {
|
|
13019
14108
|
metadata.model = model;
|
|
13020
14109
|
}
|
|
14110
|
+
let toolCalls = extractToolCallsFromSteps(result?.steps);
|
|
14111
|
+
if (!toolCalls || toolCalls.length === 0) {
|
|
14112
|
+
toolCalls = extractToolCallsFromBlocks(result?.content);
|
|
14113
|
+
}
|
|
13021
14114
|
span.log({
|
|
13022
|
-
output: result
|
|
14115
|
+
output: toolCalls.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls) : result?.content,
|
|
13023
14116
|
metadata,
|
|
13024
14117
|
metrics: normalizeUsageMetrics(
|
|
13025
14118
|
result.usage,
|
|
@@ -13041,12 +14134,12 @@ function BraintrustMiddleware(config = {}) {
|
|
|
13041
14134
|
const spanArgs = {
|
|
13042
14135
|
name: "ai-sdk.streamText",
|
|
13043
14136
|
spanAttributes: {
|
|
13044
|
-
type:
|
|
14137
|
+
type: "llm" /* LLM */
|
|
13045
14138
|
},
|
|
13046
14139
|
event: {
|
|
13047
14140
|
input: params.prompt,
|
|
13048
14141
|
metadata: {
|
|
13049
|
-
...extractModelParameters(params)
|
|
14142
|
+
...extractModelParameters(params, V2_EXCLUDE_KEYS)
|
|
13050
14143
|
}
|
|
13051
14144
|
}
|
|
13052
14145
|
};
|
|
@@ -13054,6 +14147,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
13054
14147
|
try {
|
|
13055
14148
|
const { stream, ...rest } = await doStream();
|
|
13056
14149
|
const textChunks = [];
|
|
14150
|
+
const toolBlocks = [];
|
|
13057
14151
|
let finalUsage = {};
|
|
13058
14152
|
let finalFinishReason = void 0;
|
|
13059
14153
|
let providerMetadata = {};
|
|
@@ -13064,6 +14158,9 @@ function BraintrustMiddleware(config = {}) {
|
|
|
13064
14158
|
if (chunk.type === "text-delta" && chunk.delta) {
|
|
13065
14159
|
textChunks.push(chunk.delta);
|
|
13066
14160
|
}
|
|
14161
|
+
if (chunk.type === "tool-call" || chunk.type === "tool-result") {
|
|
14162
|
+
toolBlocks.push(chunk);
|
|
14163
|
+
}
|
|
13067
14164
|
if (chunk.type === "finish") {
|
|
13068
14165
|
finalFinishReason = chunk.finishReason;
|
|
13069
14166
|
finalUsage = chunk.usage || {};
|
|
@@ -13081,11 +14178,12 @@ function BraintrustMiddleware(config = {}) {
|
|
|
13081
14178
|
flush() {
|
|
13082
14179
|
try {
|
|
13083
14180
|
const generatedText = textChunks.join("");
|
|
13084
|
-
|
|
14181
|
+
let output = generatedText ? [{ type: "text", text: generatedText }] : [];
|
|
13085
14182
|
const resultForDetection = {
|
|
13086
14183
|
providerMetadata,
|
|
13087
14184
|
response: rest.response,
|
|
13088
|
-
...rest
|
|
14185
|
+
...rest,
|
|
14186
|
+
finishReason: finalFinishReason
|
|
13089
14187
|
};
|
|
13090
14188
|
const metadata = {};
|
|
13091
14189
|
const provider = detectProviderFromResult(resultForDetection);
|
|
@@ -13099,6 +14197,17 @@ function BraintrustMiddleware(config = {}) {
|
|
|
13099
14197
|
if (model !== void 0) {
|
|
13100
14198
|
metadata.model = model;
|
|
13101
14199
|
}
|
|
14200
|
+
if (toolBlocks.length > 0) {
|
|
14201
|
+
const toolCalls = extractToolCallsFromSteps([
|
|
14202
|
+
{ content: toolBlocks }
|
|
14203
|
+
]);
|
|
14204
|
+
if (toolCalls.length > 0) {
|
|
14205
|
+
output = buildAssistantOutputWithToolCalls(
|
|
14206
|
+
resultForDetection,
|
|
14207
|
+
toolCalls
|
|
14208
|
+
);
|
|
14209
|
+
}
|
|
14210
|
+
}
|
|
13102
14211
|
span.log({
|
|
13103
14212
|
output,
|
|
13104
14213
|
metadata,
|
|
@@ -13408,8 +14517,245 @@ function postProcessOutput(text, toolCalls, finishReason) {
|
|
|
13408
14517
|
];
|
|
13409
14518
|
}
|
|
13410
14519
|
|
|
14520
|
+
// src/wrappers/ai-sdk-v3.ts
|
|
14521
|
+
var V3_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
14522
|
+
"prompt",
|
|
14523
|
+
// Already captured as input
|
|
14524
|
+
"system",
|
|
14525
|
+
// Already captured as input
|
|
14526
|
+
"messages",
|
|
14527
|
+
// Already captured as input
|
|
14528
|
+
"model",
|
|
14529
|
+
// Already captured in metadata.model
|
|
14530
|
+
"providerOptions",
|
|
14531
|
+
// Internal AI SDK configuration
|
|
14532
|
+
"tools"
|
|
14533
|
+
// Already captured in metadata.tools
|
|
14534
|
+
]);
|
|
14535
|
+
function wrapAISDK(ai) {
|
|
14536
|
+
const {
|
|
14537
|
+
wrapLanguageModel,
|
|
14538
|
+
generateText,
|
|
14539
|
+
streamText,
|
|
14540
|
+
generateObject,
|
|
14541
|
+
streamObject
|
|
14542
|
+
} = ai;
|
|
14543
|
+
const wrappedGenerateText = (params) => {
|
|
14544
|
+
return traced(
|
|
14545
|
+
async (span) => {
|
|
14546
|
+
const wrappedModel = wrapLanguageModel({
|
|
14547
|
+
model: params.model,
|
|
14548
|
+
middleware: BraintrustMiddleware()
|
|
14549
|
+
});
|
|
14550
|
+
const result = await generateText({
|
|
14551
|
+
...params,
|
|
14552
|
+
tools: params.tools ? wrapTools(params.tools) : void 0,
|
|
14553
|
+
model: wrappedModel
|
|
14554
|
+
});
|
|
14555
|
+
const provider = detectProviderFromResult(result);
|
|
14556
|
+
const model = extractModelFromResult(result);
|
|
14557
|
+
const finishReason = normalizeFinishReason(result?.finishReason);
|
|
14558
|
+
span.log({
|
|
14559
|
+
input: extractInput(params),
|
|
14560
|
+
output: result.text,
|
|
14561
|
+
metadata: {
|
|
14562
|
+
...extractModelParameters(params, V3_EXCLUDE_KEYS),
|
|
14563
|
+
...provider ? { provider } : {},
|
|
14564
|
+
...model ? { model } : {},
|
|
14565
|
+
...finishReason ? { finish_reason: finishReason } : {}
|
|
14566
|
+
}
|
|
14567
|
+
});
|
|
14568
|
+
return result;
|
|
14569
|
+
},
|
|
14570
|
+
{
|
|
14571
|
+
name: "ai-sdk.generateText"
|
|
14572
|
+
}
|
|
14573
|
+
);
|
|
14574
|
+
};
|
|
14575
|
+
const wrappedGenerateObject = (params) => {
|
|
14576
|
+
return traced(
|
|
14577
|
+
async (span) => {
|
|
14578
|
+
const wrappedModel = wrapLanguageModel({
|
|
14579
|
+
model: params.model,
|
|
14580
|
+
middleware: BraintrustMiddleware()
|
|
14581
|
+
});
|
|
14582
|
+
const result = await generateObject({
|
|
14583
|
+
...params,
|
|
14584
|
+
tools: params.tools ? wrapTools(params.tools) : void 0,
|
|
14585
|
+
model: wrappedModel
|
|
14586
|
+
});
|
|
14587
|
+
const provider = detectProviderFromResult(result);
|
|
14588
|
+
const model = extractModelFromResult(result);
|
|
14589
|
+
const finishReason = normalizeFinishReason(result.finishReason);
|
|
14590
|
+
span.log({
|
|
14591
|
+
input: extractInput(params),
|
|
14592
|
+
output: result.object,
|
|
14593
|
+
metadata: {
|
|
14594
|
+
...extractModelParameters(params, V3_EXCLUDE_KEYS),
|
|
14595
|
+
...provider ? { provider } : {},
|
|
14596
|
+
...model ? { model } : {},
|
|
14597
|
+
...finishReason ? { finish_reason: finishReason } : {}
|
|
14598
|
+
}
|
|
14599
|
+
});
|
|
14600
|
+
return result;
|
|
14601
|
+
},
|
|
14602
|
+
{
|
|
14603
|
+
name: "ai-sdk.generateObject"
|
|
14604
|
+
}
|
|
14605
|
+
);
|
|
14606
|
+
};
|
|
14607
|
+
const wrappedStreamText = (params) => {
|
|
14608
|
+
const span = startSpan({
|
|
14609
|
+
name: "ai-sdk.streamText",
|
|
14610
|
+
event: {
|
|
14611
|
+
input: extractInput(params),
|
|
14612
|
+
metadata: extractModelParameters(params, V3_EXCLUDE_KEYS)
|
|
14613
|
+
}
|
|
14614
|
+
});
|
|
14615
|
+
const userOnFinish = params.onFinish;
|
|
14616
|
+
const userOnError = params.onError;
|
|
14617
|
+
const userOnChunk = params.onChunk;
|
|
14618
|
+
try {
|
|
14619
|
+
const wrappedModel = wrapLanguageModel({
|
|
14620
|
+
model: params.model,
|
|
14621
|
+
middleware: BraintrustMiddleware()
|
|
14622
|
+
});
|
|
14623
|
+
const startTime = Date.now();
|
|
14624
|
+
let receivedFirst = false;
|
|
14625
|
+
const result = withCurrent(
|
|
14626
|
+
span,
|
|
14627
|
+
() => streamText({
|
|
14628
|
+
...params,
|
|
14629
|
+
tools: params.tools ? wrapTools(params.tools) : void 0,
|
|
14630
|
+
model: wrappedModel,
|
|
14631
|
+
onChunk: (chunk) => {
|
|
14632
|
+
if (!receivedFirst) {
|
|
14633
|
+
receivedFirst = true;
|
|
14634
|
+
span.log({
|
|
14635
|
+
metrics: {
|
|
14636
|
+
time_to_first_token: (Date.now() - startTime) / 1e3
|
|
14637
|
+
}
|
|
14638
|
+
});
|
|
14639
|
+
}
|
|
14640
|
+
if (typeof userOnChunk === "function") {
|
|
14641
|
+
userOnChunk(chunk);
|
|
14642
|
+
}
|
|
14643
|
+
},
|
|
14644
|
+
onFinish: async (event) => {
|
|
14645
|
+
if (typeof userOnFinish === "function") {
|
|
14646
|
+
await userOnFinish(event);
|
|
14647
|
+
}
|
|
14648
|
+
const provider = detectProviderFromResult(event);
|
|
14649
|
+
const model = extractModelFromResult(event);
|
|
14650
|
+
const finishReason = normalizeFinishReason(event?.finishReason);
|
|
14651
|
+
span.log({
|
|
14652
|
+
output: event?.text,
|
|
14653
|
+
metadata: {
|
|
14654
|
+
...extractModelParameters(params, V3_EXCLUDE_KEYS),
|
|
14655
|
+
...provider ? { provider } : {},
|
|
14656
|
+
...model ? { model } : {},
|
|
14657
|
+
...finishReason ? { finish_reason: finishReason } : {}
|
|
14658
|
+
}
|
|
14659
|
+
});
|
|
14660
|
+
span.end();
|
|
14661
|
+
},
|
|
14662
|
+
onError: async (err) => {
|
|
14663
|
+
if (typeof userOnError === "function") {
|
|
14664
|
+
await userOnError(err);
|
|
14665
|
+
}
|
|
14666
|
+
span.log({
|
|
14667
|
+
error: err instanceof Error ? err.message : String(err)
|
|
14668
|
+
});
|
|
14669
|
+
span.end();
|
|
14670
|
+
}
|
|
14671
|
+
})
|
|
14672
|
+
);
|
|
14673
|
+
return result;
|
|
14674
|
+
} catch (error2) {
|
|
14675
|
+
span.log({
|
|
14676
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
14677
|
+
});
|
|
14678
|
+
span.end();
|
|
14679
|
+
throw error2;
|
|
14680
|
+
}
|
|
14681
|
+
};
|
|
14682
|
+
const wrappedStreamObject = (params) => {
|
|
14683
|
+
const span = startSpan({
|
|
14684
|
+
name: "ai-sdk.streamObject",
|
|
14685
|
+
event: {
|
|
14686
|
+
input: extractInput(params),
|
|
14687
|
+
metadata: extractModelParameters(params, V3_EXCLUDE_KEYS)
|
|
14688
|
+
}
|
|
14689
|
+
});
|
|
14690
|
+
const userOnFinish = params.onFinish;
|
|
14691
|
+
const userOnError = params.onError;
|
|
14692
|
+
try {
|
|
14693
|
+
const wrappedModel = wrapLanguageModel({
|
|
14694
|
+
model: params.model,
|
|
14695
|
+
middleware: BraintrustMiddleware()
|
|
14696
|
+
});
|
|
14697
|
+
const startTime = Date.now();
|
|
14698
|
+
const result = withCurrent(
|
|
14699
|
+
span,
|
|
14700
|
+
() => streamObject({
|
|
14701
|
+
...params,
|
|
14702
|
+
tools: params.tools ? wrapTools(params.tools) : void 0,
|
|
14703
|
+
model: wrappedModel,
|
|
14704
|
+
onFinish: async (event) => {
|
|
14705
|
+
if (typeof userOnFinish === "function") {
|
|
14706
|
+
await userOnFinish(event);
|
|
14707
|
+
}
|
|
14708
|
+
const provider = detectProviderFromResult(event);
|
|
14709
|
+
const model = extractModelFromResult(event);
|
|
14710
|
+
const finishReason = normalizeFinishReason(event?.finishReason);
|
|
14711
|
+
span.log({
|
|
14712
|
+
output: event?.object,
|
|
14713
|
+
metadata: {
|
|
14714
|
+
...extractModelParameters(params, V3_EXCLUDE_KEYS),
|
|
14715
|
+
...provider ? { provider } : {},
|
|
14716
|
+
...model ? { model } : {},
|
|
14717
|
+
...finishReason ? { finish_reason: finishReason } : {}
|
|
14718
|
+
}
|
|
14719
|
+
});
|
|
14720
|
+
span.end();
|
|
14721
|
+
},
|
|
14722
|
+
onError: async (err) => {
|
|
14723
|
+
if (typeof userOnError === "function") {
|
|
14724
|
+
await userOnError(err);
|
|
14725
|
+
}
|
|
14726
|
+
span.log({
|
|
14727
|
+
error: err instanceof Error ? err.message : String(err)
|
|
14728
|
+
});
|
|
14729
|
+
span.end();
|
|
14730
|
+
}
|
|
14731
|
+
})
|
|
14732
|
+
);
|
|
14733
|
+
const wrapStream = wrapStreamObject(result.partialObjectStream, () => {
|
|
14734
|
+
span.log({
|
|
14735
|
+
metrics: { time_to_first_token: (Date.now() - startTime) / 1e3 }
|
|
14736
|
+
});
|
|
14737
|
+
});
|
|
14738
|
+
return {
|
|
14739
|
+
...result,
|
|
14740
|
+
partialObjectStream: wrapStream
|
|
14741
|
+
};
|
|
14742
|
+
} catch (error2) {
|
|
14743
|
+
span.log({
|
|
14744
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
14745
|
+
});
|
|
14746
|
+
span.end();
|
|
14747
|
+
throw error2;
|
|
14748
|
+
}
|
|
14749
|
+
};
|
|
14750
|
+
return {
|
|
14751
|
+
generateText: wrappedGenerateText,
|
|
14752
|
+
generateObject: wrappedGenerateObject,
|
|
14753
|
+
streamText: wrappedStreamText,
|
|
14754
|
+
streamObject: wrappedStreamObject
|
|
14755
|
+
};
|
|
14756
|
+
}
|
|
14757
|
+
|
|
13411
14758
|
// src/wrappers/anthropic.ts
|
|
13412
|
-
import { SpanTypeAttribute as SpanTypeAttribute5 } from "@braintrust/core";
|
|
13413
14759
|
function wrapAnthropic(anthropic) {
|
|
13414
14760
|
const au = anthropic;
|
|
13415
14761
|
if (au && typeof au === "object" && "messages" in au && typeof au.messages === "object" && au.messages && "create" in au.messages) {
|
|
@@ -13467,7 +14813,7 @@ function createProxy(create) {
|
|
|
13467
14813
|
const spanArgs = {
|
|
13468
14814
|
name: "anthropic.messages.create",
|
|
13469
14815
|
spanAttributes: {
|
|
13470
|
-
type:
|
|
14816
|
+
type: "llm" /* LLM */
|
|
13471
14817
|
},
|
|
13472
14818
|
event: {
|
|
13473
14819
|
input,
|
|
@@ -13811,6 +15157,15 @@ var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
|
|
|
13811
15157
|
if (!span.instrumentationScope && span.instrumentationLibrary) {
|
|
13812
15158
|
span.instrumentationScope = span.instrumentationLibrary;
|
|
13813
15159
|
}
|
|
15160
|
+
if (!span.parentSpanContext && span.parentSpanId) {
|
|
15161
|
+
const spanContext = span.spanContext?.();
|
|
15162
|
+
if (spanContext?.traceId) {
|
|
15163
|
+
span.parentSpanContext = {
|
|
15164
|
+
spanId: span.parentSpanId,
|
|
15165
|
+
traceId: spanContext.traceId
|
|
15166
|
+
};
|
|
15167
|
+
}
|
|
15168
|
+
}
|
|
13814
15169
|
return span;
|
|
13815
15170
|
});
|
|
13816
15171
|
return Reflect.apply(target.export, target, [
|
|
@@ -13901,44 +15256,44 @@ var BraintrustExporter = class _BraintrustExporter {
|
|
|
13901
15256
|
};
|
|
13902
15257
|
|
|
13903
15258
|
// dev/types.ts
|
|
13904
|
-
import { z as
|
|
13905
|
-
var evalBodySchema =
|
|
13906
|
-
name:
|
|
13907
|
-
parameters:
|
|
15259
|
+
import { z as z10 } from "zod/v3";
|
|
15260
|
+
var evalBodySchema = z10.object({
|
|
15261
|
+
name: z10.string(),
|
|
15262
|
+
parameters: z10.record(z10.string(), z10.unknown()).nullish(),
|
|
13908
15263
|
data: RunEval.shape.data,
|
|
13909
|
-
scores:
|
|
13910
|
-
|
|
15264
|
+
scores: z10.array(
|
|
15265
|
+
z10.object({
|
|
13911
15266
|
function_id: FunctionId,
|
|
13912
|
-
name:
|
|
15267
|
+
name: z10.string()
|
|
13913
15268
|
})
|
|
13914
15269
|
).nullish(),
|
|
13915
|
-
experiment_name:
|
|
13916
|
-
project_id:
|
|
15270
|
+
experiment_name: z10.string().nullish(),
|
|
15271
|
+
project_id: z10.string().nullish(),
|
|
13917
15272
|
parent: InvokeParent.optional(),
|
|
13918
|
-
stream:
|
|
15273
|
+
stream: z10.boolean().optional()
|
|
13919
15274
|
});
|
|
13920
|
-
var evalParametersSerializedSchema =
|
|
13921
|
-
|
|
13922
|
-
|
|
13923
|
-
|
|
13924
|
-
type:
|
|
15275
|
+
var evalParametersSerializedSchema = z10.record(
|
|
15276
|
+
z10.string(),
|
|
15277
|
+
z10.union([
|
|
15278
|
+
z10.object({
|
|
15279
|
+
type: z10.literal("prompt"),
|
|
13925
15280
|
default: PromptData.optional(),
|
|
13926
|
-
description:
|
|
15281
|
+
description: z10.string().optional()
|
|
13927
15282
|
}),
|
|
13928
|
-
|
|
13929
|
-
type:
|
|
13930
|
-
schema:
|
|
15283
|
+
z10.object({
|
|
15284
|
+
type: z10.literal("data"),
|
|
15285
|
+
schema: z10.record(z10.unknown()),
|
|
13931
15286
|
// JSON Schema
|
|
13932
|
-
default:
|
|
13933
|
-
description:
|
|
15287
|
+
default: z10.unknown().optional(),
|
|
15288
|
+
description: z10.string().optional()
|
|
13934
15289
|
})
|
|
13935
15290
|
])
|
|
13936
15291
|
);
|
|
13937
|
-
var evaluatorDefinitionSchema =
|
|
15292
|
+
var evaluatorDefinitionSchema = z10.object({
|
|
13938
15293
|
parameters: evalParametersSerializedSchema.optional()
|
|
13939
15294
|
});
|
|
13940
|
-
var evaluatorDefinitionsSchema =
|
|
13941
|
-
|
|
15295
|
+
var evaluatorDefinitionsSchema = z10.record(
|
|
15296
|
+
z10.string(),
|
|
13942
15297
|
evaluatorDefinitionSchema
|
|
13943
15298
|
);
|
|
13944
15299
|
|
|
@@ -14039,6 +15394,7 @@ export {
|
|
|
14039
15394
|
withExperiment,
|
|
14040
15395
|
withLogger,
|
|
14041
15396
|
withParent,
|
|
15397
|
+
wrapAISDK,
|
|
14042
15398
|
wrapAISDKModel,
|
|
14043
15399
|
wrapAnthropic,
|
|
14044
15400
|
wrapOpenAI,
|