braintrust 0.0.136 → 0.0.138
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/dist/browser.js +1867 -259
- package/dist/cli.js +11041 -7493
- package/dist/framework.d.ts +11 -2
- package/dist/gitutil.d.ts +12 -2
- package/dist/index.js +12299 -8744
- package/dist/logger.d.ts +78 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -3
package/dist/browser.js
CHANGED
|
@@ -31,8 +31,8 @@ var require_zod_is_type = __commonJS({
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.isAnyZodType = exports.isZodType = void 0;
|
|
33
33
|
function isZodType(schema, typeName) {
|
|
34
|
-
var
|
|
35
|
-
return ((
|
|
34
|
+
var _a3;
|
|
35
|
+
return ((_a3 = schema === null || schema === void 0 ? void 0 : schema._def) === null || _a3 === void 0 ? void 0 : _a3.typeName) === typeName;
|
|
36
36
|
}
|
|
37
37
|
exports.isZodType = isZodType;
|
|
38
38
|
function isAnyZodType(schema) {
|
|
@@ -69,15 +69,15 @@ var require_zod_extensions = __commonJS({
|
|
|
69
69
|
return result;
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function extendZodWithOpenApi5(zod) {
|
|
73
73
|
if (typeof zod.ZodType.prototype.openapi !== "undefined") {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
zod.ZodType.prototype.openapi = function(refOrOpenapi, metadata) {
|
|
77
|
-
var
|
|
77
|
+
var _a3, _b, _c, _d, _e, _f;
|
|
78
78
|
const openapi = typeof refOrOpenapi === "string" ? metadata : refOrOpenapi;
|
|
79
79
|
const _g = openapi !== null && openapi !== void 0 ? openapi : {}, { param } = _g, restOfOpenApi = __rest(_g, ["param"]);
|
|
80
|
-
const _internal = Object.assign(Object.assign({}, (
|
|
80
|
+
const _internal = Object.assign(Object.assign({}, (_a3 = this._def.openapi) === null || _a3 === void 0 ? void 0 : _a3._internal), typeof refOrOpenapi === "string" ? { refId: refOrOpenapi } : void 0);
|
|
81
81
|
const resultMetadata = Object.assign(Object.assign(Object.assign({}, (_b = this._def.openapi) === null || _b === void 0 ? void 0 : _b.metadata), restOfOpenApi), ((_d = (_c = this._def.openapi) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.param) || param ? {
|
|
82
82
|
param: Object.assign(Object.assign({}, (_f = (_e = this._def.openapi) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f.param), param)
|
|
83
83
|
} : void 0);
|
|
@@ -85,11 +85,11 @@ var require_zod_extensions = __commonJS({
|
|
|
85
85
|
if ((0, zod_is_type_1.isZodType)(this, "ZodObject")) {
|
|
86
86
|
const originalExtend = this.extend;
|
|
87
87
|
result.extend = function(...args) {
|
|
88
|
-
var
|
|
88
|
+
var _a4, _b2, _c2, _d2, _e2, _f2;
|
|
89
89
|
const extendedResult = originalExtend.apply(this, args);
|
|
90
90
|
extendedResult._def.openapi = {
|
|
91
91
|
_internal: {
|
|
92
|
-
extendedFrom: ((_b2 = (
|
|
92
|
+
extendedFrom: ((_b2 = (_a4 = this._def.openapi) === null || _a4 === void 0 ? void 0 : _a4._internal) === null || _b2 === void 0 ? void 0 : _b2.refId) ? { refId: (_d2 = (_c2 = this._def.openapi) === null || _c2 === void 0 ? void 0 : _c2._internal) === null || _d2 === void 0 ? void 0 : _d2.refId, schema: this } : (_e2 = this._def.openapi) === null || _e2 === void 0 ? void 0 : _e2._internal.extendedFrom
|
|
93
93
|
},
|
|
94
94
|
metadata: (_f2 = extendedResult._def.openapi) === null || _f2 === void 0 ? void 0 : _f2.metadata
|
|
95
95
|
};
|
|
@@ -109,8 +109,8 @@ var require_zod_extensions = __commonJS({
|
|
|
109
109
|
const result = zodDeepPartial.apply(this);
|
|
110
110
|
const resultShape = result._def.shape();
|
|
111
111
|
Object.entries(resultShape).forEach(([key, value]) => {
|
|
112
|
-
var
|
|
113
|
-
value._def.openapi = (_b = (
|
|
112
|
+
var _a3, _b;
|
|
113
|
+
value._def.openapi = (_b = (_a3 = initialShape[key]) === null || _a3 === void 0 ? void 0 : _a3._def) === null || _b === void 0 ? void 0 : _b.openapi;
|
|
114
114
|
});
|
|
115
115
|
result._def.openapi = void 0;
|
|
116
116
|
return result;
|
|
@@ -128,7 +128,7 @@ var require_zod_extensions = __commonJS({
|
|
|
128
128
|
return result;
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
exports.extendZodWithOpenApi =
|
|
131
|
+
exports.extendZodWithOpenApi = extendZodWithOpenApi5;
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
|
|
@@ -295,8 +295,8 @@ var require_openapi_metadata = __commonJS({
|
|
|
295
295
|
exports.getOpenApiMetadata = void 0;
|
|
296
296
|
var lodash_1 = require_lodash();
|
|
297
297
|
function getOpenApiMetadata(zodSchema) {
|
|
298
|
-
var
|
|
299
|
-
return (0, lodash_1.omitBy)((_b = (
|
|
298
|
+
var _a3, _b;
|
|
299
|
+
return (0, lodash_1.omitBy)((_b = (_a3 = zodSchema._def.openapi) === null || _a3 === void 0 ? void 0 : _a3.metadata) !== null && _b !== void 0 ? _b : {}, lodash_1.isNil);
|
|
300
300
|
}
|
|
301
301
|
exports.getOpenApiMetadata = getOpenApiMetadata;
|
|
302
302
|
}
|
|
@@ -314,8 +314,8 @@ var require_openapi_registry = __commonJS({
|
|
|
314
314
|
this._definitions = [];
|
|
315
315
|
}
|
|
316
316
|
get definitions() {
|
|
317
|
-
var
|
|
318
|
-
const parentDefinitions = (_b = (
|
|
317
|
+
var _a3, _b;
|
|
318
|
+
const parentDefinitions = (_b = (_a3 = this.parents) === null || _a3 === void 0 ? void 0 : _a3.flatMap((par) => par.definitions)) !== null && _b !== void 0 ? _b : [];
|
|
319
319
|
return [...parentDefinitions, ...this._definitions];
|
|
320
320
|
}
|
|
321
321
|
/**
|
|
@@ -330,9 +330,9 @@ var require_openapi_registry = __commonJS({
|
|
|
330
330
|
* Registers a new parameter schema under /components/parameters/${name}
|
|
331
331
|
*/
|
|
332
332
|
registerParameter(refId, zodSchema) {
|
|
333
|
-
var
|
|
333
|
+
var _a3, _b, _c;
|
|
334
334
|
const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);
|
|
335
|
-
const currentMetadata = (
|
|
335
|
+
const currentMetadata = (_a3 = schemaWithRefId._def.openapi) === null || _a3 === void 0 ? void 0 : _a3.metadata;
|
|
336
336
|
const schemaWithMetadata = schemaWithRefId.openapi(Object.assign(Object.assign({}, currentMetadata), { param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param), { name: (_c = (_b = currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : refId }) }));
|
|
337
337
|
this._definitions.push({
|
|
338
338
|
type: "parameter",
|
|
@@ -485,14 +485,14 @@ var require_openapi_generator = __commonJS({
|
|
|
485
485
|
};
|
|
486
486
|
}
|
|
487
487
|
buildComponents() {
|
|
488
|
-
var
|
|
488
|
+
var _a3, _b;
|
|
489
489
|
const rawComponents = {};
|
|
490
490
|
this.rawComponents.forEach(({ componentType, name, component }) => {
|
|
491
|
-
var
|
|
492
|
-
(
|
|
491
|
+
var _a4;
|
|
492
|
+
(_a4 = rawComponents[componentType]) !== null && _a4 !== void 0 ? _a4 : rawComponents[componentType] = {};
|
|
493
493
|
rawComponents[componentType][name] = component;
|
|
494
494
|
});
|
|
495
|
-
return Object.assign(Object.assign({}, rawComponents), { schemas: Object.assign(Object.assign({}, (
|
|
495
|
+
return Object.assign(Object.assign({}, rawComponents), { schemas: Object.assign(Object.assign({}, (_a3 = rawComponents.schemas) !== null && _a3 !== void 0 ? _a3 : {}), this.schemaRefs), parameters: Object.assign(Object.assign({}, (_b = rawComponents.parameters) !== null && _b !== void 0 ? _b : {}), this.paramRefs) });
|
|
496
496
|
}
|
|
497
497
|
sortDefinitions() {
|
|
498
498
|
const generationOrder = [
|
|
@@ -545,8 +545,8 @@ var require_openapi_generator = __commonJS({
|
|
|
545
545
|
return result;
|
|
546
546
|
}
|
|
547
547
|
getParameterRef(schemaMetadata, external) {
|
|
548
|
-
var
|
|
549
|
-
const parameterMetadata = (
|
|
548
|
+
var _a3, _b, _c, _d, _e;
|
|
549
|
+
const parameterMetadata = (_a3 = schemaMetadata === null || schemaMetadata === void 0 ? void 0 : schemaMetadata.metadata) === null || _a3 === void 0 ? void 0 : _a3.param;
|
|
550
550
|
const existingRef = ((_b = schemaMetadata === null || schemaMetadata === void 0 ? void 0 : schemaMetadata._internal) === null || _b === void 0 ? void 0 : _b.refId) ? this.paramRefs[(_c = schemaMetadata._internal) === null || _c === void 0 ? void 0 : _c.refId] : void 0;
|
|
551
551
|
if (!((_d = schemaMetadata === null || schemaMetadata === void 0 ? void 0 : schemaMetadata._internal) === null || _d === void 0 ? void 0 : _d.refId) || !existingRef) {
|
|
552
552
|
return void 0;
|
|
@@ -576,9 +576,9 @@ var require_openapi_generator = __commonJS({
|
|
|
576
576
|
};
|
|
577
577
|
}
|
|
578
578
|
generateInlineParameters(zodSchema, location) {
|
|
579
|
-
var
|
|
579
|
+
var _a3;
|
|
580
580
|
const metadata = this.getMetadata(zodSchema);
|
|
581
|
-
const parameterMetadata = (
|
|
581
|
+
const parameterMetadata = (_a3 = metadata === null || metadata === void 0 ? void 0 : metadata.metadata) === null || _a3 === void 0 ? void 0 : _a3.param;
|
|
582
582
|
const referencedSchema = this.getParameterRef(metadata, { in: location });
|
|
583
583
|
if (referencedSchema) {
|
|
584
584
|
return [referencedSchema];
|
|
@@ -586,7 +586,7 @@ var require_openapi_generator = __commonJS({
|
|
|
586
586
|
if ((0, zod_is_type_1.isZodType)(zodSchema, "ZodObject")) {
|
|
587
587
|
const propTypes = zodSchema._def.shape();
|
|
588
588
|
const parameters = Object.entries(propTypes).map(([key, schema]) => {
|
|
589
|
-
var
|
|
589
|
+
var _a4, _b;
|
|
590
590
|
const innerMetadata = this.getMetadata(schema);
|
|
591
591
|
const referencedSchema2 = this.getParameterRef(innerMetadata, {
|
|
592
592
|
in: location,
|
|
@@ -595,7 +595,7 @@ var require_openapi_generator = __commonJS({
|
|
|
595
595
|
if (referencedSchema2) {
|
|
596
596
|
return referencedSchema2;
|
|
597
597
|
}
|
|
598
|
-
const innerParameterMetadata = (
|
|
598
|
+
const innerParameterMetadata = (_a4 = innerMetadata === null || innerMetadata === void 0 ? void 0 : innerMetadata.metadata) === null || _a4 === void 0 ? void 0 : _a4.param;
|
|
599
599
|
if ((innerParameterMetadata === null || innerParameterMetadata === void 0 ? void 0 : innerParameterMetadata.name) && innerParameterMetadata.name !== key) {
|
|
600
600
|
throw new errors_1.ConflictError(`Conflicting names for parameter`, {
|
|
601
601
|
key: "name",
|
|
@@ -623,9 +623,9 @@ var require_openapi_generator = __commonJS({
|
|
|
623
623
|
];
|
|
624
624
|
}
|
|
625
625
|
generateSimpleParameter(zodSchema) {
|
|
626
|
-
var
|
|
626
|
+
var _a3;
|
|
627
627
|
const metadata = this.getParamMetadata(zodSchema);
|
|
628
|
-
const paramMetadata = (
|
|
628
|
+
const paramMetadata = (_a3 = metadata === null || metadata === void 0 ? void 0 : metadata.metadata) === null || _a3 === void 0 ? void 0 : _a3.param;
|
|
629
629
|
const required = !this.isOptionalSchema(zodSchema) && !zodSchema.isNullable();
|
|
630
630
|
const schema = this.generateSchemaWithRef(zodSchema);
|
|
631
631
|
return Object.assign({
|
|
@@ -634,9 +634,9 @@ var require_openapi_generator = __commonJS({
|
|
|
634
634
|
}, paramMetadata ? this.buildParameterMetadata(paramMetadata) : {});
|
|
635
635
|
}
|
|
636
636
|
generateParameter(zodSchema) {
|
|
637
|
-
var
|
|
637
|
+
var _a3;
|
|
638
638
|
const metadata = this.getMetadata(zodSchema);
|
|
639
|
-
const paramMetadata = (
|
|
639
|
+
const paramMetadata = (_a3 = metadata === null || metadata === void 0 ? void 0 : metadata.metadata) === null || _a3 === void 0 ? void 0 : _a3.param;
|
|
640
640
|
const paramName = paramMetadata === null || paramMetadata === void 0 ? void 0 : paramMetadata.name;
|
|
641
641
|
const paramLocation = paramMetadata === null || paramMetadata === void 0 ? void 0 : paramMetadata.in;
|
|
642
642
|
if (!paramName) {
|
|
@@ -652,18 +652,18 @@ var require_openapi_generator = __commonJS({
|
|
|
652
652
|
return Object.assign(Object.assign({}, baseParameter), { in: paramLocation, name: paramName });
|
|
653
653
|
}
|
|
654
654
|
generateSchemaWithMetadata(zodSchema) {
|
|
655
|
-
var
|
|
655
|
+
var _a3;
|
|
656
656
|
const innerSchema = this.unwrapChained(zodSchema);
|
|
657
657
|
const metadata = this.getMetadata(zodSchema);
|
|
658
658
|
const defaultValue = this.getDefaultValue(zodSchema);
|
|
659
|
-
const result = ((
|
|
659
|
+
const result = ((_a3 = metadata === null || metadata === void 0 ? void 0 : metadata.metadata) === null || _a3 === void 0 ? void 0 : _a3.type) ? { type: metadata === null || metadata === void 0 ? void 0 : metadata.metadata.type } : this.toOpenAPISchema(innerSchema, zodSchema.isNullable(), defaultValue);
|
|
660
660
|
return (metadata === null || metadata === void 0 ? void 0 : metadata.metadata) ? this.applySchemaMetadata(result, metadata.metadata) : (0, lodash_1.omitBy)(result, lodash_1.isNil);
|
|
661
661
|
}
|
|
662
662
|
/**
|
|
663
663
|
* Generates an OpenAPI SchemaObject or a ReferenceObject with all the provided metadata applied
|
|
664
664
|
*/
|
|
665
665
|
generateSimpleSchema(zodSchema) {
|
|
666
|
-
var
|
|
666
|
+
var _a3;
|
|
667
667
|
const metadata = this.getMetadata(zodSchema);
|
|
668
668
|
const refId = this.getRefId(zodSchema);
|
|
669
669
|
if (!refId || !this.schemaRefs[refId]) {
|
|
@@ -673,7 +673,7 @@ var require_openapi_generator = __commonJS({
|
|
|
673
673
|
const referenceObject = {
|
|
674
674
|
$ref: this.generateSchemaRef(refId)
|
|
675
675
|
};
|
|
676
|
-
const newMetadata = (0, lodash_1.omitBy)(this.buildSchemaMetadata((
|
|
676
|
+
const newMetadata = (0, lodash_1.omitBy)(this.buildSchemaMetadata((_a3 = metadata === null || metadata === void 0 ? void 0 : metadata.metadata) !== null && _a3 !== void 0 ? _a3 : {}), (value, key) => value === void 0 || (0, lodash_1.objectEquals)(value, schemaRef[key]));
|
|
677
677
|
if (newMetadata.type) {
|
|
678
678
|
return {
|
|
679
679
|
allOf: [referenceObject, newMetadata]
|
|
@@ -762,8 +762,8 @@ var require_openapi_generator = __commonJS({
|
|
|
762
762
|
this.pathRefs[route.path] = Object.assign(Object.assign({}, this.pathRefs[route.path]), routeDoc);
|
|
763
763
|
return routeDoc;
|
|
764
764
|
}
|
|
765
|
-
getResponse(
|
|
766
|
-
var { content, headers } =
|
|
765
|
+
getResponse(_a3) {
|
|
766
|
+
var { content, headers } = _a3, rest = __rest(_a3, ["content", "headers"]);
|
|
767
767
|
const responseContent = content ? { content: this.getBodyContent(content) } : {};
|
|
768
768
|
if (!headers) {
|
|
769
769
|
return Object.assign(Object.assign({}, rest), responseContent);
|
|
@@ -820,9 +820,9 @@ var require_openapi_generator = __commonJS({
|
|
|
820
820
|
}
|
|
821
821
|
const mapping = {};
|
|
822
822
|
zodObjects.forEach((obj) => {
|
|
823
|
-
var
|
|
823
|
+
var _a3;
|
|
824
824
|
const refId = this.getRefId(obj);
|
|
825
|
-
const value = (
|
|
825
|
+
const value = (_a3 = obj.shape) === null || _a3 === void 0 ? void 0 : _a3[discriminator];
|
|
826
826
|
if ((0, zod_is_type_1.isZodType)(value, "ZodEnum")) {
|
|
827
827
|
value._def.values.forEach((enumValue) => {
|
|
828
828
|
mapping[enumValue] = this.generateSchemaRef(refId);
|
|
@@ -850,24 +850,24 @@ var require_openapi_generator = __commonJS({
|
|
|
850
850
|
return this.versionSpecifics.getNumberChecks(checks);
|
|
851
851
|
}
|
|
852
852
|
constructReferencedOpenAPISchema(zodSchema) {
|
|
853
|
-
var
|
|
853
|
+
var _a3;
|
|
854
854
|
const metadata = this.getMetadata(zodSchema);
|
|
855
855
|
const innerSchema = this.unwrapChained(zodSchema);
|
|
856
856
|
const defaultValue = this.getDefaultValue(zodSchema);
|
|
857
857
|
const isNullableSchema = zodSchema.isNullable();
|
|
858
|
-
if ((
|
|
858
|
+
if ((_a3 = metadata === null || metadata === void 0 ? void 0 : metadata.metadata) === null || _a3 === void 0 ? void 0 : _a3.type) {
|
|
859
859
|
return this.mapNullableType(metadata.metadata.type, isNullableSchema);
|
|
860
860
|
}
|
|
861
861
|
return this.toOpenAPISchema(innerSchema, isNullableSchema, defaultValue);
|
|
862
862
|
}
|
|
863
863
|
toOpenAPISchema(zodSchema, isNullable, defaultValue) {
|
|
864
|
-
var
|
|
864
|
+
var _a3, _b, _c, _d, _e;
|
|
865
865
|
if ((0, zod_is_type_1.isZodType)(zodSchema, "ZodNull")) {
|
|
866
866
|
return this.versionSpecifics.nullType;
|
|
867
867
|
}
|
|
868
868
|
if ((0, zod_is_type_1.isZodType)(zodSchema, "ZodString")) {
|
|
869
869
|
const regexCheck = this.getZodStringCheck(zodSchema, "regex");
|
|
870
|
-
const length = (
|
|
870
|
+
const length = (_a3 = this.getZodStringCheck(zodSchema, "length")) === null || _a3 === void 0 ? void 0 : _a3.value;
|
|
871
871
|
const maxLength = Number.isFinite(zodSchema.minLength) ? (_b = zodSchema.minLength) !== null && _b !== void 0 ? _b : void 0 : void 0;
|
|
872
872
|
const minLength = Number.isFinite(zodSchema.maxLength) ? (_c = zodSchema.maxLength) !== null && _c !== void 0 ? _c : void 0 : void 0;
|
|
873
873
|
return Object.assign(Object.assign({}, this.mapNullableType("string", isNullable)), {
|
|
@@ -1009,8 +1009,8 @@ var require_openapi_generator = __commonJS({
|
|
|
1009
1009
|
return Object.entries(objectSchema._def.shape()).filter(([_key, type]) => !this.isOptionalSchema(type)).map(([key, _type]) => key);
|
|
1010
1010
|
}
|
|
1011
1011
|
toOpenAPIObjectSchema(zodSchema, isNullable, defaultValue) {
|
|
1012
|
-
var
|
|
1013
|
-
const extendedFrom = (
|
|
1012
|
+
var _a3;
|
|
1013
|
+
const extendedFrom = (_a3 = this.getInternalMetadata(zodSchema)) === null || _a3 === void 0 ? void 0 : _a3.extendedFrom;
|
|
1014
1014
|
const required = this.requiredKeysOf(zodSchema);
|
|
1015
1015
|
const properties = (0, lodash_1.mapValues)(zodSchema._def.shape(), (_) => this.generateSchemaWithRef(_));
|
|
1016
1016
|
if (!extendedFrom) {
|
|
@@ -1087,10 +1087,10 @@ var require_openapi_generator = __commonJS({
|
|
|
1087
1087
|
return (0, lodash_1.omitBy)(metadata, lodash_1.isNil);
|
|
1088
1088
|
}
|
|
1089
1089
|
getParamMetadata(zodSchema) {
|
|
1090
|
-
var
|
|
1090
|
+
var _a3;
|
|
1091
1091
|
const innerSchema = this.unwrapChained(zodSchema);
|
|
1092
1092
|
const metadata = zodSchema._def.openapi ? zodSchema._def.openapi : innerSchema._def.openapi;
|
|
1093
|
-
const zodDescription = (
|
|
1093
|
+
const zodDescription = (_a3 = zodSchema.description) !== null && _a3 !== void 0 ? _a3 : innerSchema.description;
|
|
1094
1094
|
return {
|
|
1095
1095
|
_internal: metadata === null || metadata === void 0 ? void 0 : metadata._internal,
|
|
1096
1096
|
metadata: Object.assign(Object.assign({}, metadata === null || metadata === void 0 ? void 0 : metadata.metadata), {
|
|
@@ -1100,10 +1100,10 @@ var require_openapi_generator = __commonJS({
|
|
|
1100
1100
|
};
|
|
1101
1101
|
}
|
|
1102
1102
|
getMetadata(zodSchema) {
|
|
1103
|
-
var
|
|
1103
|
+
var _a3;
|
|
1104
1104
|
const innerSchema = this.unwrapChained(zodSchema);
|
|
1105
1105
|
const metadata = zodSchema._def.openapi ? zodSchema._def.openapi : innerSchema._def.openapi;
|
|
1106
|
-
const zodDescription = (
|
|
1106
|
+
const zodDescription = (_a3 = zodSchema.description) !== null && _a3 !== void 0 ? _a3 : innerSchema.description;
|
|
1107
1107
|
return {
|
|
1108
1108
|
_internal: metadata === null || metadata === void 0 ? void 0 : metadata._internal,
|
|
1109
1109
|
metadata: Object.assign({ description: zodDescription }, metadata === null || metadata === void 0 ? void 0 : metadata.metadata)
|
|
@@ -1115,8 +1115,8 @@ var require_openapi_generator = __commonJS({
|
|
|
1115
1115
|
return openapi === null || openapi === void 0 ? void 0 : openapi._internal;
|
|
1116
1116
|
}
|
|
1117
1117
|
getRefId(zodSchema) {
|
|
1118
|
-
var
|
|
1119
|
-
return (
|
|
1118
|
+
var _a3;
|
|
1119
|
+
return (_a3 = this.getInternalMetadata(zodSchema)) === null || _a3 === void 0 ? void 0 : _a3.refId;
|
|
1120
1120
|
}
|
|
1121
1121
|
applySchemaMetadata(initialData, metadata) {
|
|
1122
1122
|
return (0, lodash_1.omitBy)(Object.assign(Object.assign({}, initialData), this.buildSchemaMetadata(metadata)), lodash_1.isNil);
|
|
@@ -2021,11 +2021,11 @@ var ZodType = class {
|
|
|
2021
2021
|
throw result.error;
|
|
2022
2022
|
}
|
|
2023
2023
|
safeParse(data, params) {
|
|
2024
|
-
var
|
|
2024
|
+
var _a3;
|
|
2025
2025
|
const ctx = {
|
|
2026
2026
|
common: {
|
|
2027
2027
|
issues: [],
|
|
2028
|
-
async: (
|
|
2028
|
+
async: (_a3 = params === null || params === void 0 ? void 0 : params.async) !== null && _a3 !== void 0 ? _a3 : false,
|
|
2029
2029
|
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
|
|
2030
2030
|
},
|
|
2031
2031
|
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
|
@@ -2367,7 +2367,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
2367
2367
|
} else if (check.kind === "url") {
|
|
2368
2368
|
try {
|
|
2369
2369
|
new URL(input.data);
|
|
2370
|
-
} catch (
|
|
2370
|
+
} catch (_a3) {
|
|
2371
2371
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
2372
2372
|
addIssueToContext(ctx, {
|
|
2373
2373
|
validation: "url",
|
|
@@ -2489,7 +2489,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
2489
2489
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
2490
2490
|
}
|
|
2491
2491
|
datetime(options) {
|
|
2492
|
-
var
|
|
2492
|
+
var _a3;
|
|
2493
2493
|
if (typeof options === "string") {
|
|
2494
2494
|
return this._addCheck({
|
|
2495
2495
|
kind: "datetime",
|
|
@@ -2501,7 +2501,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
2501
2501
|
return this._addCheck({
|
|
2502
2502
|
kind: "datetime",
|
|
2503
2503
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
2504
|
-
offset: (
|
|
2504
|
+
offset: (_a3 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a3 !== void 0 ? _a3 : false,
|
|
2505
2505
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
2506
2506
|
});
|
|
2507
2507
|
}
|
|
@@ -2629,11 +2629,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
2629
2629
|
}
|
|
2630
2630
|
};
|
|
2631
2631
|
ZodString.create = (params) => {
|
|
2632
|
-
var
|
|
2632
|
+
var _a3;
|
|
2633
2633
|
return new ZodString({
|
|
2634
2634
|
checks: [],
|
|
2635
2635
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
2636
|
-
coerce: (
|
|
2636
|
+
coerce: (_a3 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a3 !== void 0 ? _a3 : false,
|
|
2637
2637
|
...processCreateParams(params)
|
|
2638
2638
|
});
|
|
2639
2639
|
};
|
|
@@ -3034,11 +3034,11 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
3034
3034
|
}
|
|
3035
3035
|
};
|
|
3036
3036
|
ZodBigInt.create = (params) => {
|
|
3037
|
-
var
|
|
3037
|
+
var _a3;
|
|
3038
3038
|
return new ZodBigInt({
|
|
3039
3039
|
checks: [],
|
|
3040
3040
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
3041
|
-
coerce: (
|
|
3041
|
+
coerce: (_a3 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a3 !== void 0 ? _a3 : false,
|
|
3042
3042
|
...processCreateParams(params)
|
|
3043
3043
|
});
|
|
3044
3044
|
};
|
|
@@ -3544,8 +3544,8 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
3544
3544
|
unknownKeys: "strict",
|
|
3545
3545
|
...message !== void 0 ? {
|
|
3546
3546
|
errorMap: (issue, ctx) => {
|
|
3547
|
-
var
|
|
3548
|
-
const defaultError = (_c = (_b = (
|
|
3547
|
+
var _a3, _b, _c, _d;
|
|
3548
|
+
const defaultError = (_c = (_b = (_a3 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a3, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
|
|
3549
3549
|
if (issue.code === "unrecognized_keys")
|
|
3550
3550
|
return {
|
|
3551
3551
|
message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
|
|
@@ -4955,10 +4955,10 @@ ZodReadonly.create = (type, params) => {
|
|
|
4955
4955
|
var custom = (check, params = {}, fatal) => {
|
|
4956
4956
|
if (check)
|
|
4957
4957
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
4958
|
-
var
|
|
4958
|
+
var _a3, _b;
|
|
4959
4959
|
if (!check(data)) {
|
|
4960
4960
|
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
4961
|
-
const _fatal = (_b = (
|
|
4961
|
+
const _fatal = (_b = (_a3 = p.fatal) !== null && _a3 !== void 0 ? _a3 : fatal) !== null && _b !== void 0 ? _b : true;
|
|
4962
4962
|
const p2 = typeof p === "string" ? { message: p } : p;
|
|
4963
4963
|
ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
|
|
4964
4964
|
}
|
|
@@ -5175,7 +5175,11 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
5175
5175
|
});
|
|
5176
5176
|
|
|
5177
5177
|
// ../core/js/dist/index.mjs
|
|
5178
|
+
var import_zod_to_openapi = __toESM(require_dist(), 1);
|
|
5179
|
+
var import_zod_to_openapi2 = __toESM(require_dist(), 1);
|
|
5180
|
+
var import_zod_to_openapi3 = __toESM(require_dist(), 1);
|
|
5178
5181
|
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
5182
|
+
var OBJECT_DELETE_FIELD = "_object_delete";
|
|
5179
5183
|
var IS_MERGE_FIELD = "_is_merge";
|
|
5180
5184
|
var MERGE_PATHS_FIELD = "_merge_paths";
|
|
5181
5185
|
var AUDIT_SOURCE_FIELD = "_audit_source";
|
|
@@ -5196,6 +5200,10 @@ function mergeDicts(mergeInto, mergeFrom) {
|
|
|
5196
5200
|
}
|
|
5197
5201
|
return mergeInto;
|
|
5198
5202
|
}
|
|
5203
|
+
function capitalize(s, sep) {
|
|
5204
|
+
const items = sep ? s.split(sep) : [s];
|
|
5205
|
+
return items.map((s2) => s2 ? s2.charAt(0).toUpperCase() + s2.slice(1) : s2).join(sep || "");
|
|
5206
|
+
}
|
|
5199
5207
|
function constructJsonArray(items) {
|
|
5200
5208
|
return `[${items.join(",")}]`;
|
|
5201
5209
|
}
|
|
@@ -5207,7 +5215,7 @@ function mapAt(m, k) {
|
|
|
5207
5215
|
return ret;
|
|
5208
5216
|
}
|
|
5209
5217
|
function depthFirstSearch(args) {
|
|
5210
|
-
var
|
|
5218
|
+
var _a22;
|
|
5211
5219
|
const { graph, firstVisitF, lastVisitF } = args;
|
|
5212
5220
|
for (const vs of graph.values()) {
|
|
5213
5221
|
for (const v of vs.values()) {
|
|
@@ -5217,7 +5225,7 @@ function depthFirstSearch(args) {
|
|
|
5217
5225
|
}
|
|
5218
5226
|
}
|
|
5219
5227
|
const firstVisitedVertices = /* @__PURE__ */ new Set();
|
|
5220
|
-
const visitationOrder = (
|
|
5228
|
+
const visitationOrder = (_a22 = args.visitationOrder) != null ? _a22 : [...graph.keys()];
|
|
5221
5229
|
const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
|
|
5222
5230
|
while (events.length) {
|
|
5223
5231
|
const { eventType, vertex, extras } = events.pop();
|
|
@@ -5347,9 +5355,9 @@ function mergeRowBatch(rows) {
|
|
|
5347
5355
|
return buckets.map((bucket) => bucket.map((i) => merged[i]));
|
|
5348
5356
|
}
|
|
5349
5357
|
function batchItems(args) {
|
|
5350
|
-
var
|
|
5358
|
+
var _a22, _b;
|
|
5351
5359
|
let { items } = args;
|
|
5352
|
-
const batchMaxNumItems = (
|
|
5360
|
+
const batchMaxNumItems = (_a22 = args.batchMaxNumItems) != null ? _a22 : Number.POSITIVE_INFINITY;
|
|
5353
5361
|
const batchMaxNumBytes = (_b = args.batchMaxNumBytes) != null ? _b : Number.POSITIVE_INFINITY;
|
|
5354
5362
|
const output = [];
|
|
5355
5363
|
let nextItems = [];
|
|
@@ -5571,11 +5579,11 @@ var SpanComponentsV1 = class _SpanComponentsV1 {
|
|
|
5571
5579
|
}
|
|
5572
5580
|
}
|
|
5573
5581
|
toObject() {
|
|
5574
|
-
var
|
|
5582
|
+
var _a22;
|
|
5575
5583
|
return {
|
|
5576
5584
|
objectType: this.objectType,
|
|
5577
5585
|
objectId: this.objectId,
|
|
5578
|
-
rowIds: (
|
|
5586
|
+
rowIds: (_a22 = this.rowIds) == null ? void 0 : _a22.toObject()
|
|
5579
5587
|
};
|
|
5580
5588
|
}
|
|
5581
5589
|
};
|
|
@@ -5775,15 +5783,23 @@ var SpanComponentsV2 = class _SpanComponentsV2 {
|
|
|
5775
5783
|
}
|
|
5776
5784
|
}
|
|
5777
5785
|
toObject() {
|
|
5778
|
-
var
|
|
5786
|
+
var _a22;
|
|
5779
5787
|
return {
|
|
5780
5788
|
objectType: this.objectType,
|
|
5781
5789
|
objectId: this.objectId,
|
|
5782
5790
|
computeObjectMetadataArgs: this.computeObjectMetadataArgs,
|
|
5783
|
-
rowIds: (
|
|
5791
|
+
rowIds: (_a22 = this.rowIds) == null ? void 0 : _a22.toObject()
|
|
5784
5792
|
};
|
|
5785
5793
|
}
|
|
5786
5794
|
};
|
|
5795
|
+
var spanTypeAttributeValues = [
|
|
5796
|
+
"llm",
|
|
5797
|
+
"score",
|
|
5798
|
+
"function",
|
|
5799
|
+
"eval",
|
|
5800
|
+
"task",
|
|
5801
|
+
"tool"
|
|
5802
|
+
];
|
|
5787
5803
|
var SpanTypeAttribute = /* @__PURE__ */ ((SpanTypeAttribute2) => {
|
|
5788
5804
|
SpanTypeAttribute2["LLM"] = "llm";
|
|
5789
5805
|
SpanTypeAttribute2["SCORE"] = "score";
|
|
@@ -5793,33 +5809,6 @@ var SpanTypeAttribute = /* @__PURE__ */ ((SpanTypeAttribute2) => {
|
|
|
5793
5809
|
SpanTypeAttribute2["TOOL"] = "tool";
|
|
5794
5810
|
return SpanTypeAttribute2;
|
|
5795
5811
|
})(SpanTypeAttribute || {});
|
|
5796
|
-
function mergeGitMetadataSettings(s1, s2) {
|
|
5797
|
-
var _a2;
|
|
5798
|
-
if (s1.collect === "all") {
|
|
5799
|
-
return s2;
|
|
5800
|
-
} else if (s2.collect === "all") {
|
|
5801
|
-
return s1;
|
|
5802
|
-
} else if (s1.collect === "none") {
|
|
5803
|
-
return s1;
|
|
5804
|
-
} else if (s2.collect === "none") {
|
|
5805
|
-
return s2;
|
|
5806
|
-
}
|
|
5807
|
-
const fields = ((_a2 = s1.fields) != null ? _a2 : []).filter((f) => {
|
|
5808
|
-
var _a22;
|
|
5809
|
-
return ((_a22 = s2.fields) != null ? _a22 : []).includes(f);
|
|
5810
|
-
});
|
|
5811
|
-
const collect = fields.length > 0 ? "some" : "none";
|
|
5812
|
-
return { collect, fields };
|
|
5813
|
-
}
|
|
5814
|
-
var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
|
|
5815
|
-
var MOD = BigInt(1) << BigInt(64);
|
|
5816
|
-
var COPRIME = BigInt("205891132094649");
|
|
5817
|
-
var COPRIME_INVERSE = BigInt("1522336535492693385");
|
|
5818
|
-
|
|
5819
|
-
// ../core/js/typespecs/dist/index.mjs
|
|
5820
|
-
var import_zod_to_openapi = __toESM(require_dist(), 1);
|
|
5821
|
-
var import_zod_to_openapi2 = __toESM(require_dist(), 1);
|
|
5822
|
-
var import_zod_to_openapi3 = __toESM(require_dist(), 1);
|
|
5823
5812
|
var literalSchema = z.union([
|
|
5824
5813
|
z.string(),
|
|
5825
5814
|
z.number(),
|
|
@@ -5842,7 +5831,9 @@ var objectTypes = z.enum([
|
|
|
5842
5831
|
"user",
|
|
5843
5832
|
"project_score",
|
|
5844
5833
|
"project_tag",
|
|
5845
|
-
"function"
|
|
5834
|
+
"function",
|
|
5835
|
+
"view",
|
|
5836
|
+
"organization"
|
|
5846
5837
|
]);
|
|
5847
5838
|
var objectTypesWithEvent = z.enum([
|
|
5848
5839
|
"project",
|
|
@@ -5883,6 +5874,14 @@ var modeToTypes = {
|
|
|
5883
5874
|
}
|
|
5884
5875
|
};
|
|
5885
5876
|
var customTypes = modeToTypes[mode];
|
|
5877
|
+
var messageRoleSchema = z.enum([
|
|
5878
|
+
"system",
|
|
5879
|
+
"user",
|
|
5880
|
+
"assistant",
|
|
5881
|
+
"function",
|
|
5882
|
+
"tool",
|
|
5883
|
+
"model"
|
|
5884
|
+
]);
|
|
5886
5885
|
var chatCompletionSystemMessageParamSchema = z.strictObject({
|
|
5887
5886
|
content: z.string().default(""),
|
|
5888
5887
|
role: z.literal("system"),
|
|
@@ -5943,13 +5942,27 @@ var chatCompletionAssistantMessageParamSchema = z.strictObject({
|
|
|
5943
5942
|
name: z.string().optional(),
|
|
5944
5943
|
tool_calls: z.array(chatCompletionMessageToolCallSchema).optional()
|
|
5945
5944
|
}).strip();
|
|
5946
|
-
var
|
|
5945
|
+
var chatCompletionFallbackMessageParamSchema = z.strictObject({
|
|
5946
|
+
role: messageRoleSchema.exclude([
|
|
5947
|
+
"system",
|
|
5948
|
+
"user",
|
|
5949
|
+
"assistant",
|
|
5950
|
+
"tool",
|
|
5951
|
+
"function"
|
|
5952
|
+
]),
|
|
5953
|
+
content: z.string().nullish()
|
|
5954
|
+
}).strip();
|
|
5955
|
+
var chatCompletionOpenAIMessageParamSchema = z.union([
|
|
5947
5956
|
chatCompletionSystemMessageParamSchema,
|
|
5948
5957
|
chatCompletionUserMessageParamSchema,
|
|
5949
5958
|
chatCompletionAssistantMessageParamSchema,
|
|
5950
5959
|
chatCompletionToolMessageParamSchema,
|
|
5951
5960
|
chatCompletionFunctionMessageParamSchema
|
|
5952
5961
|
]);
|
|
5962
|
+
var chatCompletionMessageParamSchema = z.union([
|
|
5963
|
+
chatCompletionOpenAIMessageParamSchema,
|
|
5964
|
+
chatCompletionFallbackMessageParamSchema
|
|
5965
|
+
]);
|
|
5953
5966
|
var functionParametersSchema = z.record(z.unknown());
|
|
5954
5967
|
var functionDefinitionSchema = z.strictObject({
|
|
5955
5968
|
name: z.string(),
|
|
@@ -5961,14 +5974,6 @@ var chatCompletionToolSchema = z.strictObject({
|
|
|
5961
5974
|
type: z.literal("function")
|
|
5962
5975
|
}).strip();
|
|
5963
5976
|
var toolsSchema = z.array(chatCompletionToolSchema);
|
|
5964
|
-
var messageRoleSchema = z.enum([
|
|
5965
|
-
"system",
|
|
5966
|
-
"user",
|
|
5967
|
-
"assistant",
|
|
5968
|
-
"function",
|
|
5969
|
-
"tool",
|
|
5970
|
-
"model"
|
|
5971
|
-
]);
|
|
5972
5977
|
var promptBlockDataSchema = z.union([
|
|
5973
5978
|
z.strictObject({
|
|
5974
5979
|
type: z.literal("completion"),
|
|
@@ -6018,17 +6023,22 @@ var anthropicModelParamsSchema = z.strictObject({
|
|
|
6018
6023
|
max_tokens_to_sample: z.number().optional().describe("This is a legacy parameter that should not be used.")
|
|
6019
6024
|
}).strip();
|
|
6020
6025
|
var googleModelParamsSchema = z.strictObject({
|
|
6021
|
-
temperature: z.number(),
|
|
6026
|
+
temperature: z.number().optional(),
|
|
6022
6027
|
maxOutputTokens: z.number().optional(),
|
|
6023
6028
|
topP: z.number().optional(),
|
|
6024
6029
|
topK: z.number().optional()
|
|
6025
6030
|
}).strip();
|
|
6031
|
+
var windowAIModelParamsSchema = z.strictObject({
|
|
6032
|
+
temperature: z.number().optional(),
|
|
6033
|
+
topK: z.number().optional()
|
|
6034
|
+
}).strip();
|
|
6026
6035
|
var jsCompletionParamsSchema = z.strictObject({}).strip();
|
|
6027
6036
|
var modelParamsSchema = z.union([
|
|
6028
|
-
braintrustModelParamsSchema.merge(openAIModelParamsSchema),
|
|
6029
|
-
braintrustModelParamsSchema.merge(anthropicModelParamsSchema),
|
|
6030
|
-
braintrustModelParamsSchema.merge(googleModelParamsSchema),
|
|
6031
|
-
braintrustModelParamsSchema.merge(
|
|
6037
|
+
braintrustModelParamsSchema.merge(openAIModelParamsSchema).passthrough(),
|
|
6038
|
+
braintrustModelParamsSchema.merge(anthropicModelParamsSchema).passthrough(),
|
|
6039
|
+
braintrustModelParamsSchema.merge(googleModelParamsSchema).passthrough(),
|
|
6040
|
+
braintrustModelParamsSchema.merge(windowAIModelParamsSchema).passthrough(),
|
|
6041
|
+
braintrustModelParamsSchema.merge(jsCompletionParamsSchema).passthrough()
|
|
6032
6042
|
]);
|
|
6033
6043
|
var anyModelParamsSchema = openAIModelParamsSchema.merge(anthropicModelParamsSchema).merge(googleModelParamsSchema).merge(braintrustModelParamsSchema);
|
|
6034
6044
|
var promptOptionsSchema = z.strictObject({
|
|
@@ -6045,6 +6055,30 @@ var promptDataSchema = z.strictObject({
|
|
|
6045
6055
|
prompt_version: z.string().optional()
|
|
6046
6056
|
}).nullish()
|
|
6047
6057
|
}).openapi("PromptData");
|
|
6058
|
+
var viewTypeEnum = z.enum([
|
|
6059
|
+
"projects",
|
|
6060
|
+
"logs",
|
|
6061
|
+
"experiments",
|
|
6062
|
+
"datasets",
|
|
6063
|
+
"prompts",
|
|
6064
|
+
"playgrounds",
|
|
6065
|
+
"experiment",
|
|
6066
|
+
"dataset"
|
|
6067
|
+
]).describe("Type of table that the view corresponds to.");
|
|
6068
|
+
var viewDataSearchSchema = z.strictObject({
|
|
6069
|
+
filter: z.array(customTypes.any).nullish(),
|
|
6070
|
+
tag: z.array(customTypes.any).nullish(),
|
|
6071
|
+
match: z.array(customTypes.any).nullish(),
|
|
6072
|
+
sort: z.array(customTypes.any).nullish()
|
|
6073
|
+
}).openapi("ViewDataSearch");
|
|
6074
|
+
var viewDataSchema = z.strictObject({
|
|
6075
|
+
search: viewDataSearchSchema.nullish()
|
|
6076
|
+
}).openapi("ViewData");
|
|
6077
|
+
var viewOptionsSchema = z.strictObject({
|
|
6078
|
+
columnVisibility: z.record(z.boolean()).nullish(),
|
|
6079
|
+
columnOrder: z.array(z.string()).nullish(),
|
|
6080
|
+
columnSizing: z.record(z.number()).nullish()
|
|
6081
|
+
}).openapi("ViewOptions");
|
|
6048
6082
|
(0, import_zod_to_openapi2.extendZodWithOpenApi)(z);
|
|
6049
6083
|
function generateBaseTableSchema(objectName, opts) {
|
|
6050
6084
|
let nameDescription = `Name of the ${objectName}`;
|
|
@@ -6147,7 +6181,8 @@ var datasetSchema = z.strictObject({
|
|
|
6147
6181
|
description: datasetBaseSchema.shape.description,
|
|
6148
6182
|
created: datasetBaseSchema.shape.created,
|
|
6149
6183
|
deleted_at: datasetBaseSchema.shape.deleted_at,
|
|
6150
|
-
user_id: datasetBaseSchema.shape.user_id
|
|
6184
|
+
user_id: datasetBaseSchema.shape.user_id,
|
|
6185
|
+
metadata: datasetBaseSchema.shape.metadata
|
|
6151
6186
|
}).openapi("Dataset");
|
|
6152
6187
|
var validRuntimesEnum = z.enum(["node"]);
|
|
6153
6188
|
var runtimeContextSchema = z.strictObject({
|
|
@@ -6406,6 +6441,19 @@ var projectTagSchema = z.strictObject({
|
|
|
6406
6441
|
}).describe(
|
|
6407
6442
|
"A project tag is a user-configured tag for tracking and filtering your experiments, logs, and other data"
|
|
6408
6443
|
).openapi("ProjectTag");
|
|
6444
|
+
var viewBaseSchema = generateBaseTableSchema("view");
|
|
6445
|
+
var viewSchema = z.strictObject({
|
|
6446
|
+
id: viewBaseSchema.shape.id,
|
|
6447
|
+
object_type: aclObjectTypeEnum,
|
|
6448
|
+
object_id: z.string().uuid().describe("The id of the object the view applies to"),
|
|
6449
|
+
view_type: viewTypeEnum,
|
|
6450
|
+
name: viewBaseSchema.shape.name,
|
|
6451
|
+
created: viewBaseSchema.shape.created,
|
|
6452
|
+
view_data: viewDataSchema.nullish().describe("The view definition"),
|
|
6453
|
+
options: viewOptionsSchema.nullish().describe("Options for the view in the app"),
|
|
6454
|
+
user_id: viewBaseSchema.shape.user_id,
|
|
6455
|
+
deleted_at: roleBaseSchema.shape.deleted_at
|
|
6456
|
+
}).openapi("View");
|
|
6409
6457
|
var aclBaseSchema = generateBaseTableSchema("acl");
|
|
6410
6458
|
var aclSchema = z.strictObject({
|
|
6411
6459
|
id: aclBaseSchema.shape.id,
|
|
@@ -6595,33 +6643,38 @@ var patchProjectTagSchema = z.strictObject({
|
|
|
6595
6643
|
description: projectTagSchema.shape.description,
|
|
6596
6644
|
color: projectTagSchema.shape.color
|
|
6597
6645
|
}).openapi("PatchProjectTag");
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
}
|
|
6602
|
-
var
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6646
|
+
var createViewSchema = viewSchema.omit({
|
|
6647
|
+
id: true,
|
|
6648
|
+
created: true
|
|
6649
|
+
}).openapi("CreateView");
|
|
6650
|
+
var patchViewSchema = z.strictObject({
|
|
6651
|
+
object_type: viewSchema.shape.object_type,
|
|
6652
|
+
object_id: viewSchema.shape.object_id,
|
|
6653
|
+
view_type: viewSchema.shape.view_type.nullish(),
|
|
6654
|
+
name: viewSchema.shape.name.nullish(),
|
|
6655
|
+
view_data: viewSchema.shape.view_data,
|
|
6656
|
+
options: viewSchema.shape.options,
|
|
6657
|
+
user_id: viewSchema.shape.user_id
|
|
6658
|
+
}).openapi("PatchView");
|
|
6659
|
+
var deleteViewSchema = z.strictObject({
|
|
6660
|
+
object_type: viewSchema.shape.object_type,
|
|
6661
|
+
object_id: viewSchema.shape.object_id
|
|
6662
|
+
}).openapi("DeleteView");
|
|
6663
|
+
var patchOrganizationSchema = z.strictObject({
|
|
6664
|
+
name: organizationSchema.shape.name.nullish(),
|
|
6665
|
+
api_url: organizationSchema.shape.api_url.nullish(),
|
|
6666
|
+
proxy_url: organizationSchema.shape.proxy_url.nullish(),
|
|
6667
|
+
realtime_url: organizationSchema.shape.realtime_url.nullish()
|
|
6668
|
+
}).openapi("PatchOrganization");
|
|
6616
6669
|
(0, import_zod_to_openapi.extendZodWithOpenApi)(z);
|
|
6617
|
-
var auditSourcesSchema = z.enum(
|
|
6670
|
+
var auditSourcesSchema = z.enum(VALID_SOURCES);
|
|
6618
6671
|
function generateBaseEventOpSchema(objectType2) {
|
|
6619
6672
|
const eventDescription = getEventObjectDescription(objectType2);
|
|
6620
6673
|
return z.strictObject({
|
|
6621
6674
|
id: z.string().describe(
|
|
6622
6675
|
`A unique identifier for the ${eventDescription} event. If you don't provide one, BrainTrust will generate one for you`
|
|
6623
6676
|
),
|
|
6624
|
-
[
|
|
6677
|
+
[TRANSACTION_ID_FIELD]: z.string().describe(
|
|
6625
6678
|
`The transaction id of an event is unique to the network operation that processed the event insertion. Transaction ids are monotonically increasing over time and can be used to retrieve a versioned snapshot of the ${eventDescription} (see the \`version\` parameter)`
|
|
6626
6679
|
),
|
|
6627
6680
|
created: datetimeStringSchema.describe(
|
|
@@ -6715,14 +6768,14 @@ function generateBaseEventFeedbackSchema(objectType2) {
|
|
|
6715
6768
|
var fetchLimitSchema = z.number().int().nonnegative().describe(
|
|
6716
6769
|
[
|
|
6717
6770
|
"limit the number of traces fetched",
|
|
6718
|
-
`Fetch queries may be paginated if the total result size is expected to be large (e.g. project_logs which accumulate over a long time). Note that fetch queries only support pagination in descending time order (from latest to earliest \`${
|
|
6771
|
+
`Fetch queries may be paginated if the total result size is expected to be large (e.g. project_logs which accumulate over a long time). Note that fetch queries only support pagination in descending time order (from latest to earliest \`${TRANSACTION_ID_FIELD}\`. Furthermore, later pages may return rows which showed up in earlier pages, except with an earlier \`${TRANSACTION_ID_FIELD}\`. This happens because pagination occurs over the whole version history of the event log. You will most likely want to exclude any such duplicate, outdated rows (by \`id\`) from your combined result set.`,
|
|
6719
6772
|
`The \`limit\` parameter controls the number of full traces to return. So you may end up with more individual rows than the specified limit if you are fetching events containing traces.`
|
|
6720
6773
|
].join("\n\n")
|
|
6721
6774
|
);
|
|
6722
6775
|
var fetchPaginationCursorDescription = [
|
|
6723
6776
|
"DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.",
|
|
6724
6777
|
"Together, `max_xact_id` and `max_root_span_id` form a pagination cursor",
|
|
6725
|
-
`Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple \`(${
|
|
6778
|
+
`Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple \`(${TRANSACTION_ID_FIELD}, root_span_id)\`. See the documentation of \`limit\` for an overview of paginating fetch queries.`
|
|
6726
6779
|
].join("\n\n");
|
|
6727
6780
|
var maxXactIdSchema = z.string().describe(fetchPaginationCursorDescription);
|
|
6728
6781
|
var maxRootSpanIdSchema = z.string().describe(fetchPaginationCursorDescription);
|
|
@@ -6792,7 +6845,7 @@ var experimentEventSchema = z.strictObject({
|
|
|
6792
6845
|
dataset_record_id: z.string().nullish().describe(
|
|
6793
6846
|
"If the experiment is associated to a dataset, this is the event-level dataset id this experiment event is tied to"
|
|
6794
6847
|
),
|
|
6795
|
-
[
|
|
6848
|
+
[TRANSACTION_ID_FIELD]: experimentEventBaseSchema.shape[TRANSACTION_ID_FIELD],
|
|
6796
6849
|
created: experimentEventBaseSchema.shape.created,
|
|
6797
6850
|
project_id: experimentSchema.shape.project_id,
|
|
6798
6851
|
experiment_id: experimentSchema.shape.id,
|
|
@@ -6820,7 +6873,7 @@ var experimentEventSchema = z.strictObject({
|
|
|
6820
6873
|
var datasetEventBaseSchema = generateBaseEventOpSchema("dataset");
|
|
6821
6874
|
var datasetEventSchema = z.strictObject({
|
|
6822
6875
|
id: datasetEventBaseSchema.shape.id,
|
|
6823
|
-
[
|
|
6876
|
+
[TRANSACTION_ID_FIELD]: datasetEventBaseSchema.shape[TRANSACTION_ID_FIELD],
|
|
6824
6877
|
created: datasetEventBaseSchema.shape.created,
|
|
6825
6878
|
project_id: datasetSchema.shape.project_id,
|
|
6826
6879
|
dataset_id: datasetSchema.shape.id,
|
|
@@ -6838,7 +6891,7 @@ var datasetEventSchema = z.strictObject({
|
|
|
6838
6891
|
var promptSessionEventBaseSchema = generateBaseEventOpSchema("prompt_session");
|
|
6839
6892
|
var promptSessionEventSchema = z.strictObject({
|
|
6840
6893
|
id: promptSessionEventBaseSchema.shape.id,
|
|
6841
|
-
[
|
|
6894
|
+
[TRANSACTION_ID_FIELD]: promptSessionEventBaseSchema.shape[TRANSACTION_ID_FIELD],
|
|
6842
6895
|
created: promptSessionEventBaseSchema.shape.created,
|
|
6843
6896
|
project_id: promptSchema.shape.project_id,
|
|
6844
6897
|
prompt_session_id: promptSchema.shape.id,
|
|
@@ -6850,11 +6903,10 @@ var promptSessionEventSchema = z.strictObject({
|
|
|
6850
6903
|
completion: customTypes.any.describe("Data about the completion"),
|
|
6851
6904
|
tags: promptSessionEventBaseSchema.shape.tags
|
|
6852
6905
|
}).openapi("PromptSessionEvent");
|
|
6853
|
-
var functionEventBaseSchema = generateBaseEventOpSchema("function");
|
|
6854
6906
|
var projectLogsEventBaseSchema = generateBaseEventOpSchema("project");
|
|
6855
6907
|
var projectLogsEventSchema = z.strictObject({
|
|
6856
6908
|
id: projectLogsEventBaseSchema.shape.id,
|
|
6857
|
-
[
|
|
6909
|
+
[TRANSACTION_ID_FIELD]: projectLogsEventBaseSchema.shape[TRANSACTION_ID_FIELD],
|
|
6858
6910
|
created: projectLogsEventBaseSchema.shape.created,
|
|
6859
6911
|
org_id: projectSchema.shape.org_id,
|
|
6860
6912
|
project_id: projectSchema.shape.id,
|
|
@@ -6885,8 +6937,8 @@ var isMergeDescription = [
|
|
|
6885
6937
|
'For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}`'
|
|
6886
6938
|
].join("\n\n");
|
|
6887
6939
|
var mergeEventSchema = z.strictObject({
|
|
6888
|
-
[
|
|
6889
|
-
[
|
|
6940
|
+
[IS_MERGE_FIELD]: customTypes.literalTrue.describe(isMergeDescription),
|
|
6941
|
+
[MERGE_PATHS_FIELD]: z.string().array().array().nullish().describe(
|
|
6890
6942
|
[
|
|
6891
6943
|
"The `_merge_paths` field allows controlling the depth of the merge. It can only be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge will not descend below any of the specified merge paths.",
|
|
6892
6944
|
'For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and `input.c`.'
|
|
@@ -6894,8 +6946,8 @@ var mergeEventSchema = z.strictObject({
|
|
|
6894
6946
|
)
|
|
6895
6947
|
});
|
|
6896
6948
|
var replacementEventSchema = z.strictObject({
|
|
6897
|
-
[
|
|
6898
|
-
[
|
|
6949
|
+
[IS_MERGE_FIELD]: customTypes.literalFalse.nullish().describe(isMergeDescription),
|
|
6950
|
+
[PARENT_ID_FIELD]: z.string().nullish().describe(
|
|
6899
6951
|
[
|
|
6900
6952
|
"Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details).",
|
|
6901
6953
|
'For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row.'
|
|
@@ -7188,113 +7240,1595 @@ var summarizeDatasetResponseSchema = z.strictObject({
|
|
|
7188
7240
|
total_records: z.number().int().min(0).describe("Total number of records in the dataset")
|
|
7189
7241
|
}).nullish().describe("Summary of a dataset's data").openapi("DataSummary")
|
|
7190
7242
|
}).describe("Summary of a dataset").openapi("SummarizeDatasetResponse");
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
var
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
}
|
|
7243
|
+
var gitFieldsSchema = repoInfoSchema.keyof();
|
|
7244
|
+
var collectMetadataEnum = z.enum(["all", "none", "some"]);
|
|
7245
|
+
var gitMetadataSettingsSchema = z.strictObject({
|
|
7246
|
+
collect: collectMetadataEnum,
|
|
7247
|
+
fields: z.array(gitFieldsSchema).optional()
|
|
7248
|
+
});
|
|
7249
|
+
function mergeGitMetadataSettings(s1, s2) {
|
|
7250
|
+
var _a22;
|
|
7251
|
+
if (s1.collect === "all") {
|
|
7252
|
+
return s2;
|
|
7253
|
+
} else if (s2.collect === "all") {
|
|
7254
|
+
return s1;
|
|
7255
|
+
} else if (s1.collect === "none") {
|
|
7256
|
+
return s1;
|
|
7257
|
+
} else if (s2.collect === "none") {
|
|
7258
|
+
return s2;
|
|
7208
7259
|
}
|
|
7260
|
+
const fields = ((_a22 = s1.fields) != null ? _a22 : []).filter((f) => {
|
|
7261
|
+
var _a3;
|
|
7262
|
+
return ((_a3 = s2.fields) != null ? _a3 : []).includes(f);
|
|
7263
|
+
});
|
|
7264
|
+
const collect = fields.length > 0 ? "some" : "none";
|
|
7265
|
+
return { collect, fields };
|
|
7209
7266
|
}
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
return a === void 0 || a === null;
|
|
7215
|
-
}
|
|
7216
|
-
var LazyValue = class {
|
|
7217
|
-
callable;
|
|
7218
|
-
value = {
|
|
7219
|
-
hasComputed: false
|
|
7220
|
-
};
|
|
7221
|
-
constructor(callable) {
|
|
7222
|
-
this.callable = callable;
|
|
7223
|
-
}
|
|
7224
|
-
get() {
|
|
7225
|
-
if (this.value.hasComputed) {
|
|
7226
|
-
return this.value.val;
|
|
7227
|
-
}
|
|
7228
|
-
this.value = { hasComputed: true, val: this.callable() };
|
|
7229
|
-
return this.value.val;
|
|
7230
|
-
}
|
|
7231
|
-
get hasComputed() {
|
|
7232
|
-
return this.value.hasComputed;
|
|
7233
|
-
}
|
|
7234
|
-
};
|
|
7267
|
+
var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
|
|
7268
|
+
var MOD = BigInt(1) << BigInt(64);
|
|
7269
|
+
var COPRIME = BigInt("205891132094649");
|
|
7270
|
+
var COPRIME_INVERSE = BigInt("1522336535492693385");
|
|
7235
7271
|
|
|
7236
|
-
//
|
|
7237
|
-
var
|
|
7238
|
-
var
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
}
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7272
|
+
// ../core/js/typespecs/dist/index.mjs
|
|
7273
|
+
var import_zod_to_openapi4 = __toESM(require_dist(), 1);
|
|
7274
|
+
var import_zod_to_openapi5 = __toESM(require_dist(), 1);
|
|
7275
|
+
var import_zod_to_openapi6 = __toESM(require_dist(), 1);
|
|
7276
|
+
var literalSchema2 = z.union([
|
|
7277
|
+
z.string(),
|
|
7278
|
+
z.number(),
|
|
7279
|
+
z.boolean(),
|
|
7280
|
+
z.null()
|
|
7281
|
+
]);
|
|
7282
|
+
var jsonSchema2 = z.lazy(
|
|
7283
|
+
() => z.union([literalSchema2, z.array(jsonSchema2), z.record(jsonSchema2)])
|
|
7284
|
+
);
|
|
7285
|
+
var datetimeStringSchema2 = z.string().datetime({ offset: true });
|
|
7286
|
+
var objectTypes2 = z.enum([
|
|
7287
|
+
"project",
|
|
7288
|
+
"experiment",
|
|
7289
|
+
"dataset",
|
|
7290
|
+
"prompt",
|
|
7291
|
+
"prompt_session",
|
|
7292
|
+
"role",
|
|
7293
|
+
"group",
|
|
7294
|
+
"acl",
|
|
7295
|
+
"user",
|
|
7296
|
+
"project_score",
|
|
7297
|
+
"project_tag",
|
|
7298
|
+
"function",
|
|
7299
|
+
"view",
|
|
7300
|
+
"organization"
|
|
7301
|
+
]);
|
|
7302
|
+
var objectTypesWithEvent2 = z.enum([
|
|
7303
|
+
"project",
|
|
7304
|
+
"experiment",
|
|
7305
|
+
"dataset",
|
|
7306
|
+
"prompt",
|
|
7307
|
+
"function",
|
|
7308
|
+
"prompt_session"
|
|
7309
|
+
]);
|
|
7310
|
+
function getEventObjectType2(objectType2) {
|
|
7311
|
+
return objectType2 === "project" ? "project_logs" : objectType2;
|
|
7255
7312
|
}
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
return regExpTest.call(re, string);
|
|
7313
|
+
function getEventObjectDescription2(objectType2) {
|
|
7314
|
+
return getEventObjectType2(objectType2).replace("_", " ");
|
|
7259
7315
|
}
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
return !testRegExp(nonSpaceRe, string);
|
|
7316
|
+
function getObjectArticle2(objectType2) {
|
|
7317
|
+
return ["acl", "experiment"].includes(objectType2) ? "an" : "a";
|
|
7263
7318
|
}
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7319
|
+
(0, import_zod_to_openapi6.extendZodWithOpenApi)(z);
|
|
7320
|
+
var modeSchema2 = z.enum(["default", "stainless"]);
|
|
7321
|
+
var _a2;
|
|
7322
|
+
var mode2 = modeSchema2.parse(
|
|
7323
|
+
typeof process === "undefined" ? "default" : ((_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2.BRAINTRUST_TYPESPECS_MODE) || "default"
|
|
7324
|
+
);
|
|
7325
|
+
var modeToTypes2 = {
|
|
7326
|
+
default: {
|
|
7327
|
+
any: z.any(),
|
|
7328
|
+
literalTrue: z.literal(true),
|
|
7329
|
+
literalFalse: z.literal(false)
|
|
7330
|
+
},
|
|
7331
|
+
stainless: {
|
|
7332
|
+
// Stainless requires schemas which are completely permissive to be
|
|
7333
|
+
// tagged.
|
|
7334
|
+
any: z.any().openapi({ ["x-stainless-any"]: true }),
|
|
7335
|
+
// Stainless does not support boolean literals in all SDKs.
|
|
7336
|
+
literalTrue: z.boolean(),
|
|
7337
|
+
literalFalse: z.boolean()
|
|
7338
|
+
}
|
|
7273
7339
|
};
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
var
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7340
|
+
var customTypes2 = modeToTypes2[mode2];
|
|
7341
|
+
var messageRoleSchema2 = z.enum([
|
|
7342
|
+
"system",
|
|
7343
|
+
"user",
|
|
7344
|
+
"assistant",
|
|
7345
|
+
"function",
|
|
7346
|
+
"tool",
|
|
7347
|
+
"model"
|
|
7348
|
+
]);
|
|
7349
|
+
var chatCompletionSystemMessageParamSchema2 = z.strictObject({
|
|
7350
|
+
content: z.string().default(""),
|
|
7351
|
+
role: z.literal("system"),
|
|
7352
|
+
name: z.string().optional()
|
|
7353
|
+
}).strip();
|
|
7354
|
+
var chatCompletionContentPartTextSchema2 = z.strictObject({
|
|
7355
|
+
text: z.string().default(""),
|
|
7356
|
+
type: z.literal("text")
|
|
7357
|
+
}).strip();
|
|
7358
|
+
var imageURLSchema2 = z.strictObject({
|
|
7359
|
+
url: z.string(),
|
|
7360
|
+
detail: z.union([z.literal("auto"), z.literal("low"), z.literal("high")]).optional()
|
|
7361
|
+
}).strip();
|
|
7362
|
+
var chatCompletionContentPartImageSchema2 = z.strictObject({
|
|
7363
|
+
image_url: imageURLSchema2,
|
|
7364
|
+
type: z.literal("image_url")
|
|
7365
|
+
}).strip();
|
|
7366
|
+
var chatCompletionContentPartSchema2 = z.union([
|
|
7367
|
+
chatCompletionContentPartTextSchema2,
|
|
7368
|
+
chatCompletionContentPartImageSchema2
|
|
7369
|
+
]);
|
|
7370
|
+
var chatCompletionContentSchema2 = z.union([
|
|
7371
|
+
z.string().default(""),
|
|
7372
|
+
z.array(chatCompletionContentPartSchema2)
|
|
7373
|
+
]);
|
|
7374
|
+
var chatCompletionUserMessageParamSchema2 = z.strictObject({
|
|
7375
|
+
content: chatCompletionContentSchema2,
|
|
7376
|
+
role: z.literal("user"),
|
|
7377
|
+
name: z.string().optional()
|
|
7378
|
+
}).strip();
|
|
7379
|
+
var functionCallSchema2 = z.strictObject({
|
|
7380
|
+
arguments: z.string(),
|
|
7381
|
+
name: z.string()
|
|
7382
|
+
}).strip();
|
|
7383
|
+
var functionSchema3 = z.strictObject({
|
|
7384
|
+
arguments: z.string(),
|
|
7385
|
+
name: z.string()
|
|
7386
|
+
}).strip();
|
|
7387
|
+
var chatCompletionToolMessageParamSchema2 = z.strictObject({
|
|
7388
|
+
content: z.string().default(""),
|
|
7389
|
+
role: z.literal("tool"),
|
|
7390
|
+
tool_call_id: z.string()
|
|
7391
|
+
}).strip();
|
|
7392
|
+
var chatCompletionFunctionMessageParamSchema2 = z.strictObject({
|
|
7393
|
+
content: z.string().default(""),
|
|
7394
|
+
name: z.string(),
|
|
7395
|
+
role: z.literal("function")
|
|
7396
|
+
}).strip();
|
|
7397
|
+
var chatCompletionMessageToolCallSchema2 = z.strictObject({
|
|
7398
|
+
id: z.string(),
|
|
7399
|
+
function: functionSchema3,
|
|
7400
|
+
type: z.literal("function")
|
|
7401
|
+
}).strip();
|
|
7402
|
+
var chatCompletionAssistantMessageParamSchema2 = z.strictObject({
|
|
7403
|
+
role: z.literal("assistant"),
|
|
7404
|
+
content: z.string().nullish(),
|
|
7405
|
+
function_call: functionCallSchema2.optional(),
|
|
7406
|
+
name: z.string().optional(),
|
|
7407
|
+
tool_calls: z.array(chatCompletionMessageToolCallSchema2).optional()
|
|
7408
|
+
}).strip();
|
|
7409
|
+
var chatCompletionFallbackMessageParamSchema2 = z.strictObject({
|
|
7410
|
+
role: messageRoleSchema2.exclude([
|
|
7411
|
+
"system",
|
|
7412
|
+
"user",
|
|
7413
|
+
"assistant",
|
|
7414
|
+
"tool",
|
|
7415
|
+
"function"
|
|
7416
|
+
]),
|
|
7417
|
+
content: z.string().nullish()
|
|
7418
|
+
}).strip();
|
|
7419
|
+
var chatCompletionOpenAIMessageParamSchema2 = z.union([
|
|
7420
|
+
chatCompletionSystemMessageParamSchema2,
|
|
7421
|
+
chatCompletionUserMessageParamSchema2,
|
|
7422
|
+
chatCompletionAssistantMessageParamSchema2,
|
|
7423
|
+
chatCompletionToolMessageParamSchema2,
|
|
7424
|
+
chatCompletionFunctionMessageParamSchema2
|
|
7425
|
+
]);
|
|
7426
|
+
var chatCompletionMessageParamSchema2 = z.union([
|
|
7427
|
+
chatCompletionOpenAIMessageParamSchema2,
|
|
7428
|
+
chatCompletionFallbackMessageParamSchema2
|
|
7429
|
+
]);
|
|
7430
|
+
var functionParametersSchema2 = z.record(z.unknown());
|
|
7431
|
+
var functionDefinitionSchema2 = z.strictObject({
|
|
7432
|
+
name: z.string(),
|
|
7433
|
+
description: z.string().optional(),
|
|
7434
|
+
parameters: functionParametersSchema2.optional()
|
|
7435
|
+
}).strip();
|
|
7436
|
+
var chatCompletionToolSchema2 = z.strictObject({
|
|
7437
|
+
function: functionDefinitionSchema2,
|
|
7438
|
+
type: z.literal("function")
|
|
7439
|
+
}).strip();
|
|
7440
|
+
var toolsSchema2 = z.array(chatCompletionToolSchema2);
|
|
7441
|
+
var promptBlockDataSchema2 = z.union([
|
|
7442
|
+
z.strictObject({
|
|
7443
|
+
type: z.literal("completion"),
|
|
7444
|
+
content: z.string()
|
|
7445
|
+
}),
|
|
7446
|
+
z.strictObject({
|
|
7447
|
+
type: z.literal("chat"),
|
|
7448
|
+
messages: z.array(chatCompletionMessageParamSchema2),
|
|
7449
|
+
tools: z.string().optional()
|
|
7450
|
+
})
|
|
7451
|
+
]);
|
|
7452
|
+
var braintrustModelParamsSchema2 = z.strictObject({
|
|
7453
|
+
use_cache: z.boolean().optional()
|
|
7454
|
+
}).strip();
|
|
7455
|
+
var BRAINTRUST_PARAMS2 = Object.keys(braintrustModelParamsSchema2.shape);
|
|
7456
|
+
var openAIModelParamsSchema2 = z.strictObject({
|
|
7457
|
+
temperature: z.number().optional(),
|
|
7458
|
+
top_p: z.number().optional(),
|
|
7459
|
+
max_tokens: z.number().optional(),
|
|
7460
|
+
frequency_penalty: z.number().optional(),
|
|
7461
|
+
presence_penalty: z.number().optional(),
|
|
7462
|
+
response_format: z.strictObject({ type: z.literal("json_object") }).nullish(),
|
|
7463
|
+
tool_choice: z.union([
|
|
7464
|
+
z.literal("auto"),
|
|
7465
|
+
z.literal("none"),
|
|
7466
|
+
z.strictObject({
|
|
7467
|
+
type: z.literal("function"),
|
|
7468
|
+
function: z.strictObject({ name: z.string() }).strip()
|
|
7469
|
+
}).strip()
|
|
7470
|
+
]).optional(),
|
|
7471
|
+
function_call: z.union([
|
|
7472
|
+
z.literal("auto"),
|
|
7473
|
+
z.literal("none"),
|
|
7474
|
+
z.strictObject({
|
|
7475
|
+
name: z.string()
|
|
7476
|
+
})
|
|
7477
|
+
]).optional(),
|
|
7478
|
+
n: z.number().optional(),
|
|
7479
|
+
stop: z.array(z.string()).optional()
|
|
7480
|
+
}).strip();
|
|
7481
|
+
var anthropicModelParamsSchema2 = z.strictObject({
|
|
7482
|
+
max_tokens: z.number(),
|
|
7483
|
+
temperature: z.number(),
|
|
7484
|
+
top_p: z.number().optional(),
|
|
7485
|
+
top_k: z.number().optional(),
|
|
7486
|
+
stop_sequences: z.array(z.string()).optional(),
|
|
7487
|
+
max_tokens_to_sample: z.number().optional().describe("This is a legacy parameter that should not be used.")
|
|
7488
|
+
}).strip();
|
|
7489
|
+
var googleModelParamsSchema2 = z.strictObject({
|
|
7490
|
+
temperature: z.number().optional(),
|
|
7491
|
+
maxOutputTokens: z.number().optional(),
|
|
7492
|
+
topP: z.number().optional(),
|
|
7493
|
+
topK: z.number().optional()
|
|
7494
|
+
}).strip();
|
|
7495
|
+
var windowAIModelParamsSchema2 = z.strictObject({
|
|
7496
|
+
temperature: z.number().optional(),
|
|
7497
|
+
topK: z.number().optional()
|
|
7498
|
+
}).strip();
|
|
7499
|
+
var jsCompletionParamsSchema2 = z.strictObject({}).strip();
|
|
7500
|
+
var modelParamsSchema2 = z.union([
|
|
7501
|
+
braintrustModelParamsSchema2.merge(openAIModelParamsSchema2).passthrough(),
|
|
7502
|
+
braintrustModelParamsSchema2.merge(anthropicModelParamsSchema2).passthrough(),
|
|
7503
|
+
braintrustModelParamsSchema2.merge(googleModelParamsSchema2).passthrough(),
|
|
7504
|
+
braintrustModelParamsSchema2.merge(windowAIModelParamsSchema2).passthrough(),
|
|
7505
|
+
braintrustModelParamsSchema2.merge(jsCompletionParamsSchema2).passthrough()
|
|
7506
|
+
]);
|
|
7507
|
+
var anyModelParamsSchema2 = openAIModelParamsSchema2.merge(anthropicModelParamsSchema2).merge(googleModelParamsSchema2).merge(braintrustModelParamsSchema2);
|
|
7508
|
+
var promptOptionsSchema2 = z.strictObject({
|
|
7509
|
+
model: z.string().optional(),
|
|
7510
|
+
params: modelParamsSchema2.optional(),
|
|
7511
|
+
position: z.string().optional()
|
|
7512
|
+
}).strip();
|
|
7513
|
+
var promptDataSchema2 = z.strictObject({
|
|
7514
|
+
prompt: promptBlockDataSchema2.nullish(),
|
|
7515
|
+
options: promptOptionsSchema2.nullish(),
|
|
7516
|
+
origin: z.strictObject({
|
|
7517
|
+
prompt_id: z.string().optional(),
|
|
7518
|
+
project_id: z.string().optional(),
|
|
7519
|
+
prompt_version: z.string().optional()
|
|
7520
|
+
}).nullish()
|
|
7521
|
+
}).openapi("PromptData");
|
|
7522
|
+
var viewTypeEnum2 = z.enum([
|
|
7523
|
+
"projects",
|
|
7524
|
+
"logs",
|
|
7525
|
+
"experiments",
|
|
7526
|
+
"datasets",
|
|
7527
|
+
"prompts",
|
|
7528
|
+
"playgrounds",
|
|
7529
|
+
"experiment",
|
|
7530
|
+
"dataset"
|
|
7531
|
+
]).describe("Type of table that the view corresponds to.");
|
|
7532
|
+
var viewDataSearchSchema2 = z.strictObject({
|
|
7533
|
+
filter: z.array(customTypes2.any).nullish(),
|
|
7534
|
+
tag: z.array(customTypes2.any).nullish(),
|
|
7535
|
+
match: z.array(customTypes2.any).nullish(),
|
|
7536
|
+
sort: z.array(customTypes2.any).nullish()
|
|
7537
|
+
}).openapi("ViewDataSearch");
|
|
7538
|
+
var viewDataSchema2 = z.strictObject({
|
|
7539
|
+
search: viewDataSearchSchema2.nullish()
|
|
7540
|
+
}).openapi("ViewData");
|
|
7541
|
+
var viewOptionsSchema2 = z.strictObject({
|
|
7542
|
+
columnVisibility: z.record(z.boolean()).nullish(),
|
|
7543
|
+
columnOrder: z.array(z.string()).nullish(),
|
|
7544
|
+
columnSizing: z.record(z.number()).nullish()
|
|
7545
|
+
}).openapi("ViewOptions");
|
|
7546
|
+
(0, import_zod_to_openapi5.extendZodWithOpenApi)(z);
|
|
7547
|
+
function generateBaseTableSchema2(objectName, opts) {
|
|
7548
|
+
let nameDescription = `Name of the ${objectName}`;
|
|
7549
|
+
if (opts == null ? void 0 : opts.uniqueName) {
|
|
7550
|
+
nameDescription += `. Within a project, ${objectName} names are unique`;
|
|
7551
|
+
}
|
|
7552
|
+
return z.strictObject({
|
|
7553
|
+
id: z.string().uuid().describe(`Unique identifier for the ${objectName}`),
|
|
7554
|
+
project_id: z.string().uuid().describe(
|
|
7555
|
+
`Unique identifier for the project that the ${objectName} belongs under`
|
|
7556
|
+
),
|
|
7557
|
+
name: z.string().describe(nameDescription),
|
|
7558
|
+
description: z.string().nullish().describe(`Textual description of the ${objectName}`),
|
|
7559
|
+
created: datetimeStringSchema2.nullish().describe(`Date of ${objectName} creation`),
|
|
7560
|
+
deleted_at: datetimeStringSchema2.nullish().describe(
|
|
7561
|
+
`Date of ${objectName} deletion, or null if the ${objectName} is still active`
|
|
7562
|
+
),
|
|
7563
|
+
user_id: z.string().uuid().nullish().describe(`Identifies the user who created the ${objectName}`),
|
|
7564
|
+
metadata: z.record(customTypes2.any).nullish().describe(`User-controlled metadata about the ${objectName}`)
|
|
7565
|
+
});
|
|
7566
|
+
}
|
|
7567
|
+
var userBaseSchema2 = generateBaseTableSchema2("user");
|
|
7568
|
+
var userSchema2 = z.strictObject({
|
|
7569
|
+
id: userBaseSchema2.shape.id,
|
|
7570
|
+
given_name: z.string().nullish().describe("Given name of the user"),
|
|
7571
|
+
family_name: z.string().nullish().describe("Family name of the user"),
|
|
7572
|
+
email: z.string().nullish().describe("The user's email"),
|
|
7573
|
+
avatar_url: z.string().nullish().describe("URL of the user's Avatar image"),
|
|
7574
|
+
created: userBaseSchema2.shape.created
|
|
7575
|
+
}).openapi("User");
|
|
7576
|
+
var organizationBaseSchema2 = generateBaseTableSchema2("organization");
|
|
7577
|
+
var organizationSchema2 = z.strictObject({
|
|
7578
|
+
id: organizationBaseSchema2.shape.id,
|
|
7579
|
+
name: organizationBaseSchema2.shape.name,
|
|
7580
|
+
api_url: z.string().nullish(),
|
|
7581
|
+
proxy_url: z.string().nullish(),
|
|
7582
|
+
realtime_url: z.string().nullish(),
|
|
7583
|
+
created: organizationBaseSchema2.shape.created
|
|
7584
|
+
}).openapi("Organization");
|
|
7585
|
+
var maxOverWindowSchema2 = z.strictObject({
|
|
7586
|
+
window_size_days: z.number().int().positive(),
|
|
7587
|
+
max_value: z.number().nonnegative()
|
|
7588
|
+
}).openapi("MaxOverWindow");
|
|
7589
|
+
var resourcesSchema2 = z.strictObject({
|
|
7590
|
+
org_id: organizationSchema2.shape.id,
|
|
7591
|
+
forbid_toggle_experiment_public_to_private: z.boolean().nullish(),
|
|
7592
|
+
num_private_experiment_row_actions: maxOverWindowSchema2.nullish(),
|
|
7593
|
+
forbid_insert_datasets: z.boolean().nullish(),
|
|
7594
|
+
forbid_insert_prompt_sessions: z.boolean().nullish(),
|
|
7595
|
+
forbid_access_sql_explorer: z.boolean().nullish(),
|
|
7596
|
+
num_production_log_row_actions: maxOverWindowSchema2.nullish(),
|
|
7597
|
+
num_dataset_row_actions: maxOverWindowSchema2.nullish()
|
|
7598
|
+
}).openapi("Resources");
|
|
7599
|
+
var memberSchema2 = z.strictObject({
|
|
7600
|
+
org_id: organizationSchema2.shape.id,
|
|
7601
|
+
user_id: userSchema2.shape.id
|
|
7602
|
+
}).openapi("Member");
|
|
7603
|
+
var orgSecretsBaseSchema2 = generateBaseTableSchema2("org secrets");
|
|
7604
|
+
var orgSecretsSchema2 = z.strictObject({
|
|
7605
|
+
id: orgSecretsBaseSchema2.shape.id,
|
|
7606
|
+
created: orgSecretsBaseSchema2.shape.created,
|
|
7607
|
+
key_id: z.string().uuid(),
|
|
7608
|
+
org_id: organizationSchema2.shape.id,
|
|
7609
|
+
name: orgSecretsBaseSchema2.shape.name,
|
|
7610
|
+
secret: z.string().nullish(),
|
|
7611
|
+
type: z.string().nullish(),
|
|
7612
|
+
metadata: customTypes2.any
|
|
7613
|
+
}).openapi("OrgSecrets");
|
|
7614
|
+
var apiKeyBaseSchema2 = generateBaseTableSchema2("api key");
|
|
7615
|
+
var apiKeySchema2 = z.strictObject({
|
|
7616
|
+
id: apiKeyBaseSchema2.shape.id,
|
|
7617
|
+
created: apiKeyBaseSchema2.shape.created,
|
|
7618
|
+
name: apiKeyBaseSchema2.shape.name,
|
|
7619
|
+
preview_name: z.string(),
|
|
7620
|
+
user_id: userSchema2.shape.id.nullish(),
|
|
7621
|
+
org_id: organizationSchema2.shape.id.nullish()
|
|
7622
|
+
}).openapi("ApiKey");
|
|
7623
|
+
var projectSettingsSchema2 = z.strictObject({
|
|
7624
|
+
comparison_key: z.string().nullish().describe("The key used to join two experiments (defaults to `input`).")
|
|
7625
|
+
}).strip();
|
|
7626
|
+
var projectBaseSchema2 = generateBaseTableSchema2("project");
|
|
7627
|
+
var projectSchema2 = z.strictObject({
|
|
7628
|
+
id: projectBaseSchema2.shape.id,
|
|
7629
|
+
org_id: z.string().uuid().describe(
|
|
7630
|
+
"Unique id for the organization that the project belongs under"
|
|
7631
|
+
),
|
|
7632
|
+
name: projectBaseSchema2.shape.name,
|
|
7633
|
+
created: projectBaseSchema2.shape.created,
|
|
7634
|
+
deleted_at: projectBaseSchema2.shape.deleted_at,
|
|
7635
|
+
user_id: projectBaseSchema2.shape.user_id,
|
|
7636
|
+
settings: projectSettingsSchema2.nullish()
|
|
7637
|
+
}).openapi("Project");
|
|
7638
|
+
var datasetBaseSchema2 = generateBaseTableSchema2("dataset", {
|
|
7639
|
+
uniqueName: true
|
|
7640
|
+
});
|
|
7641
|
+
var datasetSchema2 = z.strictObject({
|
|
7642
|
+
id: datasetBaseSchema2.shape.id,
|
|
7643
|
+
project_id: datasetBaseSchema2.shape.project_id.nullish(),
|
|
7644
|
+
name: datasetBaseSchema2.shape.name,
|
|
7645
|
+
description: datasetBaseSchema2.shape.description,
|
|
7646
|
+
created: datasetBaseSchema2.shape.created,
|
|
7647
|
+
deleted_at: datasetBaseSchema2.shape.deleted_at,
|
|
7648
|
+
user_id: datasetBaseSchema2.shape.user_id,
|
|
7649
|
+
metadata: datasetBaseSchema2.shape.metadata
|
|
7650
|
+
}).openapi("Dataset");
|
|
7651
|
+
var validRuntimesEnum2 = z.enum(["node"]);
|
|
7652
|
+
var runtimeContextSchema2 = z.strictObject({
|
|
7653
|
+
runtime: validRuntimesEnum2,
|
|
7654
|
+
version: z.string()
|
|
7655
|
+
});
|
|
7656
|
+
var promptBaseSchema2 = generateBaseTableSchema2("prompt");
|
|
7657
|
+
var promptSchemaObject2 = z.strictObject({
|
|
7658
|
+
id: promptBaseSchema2.shape.id,
|
|
7659
|
+
// This has to be copy/pasted because zod blows up when there are circular dependencies
|
|
7660
|
+
_xact_id: z.string().describe(
|
|
7661
|
+
`The transaction id of an event is unique to the network operation that processed the event insertion. Transaction ids are monotonically increasing over time and can be used to retrieve a versioned snapshot of the prompt (see the \`version\` parameter)`
|
|
7662
|
+
),
|
|
7663
|
+
project_id: promptBaseSchema2.shape.project_id,
|
|
7664
|
+
log_id: z.literal("p").describe("A literal 'p' which identifies the object as a project prompt"),
|
|
7665
|
+
org_id: organizationSchema2.shape.id,
|
|
7666
|
+
name: promptBaseSchema2.shape.name,
|
|
7667
|
+
slug: z.string().describe("Unique identifier for the prompt"),
|
|
7668
|
+
description: promptBaseSchema2.shape.description,
|
|
7669
|
+
created: promptBaseSchema2.shape.created,
|
|
7670
|
+
prompt_data: promptDataSchema2.nullish().describe("The prompt, model, and its parameters"),
|
|
7671
|
+
tags: z.array(z.string()).nullish().describe("A list of tags for the prompt"),
|
|
7672
|
+
metadata: promptBaseSchema2.shape.metadata
|
|
7673
|
+
});
|
|
7674
|
+
var promptSchema2 = promptSchemaObject2.openapi("Prompt");
|
|
7675
|
+
var codeBundleSchema2 = z.strictObject({
|
|
7676
|
+
runtime_context: z.strictObject({
|
|
7677
|
+
runtime: validRuntimesEnum2,
|
|
7678
|
+
version: z.string()
|
|
7679
|
+
}),
|
|
7680
|
+
// This should be a union, once we support code living in different places
|
|
7681
|
+
// Other options should be:
|
|
7682
|
+
// - a "handler" function that has some signature [does AWS lambda assume it's always called "handler"?]
|
|
7683
|
+
location: z.strictObject({
|
|
7684
|
+
type: z.literal("experiment"),
|
|
7685
|
+
eval_name: z.string(),
|
|
7686
|
+
position: z.union([
|
|
7687
|
+
z.literal("task"),
|
|
7688
|
+
z.strictObject({ score: z.number() })
|
|
7689
|
+
])
|
|
7690
|
+
}),
|
|
7691
|
+
bundle_id: z.string()
|
|
7692
|
+
});
|
|
7693
|
+
var functionDataSchema2 = z.union([
|
|
7694
|
+
z.strictObject({
|
|
7695
|
+
type: z.literal("prompt")
|
|
7696
|
+
// For backwards compatibility reasons, this is hoisted out and stored
|
|
7697
|
+
// in the outer object
|
|
7698
|
+
}),
|
|
7699
|
+
z.strictObject({
|
|
7700
|
+
type: z.literal("code"),
|
|
7701
|
+
data: codeBundleSchema2
|
|
7702
|
+
}),
|
|
7703
|
+
z.strictObject({
|
|
7704
|
+
type: z.literal("global"),
|
|
7705
|
+
name: z.string()
|
|
7706
|
+
})
|
|
7707
|
+
]);
|
|
7708
|
+
var functionSchema22 = promptSchemaObject2.merge(
|
|
7709
|
+
z.strictObject({
|
|
7710
|
+
function_data: functionDataSchema2
|
|
7711
|
+
})
|
|
7712
|
+
).openapi("Function");
|
|
7713
|
+
var repoInfoSchema2 = z.strictObject({
|
|
7714
|
+
commit: z.string().nullish().describe("SHA of most recent commit"),
|
|
7715
|
+
branch: z.string().nullish().describe("Name of the branch the most recent commit belongs to"),
|
|
7716
|
+
tag: z.string().nullish().describe("Name of the tag on the most recent commit"),
|
|
7717
|
+
dirty: z.boolean().nullish().describe(
|
|
7718
|
+
"Whether or not the repo had uncommitted changes when snapshotted"
|
|
7719
|
+
),
|
|
7720
|
+
author_name: z.string().nullish().describe("Name of the author of the most recent commit"),
|
|
7721
|
+
author_email: z.string().nullish().describe("Email of the author of the most recent commit"),
|
|
7722
|
+
commit_message: z.string().nullish().describe("Most recent commit message"),
|
|
7723
|
+
commit_time: z.string().nullish().describe("Time of the most recent commit"),
|
|
7724
|
+
git_diff: z.string().nullish().describe(
|
|
7725
|
+
"If the repo was dirty when run, this includes the diff between the current state of the repo and the most recent commit."
|
|
7726
|
+
)
|
|
7727
|
+
}).describe(
|
|
7728
|
+
"Metadata about the state of the repo when the experiment was created"
|
|
7729
|
+
).openapi("RepoInfo");
|
|
7730
|
+
var experimentBaseSchema2 = generateBaseTableSchema2("experiment", {
|
|
7731
|
+
uniqueName: true
|
|
7732
|
+
});
|
|
7733
|
+
var experimentSchema2 = z.strictObject({
|
|
7734
|
+
id: experimentBaseSchema2.shape.id,
|
|
7735
|
+
project_id: experimentBaseSchema2.shape.project_id,
|
|
7736
|
+
name: experimentBaseSchema2.shape.name,
|
|
7737
|
+
description: experimentBaseSchema2.shape.description,
|
|
7738
|
+
created: experimentBaseSchema2.shape.created,
|
|
7739
|
+
repo_info: repoInfoSchema2.nullish(),
|
|
7740
|
+
commit: z.string().nullish().describe("Commit, taken directly from `repo_info.commit`"),
|
|
7741
|
+
base_exp_id: z.string().uuid().nullish().describe(
|
|
7742
|
+
"Id of default base experiment to compare against when viewing this experiment"
|
|
7743
|
+
),
|
|
7744
|
+
deleted_at: experimentBaseSchema2.shape.deleted_at,
|
|
7745
|
+
dataset_id: z.string().uuid().nullish().describe(
|
|
7746
|
+
"Identifier of the linked dataset, or null if the experiment is not linked to a dataset"
|
|
7747
|
+
),
|
|
7748
|
+
dataset_version: z.string().nullish().describe(
|
|
7749
|
+
"Version number of the linked dataset the experiment was run against. This can be used to reproduce the experiment after the dataset has been modified."
|
|
7750
|
+
),
|
|
7751
|
+
public: z.boolean().describe(
|
|
7752
|
+
"Whether or not the experiment is public. Public experiments can be viewed by anybody inside or outside the organization"
|
|
7753
|
+
),
|
|
7754
|
+
user_id: experimentBaseSchema2.shape.user_id,
|
|
7755
|
+
metadata: experimentBaseSchema2.shape.metadata
|
|
7756
|
+
}).openapi("Experiment");
|
|
7757
|
+
var promptSessionBaseSchema2 = generateBaseTableSchema2("promptSession", {
|
|
7758
|
+
uniqueName: true
|
|
7759
|
+
});
|
|
7760
|
+
var promptSessionSchema2 = z.strictObject({
|
|
7761
|
+
id: promptSessionBaseSchema2.shape.id,
|
|
7762
|
+
name: promptSessionBaseSchema2.shape.name,
|
|
7763
|
+
description: promptSessionBaseSchema2.shape.description,
|
|
7764
|
+
created: promptSessionBaseSchema2.shape.created,
|
|
7765
|
+
deleted_at: promptSessionBaseSchema2.shape.deleted_at,
|
|
7766
|
+
user_id: promptSessionBaseSchema2.shape.user_id,
|
|
7767
|
+
project_id: promptSessionBaseSchema2.shape.project_id,
|
|
7768
|
+
org_id: organizationSchema2.shape.id.nullish().describe(
|
|
7769
|
+
"This field is deprecated and will be removed in a future revision"
|
|
7770
|
+
)
|
|
7771
|
+
}).openapi("PromptSession");
|
|
7772
|
+
var permissionEnum2 = z.enum([
|
|
7773
|
+
"create",
|
|
7774
|
+
"read",
|
|
7775
|
+
"update",
|
|
7776
|
+
"delete",
|
|
7777
|
+
"create_acls",
|
|
7778
|
+
"read_acls",
|
|
7779
|
+
"update_acls",
|
|
7780
|
+
"delete_acls"
|
|
7781
|
+
]).describe(
|
|
7782
|
+
[
|
|
7783
|
+
"Each permission permits a certain type of operation on an object in the system",
|
|
7784
|
+
"Permissions can be assigned to to objects on an individual basis, or grouped into roles"
|
|
7785
|
+
].join("\n\n")
|
|
7786
|
+
);
|
|
7787
|
+
var aclObjectTypeEnum2 = z.enum([
|
|
7788
|
+
"organization",
|
|
7789
|
+
"project",
|
|
7790
|
+
"experiment",
|
|
7791
|
+
"dataset",
|
|
7792
|
+
"prompt",
|
|
7793
|
+
"prompt_session",
|
|
7794
|
+
"group",
|
|
7795
|
+
"role",
|
|
7796
|
+
"org_member",
|
|
7797
|
+
"project_log",
|
|
7798
|
+
"org_project"
|
|
7799
|
+
]).describe("The object type that the ACL applies to");
|
|
7800
|
+
var roleBaseSchema2 = generateBaseTableSchema2("role");
|
|
7801
|
+
var roleSchema2 = z.strictObject({
|
|
7802
|
+
id: roleBaseSchema2.shape.id,
|
|
7803
|
+
org_id: z.string().uuid().nullish().describe(
|
|
7804
|
+
[
|
|
7805
|
+
"Unique id for the organization that the role belongs under",
|
|
7806
|
+
"A null org_id indicates a system role, which may be assigned to anybody and inherited by any other role, but cannot be edited.",
|
|
7807
|
+
"It is forbidden to change the org after creating a role"
|
|
7808
|
+
].join("\n\n")
|
|
7809
|
+
),
|
|
7810
|
+
user_id: roleBaseSchema2.shape.user_id,
|
|
7811
|
+
created: roleBaseSchema2.shape.created,
|
|
7812
|
+
name: roleBaseSchema2.shape.name,
|
|
7813
|
+
description: roleBaseSchema2.shape.description,
|
|
7814
|
+
deleted_at: roleBaseSchema2.shape.deleted_at,
|
|
7815
|
+
member_permissions: z.array(
|
|
7816
|
+
z.strictObject({
|
|
7817
|
+
permission: permissionEnum2,
|
|
7818
|
+
restrict_object_type: aclObjectTypeEnum2.nullish()
|
|
7819
|
+
})
|
|
7820
|
+
).nullish().describe(
|
|
7821
|
+
"(permission, restrict_object_type) tuples which belong to this role"
|
|
7822
|
+
),
|
|
7823
|
+
member_roles: z.array(z.string().uuid()).nullish().describe(
|
|
7824
|
+
[
|
|
7825
|
+
"Ids of the roles this role inherits from",
|
|
7826
|
+
"An inheriting role has all the permissions contained in its member roles, as well as all of their inherited permissions"
|
|
7827
|
+
].join("\n\n")
|
|
7828
|
+
)
|
|
7829
|
+
}).describe(
|
|
7830
|
+
[
|
|
7831
|
+
"A role is a collection of permissions which can be granted as part of an ACL",
|
|
7832
|
+
"Roles can consist of individual permissions, as well as a set of roles they inherit from"
|
|
7833
|
+
].join("\n\n")
|
|
7834
|
+
).openapi("Role");
|
|
7835
|
+
var groupBaseSchema2 = generateBaseTableSchema2("group");
|
|
7836
|
+
var groupSchema2 = z.strictObject({
|
|
7837
|
+
id: groupBaseSchema2.shape.id,
|
|
7838
|
+
org_id: z.string().uuid().describe(
|
|
7839
|
+
[
|
|
7840
|
+
"Unique id for the organization that the group belongs under",
|
|
7841
|
+
"It is forbidden to change the org after creating a group"
|
|
7842
|
+
].join("\n\n")
|
|
7843
|
+
),
|
|
7844
|
+
user_id: groupBaseSchema2.shape.user_id,
|
|
7845
|
+
created: groupBaseSchema2.shape.created,
|
|
7846
|
+
name: groupBaseSchema2.shape.name,
|
|
7847
|
+
description: groupBaseSchema2.shape.description,
|
|
7848
|
+
deleted_at: groupBaseSchema2.shape.deleted_at,
|
|
7849
|
+
member_users: z.array(z.string().uuid()).nullish().describe("Ids of users which belong to this group"),
|
|
7850
|
+
member_groups: z.array(z.string().uuid()).nullish().describe(
|
|
7851
|
+
[
|
|
7852
|
+
"Ids of the groups this group inherits from",
|
|
7853
|
+
"An inheriting group has all the users contained in its member groups, as well as all of their inherited users"
|
|
7854
|
+
].join("\n\n")
|
|
7855
|
+
)
|
|
7856
|
+
}).describe(
|
|
7857
|
+
[
|
|
7858
|
+
"A group is a collection of users which can be assigned an ACL",
|
|
7859
|
+
"Groups can consist of individual users, as well as a set of groups they inherit from"
|
|
7860
|
+
].join("\n\n")
|
|
7861
|
+
).openapi("Group");
|
|
7862
|
+
var projectScoreTypeEnum2 = z.enum(["slider", "categorical", "weighted", "minimum"]).describe("The type of the configured score");
|
|
7863
|
+
var projectScoreCategory2 = z.object({
|
|
7864
|
+
name: z.string().describe("Name of the category"),
|
|
7865
|
+
value: z.number().describe(
|
|
7866
|
+
"Numerical value of the category. Must be between 0 and 1, inclusive"
|
|
7867
|
+
)
|
|
7868
|
+
}).describe("For categorical-type project scores, defines a single category").openapi("ProjectScoreCategory");
|
|
7869
|
+
var projectScoreBaseSchema2 = generateBaseTableSchema2("project score");
|
|
7870
|
+
var projectScoreSchema2 = z.strictObject({
|
|
7871
|
+
id: projectScoreBaseSchema2.shape.id,
|
|
7872
|
+
project_id: projectScoreBaseSchema2.shape.project_id,
|
|
7873
|
+
user_id: projectScoreBaseSchema2.shape.user_id.unwrap().unwrap(),
|
|
7874
|
+
created: projectScoreBaseSchema2.shape.created,
|
|
7875
|
+
name: projectScoreBaseSchema2.shape.name,
|
|
7876
|
+
description: projectScoreBaseSchema2.shape.description,
|
|
7877
|
+
score_type: projectScoreTypeEnum2,
|
|
7878
|
+
categories: z.union([
|
|
7879
|
+
projectScoreCategory2.array().describe(
|
|
7880
|
+
"For categorical-type project scores, the list of all categories"
|
|
7881
|
+
),
|
|
7882
|
+
z.record(z.number()).describe(
|
|
7883
|
+
"For weighted-type project scores, the weights of each score"
|
|
7884
|
+
),
|
|
7885
|
+
z.array(z.string()).describe(
|
|
7886
|
+
"For minimum-type project scores, the list of included scores"
|
|
7887
|
+
)
|
|
7888
|
+
]).nullish(),
|
|
7889
|
+
config: z.strictObject({
|
|
7890
|
+
multi_select: z.boolean().nullish(),
|
|
7891
|
+
destination: z.literal("expected").nullish()
|
|
7892
|
+
}).nullish()
|
|
7893
|
+
}).describe(
|
|
7894
|
+
"A project score is a user-configured score, which can be manually-labeled through the UI"
|
|
7895
|
+
).openapi("ProjectScore");
|
|
7896
|
+
var projectTagBaseSchema2 = generateBaseTableSchema2("project tag");
|
|
7897
|
+
var projectTagSchema2 = z.strictObject({
|
|
7898
|
+
id: projectTagBaseSchema2.shape.id,
|
|
7899
|
+
project_id: projectTagBaseSchema2.shape.project_id,
|
|
7900
|
+
user_id: projectTagBaseSchema2.shape.user_id.unwrap().unwrap(),
|
|
7901
|
+
created: projectTagBaseSchema2.shape.created,
|
|
7902
|
+
name: projectTagBaseSchema2.shape.name,
|
|
7903
|
+
description: projectTagBaseSchema2.shape.description,
|
|
7904
|
+
color: z.string().nullish().describe("Color of the tag for the UI")
|
|
7905
|
+
}).describe(
|
|
7906
|
+
"A project tag is a user-configured tag for tracking and filtering your experiments, logs, and other data"
|
|
7907
|
+
).openapi("ProjectTag");
|
|
7908
|
+
var viewBaseSchema2 = generateBaseTableSchema2("view");
|
|
7909
|
+
var viewSchema2 = z.strictObject({
|
|
7910
|
+
id: viewBaseSchema2.shape.id,
|
|
7911
|
+
object_type: aclObjectTypeEnum2,
|
|
7912
|
+
object_id: z.string().uuid().describe("The id of the object the view applies to"),
|
|
7913
|
+
view_type: viewTypeEnum2,
|
|
7914
|
+
name: viewBaseSchema2.shape.name,
|
|
7915
|
+
created: viewBaseSchema2.shape.created,
|
|
7916
|
+
view_data: viewDataSchema2.nullish().describe("The view definition"),
|
|
7917
|
+
options: viewOptionsSchema2.nullish().describe("Options for the view in the app"),
|
|
7918
|
+
user_id: viewBaseSchema2.shape.user_id,
|
|
7919
|
+
deleted_at: roleBaseSchema2.shape.deleted_at
|
|
7920
|
+
}).openapi("View");
|
|
7921
|
+
var aclBaseSchema2 = generateBaseTableSchema2("acl");
|
|
7922
|
+
var aclSchema2 = z.strictObject({
|
|
7923
|
+
id: aclBaseSchema2.shape.id,
|
|
7924
|
+
object_type: aclObjectTypeEnum2,
|
|
7925
|
+
object_id: z.string().uuid().describe("The id of the object the ACL applies to"),
|
|
7926
|
+
user_id: z.string().uuid().nullish().describe(
|
|
7927
|
+
"Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided"
|
|
7928
|
+
),
|
|
7929
|
+
group_id: z.string().uuid().nullish().describe(
|
|
7930
|
+
"Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided"
|
|
7931
|
+
),
|
|
7932
|
+
permission: permissionEnum2.nullish().describe(
|
|
7933
|
+
"Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided"
|
|
7934
|
+
),
|
|
7935
|
+
restrict_object_type: aclObjectTypeEnum2.nullish().describe(
|
|
7936
|
+
"When setting a permission directly, optionally restricts the permission grant to just the specified object type. Cannot be set alongside a `role_id`."
|
|
7937
|
+
),
|
|
7938
|
+
role_id: z.string().uuid().nullish().describe(
|
|
7939
|
+
"Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided"
|
|
7940
|
+
),
|
|
7941
|
+
_object_org_id: z.string().uuid().describe("The organization the ACL's referred object belongs to"),
|
|
7942
|
+
created: aclBaseSchema2.shape.created
|
|
7943
|
+
}).describe(
|
|
7944
|
+
[
|
|
7945
|
+
"An ACL grants a certain permission or role to a certain user or group on an object.",
|
|
7946
|
+
"ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on a project, they will also have read permissions on any experiment, dataset, etc. created within that project.",
|
|
7947
|
+
"To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the ACL, as part of a direct permission grant or as part of a role."
|
|
7948
|
+
].join("\n\n")
|
|
7949
|
+
).openapi("Acl");
|
|
7950
|
+
var appLimitSchema2 = z.number().int().nonnegative().describe("Limit the number of objects to return");
|
|
7951
|
+
function generateBaseTableOpSchema2(objectName) {
|
|
7952
|
+
return z.strictObject({
|
|
7953
|
+
org_name: z.string().nullish().describe(
|
|
7954
|
+
`For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the ${objectName} belongs in.`
|
|
7955
|
+
)
|
|
7956
|
+
});
|
|
7957
|
+
}
|
|
7958
|
+
var startingAfterSchema2 = z.string().uuid().describe(
|
|
7959
|
+
[
|
|
7960
|
+
"Pagination cursor id.",
|
|
7961
|
+
"For example, if the final item in the last page you fetched had an id of `foo`, pass `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` and `ending_before`"
|
|
7962
|
+
].join("\n\n")
|
|
7963
|
+
).openapi("StartingAfter");
|
|
7964
|
+
var endingBeforeSchema2 = z.string().uuid().describe(
|
|
7965
|
+
[
|
|
7966
|
+
"Pagination cursor id.",
|
|
7967
|
+
"For example, if the initial item in the last page you fetched had an id of `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only pass one of `starting_after` and `ending_before`"
|
|
7968
|
+
].join("\n\n")
|
|
7969
|
+
).openapi("EndingBefore");
|
|
7970
|
+
var createProjectBaseSchema2 = generateBaseTableOpSchema2("project");
|
|
7971
|
+
var createProjectSchema2 = z.strictObject({
|
|
7972
|
+
name: projectSchema2.shape.name,
|
|
7973
|
+
org_name: createProjectBaseSchema2.shape.org_name
|
|
7974
|
+
}).openapi("CreateProject");
|
|
7975
|
+
var patchProjectSchema2 = z.strictObject({
|
|
7976
|
+
name: projectSchema2.shape.name.nullish(),
|
|
7977
|
+
settings: projectSchema2.shape.settings.describe(
|
|
7978
|
+
"Project settings. Patch operations replace all settings, so make sure you include all settings you want to keep."
|
|
7979
|
+
).nullish()
|
|
7980
|
+
}).openapi("PatchProject");
|
|
7981
|
+
var createExperimentSchema2 = z.strictObject({
|
|
7982
|
+
project_id: experimentSchema2.shape.project_id,
|
|
7983
|
+
name: experimentSchema2.shape.name.nullish(),
|
|
7984
|
+
description: experimentSchema2.shape.description,
|
|
7985
|
+
repo_info: experimentSchema2.shape.repo_info,
|
|
7986
|
+
base_exp_id: experimentSchema2.shape.base_exp_id,
|
|
7987
|
+
dataset_id: experimentSchema2.shape.dataset_id,
|
|
7988
|
+
dataset_version: experimentSchema2.shape.dataset_version,
|
|
7989
|
+
public: experimentSchema2.shape.public.nullish(),
|
|
7990
|
+
metadata: experimentSchema2.shape.metadata,
|
|
7991
|
+
ensure_new: z.boolean().nullish().describe(
|
|
7992
|
+
"Normally, creating an experiment with the same name as an existing experiment will return the existing one un-modified. But if `ensure_new` is true, registration will generate a new experiment with a unique name in case of a conflict."
|
|
7993
|
+
)
|
|
7994
|
+
}).openapi("CreateExperiment");
|
|
7995
|
+
var patchExperimentSchema2 = createExperimentSchema2.omit({ project_id: true, ensure_new: true }).openapi("PatchExperiment");
|
|
7996
|
+
var createDatasetSchema2 = z.strictObject({
|
|
7997
|
+
project_id: datasetSchema2.shape.project_id,
|
|
7998
|
+
name: datasetSchema2.shape.name,
|
|
7999
|
+
description: datasetSchema2.shape.description
|
|
8000
|
+
}).openapi("CreateDataset");
|
|
8001
|
+
var patchDatasetSchema2 = z.strictObject({
|
|
8002
|
+
name: datasetSchema2.shape.name.nullish(),
|
|
8003
|
+
description: datasetSchema2.shape.description
|
|
8004
|
+
}).openapi("PatchDataset");
|
|
8005
|
+
var createPromptSchema2 = promptSchema2.omit({
|
|
8006
|
+
id: true,
|
|
8007
|
+
_xact_id: true,
|
|
8008
|
+
org_id: true,
|
|
8009
|
+
log_id: true,
|
|
8010
|
+
created: true,
|
|
8011
|
+
metadata: true
|
|
8012
|
+
}).openapi("CreatePrompt");
|
|
8013
|
+
var createFunctionSchema2 = functionSchema22.omit({
|
|
8014
|
+
id: true,
|
|
8015
|
+
_xact_id: true,
|
|
8016
|
+
org_id: true,
|
|
8017
|
+
log_id: true,
|
|
8018
|
+
created: true,
|
|
8019
|
+
metadata: true
|
|
8020
|
+
}).openapi("CreateFunction");
|
|
8021
|
+
var patchPromptSchema2 = z.strictObject({
|
|
8022
|
+
name: promptSchema2.shape.name.nullish(),
|
|
8023
|
+
description: promptSchema2.shape.description.nullish(),
|
|
8024
|
+
prompt_data: promptSchema2.shape.prompt_data.nullish(),
|
|
8025
|
+
tags: promptSchema2.shape.tags.nullish()
|
|
8026
|
+
}).openapi("PatchPrompt");
|
|
8027
|
+
var patchFunctionSchema2 = z.strictObject({
|
|
8028
|
+
name: functionSchema22.shape.name.nullish(),
|
|
8029
|
+
description: functionSchema22.shape.description.nullish(),
|
|
8030
|
+
prompt_data: functionSchema22.shape.prompt_data.nullish(),
|
|
8031
|
+
function_data: functionSchema22.shape.function_data.nullish(),
|
|
8032
|
+
tags: functionSchema22.shape.tags.nullish()
|
|
8033
|
+
}).openapi("PatchFunction");
|
|
8034
|
+
var createRoleBaseSchema2 = generateBaseTableOpSchema2("role");
|
|
8035
|
+
var createRoleSchema2 = z.strictObject({
|
|
8036
|
+
name: roleSchema2.shape.name,
|
|
8037
|
+
description: roleSchema2.shape.description,
|
|
8038
|
+
member_permissions: roleSchema2.shape.member_permissions,
|
|
8039
|
+
member_roles: roleSchema2.shape.member_roles,
|
|
8040
|
+
org_name: createRoleBaseSchema2.shape.org_name
|
|
8041
|
+
}).openapi("CreateRole");
|
|
8042
|
+
var patchRoleSchema2 = createRoleSchema2.omit({
|
|
8043
|
+
name: true,
|
|
8044
|
+
org_name: true,
|
|
8045
|
+
member_permissions: true,
|
|
8046
|
+
member_roles: true
|
|
8047
|
+
}).merge(
|
|
8048
|
+
z.strictObject({
|
|
8049
|
+
name: createRoleSchema2.shape.name.nullish(),
|
|
8050
|
+
add_member_permissions: roleSchema2.shape.member_permissions.nullish().describe("A list of permissions to add to the role"),
|
|
8051
|
+
remove_member_permissions: roleSchema2.shape.member_permissions.nullish().describe("A list of permissions to remove from the role"),
|
|
8052
|
+
add_member_roles: roleSchema2.shape.member_roles.nullish().describe(
|
|
8053
|
+
"A list of role IDs to add to the role's inheriting-from set"
|
|
8054
|
+
),
|
|
8055
|
+
remove_member_roles: roleSchema2.shape.member_roles.nullish().describe(
|
|
8056
|
+
"A list of role IDs to remove from the role's inheriting-from set"
|
|
8057
|
+
)
|
|
8058
|
+
})
|
|
8059
|
+
).openapi("PatchRole");
|
|
8060
|
+
var createGroupBaseSchema2 = generateBaseTableOpSchema2("group");
|
|
8061
|
+
var createGroupSchema2 = z.strictObject({
|
|
8062
|
+
name: groupSchema2.shape.name,
|
|
8063
|
+
description: groupSchema2.shape.description,
|
|
8064
|
+
member_users: groupSchema2.shape.member_users,
|
|
8065
|
+
member_groups: groupSchema2.shape.member_groups,
|
|
8066
|
+
org_name: createGroupBaseSchema2.shape.org_name
|
|
8067
|
+
}).openapi("CreateGroup");
|
|
8068
|
+
var patchGroupSchema2 = createGroupSchema2.omit({ name: true, org_name: true, member_users: true, member_groups: true }).merge(
|
|
8069
|
+
z.strictObject({
|
|
8070
|
+
name: createGroupSchema2.shape.name.nullish(),
|
|
8071
|
+
add_member_users: groupSchema2.shape.member_users.nullish().describe("A list of user IDs to add to the group"),
|
|
8072
|
+
remove_member_users: groupSchema2.shape.member_users.nullish().describe("A list of user IDs to remove from the group"),
|
|
8073
|
+
add_member_groups: groupSchema2.shape.member_groups.nullish().describe(
|
|
8074
|
+
"A list of group IDs to add to the group's inheriting-from set"
|
|
8075
|
+
),
|
|
8076
|
+
remove_member_groups: groupSchema2.shape.member_groups.nullish().describe(
|
|
8077
|
+
"A list of group IDs to remove from the group's inheriting-from set"
|
|
8078
|
+
)
|
|
8079
|
+
})
|
|
8080
|
+
).openapi("PatchGroup");
|
|
8081
|
+
var createAclSchema2 = aclSchema2.omit({
|
|
8082
|
+
id: true,
|
|
8083
|
+
created: true,
|
|
8084
|
+
_object_org_id: true
|
|
8085
|
+
}).openapi("CreateAcl");
|
|
8086
|
+
var createProjectScoreSchema2 = z.strictObject({
|
|
8087
|
+
project_id: projectScoreSchema2.shape.project_id,
|
|
8088
|
+
name: projectScoreSchema2.shape.name,
|
|
8089
|
+
description: projectScoreSchema2.shape.description,
|
|
8090
|
+
score_type: projectScoreSchema2.shape.score_type,
|
|
8091
|
+
categories: projectScoreSchema2.shape.categories
|
|
8092
|
+
}).openapi("CreateProjectScore");
|
|
8093
|
+
var patchProjectScoreSchema2 = z.strictObject({
|
|
8094
|
+
name: projectScoreSchema2.shape.name.nullish(),
|
|
8095
|
+
description: projectScoreSchema2.shape.description,
|
|
8096
|
+
score_type: projectScoreSchema2.shape.score_type.nullish(),
|
|
8097
|
+
categories: projectScoreSchema2.shape.categories
|
|
8098
|
+
}).openapi("PatchProjectScore");
|
|
8099
|
+
var createProjectTagSchema2 = z.strictObject({
|
|
8100
|
+
project_id: projectTagSchema2.shape.project_id,
|
|
8101
|
+
name: projectTagSchema2.shape.name,
|
|
8102
|
+
description: projectTagSchema2.shape.description,
|
|
8103
|
+
color: projectTagSchema2.shape.color
|
|
8104
|
+
}).openapi("CreateProjectTag");
|
|
8105
|
+
var patchProjectTagSchema2 = z.strictObject({
|
|
8106
|
+
name: projectTagSchema2.shape.name.nullish(),
|
|
8107
|
+
description: projectTagSchema2.shape.description,
|
|
8108
|
+
color: projectTagSchema2.shape.color
|
|
8109
|
+
}).openapi("PatchProjectTag");
|
|
8110
|
+
var createViewSchema2 = viewSchema2.omit({
|
|
8111
|
+
id: true,
|
|
8112
|
+
created: true
|
|
8113
|
+
}).openapi("CreateView");
|
|
8114
|
+
var patchViewSchema2 = z.strictObject({
|
|
8115
|
+
object_type: viewSchema2.shape.object_type,
|
|
8116
|
+
object_id: viewSchema2.shape.object_id,
|
|
8117
|
+
view_type: viewSchema2.shape.view_type.nullish(),
|
|
8118
|
+
name: viewSchema2.shape.name.nullish(),
|
|
8119
|
+
view_data: viewSchema2.shape.view_data,
|
|
8120
|
+
options: viewSchema2.shape.options,
|
|
8121
|
+
user_id: viewSchema2.shape.user_id
|
|
8122
|
+
}).openapi("PatchView");
|
|
8123
|
+
var deleteViewSchema2 = z.strictObject({
|
|
8124
|
+
object_type: viewSchema2.shape.object_type,
|
|
8125
|
+
object_id: viewSchema2.shape.object_id
|
|
8126
|
+
}).openapi("DeleteView");
|
|
8127
|
+
var patchOrganizationSchema2 = z.strictObject({
|
|
8128
|
+
name: organizationSchema2.shape.name.nullish(),
|
|
8129
|
+
api_url: organizationSchema2.shape.api_url.nullish(),
|
|
8130
|
+
proxy_url: organizationSchema2.shape.proxy_url.nullish(),
|
|
8131
|
+
realtime_url: organizationSchema2.shape.realtime_url.nullish()
|
|
8132
|
+
}).openapi("PatchOrganization");
|
|
8133
|
+
function capitalize2(s, sep) {
|
|
8134
|
+
const items = sep ? s.split(sep) : [s];
|
|
8135
|
+
return items.map((s2) => s2 ? s2.charAt(0).toUpperCase() + s2.slice(1) : s2).join(sep || "");
|
|
8136
|
+
}
|
|
8137
|
+
var TRANSACTION_ID_FIELD2 = "_xact_id";
|
|
8138
|
+
var OBJECT_DELETE_FIELD2 = "_object_delete";
|
|
8139
|
+
var IS_MERGE_FIELD2 = "_is_merge";
|
|
8140
|
+
var MERGE_PATHS_FIELD2 = "_merge_paths";
|
|
8141
|
+
var VALID_SOURCES2 = ["app", "api", "external"];
|
|
8142
|
+
var PARENT_ID_FIELD2 = "_parent_id";
|
|
8143
|
+
var spanTypeAttributeValues2 = [
|
|
8144
|
+
"llm",
|
|
8145
|
+
"score",
|
|
8146
|
+
"function",
|
|
8147
|
+
"eval",
|
|
8148
|
+
"task",
|
|
8149
|
+
"tool"
|
|
8150
|
+
];
|
|
8151
|
+
(0, import_zod_to_openapi4.extendZodWithOpenApi)(z);
|
|
8152
|
+
var auditSourcesSchema2 = z.enum(VALID_SOURCES2);
|
|
8153
|
+
function generateBaseEventOpSchema2(objectType2) {
|
|
8154
|
+
const eventDescription = getEventObjectDescription2(objectType2);
|
|
8155
|
+
return z.strictObject({
|
|
8156
|
+
id: z.string().describe(
|
|
8157
|
+
`A unique identifier for the ${eventDescription} event. If you don't provide one, BrainTrust will generate one for you`
|
|
8158
|
+
),
|
|
8159
|
+
[TRANSACTION_ID_FIELD2]: z.string().describe(
|
|
8160
|
+
`The transaction id of an event is unique to the network operation that processed the event insertion. Transaction ids are monotonically increasing over time and can be used to retrieve a versioned snapshot of the ${eventDescription} (see the \`version\` parameter)`
|
|
8161
|
+
),
|
|
8162
|
+
created: datetimeStringSchema2.describe(
|
|
8163
|
+
`The timestamp the ${eventDescription} event was created`
|
|
8164
|
+
),
|
|
8165
|
+
input: customTypes2.any,
|
|
8166
|
+
output: customTypes2.any,
|
|
8167
|
+
expected: customTypes2.any,
|
|
8168
|
+
tags: z.array(z.string()).nullish().describe("A list of tags to log"),
|
|
8169
|
+
scores: z.record(z.number().min(0).max(1).nullish()).nullish(),
|
|
8170
|
+
metadata: z.record(customTypes2.any).nullish().describe(
|
|
8171
|
+
"A dictionary with additional data about the test example, model outputs, or just about anything else that's relevant, that you can use to help find and analyze examples later. For example, you could log the `prompt`, example's `id`, or anything else that would be useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys must be strings"
|
|
8172
|
+
),
|
|
8173
|
+
metrics: z.strictObject({
|
|
8174
|
+
start: z.number().nullish().describe(
|
|
8175
|
+
`A unix timestamp recording when the section of code which produced the ${eventDescription} event started`
|
|
8176
|
+
),
|
|
8177
|
+
end: z.number().nullish().describe(
|
|
8178
|
+
`A unix timestamp recording when the section of code which produced the ${eventDescription} event finished`
|
|
8179
|
+
),
|
|
8180
|
+
prompt_tokens: z.number().int().nullish().describe(
|
|
8181
|
+
`The number of tokens in the prompt used to generate the ${eventDescription} event (only set if this is an LLM span)`
|
|
8182
|
+
),
|
|
8183
|
+
completion_tokens: z.number().int().nullish().describe(
|
|
8184
|
+
`The number of tokens in the completion generated by the model (only set if this is an LLM span)`
|
|
8185
|
+
),
|
|
8186
|
+
tokens: z.number().int().nullish().describe(
|
|
8187
|
+
`The total number of tokens in the input and output of the ${eventDescription} event.`
|
|
8188
|
+
)
|
|
8189
|
+
}).catchall(customTypes2.any).nullish().describe(
|
|
8190
|
+
`Metrics are numerical measurements tracking the execution of the code that produced the ${eventDescription} event. Use "start" and "end" to track the time span over which the ${eventDescription} event was produced`
|
|
8191
|
+
),
|
|
8192
|
+
context: z.strictObject({
|
|
8193
|
+
caller_functionname: z.string().nullish().describe(
|
|
8194
|
+
`The function in code which created the ${eventDescription} event`
|
|
8195
|
+
),
|
|
8196
|
+
caller_filename: z.string().nullish().describe(
|
|
8197
|
+
`Name of the file in code where the ${eventDescription} event was created`
|
|
8198
|
+
),
|
|
8199
|
+
caller_lineno: z.number().int().nullish().describe(
|
|
8200
|
+
`Line of code where the ${eventDescription} event was created`
|
|
8201
|
+
)
|
|
8202
|
+
}).catchall(customTypes2.any).nullish().describe(
|
|
8203
|
+
`Context is additional information about the code that produced the ${eventDescription} event. It is essentially the textual counterpart to \`metrics\`. Use the \`caller_*\` attributes to track the location in code which produced the ${eventDescription} event`
|
|
8204
|
+
),
|
|
8205
|
+
span_id: z.string().uuid().describe(
|
|
8206
|
+
`A unique identifier used to link different ${eventDescription} events together as part of a full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on tracing`
|
|
8207
|
+
),
|
|
8208
|
+
span_parents: z.string().array().nullish().describe(
|
|
8209
|
+
`An array of the parent \`span_ids\` of this ${eventDescription} event. This should be empty for the root span of a trace, and should most often contain just one parent element for subspans`
|
|
8210
|
+
),
|
|
8211
|
+
root_span_id: z.string().uuid().describe(
|
|
8212
|
+
`The \`span_id\` of the root of the trace this ${eventDescription} event belongs to`
|
|
8213
|
+
),
|
|
8214
|
+
span_attributes: z.strictObject({
|
|
8215
|
+
name: z.string().nullish().describe("Name of the span, for display purposes only"),
|
|
8216
|
+
type: z.enum(spanTypeAttributeValues2).nullish().describe("Type of the span, for display purposes only")
|
|
8217
|
+
}).catchall(customTypes2.any).nullish().describe(
|
|
8218
|
+
"Human-identifying attributes of the span, such as name, type, etc."
|
|
8219
|
+
),
|
|
8220
|
+
[OBJECT_DELETE_FIELD2]: z.boolean().nullish().describe(
|
|
8221
|
+
`Pass \`${OBJECT_DELETE_FIELD2}=true\` to mark the ${eventDescription} event deleted. Deleted events will not show up in subsequent fetches for this ${eventDescription}`
|
|
8222
|
+
)
|
|
8223
|
+
});
|
|
8224
|
+
}
|
|
8225
|
+
function generateBaseEventFeedbackSchema2(objectType2) {
|
|
8226
|
+
const eventObjectType = getEventObjectType2(objectType2);
|
|
8227
|
+
const eventDescription = getEventObjectDescription2(objectType2);
|
|
8228
|
+
return z.strictObject({
|
|
8229
|
+
id: z.string().describe(
|
|
8230
|
+
`The id of the ${eventDescription} event to log feedback for. This is the row \`id\` returned by \`POST /v1/${eventObjectType}/{${objectType2}_id}/insert\``
|
|
8231
|
+
),
|
|
8232
|
+
scores: z.record(z.number().min(0).max(1).nullish()).nullish().describe(
|
|
8233
|
+
`A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the existing scores for the ${eventDescription} event`
|
|
8234
|
+
),
|
|
8235
|
+
expected: customTypes2.any.describe(
|
|
8236
|
+
"The ground truth value (an arbitrary, JSON serializable object) that you'd compare to `output` to determine if your `output` value is correct or not"
|
|
8237
|
+
),
|
|
8238
|
+
tags: z.array(z.string()).nullish().describe("A list of tags to log"),
|
|
8239
|
+
comment: z.string().nullish().describe(
|
|
8240
|
+
`An optional comment string to log about the ${eventDescription} event`
|
|
8241
|
+
),
|
|
8242
|
+
metadata: z.record(customTypes2.any).nullish().describe(
|
|
8243
|
+
"A dictionary with additional data about the feedback. If you have a `user_id`, you can log it here and access it in the Braintrust UI."
|
|
8244
|
+
),
|
|
8245
|
+
source: auditSourcesSchema2.nullish().describe(
|
|
8246
|
+
'The source of the feedback. Must be one of "external" (default), "app", or "api"'
|
|
8247
|
+
)
|
|
8248
|
+
});
|
|
8249
|
+
}
|
|
8250
|
+
var fetchLimitSchema2 = z.number().int().nonnegative().describe(
|
|
8251
|
+
[
|
|
8252
|
+
"limit the number of traces fetched",
|
|
8253
|
+
`Fetch queries may be paginated if the total result size is expected to be large (e.g. project_logs which accumulate over a long time). Note that fetch queries only support pagination in descending time order (from latest to earliest \`${TRANSACTION_ID_FIELD2}\`. Furthermore, later pages may return rows which showed up in earlier pages, except with an earlier \`${TRANSACTION_ID_FIELD2}\`. This happens because pagination occurs over the whole version history of the event log. You will most likely want to exclude any such duplicate, outdated rows (by \`id\`) from your combined result set.`,
|
|
8254
|
+
`The \`limit\` parameter controls the number of full traces to return. So you may end up with more individual rows than the specified limit if you are fetching events containing traces.`
|
|
8255
|
+
].join("\n\n")
|
|
8256
|
+
);
|
|
8257
|
+
var fetchPaginationCursorDescription2 = [
|
|
8258
|
+
"DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.",
|
|
8259
|
+
"Together, `max_xact_id` and `max_root_span_id` form a pagination cursor",
|
|
8260
|
+
`Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple \`(${TRANSACTION_ID_FIELD2}, root_span_id)\`. See the documentation of \`limit\` for an overview of paginating fetch queries.`
|
|
8261
|
+
].join("\n\n");
|
|
8262
|
+
var maxXactIdSchema2 = z.string().describe(fetchPaginationCursorDescription2);
|
|
8263
|
+
var maxRootSpanIdSchema2 = z.string().describe(fetchPaginationCursorDescription2);
|
|
8264
|
+
var fetchPaginationCursorSchema2 = z.string().describe(
|
|
8265
|
+
[
|
|
8266
|
+
"An opaque string to be used as a cursor for the next page of results, in order from latest to earliest.",
|
|
8267
|
+
"The string can be obtained directly from the `cursor` property of the previous fetch query"
|
|
8268
|
+
].join("\n\n")
|
|
8269
|
+
);
|
|
8270
|
+
var versionSchema2 = z.string().describe(
|
|
8271
|
+
[
|
|
8272
|
+
"Retrieve a snapshot of events from a past time",
|
|
8273
|
+
"The version id is essentially a filter on the latest event transaction id. You can use the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch."
|
|
8274
|
+
].join("\n\n")
|
|
8275
|
+
);
|
|
8276
|
+
var pathTypeFilterSchema2 = z.strictObject({
|
|
8277
|
+
type: z.literal("path_lookup").describe("Denotes the type of filter as a path-lookup filter"),
|
|
8278
|
+
path: z.string().array().describe(
|
|
8279
|
+
'List of fields describing the path to the value to be checked against. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]`'
|
|
8280
|
+
),
|
|
8281
|
+
value: customTypes2.any.describe(
|
|
8282
|
+
'The value to compare equality-wise against the event value at the specified `path`. The value must be a "primitive", that is, any JSON-serializable object except for objects and arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"`'
|
|
8283
|
+
)
|
|
8284
|
+
}).describe(
|
|
8285
|
+
'A path-lookup filter describes an equality comparison against a specific sub-field in the event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"`'
|
|
8286
|
+
).openapi("PathLookupFilter");
|
|
8287
|
+
var sqlTypeFilterSchema2 = z.strictObject({
|
|
8288
|
+
type: z.literal("sql_filter").describe("Denotes the type of filter as a sql-type filter"),
|
|
8289
|
+
expr: z.string().describe(
|
|
8290
|
+
`A SQL expression in [duckDB syntax](https://duckdb.org/docs/sql/expressions/overview). For instance, if you wish to fuzzy-match the value of \`c\` in \`{"input": {"a": {"b": {"c": "hello"}}}}\`, pass \`expr="input->'a'->'b'->>'c' LIKE '%el%'"\`.`
|
|
8291
|
+
)
|
|
8292
|
+
}).describe(
|
|
8293
|
+
`A sql-type filter describes a general filter over an individual row in [duckDB syntax](https://duckdb.org/docs/sql/expressions/overview). For instance, if you wish to fuzzy-match the value of \`c\` in \`{"input": {"a": {"b": {"c": "hello"}}}}\`, pass \`expr="input->'a'->'b'->>'c' LIKE '%el%'"\`.`
|
|
8294
|
+
).openapi("SQLFilter");
|
|
8295
|
+
var allFetchFiltersSchema2 = z.union([pathTypeFilterSchema2, sqlTypeFilterSchema2]).array().describe(
|
|
8296
|
+
"A list of filters on the events to fetch. Filters can either be specialized `path=value` expressions or general SQL expressions in [duckDB syntax](https://duckdb.org/docs/sql/expressions/overview). When possible, prefer path-lookup type filters over general SQL-type filters, as they are likely to activate indices in the DB and run faster"
|
|
8297
|
+
).openapi("AllFetchEventsFilters");
|
|
8298
|
+
var fetchFiltersSchema2 = pathTypeFilterSchema2.array().describe(
|
|
8299
|
+
"A list of filters on the events to fetch. Currently, only path-lookup type filters are supported, but we may add more in the future"
|
|
8300
|
+
).openapi("FetchEventsFilters");
|
|
8301
|
+
var fetchEventsRequestSchema2 = z.strictObject({
|
|
8302
|
+
limit: fetchLimitSchema2.nullish(),
|
|
8303
|
+
cursor: fetchPaginationCursorSchema2.nullish(),
|
|
8304
|
+
max_xact_id: maxXactIdSchema2.nullish(),
|
|
8305
|
+
max_root_span_id: maxRootSpanIdSchema2.nullish(),
|
|
8306
|
+
filters: fetchFiltersSchema2.nullish(),
|
|
8307
|
+
version: versionSchema2.nullish()
|
|
8308
|
+
}).openapi("FetchEventsRequest");
|
|
8309
|
+
function makeFetchEventsResponseSchema2(objectType2, eventSchema) {
|
|
8310
|
+
const eventName = capitalize2(getEventObjectType2(objectType2), "_").replace(
|
|
8311
|
+
"_",
|
|
8312
|
+
""
|
|
8313
|
+
);
|
|
8314
|
+
return z.strictObject({
|
|
8315
|
+
events: eventSchema.array().describe("A list of fetched events"),
|
|
8316
|
+
cursor: z.string().nullish().describe(
|
|
8317
|
+
[
|
|
8318
|
+
"Pagination cursor",
|
|
8319
|
+
"Pass this string directly as the `cursor` param to your next fetch request to get the next page of results. Not provided if the returned result set is empty."
|
|
8320
|
+
].join("\n\n")
|
|
8321
|
+
)
|
|
8322
|
+
}).openapi(`Fetch${eventName}EventsResponse`);
|
|
8323
|
+
}
|
|
8324
|
+
var experimentEventBaseSchema2 = generateBaseEventOpSchema2("experiment");
|
|
8325
|
+
var experimentEventSchema2 = z.strictObject({
|
|
8326
|
+
id: experimentEventBaseSchema2.shape.id,
|
|
8327
|
+
dataset_record_id: z.string().nullish().describe(
|
|
8328
|
+
"If the experiment is associated to a dataset, this is the event-level dataset id this experiment event is tied to"
|
|
8329
|
+
),
|
|
8330
|
+
[TRANSACTION_ID_FIELD2]: experimentEventBaseSchema2.shape[TRANSACTION_ID_FIELD2],
|
|
8331
|
+
created: experimentEventBaseSchema2.shape.created,
|
|
8332
|
+
project_id: experimentSchema2.shape.project_id,
|
|
8333
|
+
experiment_id: experimentSchema2.shape.id,
|
|
8334
|
+
input: experimentEventBaseSchema2.shape.input.describe(
|
|
8335
|
+
"The arguments that uniquely define a test case (an arbitrary, JSON serializable object). Later on, Braintrust will use the `input` to know whether two test cases are the same between experiments, so they should not contain experiment-specific state. A simple rule of thumb is that if you run the same experiment twice, the `input` should be identical"
|
|
8336
|
+
),
|
|
8337
|
+
output: experimentEventBaseSchema2.shape.output.describe(
|
|
8338
|
+
"The output of your application, including post-processing (an arbitrary, JSON serializable object), that allows you to determine whether the result is correct or not. For example, in an app that generates SQL queries, the `output` should be the _result_ of the SQL query generated by the model, not the query itself, because there may be multiple valid queries that answer a single question"
|
|
8339
|
+
),
|
|
8340
|
+
expected: experimentEventBaseSchema2.shape.expected.describe(
|
|
8341
|
+
"The ground truth value (an arbitrary, JSON serializable object) that you'd compare to `output` to determine if your `output` value is correct or not. Braintrust currently does not compare `output` to `expected` for you, since there are so many different ways to do that correctly. Instead, these values are just used to help you navigate your experiments while digging into analyses. However, we may later use these values to re-score outputs or fine-tune your models"
|
|
8342
|
+
),
|
|
8343
|
+
scores: experimentEventBaseSchema2.shape.scores.describe(
|
|
8344
|
+
"A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety of signals that help you determine how accurate the outputs are compared to what you expect and diagnose failures. For example, a summarization app might have one score that tells you how accurate the summary is, and another that measures the word similarity between the generated and grouth truth summary. The word similarity score could help you determine whether the summarization was covering similar concepts or not. You can use these scores to help you sort, filter, and compare experiments"
|
|
8345
|
+
),
|
|
8346
|
+
metadata: experimentEventBaseSchema2.shape.metadata,
|
|
8347
|
+
tags: experimentEventBaseSchema2.shape.tags,
|
|
8348
|
+
metrics: experimentEventBaseSchema2.shape.metrics,
|
|
8349
|
+
context: experimentEventBaseSchema2.shape.context,
|
|
8350
|
+
span_id: experimentEventBaseSchema2.shape.span_id,
|
|
8351
|
+
span_parents: experimentEventBaseSchema2.shape.span_parents,
|
|
8352
|
+
root_span_id: experimentEventBaseSchema2.shape.root_span_id,
|
|
8353
|
+
span_attributes: experimentEventBaseSchema2.shape.span_attributes
|
|
8354
|
+
}).openapi("ExperimentEvent");
|
|
8355
|
+
var datasetEventBaseSchema2 = generateBaseEventOpSchema2("dataset");
|
|
8356
|
+
var datasetEventSchema2 = z.strictObject({
|
|
8357
|
+
id: datasetEventBaseSchema2.shape.id,
|
|
8358
|
+
[TRANSACTION_ID_FIELD2]: datasetEventBaseSchema2.shape[TRANSACTION_ID_FIELD2],
|
|
8359
|
+
created: datasetEventBaseSchema2.shape.created,
|
|
8360
|
+
project_id: datasetSchema2.shape.project_id,
|
|
8361
|
+
dataset_id: datasetSchema2.shape.id,
|
|
8362
|
+
input: datasetEventBaseSchema2.shape.input.describe(
|
|
8363
|
+
"The argument that uniquely define an input case (an arbitrary, JSON serializable object)"
|
|
8364
|
+
),
|
|
8365
|
+
expected: datasetEventBaseSchema2.shape.expected.describe(
|
|
8366
|
+
"The output of your application, including post-processing (an arbitrary, JSON serializable object)"
|
|
8367
|
+
),
|
|
8368
|
+
metadata: datasetEventBaseSchema2.shape.metadata,
|
|
8369
|
+
tags: datasetEventBaseSchema2.shape.tags,
|
|
8370
|
+
span_id: datasetEventBaseSchema2.shape.span_id,
|
|
8371
|
+
root_span_id: datasetEventBaseSchema2.shape.root_span_id
|
|
8372
|
+
}).openapi("DatasetEvent");
|
|
8373
|
+
var promptSessionEventBaseSchema2 = generateBaseEventOpSchema2("prompt_session");
|
|
8374
|
+
var promptSessionEventSchema2 = z.strictObject({
|
|
8375
|
+
id: promptSessionEventBaseSchema2.shape.id,
|
|
8376
|
+
[TRANSACTION_ID_FIELD2]: promptSessionEventBaseSchema2.shape[TRANSACTION_ID_FIELD2],
|
|
8377
|
+
created: promptSessionEventBaseSchema2.shape.created,
|
|
8378
|
+
project_id: promptSchema2.shape.project_id,
|
|
8379
|
+
prompt_session_id: promptSchema2.shape.id,
|
|
8380
|
+
prompt_session_data: customTypes2.any.describe(
|
|
8381
|
+
"Data about the prompt session"
|
|
8382
|
+
),
|
|
8383
|
+
prompt_data: customTypes2.any.describe("Data about the prompt"),
|
|
8384
|
+
object_data: customTypes2.any.describe("Data about the mapped data"),
|
|
8385
|
+
completion: customTypes2.any.describe("Data about the completion"),
|
|
8386
|
+
tags: promptSessionEventBaseSchema2.shape.tags
|
|
8387
|
+
}).openapi("PromptSessionEvent");
|
|
8388
|
+
var projectLogsEventBaseSchema2 = generateBaseEventOpSchema2("project");
|
|
8389
|
+
var projectLogsEventSchema2 = z.strictObject({
|
|
8390
|
+
id: projectLogsEventBaseSchema2.shape.id,
|
|
8391
|
+
[TRANSACTION_ID_FIELD2]: projectLogsEventBaseSchema2.shape[TRANSACTION_ID_FIELD2],
|
|
8392
|
+
created: projectLogsEventBaseSchema2.shape.created,
|
|
8393
|
+
org_id: projectSchema2.shape.org_id,
|
|
8394
|
+
project_id: projectSchema2.shape.id,
|
|
8395
|
+
log_id: z.literal("g").describe("A literal 'g' which identifies the log as a project log"),
|
|
8396
|
+
input: projectLogsEventBaseSchema2.shape.input.describe(
|
|
8397
|
+
"The arguments that uniquely define a user input (an arbitrary, JSON serializable object)."
|
|
8398
|
+
),
|
|
8399
|
+
output: projectLogsEventBaseSchema2.shape.output.describe(
|
|
8400
|
+
"The output of your application, including post-processing (an arbitrary, JSON serializable object), that allows you to determine whether the result is correct or not. For example, in an app that generates SQL queries, the `output` should be the _result_ of the SQL query generated by the model, not the query itself, because there may be multiple valid queries that answer a single question."
|
|
8401
|
+
),
|
|
8402
|
+
expected: projectLogsEventBaseSchema2.shape.expected.describe(
|
|
8403
|
+
"The ground truth value (an arbitrary, JSON serializable object) that you'd compare to `output` to determine if your `output` value is correct or not. Braintrust currently does not compare `output` to `expected` for you, since there are so many different ways to do that correctly. Instead, these values are just used to help you navigate while digging into analyses. However, we may later use these values to re-score outputs or fine-tune your models."
|
|
8404
|
+
),
|
|
8405
|
+
scores: projectLogsEventBaseSchema2.shape.scores.describe(
|
|
8406
|
+
"A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety of signals that help you determine how accurate the outputs are compared to what you expect and diagnose failures. For example, a summarization app might have one score that tells you how accurate the summary is, and another that measures the word similarity between the generated and grouth truth summary. The word similarity score could help you determine whether the summarization was covering similar concepts or not. You can use these scores to help you sort, filter, and compare logs."
|
|
8407
|
+
),
|
|
8408
|
+
metadata: projectLogsEventBaseSchema2.shape.metadata,
|
|
8409
|
+
tags: projectLogsEventBaseSchema2.shape.tags,
|
|
8410
|
+
metrics: projectLogsEventBaseSchema2.shape.metrics,
|
|
8411
|
+
context: projectLogsEventBaseSchema2.shape.context,
|
|
8412
|
+
span_id: projectLogsEventBaseSchema2.shape.span_id,
|
|
8413
|
+
span_parents: projectLogsEventBaseSchema2.shape.span_parents,
|
|
8414
|
+
root_span_id: projectLogsEventBaseSchema2.shape.root_span_id,
|
|
8415
|
+
span_attributes: projectLogsEventBaseSchema2.shape.span_attributes
|
|
8416
|
+
}).openapi("ProjectLogsEvent");
|
|
8417
|
+
var isMergeDescription2 = [
|
|
8418
|
+
"The `_is_merge` field controls how the row is merged with any existing row with the same id in the DB. By default (or when set to `false`), the existing row is completely replaced by the new row. When set to `true`, the new row is deep-merged into the existing row",
|
|
8419
|
+
'For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be `{"id": "foo", "input": {"b": 11, "c": 20}}`'
|
|
8420
|
+
].join("\n\n");
|
|
8421
|
+
var mergeEventSchema2 = z.strictObject({
|
|
8422
|
+
[IS_MERGE_FIELD2]: customTypes2.literalTrue.describe(isMergeDescription2),
|
|
8423
|
+
[MERGE_PATHS_FIELD2]: z.string().array().array().nullish().describe(
|
|
8424
|
+
[
|
|
8425
|
+
"The `_merge_paths` field allows controlling the depth of the merge. It can only be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge will not descend below any of the specified merge paths.",
|
|
8426
|
+
'For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and `input.c`.'
|
|
8427
|
+
].join("\n\n")
|
|
8428
|
+
)
|
|
8429
|
+
});
|
|
8430
|
+
var replacementEventSchema2 = z.strictObject({
|
|
8431
|
+
[IS_MERGE_FIELD2]: customTypes2.literalFalse.nullish().describe(isMergeDescription2),
|
|
8432
|
+
[PARENT_ID_FIELD2]: z.string().nullish().describe(
|
|
8433
|
+
[
|
|
8434
|
+
"Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details).",
|
|
8435
|
+
'For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row.'
|
|
8436
|
+
].join("\n\n")
|
|
8437
|
+
)
|
|
8438
|
+
});
|
|
8439
|
+
function makeInsertEventSchemas2(objectType2, insertSchema) {
|
|
8440
|
+
const eventDescription = getEventObjectDescription2(objectType2);
|
|
8441
|
+
const article = getObjectArticle2(objectType2);
|
|
8442
|
+
const eventSchemaName = capitalize2(
|
|
8443
|
+
getEventObjectType2(objectType2),
|
|
8444
|
+
"_"
|
|
8445
|
+
).replace("_", "");
|
|
8446
|
+
const replaceVariantSchema = insertSchema.merge(replacementEventSchema2).openapi(`Insert${eventSchemaName}EventReplace`);
|
|
8447
|
+
const mergeVariantSchema = insertSchema.merge(mergeEventSchema2).openapi(`Insert${eventSchemaName}EventMerge`);
|
|
8448
|
+
const eventSchema = z.union([replaceVariantSchema, mergeVariantSchema]).describe(`${capitalize2(article)} ${eventDescription} event`).openapi(`Insert${eventSchemaName}Event`);
|
|
8449
|
+
const requestSchema = z.strictObject({
|
|
8450
|
+
events: eventSchema.array().describe(`A list of ${eventDescription} events to insert`)
|
|
8451
|
+
}).openapi(`Insert${eventSchemaName}EventRequest`);
|
|
8452
|
+
return { eventSchema, requestSchema };
|
|
8453
|
+
}
|
|
8454
|
+
var insertEventsResponseSchema2 = z.strictObject({
|
|
8455
|
+
row_ids: z.string().array().describe(
|
|
8456
|
+
"The ids of all rows that were inserted, aligning one-to-one with the rows provided as input"
|
|
8457
|
+
)
|
|
8458
|
+
}).openapi("InsertEventsResponse");
|
|
8459
|
+
var {
|
|
8460
|
+
eventSchema: insertExperimentEventSchema2,
|
|
8461
|
+
requestSchema: insertExperimentEventsRequestSchema2
|
|
8462
|
+
} = makeInsertEventSchemas2(
|
|
8463
|
+
"experiment",
|
|
8464
|
+
z.strictObject({
|
|
8465
|
+
input: experimentEventSchema2.shape.input,
|
|
8466
|
+
output: experimentEventSchema2.shape.output,
|
|
8467
|
+
expected: experimentEventSchema2.shape.expected,
|
|
8468
|
+
scores: experimentEventSchema2.shape.scores,
|
|
8469
|
+
metadata: experimentEventSchema2.shape.metadata,
|
|
8470
|
+
tags: experimentEventSchema2.shape.tags,
|
|
8471
|
+
metrics: experimentEventSchema2.shape.metrics,
|
|
8472
|
+
context: experimentEventSchema2.shape.context,
|
|
8473
|
+
span_attributes: experimentEventSchema2.shape.span_attributes,
|
|
8474
|
+
id: experimentEventSchema2.shape.id.nullish(),
|
|
8475
|
+
dataset_record_id: experimentEventSchema2.shape.dataset_record_id,
|
|
8476
|
+
[OBJECT_DELETE_FIELD2]: experimentEventBaseSchema2.shape[OBJECT_DELETE_FIELD2]
|
|
8477
|
+
})
|
|
8478
|
+
);
|
|
8479
|
+
var {
|
|
8480
|
+
eventSchema: insertDatasetEventSchema2,
|
|
8481
|
+
requestSchema: insertDatasetEventsRequestSchema2
|
|
8482
|
+
} = makeInsertEventSchemas2(
|
|
8483
|
+
"dataset",
|
|
8484
|
+
z.strictObject({
|
|
8485
|
+
input: datasetEventSchema2.shape.input,
|
|
8486
|
+
expected: datasetEventSchema2.shape.expected,
|
|
8487
|
+
metadata: datasetEventSchema2.shape.metadata,
|
|
8488
|
+
tags: datasetEventSchema2.shape.tags,
|
|
8489
|
+
id: datasetEventSchema2.shape.id.nullish(),
|
|
8490
|
+
[OBJECT_DELETE_FIELD2]: datasetEventBaseSchema2.shape[OBJECT_DELETE_FIELD2]
|
|
8491
|
+
})
|
|
8492
|
+
);
|
|
8493
|
+
var {
|
|
8494
|
+
eventSchema: insertProjectLogsEventSchema2,
|
|
8495
|
+
requestSchema: insertProjectLogsEventsRequestSchema2
|
|
8496
|
+
} = makeInsertEventSchemas2(
|
|
8497
|
+
"project",
|
|
8498
|
+
z.strictObject({
|
|
8499
|
+
input: projectLogsEventSchema2.shape.input,
|
|
8500
|
+
output: projectLogsEventSchema2.shape.output,
|
|
8501
|
+
expected: projectLogsEventSchema2.shape.expected,
|
|
8502
|
+
scores: projectLogsEventSchema2.shape.scores,
|
|
8503
|
+
metadata: projectLogsEventSchema2.shape.metadata,
|
|
8504
|
+
tags: projectLogsEventSchema2.shape.tags,
|
|
8505
|
+
metrics: projectLogsEventSchema2.shape.metrics,
|
|
8506
|
+
context: projectLogsEventSchema2.shape.context,
|
|
8507
|
+
span_attributes: projectLogsEventSchema2.shape.span_attributes,
|
|
8508
|
+
id: projectLogsEventSchema2.shape.id.nullish(),
|
|
8509
|
+
[OBJECT_DELETE_FIELD2]: projectLogsEventBaseSchema2.shape[OBJECT_DELETE_FIELD2]
|
|
8510
|
+
})
|
|
8511
|
+
);
|
|
8512
|
+
function makeFeedbackRequestSchema2(objectType2, feedbackSchema) {
|
|
8513
|
+
const eventDescription = getEventObjectDescription2(objectType2);
|
|
8514
|
+
const eventSchemaName = capitalize2(
|
|
8515
|
+
getEventObjectType2(objectType2),
|
|
8516
|
+
"_"
|
|
8517
|
+
).replace("_", "");
|
|
8518
|
+
return z.strictObject({
|
|
8519
|
+
feedback: feedbackSchema.array().describe(`A list of ${eventDescription} feedback items`)
|
|
8520
|
+
}).openapi(`Feedback${eventSchemaName}EventRequest`);
|
|
8521
|
+
}
|
|
8522
|
+
var feedbackExperimentRequestBaseSchema2 = generateBaseEventFeedbackSchema2("experiment");
|
|
8523
|
+
var feedbackExperimentItemSchema2 = z.strictObject({
|
|
8524
|
+
id: feedbackExperimentRequestBaseSchema2.shape.id,
|
|
8525
|
+
scores: feedbackExperimentRequestBaseSchema2.shape.scores,
|
|
8526
|
+
expected: feedbackExperimentRequestBaseSchema2.shape.expected,
|
|
8527
|
+
comment: feedbackExperimentRequestBaseSchema2.shape.comment,
|
|
8528
|
+
metadata: feedbackExperimentRequestBaseSchema2.shape.metadata,
|
|
8529
|
+
source: feedbackExperimentRequestBaseSchema2.shape.source
|
|
8530
|
+
}).openapi("FeedbackExperimentItem");
|
|
8531
|
+
var feedbackExperimentRequestSchema2 = makeFeedbackRequestSchema2(
|
|
8532
|
+
"experiment",
|
|
8533
|
+
feedbackExperimentItemSchema2
|
|
8534
|
+
);
|
|
8535
|
+
var feedbackDatasetRequestBaseSchema2 = generateBaseEventFeedbackSchema2("dataset");
|
|
8536
|
+
var feedbackDatasetItemSchema2 = z.strictObject({
|
|
8537
|
+
id: feedbackDatasetRequestBaseSchema2.shape.id,
|
|
8538
|
+
comment: feedbackDatasetRequestBaseSchema2.shape.comment,
|
|
8539
|
+
metadata: feedbackDatasetRequestBaseSchema2.shape.metadata,
|
|
8540
|
+
source: feedbackDatasetRequestBaseSchema2.shape.source
|
|
8541
|
+
}).openapi("FeedbackDatasetItem");
|
|
8542
|
+
var feedbackDatasetRequestSchema2 = makeFeedbackRequestSchema2(
|
|
8543
|
+
"dataset",
|
|
8544
|
+
feedbackDatasetItemSchema2
|
|
8545
|
+
);
|
|
8546
|
+
var feedbackProjectLogsRequestBaseSchema2 = generateBaseEventFeedbackSchema2("project");
|
|
8547
|
+
var feedbackProjectLogsItemSchema2 = z.strictObject({
|
|
8548
|
+
id: feedbackProjectLogsRequestBaseSchema2.shape.id,
|
|
8549
|
+
scores: feedbackProjectLogsRequestBaseSchema2.shape.scores,
|
|
8550
|
+
expected: feedbackProjectLogsRequestBaseSchema2.shape.expected,
|
|
8551
|
+
comment: feedbackProjectLogsRequestBaseSchema2.shape.comment,
|
|
8552
|
+
metadata: feedbackProjectLogsRequestBaseSchema2.shape.metadata,
|
|
8553
|
+
source: feedbackProjectLogsRequestBaseSchema2.shape.source
|
|
8554
|
+
}).openapi("FeedbackProjectLogsItem");
|
|
8555
|
+
var feedbackProjectLogsRequestSchema2 = makeFeedbackRequestSchema2(
|
|
8556
|
+
"project",
|
|
8557
|
+
feedbackProjectLogsItemSchema2
|
|
8558
|
+
);
|
|
8559
|
+
var feedbackPromptRequestBaseSchema2 = generateBaseEventFeedbackSchema2("prompt");
|
|
8560
|
+
var feedbackPromptItemSchema2 = z.strictObject({
|
|
8561
|
+
id: feedbackPromptRequestBaseSchema2.shape.id,
|
|
8562
|
+
comment: feedbackPromptRequestBaseSchema2.shape.comment,
|
|
8563
|
+
metadata: feedbackPromptRequestBaseSchema2.shape.metadata,
|
|
8564
|
+
source: feedbackPromptRequestBaseSchema2.shape.source
|
|
8565
|
+
}).openapi("FeedbackPromptItem");
|
|
8566
|
+
var feedbackPromptRequestSchema2 = makeFeedbackRequestSchema2(
|
|
8567
|
+
"prompt",
|
|
8568
|
+
feedbackPromptItemSchema2
|
|
8569
|
+
);
|
|
8570
|
+
var feedbackFunctionRequestBaseSchema2 = generateBaseEventFeedbackSchema2("function");
|
|
8571
|
+
var feedbackFunctionItemSchema2 = z.strictObject({
|
|
8572
|
+
id: feedbackFunctionRequestBaseSchema2.shape.id,
|
|
8573
|
+
comment: feedbackFunctionRequestBaseSchema2.shape.comment,
|
|
8574
|
+
metadata: feedbackFunctionRequestBaseSchema2.shape.metadata,
|
|
8575
|
+
source: feedbackFunctionRequestBaseSchema2.shape.source
|
|
8576
|
+
}).openapi("FeedbackFunctionItem");
|
|
8577
|
+
var feedbackFunctionRequestSchema2 = makeFeedbackRequestSchema2(
|
|
8578
|
+
"function",
|
|
8579
|
+
feedbackFunctionItemSchema2
|
|
8580
|
+
);
|
|
8581
|
+
var feedbackPromptSessionRequestBaseSchema2 = generateBaseEventFeedbackSchema2("prompt_session");
|
|
8582
|
+
var feedbackPromptSessionItemSchema2 = z.strictObject({
|
|
8583
|
+
id: feedbackPromptSessionRequestBaseSchema2.shape.id,
|
|
8584
|
+
comment: feedbackPromptSessionRequestBaseSchema2.shape.comment,
|
|
8585
|
+
metadata: feedbackPromptSessionRequestBaseSchema2.shape.metadata,
|
|
8586
|
+
source: feedbackPromptSessionRequestBaseSchema2.shape.source
|
|
8587
|
+
}).openapi("FeedbackPromptSessionItem");
|
|
8588
|
+
var feedbackPromptSessionRequestSchema2 = makeFeedbackRequestSchema2(
|
|
8589
|
+
"prompt_session",
|
|
8590
|
+
feedbackPromptSessionItemSchema2
|
|
8591
|
+
);
|
|
8592
|
+
var eventObjectSchemas2 = {
|
|
8593
|
+
experiment: {
|
|
8594
|
+
event: experimentEventSchema2,
|
|
8595
|
+
fetchResponse: makeFetchEventsResponseSchema2(
|
|
8596
|
+
"experiment",
|
|
8597
|
+
experimentEventSchema2
|
|
8598
|
+
),
|
|
8599
|
+
insertEvent: insertExperimentEventSchema2,
|
|
8600
|
+
insertRequest: insertExperimentEventsRequestSchema2,
|
|
8601
|
+
feedbackItem: feedbackExperimentItemSchema2,
|
|
8602
|
+
feedbackRequest: feedbackExperimentRequestSchema2
|
|
8603
|
+
},
|
|
8604
|
+
dataset: {
|
|
8605
|
+
event: datasetEventSchema2,
|
|
8606
|
+
fetchResponse: makeFetchEventsResponseSchema2("dataset", datasetEventSchema2),
|
|
8607
|
+
insertEvent: insertDatasetEventSchema2,
|
|
8608
|
+
insertRequest: insertDatasetEventsRequestSchema2,
|
|
8609
|
+
feedbackItem: feedbackDatasetItemSchema2,
|
|
8610
|
+
feedbackRequest: feedbackDatasetRequestSchema2
|
|
8611
|
+
},
|
|
8612
|
+
project_logs: {
|
|
8613
|
+
event: projectLogsEventSchema2,
|
|
8614
|
+
fetchResponse: makeFetchEventsResponseSchema2(
|
|
8615
|
+
"project",
|
|
8616
|
+
projectLogsEventSchema2
|
|
8617
|
+
),
|
|
8618
|
+
insertEvent: insertProjectLogsEventSchema2,
|
|
8619
|
+
insertRequest: insertProjectLogsEventsRequestSchema2,
|
|
8620
|
+
feedbackItem: feedbackProjectLogsItemSchema2,
|
|
8621
|
+
feedbackRequest: feedbackProjectLogsRequestSchema2
|
|
8622
|
+
},
|
|
8623
|
+
prompt: {
|
|
8624
|
+
event: promptSchema2,
|
|
8625
|
+
fetchResponse: void 0,
|
|
8626
|
+
insertEvent: void 0,
|
|
8627
|
+
insertRequest: void 0,
|
|
8628
|
+
feedbackItem: feedbackPromptItemSchema2,
|
|
8629
|
+
feedbackRequest: feedbackPromptRequestSchema2
|
|
8630
|
+
},
|
|
8631
|
+
function: {
|
|
8632
|
+
event: functionSchema22,
|
|
8633
|
+
fetchResponse: void 0,
|
|
8634
|
+
insertEvent: void 0,
|
|
8635
|
+
insertRequest: void 0,
|
|
8636
|
+
feedbackItem: feedbackFunctionItemSchema2,
|
|
8637
|
+
feedbackRequest: feedbackFunctionRequestSchema2
|
|
8638
|
+
},
|
|
8639
|
+
prompt_session: {
|
|
8640
|
+
event: promptSessionEventSchema2,
|
|
8641
|
+
fetchResponse: void 0,
|
|
8642
|
+
insertEvent: void 0,
|
|
8643
|
+
insertRequest: void 0,
|
|
8644
|
+
feedbackItem: feedbackPromptSessionItemSchema2,
|
|
8645
|
+
feedbackRequest: feedbackPromptRequestBaseSchema2
|
|
8646
|
+
}
|
|
8647
|
+
};
|
|
8648
|
+
function makeCrossObjectIndividualRequestSchema2(objectType2) {
|
|
8649
|
+
const eventObjectType = getEventObjectType2(objectType2);
|
|
8650
|
+
const eventDescription = getEventObjectDescription2(objectType2);
|
|
8651
|
+
const eventObjectSchema = eventObjectSchemas2[eventObjectType];
|
|
8652
|
+
const insertObject = z.strictObject({
|
|
8653
|
+
...eventObjectSchema.insertEvent ? {
|
|
8654
|
+
events: eventObjectSchema.insertEvent.array().nullish().describe(`A list of ${eventDescription} events to insert`)
|
|
8655
|
+
} : {},
|
|
8656
|
+
feedback: eventObjectSchema.feedbackItem.array().nullish().describe(`A list of ${eventDescription} feedback items`)
|
|
8657
|
+
});
|
|
8658
|
+
return z.record(z.string().uuid(), insertObject).nullish().describe(
|
|
8659
|
+
`A mapping from ${objectType2} id to a set of log events and feedback items to insert`
|
|
8660
|
+
);
|
|
8661
|
+
}
|
|
8662
|
+
function makeCrossObjectIndividualResponseSchema2(objectType2) {
|
|
8663
|
+
return z.record(z.string().uuid(), insertEventsResponseSchema2).nullish().describe(
|
|
8664
|
+
`A mapping from ${objectType2} id to row ids for inserted \`events\``
|
|
8665
|
+
);
|
|
8666
|
+
}
|
|
8667
|
+
var crossObjectInsertRequestSchema2 = z.strictObject({
|
|
8668
|
+
experiment: makeCrossObjectIndividualRequestSchema2("experiment"),
|
|
8669
|
+
dataset: makeCrossObjectIndividualRequestSchema2("dataset"),
|
|
8670
|
+
project_logs: makeCrossObjectIndividualRequestSchema2("project")
|
|
8671
|
+
}).openapi("CrossObjectInsertRequest");
|
|
8672
|
+
var crossObjectInsertResponseSchema2 = z.strictObject({
|
|
8673
|
+
experiment: makeCrossObjectIndividualResponseSchema2("experiment"),
|
|
8674
|
+
dataset: makeCrossObjectIndividualResponseSchema2("dataset"),
|
|
8675
|
+
project_logs: makeCrossObjectIndividualResponseSchema2("project")
|
|
8676
|
+
}).openapi("CrossObjectInsertResponse");
|
|
8677
|
+
var summarizeScoresParamSchema2 = z.boolean().describe(
|
|
8678
|
+
"Whether to summarize the scores and metrics. If false (or omitted), only the metadata will be returned."
|
|
8679
|
+
);
|
|
8680
|
+
var comparisonExperimentIdParamSchema2 = z.string().uuid().describe(
|
|
8681
|
+
"The experiment to compare against, if summarizing scores and metrics. If omitted, will fall back to the `base_exp_id` stored in the experiment metadata, and then to the most recent experiment run in the same project. Must pass `summarize_scores=true` for this id to be used"
|
|
8682
|
+
);
|
|
8683
|
+
var summarizeDataParamSchema2 = z.boolean().describe(
|
|
8684
|
+
"Whether to summarize the data. If false (or omitted), only the metadata will be returned."
|
|
8685
|
+
);
|
|
8686
|
+
var summarizeExperimentResponseSchema2 = z.strictObject({
|
|
8687
|
+
project_name: z.string().describe("Name of the project that the experiment belongs to"),
|
|
8688
|
+
experiment_name: z.string().describe("Name of the experiment"),
|
|
8689
|
+
project_url: z.string().url().describe("URL to the project's page in the Braintrust app"),
|
|
8690
|
+
experiment_url: z.string().url().describe("URL to the experiment's page in the Braintrust app"),
|
|
8691
|
+
comparison_experiment_name: z.string().nullish().describe("The experiment which scores are baselined against"),
|
|
8692
|
+
scores: z.record(
|
|
8693
|
+
z.strictObject({
|
|
8694
|
+
name: z.string().describe("Name of the score"),
|
|
8695
|
+
score: z.number().min(0).max(1).describe("Average score across all examples"),
|
|
8696
|
+
diff: z.number().min(-1).max(1).optional().describe(
|
|
8697
|
+
"Difference in score between the current and comparison experiment"
|
|
8698
|
+
),
|
|
8699
|
+
improvements: z.number().int().min(0).describe("Number of improvements in the score"),
|
|
8700
|
+
regressions: z.number().int().min(0).describe("Number of regressions in the score")
|
|
8701
|
+
}).describe("Summary of a score's performance").openapi("ScoreSummary")
|
|
8702
|
+
).nullish().describe("Summary of the experiment's scores"),
|
|
8703
|
+
metrics: z.record(
|
|
8704
|
+
z.strictObject({
|
|
8705
|
+
name: z.string().describe("Name of the metric"),
|
|
8706
|
+
metric: z.number().describe("Average metric across all examples"),
|
|
8707
|
+
unit: z.string().describe("Unit label for the metric"),
|
|
8708
|
+
diff: z.number().optional().describe(
|
|
8709
|
+
"Difference in metric between the current and comparison experiment"
|
|
8710
|
+
),
|
|
8711
|
+
improvements: z.number().int().min(0).describe("Number of improvements in the metric"),
|
|
8712
|
+
regressions: z.number().int().min(0).describe("Number of regressions in the metric")
|
|
8713
|
+
}).describe("Summary of a metric's performance").openapi("MetricSummary")
|
|
8714
|
+
).nullish().describe("Summary of the experiment's metrics")
|
|
8715
|
+
}).describe("Summary of an experiment").openapi("SummarizeExperimentResponse");
|
|
8716
|
+
var summarizeDatasetResponseSchema2 = z.strictObject({
|
|
8717
|
+
project_name: z.string().describe("Name of the project that the dataset belongs to"),
|
|
8718
|
+
dataset_name: z.string().describe("Name of the dataset"),
|
|
8719
|
+
project_url: z.string().url().describe("URL to the project's page in the Braintrust app"),
|
|
8720
|
+
dataset_url: z.string().url().describe("URL to the dataset's page in the Braintrust app"),
|
|
8721
|
+
data_summary: z.strictObject({
|
|
8722
|
+
total_records: z.number().int().min(0).describe("Total number of records in the dataset")
|
|
8723
|
+
}).nullish().describe("Summary of a dataset's data").openapi("DataSummary")
|
|
8724
|
+
}).describe("Summary of a dataset").openapi("SummarizeDatasetResponse");
|
|
8725
|
+
|
|
8726
|
+
// src/util.ts
|
|
8727
|
+
var GLOBAL_PROJECT = "Global";
|
|
8728
|
+
function runFinally(f, finallyF) {
|
|
8729
|
+
let runSyncCleanup = true;
|
|
8730
|
+
try {
|
|
8731
|
+
const ret = f();
|
|
8732
|
+
if (ret instanceof Promise) {
|
|
8733
|
+
runSyncCleanup = false;
|
|
8734
|
+
return ret.finally(finallyF);
|
|
8735
|
+
} else {
|
|
8736
|
+
return ret;
|
|
8737
|
+
}
|
|
8738
|
+
} finally {
|
|
8739
|
+
if (runSyncCleanup) {
|
|
8740
|
+
finallyF();
|
|
8741
|
+
}
|
|
8742
|
+
}
|
|
8743
|
+
}
|
|
8744
|
+
function getCurrentUnixTimestamp() {
|
|
8745
|
+
return (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
8746
|
+
}
|
|
8747
|
+
function isEmpty(a) {
|
|
8748
|
+
return a === void 0 || a === null;
|
|
8749
|
+
}
|
|
8750
|
+
var LazyValue = class {
|
|
8751
|
+
callable;
|
|
8752
|
+
value = {
|
|
8753
|
+
hasComputed: false
|
|
8754
|
+
};
|
|
8755
|
+
constructor(callable) {
|
|
8756
|
+
this.callable = callable;
|
|
8757
|
+
}
|
|
8758
|
+
get() {
|
|
8759
|
+
if (this.value.hasComputed) {
|
|
8760
|
+
return this.value.val;
|
|
8761
|
+
}
|
|
8762
|
+
this.value = { hasComputed: true, val: this.callable() };
|
|
8763
|
+
return this.value.val;
|
|
8764
|
+
}
|
|
8765
|
+
get hasComputed() {
|
|
8766
|
+
return this.value.hasComputed;
|
|
8767
|
+
}
|
|
8768
|
+
};
|
|
8769
|
+
|
|
8770
|
+
// ../../node_modules/.pnpm/mustache@4.2.0/node_modules/mustache/mustache.mjs
|
|
8771
|
+
var objectToString = Object.prototype.toString;
|
|
8772
|
+
var isArray = Array.isArray || function isArrayPolyfill(object) {
|
|
8773
|
+
return objectToString.call(object) === "[object Array]";
|
|
8774
|
+
};
|
|
8775
|
+
function isFunction(object) {
|
|
8776
|
+
return typeof object === "function";
|
|
8777
|
+
}
|
|
8778
|
+
function typeStr(obj) {
|
|
8779
|
+
return isArray(obj) ? "array" : typeof obj;
|
|
8780
|
+
}
|
|
8781
|
+
function escapeRegExp(string) {
|
|
8782
|
+
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
8783
|
+
}
|
|
8784
|
+
function hasProperty(obj, propName) {
|
|
8785
|
+
return obj != null && typeof obj === "object" && propName in obj;
|
|
8786
|
+
}
|
|
8787
|
+
function primitiveHasOwnProperty(primitive, propName) {
|
|
8788
|
+
return primitive != null && typeof primitive !== "object" && primitive.hasOwnProperty && primitive.hasOwnProperty(propName);
|
|
8789
|
+
}
|
|
8790
|
+
var regExpTest = RegExp.prototype.test;
|
|
8791
|
+
function testRegExp(re, string) {
|
|
8792
|
+
return regExpTest.call(re, string);
|
|
8793
|
+
}
|
|
8794
|
+
var nonSpaceRe = /\S/;
|
|
8795
|
+
function isWhitespace(string) {
|
|
8796
|
+
return !testRegExp(nonSpaceRe, string);
|
|
8797
|
+
}
|
|
8798
|
+
var entityMap = {
|
|
8799
|
+
"&": "&",
|
|
8800
|
+
"<": "<",
|
|
8801
|
+
">": ">",
|
|
8802
|
+
'"': """,
|
|
8803
|
+
"'": "'",
|
|
8804
|
+
"/": "/",
|
|
8805
|
+
"`": "`",
|
|
8806
|
+
"=": "="
|
|
8807
|
+
};
|
|
8808
|
+
function escapeHtml(string) {
|
|
8809
|
+
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) {
|
|
8810
|
+
return entityMap[s];
|
|
8811
|
+
});
|
|
8812
|
+
}
|
|
8813
|
+
var whiteRe = /\s*/;
|
|
8814
|
+
var spaceRe = /\s+/;
|
|
8815
|
+
var equalsRe = /\s*=/;
|
|
8816
|
+
var curlyRe = /\s*\}/;
|
|
8817
|
+
var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
|
8818
|
+
function parseTemplate(template, tags) {
|
|
8819
|
+
if (!template)
|
|
8820
|
+
return [];
|
|
8821
|
+
var lineHasNonSpace = false;
|
|
8822
|
+
var sections = [];
|
|
8823
|
+
var tokens = [];
|
|
8824
|
+
var spaces = [];
|
|
8825
|
+
var hasTag = false;
|
|
8826
|
+
var nonSpace = false;
|
|
8827
|
+
var indentation = "";
|
|
8828
|
+
var tagIndex = 0;
|
|
8829
|
+
function stripSpace() {
|
|
8830
|
+
if (hasTag && !nonSpace) {
|
|
8831
|
+
while (spaces.length)
|
|
7298
8832
|
delete tokens[spaces.pop()];
|
|
7299
8833
|
} else {
|
|
7300
8834
|
spaces = [];
|
|
@@ -7727,20 +9261,31 @@ var NoopSpan = class {
|
|
|
7727
9261
|
}
|
|
7728
9262
|
};
|
|
7729
9263
|
var NOOP_SPAN = new NoopSpan();
|
|
7730
|
-
var
|
|
9264
|
+
var loginSchema = z.strictObject({
|
|
9265
|
+
appUrl: z.string(),
|
|
9266
|
+
appPublicUrl: z.string(),
|
|
9267
|
+
orgName: z.string(),
|
|
9268
|
+
logUrl: z.string(),
|
|
9269
|
+
loginToken: z.string(),
|
|
9270
|
+
orgId: z.string().nullish(),
|
|
9271
|
+
gitMetadataSettings: gitMetadataSettingsSchema.nullish()
|
|
9272
|
+
});
|
|
9273
|
+
var BraintrustState = class _BraintrustState {
|
|
7731
9274
|
constructor(loginParams) {
|
|
7732
9275
|
this.loginParams = loginParams;
|
|
7733
9276
|
this.id = (/* @__PURE__ */ new Date()).toLocaleString();
|
|
7734
9277
|
this.currentExperiment = void 0;
|
|
7735
9278
|
this.currentLogger = void 0;
|
|
7736
9279
|
this.currentSpan = isomorph_default.newAsyncLocalStorage();
|
|
9280
|
+
if (loginParams.fetch) {
|
|
9281
|
+
this.fetch = loginParams.fetch;
|
|
9282
|
+
}
|
|
7737
9283
|
const defaultGetLogConn = async () => {
|
|
7738
9284
|
await this.login({});
|
|
7739
9285
|
return this.logConn();
|
|
7740
9286
|
};
|
|
7741
9287
|
this._bgLogger = new BackgroundLogger(new LazyValue(defaultGetLogConn));
|
|
7742
9288
|
this.resetLoginInfo();
|
|
7743
|
-
globalThis.__inherited_braintrust_state = this;
|
|
7744
9289
|
}
|
|
7745
9290
|
id;
|
|
7746
9291
|
currentExperiment;
|
|
@@ -7761,6 +9306,7 @@ var BraintrustState = class {
|
|
|
7761
9306
|
logUrl = null;
|
|
7762
9307
|
loggedIn = false;
|
|
7763
9308
|
gitMetadataSettings;
|
|
9309
|
+
fetch = globalThis.fetch;
|
|
7764
9310
|
_apiConn = null;
|
|
7765
9311
|
_logConn = null;
|
|
7766
9312
|
resetLoginInfo() {
|
|
@@ -7787,6 +9333,55 @@ var BraintrustState = class {
|
|
|
7787
9333
|
this._apiConn = other._apiConn;
|
|
7788
9334
|
this._logConn = other._logConn;
|
|
7789
9335
|
}
|
|
9336
|
+
serialize() {
|
|
9337
|
+
if (!this.loggedIn) {
|
|
9338
|
+
throw new Error(
|
|
9339
|
+
"Cannot serialize BraintrustState without being logged in"
|
|
9340
|
+
);
|
|
9341
|
+
}
|
|
9342
|
+
if (!this.appUrl || !this.appPublicUrl || !this.logUrl || !this.orgName || !this.loginToken || !this.loggedIn) {
|
|
9343
|
+
throw new Error(
|
|
9344
|
+
"Cannot serialize BraintrustState without all login attributes"
|
|
9345
|
+
);
|
|
9346
|
+
}
|
|
9347
|
+
return {
|
|
9348
|
+
appUrl: this.appUrl,
|
|
9349
|
+
appPublicUrl: this.appPublicUrl,
|
|
9350
|
+
loginToken: this.loginToken,
|
|
9351
|
+
orgId: this.orgId,
|
|
9352
|
+
orgName: this.orgName,
|
|
9353
|
+
logUrl: this.logUrl,
|
|
9354
|
+
gitMetadataSettings: this.gitMetadataSettings
|
|
9355
|
+
};
|
|
9356
|
+
}
|
|
9357
|
+
static deserialize(serialized) {
|
|
9358
|
+
const serializedParsed = loginSchema.safeParse(serialized);
|
|
9359
|
+
if (!serializedParsed.success) {
|
|
9360
|
+
throw new Error(
|
|
9361
|
+
`Cannot deserialize BraintrustState: ${serializedParsed.error.errors}`
|
|
9362
|
+
);
|
|
9363
|
+
}
|
|
9364
|
+
const state = new _BraintrustState({});
|
|
9365
|
+
for (const key of Object.keys(loginSchema.shape)) {
|
|
9366
|
+
state[key] = serializedParsed.data[key];
|
|
9367
|
+
}
|
|
9368
|
+
if (!state.loginToken) {
|
|
9369
|
+
throw new Error(
|
|
9370
|
+
"Cannot deserialize BraintrustState without a login token"
|
|
9371
|
+
);
|
|
9372
|
+
}
|
|
9373
|
+
state.logConn().set_token(state.loginToken);
|
|
9374
|
+
state.logConn().make_long_lived();
|
|
9375
|
+
state.apiConn().set_token(state.loginToken);
|
|
9376
|
+
state.loggedIn = true;
|
|
9377
|
+
state.loginReplaceLogConn(state.logConn());
|
|
9378
|
+
return state;
|
|
9379
|
+
}
|
|
9380
|
+
setFetch(fetch) {
|
|
9381
|
+
this.fetch = fetch;
|
|
9382
|
+
this._logConn?.setFetch(fetch);
|
|
9383
|
+
this._apiConn?.setFetch(fetch);
|
|
9384
|
+
}
|
|
7790
9385
|
async login(loginParams) {
|
|
7791
9386
|
if (this.logUrl && !loginParams.forceLogin) {
|
|
7792
9387
|
return;
|
|
@@ -7802,7 +9397,7 @@ var BraintrustState = class {
|
|
|
7802
9397
|
if (!this.appUrl) {
|
|
7803
9398
|
throw new Error("Must initialize appUrl before requesting apiConn");
|
|
7804
9399
|
}
|
|
7805
|
-
this._apiConn = new HTTPConnection(this.appUrl);
|
|
9400
|
+
this._apiConn = new HTTPConnection(this.appUrl, this.fetch);
|
|
7806
9401
|
}
|
|
7807
9402
|
return this._apiConn;
|
|
7808
9403
|
}
|
|
@@ -7811,7 +9406,7 @@ var BraintrustState = class {
|
|
|
7811
9406
|
if (!this.logUrl) {
|
|
7812
9407
|
throw new Error("Must initialize logUrl before requesting logConn");
|
|
7813
9408
|
}
|
|
7814
|
-
this._logConn = new HTTPConnection(this.logUrl);
|
|
9409
|
+
this._logConn = new HTTPConnection(this.logUrl, this.fetch);
|
|
7815
9410
|
}
|
|
7816
9411
|
return this._logConn;
|
|
7817
9412
|
}
|
|
@@ -7859,11 +9454,16 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
7859
9454
|
base_url;
|
|
7860
9455
|
token;
|
|
7861
9456
|
headers;
|
|
7862
|
-
|
|
9457
|
+
fetch;
|
|
9458
|
+
constructor(base_url, fetch) {
|
|
7863
9459
|
this.base_url = base_url;
|
|
7864
9460
|
this.token = null;
|
|
7865
9461
|
this.headers = {};
|
|
7866
9462
|
this._reset();
|
|
9463
|
+
this.fetch = fetch;
|
|
9464
|
+
}
|
|
9465
|
+
setFetch(fetch) {
|
|
9466
|
+
this.fetch = fetch;
|
|
7867
9467
|
}
|
|
7868
9468
|
async ping() {
|
|
7869
9469
|
try {
|
|
@@ -7901,7 +9501,7 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
7901
9501
|
).toString();
|
|
7902
9502
|
return await checkResponse(
|
|
7903
9503
|
// Using toString() here makes it work with isomorphic fetch
|
|
7904
|
-
await fetch(url.toString(), {
|
|
9504
|
+
await this.fetch(url.toString(), {
|
|
7905
9505
|
headers: {
|
|
7906
9506
|
Accept: "application/json",
|
|
7907
9507
|
...this.headers,
|
|
@@ -7915,7 +9515,7 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
7915
9515
|
async post(path, params, config) {
|
|
7916
9516
|
const { headers, ...rest } = config || {};
|
|
7917
9517
|
return await checkResponse(
|
|
7918
|
-
await fetch(_urljoin(this.base_url, path), {
|
|
9518
|
+
await this.fetch(_urljoin(this.base_url, path), {
|
|
7919
9519
|
method: "POST",
|
|
7920
9520
|
headers: {
|
|
7921
9521
|
Accept: "application/json",
|
|
@@ -8949,7 +10549,7 @@ async function loadPrompt({
|
|
|
8949
10549
|
`Multiple prompts found with slug ${slug} in project ${projectName ?? projectId}. This should never happen.`
|
|
8950
10550
|
);
|
|
8951
10551
|
}
|
|
8952
|
-
const metadata =
|
|
10552
|
+
const metadata = promptSchema2.parse(response["objects"][0]);
|
|
8953
10553
|
return new Prompt(metadata, defaults || {}, noTrace);
|
|
8954
10554
|
}
|
|
8955
10555
|
async function login(options = {}) {
|
|
@@ -8973,12 +10573,14 @@ async function login(options = {}) {
|
|
|
8973
10573
|
return _globalState;
|
|
8974
10574
|
}
|
|
8975
10575
|
await _globalState.login(options);
|
|
10576
|
+
globalThis.__inherited_braintrust_state = _globalState;
|
|
8976
10577
|
}
|
|
8977
10578
|
async function loginToState(options = {}) {
|
|
8978
10579
|
const {
|
|
8979
10580
|
appUrl = isomorph_default.getEnv("BRAINTRUST_APP_URL") || "https://www.braintrust.dev",
|
|
8980
10581
|
apiKey = isomorph_default.getEnv("BRAINTRUST_API_KEY"),
|
|
8981
|
-
orgName = isomorph_default.getEnv("BRAINTRUST_ORG_NAME")
|
|
10582
|
+
orgName = isomorph_default.getEnv("BRAINTRUST_ORG_NAME"),
|
|
10583
|
+
fetch = globalThis.fetch
|
|
8982
10584
|
} = options || {};
|
|
8983
10585
|
const appPublicUrl = isomorph_default.getEnv("BRAINTRUST_APP_PUBLIC_URL") || appUrl;
|
|
8984
10586
|
const state = new BraintrustState(options);
|
|
@@ -9096,6 +10698,9 @@ async function flush(options) {
|
|
|
9096
10698
|
const state = options?.state ?? _globalState;
|
|
9097
10699
|
return await state.bgLogger().flush();
|
|
9098
10700
|
}
|
|
10701
|
+
function setFetch(fetch) {
|
|
10702
|
+
_globalState.setFetch(fetch);
|
|
10703
|
+
}
|
|
9099
10704
|
function startSpanAndIsLogger(args) {
|
|
9100
10705
|
const state = args?.state ?? _globalState;
|
|
9101
10706
|
if (args?.parent) {
|
|
@@ -9471,6 +11076,7 @@ var Experiment = class extends ObjectFetcher {
|
|
|
9471
11076
|
return {
|
|
9472
11077
|
projectName: (await this.project).name,
|
|
9473
11078
|
experimentName: await this.name,
|
|
11079
|
+
projectId: (await this.project).id,
|
|
9474
11080
|
experimentId: await this.id,
|
|
9475
11081
|
projectUrl,
|
|
9476
11082
|
experimentUrl,
|
|
@@ -9906,10 +11512,10 @@ var Prompt = class {
|
|
|
9906
11512
|
return this.metadata.project_id;
|
|
9907
11513
|
}
|
|
9908
11514
|
get name() {
|
|
9909
|
-
return this.metadata.name
|
|
11515
|
+
return "name" in this.metadata ? this.metadata.name : `Playground function ${this.metadata.id}`;
|
|
9910
11516
|
}
|
|
9911
11517
|
get slug() {
|
|
9912
|
-
return this.metadata.slug;
|
|
11518
|
+
return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
|
|
9913
11519
|
}
|
|
9914
11520
|
get prompt() {
|
|
9915
11521
|
return this.metadata.prompt_data?.prompt;
|
|
@@ -9938,7 +11544,7 @@ var Prompt = class {
|
|
|
9938
11544
|
...this.defaults,
|
|
9939
11545
|
...Object.fromEntries(
|
|
9940
11546
|
Object.entries(this.options.params || {}).filter(
|
|
9941
|
-
([k, _v]) => !
|
|
11547
|
+
([k, _v]) => !BRAINTRUST_PARAMS2.includes(k)
|
|
9942
11548
|
)
|
|
9943
11549
|
),
|
|
9944
11550
|
...!isEmpty(this.options.model) ? {
|
|
@@ -9957,7 +11563,8 @@ var Prompt = class {
|
|
|
9957
11563
|
variables: buildArgs,
|
|
9958
11564
|
id: this.id,
|
|
9959
11565
|
project_id: this.projectId,
|
|
9960
|
-
version: this.version
|
|
11566
|
+
version: this.version,
|
|
11567
|
+
..."prompt_session_id" in this.metadata ? { prompt_session_id: this.metadata.prompt_session_id } : {}
|
|
9961
11568
|
}
|
|
9962
11569
|
}
|
|
9963
11570
|
}
|
|
@@ -9991,7 +11598,7 @@ var Prompt = class {
|
|
|
9991
11598
|
...spanInfo,
|
|
9992
11599
|
messages,
|
|
9993
11600
|
...prompt.tools ? {
|
|
9994
|
-
tools:
|
|
11601
|
+
tools: toolsSchema2.parse(
|
|
9995
11602
|
JSON.parse(mustache_default.render(prompt.tools, variables))
|
|
9996
11603
|
)
|
|
9997
11604
|
} : void 0
|
|
@@ -10414,6 +12021,7 @@ export {
|
|
|
10414
12021
|
loginToState,
|
|
10415
12022
|
newId,
|
|
10416
12023
|
parseCachedHeader,
|
|
12024
|
+
setFetch,
|
|
10417
12025
|
startSpan,
|
|
10418
12026
|
summarize,
|
|
10419
12027
|
traced,
|