braintrust 0.2.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev/dist/index.d.mts +228 -16
- package/dev/dist/index.d.ts +228 -16
- package/dev/dist/index.js +2121 -1133
- package/dev/dist/index.mjs +2077 -1089
- package/dist/browser.d.mts +331 -39
- package/dist/browser.d.ts +331 -39
- package/dist/browser.js +2157 -1169
- package/dist/browser.mjs +2099 -1111
- package/dist/cli.js +2191 -1159
- package/dist/index.d.mts +356 -28
- package/dist/index.d.ts +356 -28
- package/dist/index.js +2642 -1286
- package/dist/index.mjs +2562 -1206
- package/package.json +13 -8
- package/util/dist/index.d.mts +5229 -0
- package/util/dist/index.d.ts +5229 -0
- package/util/dist/index.js +1264 -0
- package/util/dist/index.mjs +1264 -0
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;var __defProp = Object.defineProperty;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;var __defProp = Object.defineProperty;
|
|
2
2
|
var __export = (target, all) => {
|
|
3
3
|
for (var name in all)
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -29,7 +29,7 @@ var iso = {
|
|
|
29
29
|
var isomorph_default = iso;
|
|
30
30
|
|
|
31
31
|
// src/logger.ts
|
|
32
|
-
var _uuid = require('uuid');
|
|
32
|
+
var _uuid = require('uuid'); var uuid3 = _interopRequireWildcard(_uuid); var uuid2 = _interopRequireWildcard(_uuid); var uuid = _interopRequireWildcard(_uuid);
|
|
33
33
|
|
|
34
34
|
// src/queue.ts
|
|
35
35
|
var DEFAULT_QUEUE_SIZE = 15e3;
|
|
@@ -87,33 +87,990 @@ var Queue = (_class = class {
|
|
|
87
87
|
}
|
|
88
88
|
}, _class);
|
|
89
89
|
|
|
90
|
-
//
|
|
90
|
+
// util/db_fields.ts
|
|
91
|
+
var TRANSACTION_ID_FIELD = "_xact_id";
|
|
92
|
+
var IS_MERGE_FIELD = "_is_merge";
|
|
93
|
+
var AUDIT_SOURCE_FIELD = "_audit_source";
|
|
94
|
+
var AUDIT_METADATA_FIELD = "_audit_metadata";
|
|
95
|
+
var VALID_SOURCES = ["app", "api", "external"];
|
|
96
|
+
var PARENT_ID_FIELD = "_parent_id";
|
|
91
97
|
|
|
98
|
+
// util/span_identifier_v3.ts
|
|
92
99
|
|
|
93
100
|
|
|
101
|
+
// util/span_identifier_v2.ts
|
|
94
102
|
|
|
95
103
|
|
|
104
|
+
// util/span_identifier_v1.ts
|
|
96
105
|
|
|
106
|
+
var _v3 = require('zod/v3');
|
|
107
|
+
function tryMakeUuid(s) {
|
|
108
|
+
try {
|
|
109
|
+
const ret = uuid.parse(s);
|
|
110
|
+
if (ret.length !== 16) {
|
|
111
|
+
throw new Error();
|
|
112
|
+
}
|
|
113
|
+
return { bytes: Buffer.from(ret), isUUID: true };
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var ENCODING_VERSION_NUMBER = 1;
|
|
119
|
+
var INVALID_ENCODING_ERRMSG = "SpanComponents string is not properly encoded. This may be due to a version mismatch between the SDK library used to export the span and the library used to decode it. Please make sure you are using the same SDK version across the board";
|
|
120
|
+
var SpanObjectTypeV1 = /* @__PURE__ */ ((SpanObjectTypeV12) => {
|
|
121
|
+
SpanObjectTypeV12[SpanObjectTypeV12["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
122
|
+
SpanObjectTypeV12[SpanObjectTypeV12["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
123
|
+
return SpanObjectTypeV12;
|
|
124
|
+
})(SpanObjectTypeV1 || {});
|
|
125
|
+
var SpanObjectTypeV1EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV1);
|
|
126
|
+
var SpanRowIdsV1 = class {
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
constructor(args) {
|
|
131
|
+
this.rowId = args.rowId;
|
|
132
|
+
this.spanId = args.spanId;
|
|
133
|
+
this.rootSpanId = args.rootSpanId;
|
|
134
|
+
if (!this.rowId) {
|
|
135
|
+
throw new Error("rowId must be nonempty string");
|
|
136
|
+
}
|
|
137
|
+
if (!this.spanId) {
|
|
138
|
+
throw new Error("spanId must be nonempty string");
|
|
139
|
+
}
|
|
140
|
+
if (!this.rootSpanId) {
|
|
141
|
+
throw new Error("rootSpanId must be nonempty string");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
toObject() {
|
|
145
|
+
return {
|
|
146
|
+
rowId: this.rowId,
|
|
147
|
+
spanId: this.spanId,
|
|
148
|
+
rootSpanId: this.rootSpanId
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var SpanComponentsV1 = class _SpanComponentsV1 {
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
constructor(args) {
|
|
157
|
+
this.objectType = args.objectType;
|
|
158
|
+
this.objectId = args.objectId;
|
|
159
|
+
this.rowIds = args.rowIds;
|
|
160
|
+
}
|
|
161
|
+
toStr() {
|
|
162
|
+
const allBuffers = [];
|
|
163
|
+
const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
|
|
164
|
+
allBuffers.push(
|
|
165
|
+
Buffer.from([
|
|
166
|
+
ENCODING_VERSION_NUMBER,
|
|
167
|
+
this.objectType,
|
|
168
|
+
this.rowIds ? 1 : 0,
|
|
169
|
+
rowIdIsUUID ? 1 : 0
|
|
170
|
+
])
|
|
171
|
+
);
|
|
172
|
+
const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid(
|
|
173
|
+
this.objectId
|
|
174
|
+
);
|
|
175
|
+
if (!objectIdIsUUID) {
|
|
176
|
+
throw new Error("object_id component must be a valid UUID");
|
|
177
|
+
}
|
|
178
|
+
allBuffers.push(objectIdBytes);
|
|
179
|
+
if (this.rowIds) {
|
|
180
|
+
const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid(
|
|
181
|
+
this.rowIds.spanId
|
|
182
|
+
);
|
|
183
|
+
if (!spanIdIsUUID) {
|
|
184
|
+
throw new Error("span_id component must be a valid UUID");
|
|
185
|
+
}
|
|
186
|
+
const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid(
|
|
187
|
+
this.rowIds.rootSpanId
|
|
188
|
+
);
|
|
189
|
+
if (!rootSpanIdIsUUID) {
|
|
190
|
+
throw new Error("root_span_id component must be a valid UUID");
|
|
191
|
+
}
|
|
192
|
+
allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
|
|
193
|
+
}
|
|
194
|
+
return Buffer.concat(allBuffers).toString("base64");
|
|
195
|
+
}
|
|
196
|
+
static fromStr(s) {
|
|
197
|
+
try {
|
|
198
|
+
const rawBytes = Buffer.from(s, "base64");
|
|
199
|
+
if (rawBytes[0] !== ENCODING_VERSION_NUMBER) {
|
|
200
|
+
throw new Error();
|
|
201
|
+
}
|
|
202
|
+
const objectType = SpanObjectTypeV1EnumSchema.parse(rawBytes[1]);
|
|
203
|
+
if (![0, 1].includes(rawBytes[2])) {
|
|
204
|
+
throw new Error();
|
|
205
|
+
}
|
|
206
|
+
if (![0, 1].includes(rawBytes[3])) {
|
|
207
|
+
throw new Error();
|
|
208
|
+
}
|
|
209
|
+
const hasRowId = rawBytes[2] == 1;
|
|
210
|
+
const rowIdIsUUID = rawBytes[3] == 1;
|
|
211
|
+
const objectId = uuid.stringify(rawBytes.subarray(4, 20));
|
|
212
|
+
const rowIds = (() => {
|
|
213
|
+
if (!hasRowId) {
|
|
214
|
+
return void 0;
|
|
215
|
+
}
|
|
216
|
+
const spanId = uuid.stringify(rawBytes.subarray(20, 36));
|
|
217
|
+
const rootSpanId = uuid.stringify(rawBytes.subarray(36, 52));
|
|
218
|
+
const rowId = rowIdIsUUID ? uuid.stringify(rawBytes.subarray(52)) : rawBytes.subarray(52).toString("utf-8");
|
|
219
|
+
return new SpanRowIdsV1({ rowId, spanId, rootSpanId });
|
|
220
|
+
})();
|
|
221
|
+
return new _SpanComponentsV1({ objectType, objectId, rowIds });
|
|
222
|
+
} catch (e) {
|
|
223
|
+
throw new Error(INVALID_ENCODING_ERRMSG);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
objectIdFields() {
|
|
227
|
+
switch (this.objectType) {
|
|
228
|
+
case 1 /* EXPERIMENT */:
|
|
229
|
+
return { experiment_id: this.objectId };
|
|
230
|
+
case 2 /* PROJECT_LOGS */:
|
|
231
|
+
return { project_id: this.objectId, log_id: "g" };
|
|
232
|
+
default:
|
|
233
|
+
throw new Error("Impossible");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
toObject() {
|
|
237
|
+
return {
|
|
238
|
+
objectType: this.objectType,
|
|
239
|
+
objectId: this.objectId,
|
|
240
|
+
rowIds: _optionalChain([this, 'access', _2 => _2.rowIds, 'optionalAccess', _3 => _3.toObject, 'call', _4 => _4()])
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
};
|
|
97
244
|
|
|
245
|
+
// util/span_identifier_v2.ts
|
|
246
|
+
|
|
247
|
+
function tryMakeUuid2(s) {
|
|
248
|
+
try {
|
|
249
|
+
const ret = uuid2.parse(s);
|
|
250
|
+
if (ret.length !== 16) {
|
|
251
|
+
throw new Error();
|
|
252
|
+
}
|
|
253
|
+
return { bytes: Buffer.from(ret), isUUID: true };
|
|
254
|
+
} catch (e) {
|
|
255
|
+
return { bytes: Buffer.from(s, "utf-8"), isUUID: false };
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
var ENCODING_VERSION_NUMBER2 = 2;
|
|
259
|
+
var INVALID_ENCODING_ERRMSG2 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER2}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
|
|
260
|
+
var INTEGER_ENCODING_NUM_BYTES = 4;
|
|
261
|
+
var SpanObjectTypeV2 = /* @__PURE__ */ ((SpanObjectTypeV22) => {
|
|
262
|
+
SpanObjectTypeV22[SpanObjectTypeV22["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
263
|
+
SpanObjectTypeV22[SpanObjectTypeV22["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
264
|
+
return SpanObjectTypeV22;
|
|
265
|
+
})(SpanObjectTypeV2 || {});
|
|
266
|
+
var SpanObjectTypeV2EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV2);
|
|
267
|
+
var SpanRowIdsV2 = class {
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
constructor(args) {
|
|
272
|
+
this.rowId = args.rowId;
|
|
273
|
+
this.spanId = args.spanId;
|
|
274
|
+
this.rootSpanId = args.rootSpanId;
|
|
275
|
+
if (!this.rowId) {
|
|
276
|
+
throw new Error("rowId must be nonempty string");
|
|
277
|
+
}
|
|
278
|
+
if (!this.spanId) {
|
|
279
|
+
throw new Error("spanId must be nonempty string");
|
|
280
|
+
}
|
|
281
|
+
if (!this.rootSpanId) {
|
|
282
|
+
throw new Error("rootSpanId must be nonempty string");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
toObject() {
|
|
286
|
+
return {
|
|
287
|
+
rowId: this.rowId,
|
|
288
|
+
spanId: this.spanId,
|
|
289
|
+
rootSpanId: this.rootSpanId
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
var SpanComponentsV2 = class _SpanComponentsV2 {
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
constructor(args) {
|
|
299
|
+
this.objectType = args.objectType;
|
|
300
|
+
this.objectId = args.objectId;
|
|
301
|
+
this.computeObjectMetadataArgs = args.computeObjectMetadataArgs;
|
|
302
|
+
this.rowIds = args.rowIds;
|
|
303
|
+
if (!(this.objectId || this.computeObjectMetadataArgs)) {
|
|
304
|
+
throw new Error(
|
|
305
|
+
"Must provide either objectId or computeObjectMetadataArgs"
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
toStr() {
|
|
310
|
+
const allBuffers = [];
|
|
311
|
+
const { bytes: rowIdBytes, isUUID: rowIdIsUUID } = this.rowIds ? tryMakeUuid2(this.rowIds.rowId) : { bytes: Buffer.from(""), isUUID: false };
|
|
312
|
+
allBuffers.push(
|
|
313
|
+
Buffer.from([
|
|
314
|
+
ENCODING_VERSION_NUMBER2,
|
|
315
|
+
this.objectType,
|
|
316
|
+
this.objectId ? 1 : 0,
|
|
317
|
+
this.computeObjectMetadataArgs ? 1 : 0,
|
|
318
|
+
this.rowIds ? 1 : 0,
|
|
319
|
+
rowIdIsUUID ? 1 : 0
|
|
320
|
+
])
|
|
321
|
+
);
|
|
322
|
+
if (this.objectId) {
|
|
323
|
+
const { bytes: objectIdBytes, isUUID: objectIdIsUUID } = tryMakeUuid2(
|
|
324
|
+
this.objectId
|
|
325
|
+
);
|
|
326
|
+
if (!objectIdIsUUID) {
|
|
327
|
+
throw new Error("object_id component must be a valid UUID");
|
|
328
|
+
}
|
|
329
|
+
allBuffers.push(objectIdBytes);
|
|
330
|
+
}
|
|
331
|
+
if (this.computeObjectMetadataArgs) {
|
|
332
|
+
const computeObjectMetadataBytes = Buffer.from(
|
|
333
|
+
JSON.stringify(this.computeObjectMetadataArgs),
|
|
334
|
+
"utf-8"
|
|
335
|
+
);
|
|
336
|
+
const serializedLenBytes = Buffer.alloc(INTEGER_ENCODING_NUM_BYTES);
|
|
337
|
+
serializedLenBytes.writeInt32BE(computeObjectMetadataBytes.length);
|
|
338
|
+
allBuffers.push(serializedLenBytes, computeObjectMetadataBytes);
|
|
339
|
+
}
|
|
340
|
+
if (this.rowIds) {
|
|
341
|
+
const { bytes: spanIdBytes, isUUID: spanIdIsUUID } = tryMakeUuid2(
|
|
342
|
+
this.rowIds.spanId
|
|
343
|
+
);
|
|
344
|
+
if (!spanIdIsUUID) {
|
|
345
|
+
throw new Error("span_id component must be a valid UUID");
|
|
346
|
+
}
|
|
347
|
+
const { bytes: rootSpanIdBytes, isUUID: rootSpanIdIsUUID } = tryMakeUuid2(
|
|
348
|
+
this.rowIds.rootSpanId
|
|
349
|
+
);
|
|
350
|
+
if (!rootSpanIdIsUUID) {
|
|
351
|
+
throw new Error("root_span_id component must be a valid UUID");
|
|
352
|
+
}
|
|
353
|
+
allBuffers.push(spanIdBytes, rootSpanIdBytes, rowIdBytes);
|
|
354
|
+
}
|
|
355
|
+
return Buffer.concat(allBuffers).toString("base64");
|
|
356
|
+
}
|
|
357
|
+
static fromStr(s) {
|
|
358
|
+
try {
|
|
359
|
+
const rawBytes = Buffer.from(s, "base64");
|
|
360
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER2) {
|
|
361
|
+
const spanComponentsOld = SpanComponentsV1.fromStr(s);
|
|
362
|
+
return new _SpanComponentsV2({
|
|
363
|
+
objectType: SpanObjectTypeV2EnumSchema.parse(
|
|
364
|
+
spanComponentsOld.objectType
|
|
365
|
+
),
|
|
366
|
+
objectId: spanComponentsOld.objectId,
|
|
367
|
+
rowIds: spanComponentsOld.rowIds ? new SpanRowIdsV2({
|
|
368
|
+
rowId: spanComponentsOld.rowIds.rowId,
|
|
369
|
+
spanId: spanComponentsOld.rowIds.spanId,
|
|
370
|
+
rootSpanId: spanComponentsOld.rowIds.rootSpanId
|
|
371
|
+
}) : void 0
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
if (rawBytes[0] !== ENCODING_VERSION_NUMBER2) {
|
|
375
|
+
throw new Error();
|
|
376
|
+
}
|
|
377
|
+
const objectType = SpanObjectTypeV2EnumSchema.parse(rawBytes[1]);
|
|
378
|
+
for (let i = 2; i < 6; ++i) {
|
|
379
|
+
if (![0, 1].includes(rawBytes[i])) {
|
|
380
|
+
throw new Error();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const hasObjectId = rawBytes[2] == 1;
|
|
384
|
+
const hasComputeObjectMetadataArgs = rawBytes[3] == 1;
|
|
385
|
+
const hasRowId = rawBytes[4] == 1;
|
|
386
|
+
const rowIdIsUUID = rawBytes[5] == 1;
|
|
387
|
+
let byteCursor = 6;
|
|
388
|
+
let objectId = void 0;
|
|
389
|
+
if (hasObjectId) {
|
|
390
|
+
const nextByteCursor = byteCursor + 16;
|
|
391
|
+
objectId = uuid2.stringify(
|
|
392
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
393
|
+
);
|
|
394
|
+
byteCursor = nextByteCursor;
|
|
395
|
+
}
|
|
396
|
+
let computeObjectMetadataArgs;
|
|
397
|
+
if (hasComputeObjectMetadataArgs) {
|
|
398
|
+
let nextByteCursor = byteCursor + INTEGER_ENCODING_NUM_BYTES;
|
|
399
|
+
const serializedLenBytes = rawBytes.readInt32BE(byteCursor);
|
|
400
|
+
byteCursor = nextByteCursor;
|
|
401
|
+
nextByteCursor = byteCursor + serializedLenBytes;
|
|
402
|
+
computeObjectMetadataArgs = JSON.parse(
|
|
403
|
+
rawBytes.subarray(byteCursor, nextByteCursor).toString("utf-8")
|
|
404
|
+
);
|
|
405
|
+
byteCursor = nextByteCursor;
|
|
406
|
+
}
|
|
407
|
+
const rowIds = (() => {
|
|
408
|
+
if (!hasRowId) {
|
|
409
|
+
return void 0;
|
|
410
|
+
}
|
|
411
|
+
let nextByteCursor = byteCursor + 16;
|
|
412
|
+
const spanId = uuid2.stringify(
|
|
413
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
414
|
+
);
|
|
415
|
+
byteCursor = nextByteCursor;
|
|
416
|
+
nextByteCursor = byteCursor + 16;
|
|
417
|
+
const rootSpanId = uuid2.stringify(
|
|
418
|
+
rawBytes.subarray(byteCursor, nextByteCursor)
|
|
419
|
+
);
|
|
420
|
+
byteCursor = nextByteCursor;
|
|
421
|
+
const rowId = rowIdIsUUID ? uuid2.stringify(rawBytes.subarray(byteCursor)) : rawBytes.subarray(byteCursor).toString("utf-8");
|
|
422
|
+
return new SpanRowIdsV2({ rowId, spanId, rootSpanId });
|
|
423
|
+
})();
|
|
424
|
+
return new _SpanComponentsV2({
|
|
425
|
+
objectType,
|
|
426
|
+
objectId,
|
|
427
|
+
computeObjectMetadataArgs,
|
|
428
|
+
rowIds
|
|
429
|
+
});
|
|
430
|
+
} catch (e) {
|
|
431
|
+
throw new Error(INVALID_ENCODING_ERRMSG2);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
objectIdFields() {
|
|
435
|
+
if (!this.objectId) {
|
|
436
|
+
throw new Error(
|
|
437
|
+
"Impossible: cannot invoke `object_id_fields` unless SpanComponentsV2 is initialized with an `object_id`"
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
switch (this.objectType) {
|
|
441
|
+
case 1 /* EXPERIMENT */:
|
|
442
|
+
return { experiment_id: this.objectId };
|
|
443
|
+
case 2 /* PROJECT_LOGS */:
|
|
444
|
+
return { project_id: this.objectId, log_id: "g" };
|
|
445
|
+
default:
|
|
446
|
+
throw new Error("Impossible");
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
toObject() {
|
|
450
|
+
return {
|
|
451
|
+
objectType: this.objectType,
|
|
452
|
+
objectId: this.objectId,
|
|
453
|
+
computeObjectMetadataArgs: this.computeObjectMetadataArgs,
|
|
454
|
+
rowIds: _optionalChain([this, 'access', _5 => _5.rowIds, 'optionalAccess', _6 => _6.toObject, 'call', _7 => _7()])
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// util/span_identifier_v3.ts
|
|
98
460
|
|
|
99
461
|
|
|
462
|
+
// util/bytes.ts
|
|
463
|
+
function concatUint8Arrays(...arrays) {
|
|
464
|
+
const totalLength = arrays.reduce((acc, arr) => acc + arr.length, 0);
|
|
465
|
+
const result = new Uint8Array(totalLength);
|
|
466
|
+
let offset = 0;
|
|
467
|
+
for (const arr of arrays) {
|
|
468
|
+
result.set(arr, offset);
|
|
469
|
+
offset += arr.length;
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
}
|
|
473
|
+
function uint8ArrayToBase64(uint8Array) {
|
|
474
|
+
let binary = "";
|
|
475
|
+
for (let i = 0; i < uint8Array.length; i++) {
|
|
476
|
+
binary += String.fromCharCode(uint8Array[i]);
|
|
477
|
+
}
|
|
478
|
+
return btoa(binary);
|
|
479
|
+
}
|
|
480
|
+
function base64ToUint8Array(base64) {
|
|
481
|
+
const binary = atob(base64);
|
|
482
|
+
const uint8Array = new Uint8Array(binary.length);
|
|
483
|
+
for (let i = 0; i < binary.length; i++) {
|
|
484
|
+
uint8Array[i] = binary.charCodeAt(i);
|
|
485
|
+
}
|
|
486
|
+
return uint8Array;
|
|
487
|
+
}
|
|
488
|
+
function uint8ArrayToString(uint8Array) {
|
|
489
|
+
const decoder = new TextDecoder("utf-8");
|
|
490
|
+
return decoder.decode(uint8Array);
|
|
491
|
+
}
|
|
492
|
+
function stringToUint8Array(str) {
|
|
493
|
+
const encoder = new TextEncoder();
|
|
494
|
+
return encoder.encode(str);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// util/span_identifier_v3.ts
|
|
498
|
+
function tryMakeUuid3(s) {
|
|
499
|
+
try {
|
|
500
|
+
const ret = uuid3.parse(s);
|
|
501
|
+
if (ret.length !== 16) {
|
|
502
|
+
throw new Error();
|
|
503
|
+
}
|
|
504
|
+
return { bytes: new Uint8Array(ret), isUUID: true };
|
|
505
|
+
} catch (e2) {
|
|
506
|
+
return { bytes: void 0, isUUID: false };
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
var ENCODING_VERSION_NUMBER3 = 3;
|
|
510
|
+
var INVALID_ENCODING_ERRMSG3 = `SpanComponents string is not properly encoded. This library only supports encoding versions up to ${ENCODING_VERSION_NUMBER3}. Please make sure the SDK library used to decode the SpanComponents is at least as new as any library used to encode it.`;
|
|
511
|
+
var SpanObjectTypeV3 = /* @__PURE__ */ ((SpanObjectTypeV32) => {
|
|
512
|
+
SpanObjectTypeV32[SpanObjectTypeV32["EXPERIMENT"] = 1] = "EXPERIMENT";
|
|
513
|
+
SpanObjectTypeV32[SpanObjectTypeV32["PROJECT_LOGS"] = 2] = "PROJECT_LOGS";
|
|
514
|
+
SpanObjectTypeV32[SpanObjectTypeV32["PLAYGROUND_LOGS"] = 3] = "PLAYGROUND_LOGS";
|
|
515
|
+
return SpanObjectTypeV32;
|
|
516
|
+
})(SpanObjectTypeV3 || {});
|
|
517
|
+
var spanObjectTypeV3EnumSchema = _v3.z.nativeEnum(SpanObjectTypeV3);
|
|
518
|
+
function spanObjectTypeV3ToString(objectType) {
|
|
519
|
+
switch (objectType) {
|
|
520
|
+
case 1 /* EXPERIMENT */:
|
|
521
|
+
return "experiment";
|
|
522
|
+
case 2 /* PROJECT_LOGS */:
|
|
523
|
+
return "project_logs";
|
|
524
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
525
|
+
return "playground_logs";
|
|
526
|
+
default:
|
|
527
|
+
const x = objectType;
|
|
528
|
+
throw new Error(`Unknown SpanObjectTypeV3: ${x}`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
var InternalSpanComponentUUIDFields = /* @__PURE__ */ ((InternalSpanComponentUUIDFields2) => {
|
|
532
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["OBJECT_ID"] = 1] = "OBJECT_ID";
|
|
533
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROW_ID"] = 2] = "ROW_ID";
|
|
534
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["SPAN_ID"] = 3] = "SPAN_ID";
|
|
535
|
+
InternalSpanComponentUUIDFields2[InternalSpanComponentUUIDFields2["ROOT_SPAN_ID"] = 4] = "ROOT_SPAN_ID";
|
|
536
|
+
return InternalSpanComponentUUIDFields2;
|
|
537
|
+
})(InternalSpanComponentUUIDFields || {});
|
|
538
|
+
var internalSpanComponentUUIDFieldsEnumSchema = _v3.z.nativeEnum(
|
|
539
|
+
InternalSpanComponentUUIDFields
|
|
540
|
+
);
|
|
541
|
+
var _INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME = {
|
|
542
|
+
[1 /* OBJECT_ID */]: "object_id",
|
|
543
|
+
[2 /* ROW_ID */]: "row_id",
|
|
544
|
+
[3 /* SPAN_ID */]: "span_id",
|
|
545
|
+
[4 /* ROOT_SPAN_ID */]: "root_span_id"
|
|
546
|
+
};
|
|
547
|
+
var spanComponentsV3Schema = _v3.z.object({
|
|
548
|
+
object_type: spanObjectTypeV3EnumSchema,
|
|
549
|
+
// TODO(manu): We should have a more elaborate zod schema for
|
|
550
|
+
// `propagated_event`. This will required zod-ifying the contents of
|
|
551
|
+
// sdk/js/util/object.ts.
|
|
552
|
+
propagated_event: _v3.z.record(_v3.z.unknown()).nullish()
|
|
553
|
+
}).and(
|
|
554
|
+
_v3.z.union([
|
|
555
|
+
// Must provide one or the other.
|
|
556
|
+
_v3.z.object({
|
|
557
|
+
object_id: _v3.z.string().nullish(),
|
|
558
|
+
compute_object_metadata_args: _v3.z.optional(_v3.z.null())
|
|
559
|
+
}),
|
|
560
|
+
_v3.z.object({
|
|
561
|
+
object_id: _v3.z.optional(_v3.z.null()),
|
|
562
|
+
compute_object_metadata_args: _v3.z.record(_v3.z.unknown())
|
|
563
|
+
})
|
|
564
|
+
])
|
|
565
|
+
).and(
|
|
566
|
+
_v3.z.union([
|
|
567
|
+
// Either all of these must be provided or none.
|
|
568
|
+
_v3.z.object({
|
|
569
|
+
row_id: _v3.z.string(),
|
|
570
|
+
span_id: _v3.z.string(),
|
|
571
|
+
root_span_id: _v3.z.string()
|
|
572
|
+
}),
|
|
573
|
+
_v3.z.object({
|
|
574
|
+
row_id: _v3.z.optional(_v3.z.null()),
|
|
575
|
+
span_id: _v3.z.optional(_v3.z.null()),
|
|
576
|
+
root_span_id: _v3.z.optional(_v3.z.null())
|
|
577
|
+
})
|
|
578
|
+
])
|
|
579
|
+
);
|
|
580
|
+
var SpanComponentsV3 = class _SpanComponentsV3 {
|
|
581
|
+
constructor(data) {
|
|
582
|
+
this.data = data;
|
|
583
|
+
}
|
|
584
|
+
toStr() {
|
|
585
|
+
const jsonObj = {
|
|
586
|
+
compute_object_metadata_args: this.data.compute_object_metadata_args || void 0,
|
|
587
|
+
propagated_event: this.data.propagated_event || void 0
|
|
588
|
+
};
|
|
589
|
+
const allBuffers = [];
|
|
590
|
+
allBuffers.push(
|
|
591
|
+
new Uint8Array([ENCODING_VERSION_NUMBER3, this.data.object_type])
|
|
592
|
+
);
|
|
593
|
+
const uuidEntries = [];
|
|
594
|
+
function addUuidField(origVal, fieldId) {
|
|
595
|
+
const ret = tryMakeUuid3(origVal);
|
|
596
|
+
if (ret.isUUID) {
|
|
597
|
+
uuidEntries.push(
|
|
598
|
+
concatUint8Arrays(new Uint8Array([fieldId]), ret.bytes)
|
|
599
|
+
);
|
|
600
|
+
} else {
|
|
601
|
+
jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = origVal;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (this.data.object_id) {
|
|
605
|
+
addUuidField(
|
|
606
|
+
this.data.object_id,
|
|
607
|
+
1 /* OBJECT_ID */
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
if (this.data.row_id) {
|
|
611
|
+
addUuidField(this.data.row_id, 2 /* ROW_ID */);
|
|
612
|
+
}
|
|
613
|
+
if (this.data.span_id) {
|
|
614
|
+
addUuidField(this.data.span_id, 3 /* SPAN_ID */);
|
|
615
|
+
}
|
|
616
|
+
if (this.data.root_span_id) {
|
|
617
|
+
addUuidField(
|
|
618
|
+
this.data.root_span_id,
|
|
619
|
+
4 /* ROOT_SPAN_ID */
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
if (uuidEntries.length > 255) {
|
|
623
|
+
throw new Error("Impossible: too many UUID entries to encode");
|
|
624
|
+
}
|
|
625
|
+
allBuffers.push(new Uint8Array([uuidEntries.length]));
|
|
626
|
+
allBuffers.push(...uuidEntries);
|
|
627
|
+
if (Object.keys(jsonObj).length > 0) {
|
|
628
|
+
allBuffers.push(stringToUint8Array(JSON.stringify(jsonObj)));
|
|
629
|
+
}
|
|
630
|
+
return uint8ArrayToBase64(concatUint8Arrays(...allBuffers));
|
|
631
|
+
}
|
|
632
|
+
static fromStr(s) {
|
|
633
|
+
try {
|
|
634
|
+
const rawBytes = base64ToUint8Array(s);
|
|
635
|
+
const jsonObj = {};
|
|
636
|
+
if (rawBytes[0] < ENCODING_VERSION_NUMBER3) {
|
|
637
|
+
const spanComponentsOld = SpanComponentsV2.fromStr(s);
|
|
638
|
+
jsonObj["object_type"] = spanComponentsOld.objectType;
|
|
639
|
+
jsonObj["object_id"] = spanComponentsOld.objectId;
|
|
640
|
+
jsonObj["compute_object_metadata_args"] = spanComponentsOld.computeObjectMetadataArgs;
|
|
641
|
+
if (spanComponentsOld.rowIds) {
|
|
642
|
+
jsonObj["row_id"] = spanComponentsOld.rowIds.rowId;
|
|
643
|
+
jsonObj["span_id"] = spanComponentsOld.rowIds.spanId;
|
|
644
|
+
jsonObj["root_span_id"] = spanComponentsOld.rowIds.rootSpanId;
|
|
645
|
+
}
|
|
646
|
+
} else {
|
|
647
|
+
jsonObj["object_type"] = rawBytes[1];
|
|
648
|
+
const numUuidEntries = rawBytes[2];
|
|
649
|
+
let byteOffset = 3;
|
|
650
|
+
for (let i = 0; i < numUuidEntries; ++i) {
|
|
651
|
+
const fieldId = internalSpanComponentUUIDFieldsEnumSchema.parse(
|
|
652
|
+
rawBytes[byteOffset]
|
|
653
|
+
);
|
|
654
|
+
const fieldBytes = rawBytes.subarray(byteOffset + 1, byteOffset + 17);
|
|
655
|
+
byteOffset += 17;
|
|
656
|
+
jsonObj[_INTERNAL_SPAN_COMPONENT_UUID_FIELDS_ID_TO_NAME[fieldId]] = uuid3.stringify(fieldBytes);
|
|
657
|
+
}
|
|
658
|
+
if (byteOffset < rawBytes.length) {
|
|
659
|
+
const remainingJsonObj = JSON.parse(
|
|
660
|
+
uint8ArrayToString(rawBytes.subarray(byteOffset))
|
|
661
|
+
);
|
|
662
|
+
Object.assign(jsonObj, remainingJsonObj);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
return _SpanComponentsV3.fromJsonObj(jsonObj);
|
|
666
|
+
} catch (e3) {
|
|
667
|
+
throw new Error(INVALID_ENCODING_ERRMSG3);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
objectIdFields() {
|
|
671
|
+
if (!this.data.object_id) {
|
|
672
|
+
throw new Error(
|
|
673
|
+
"Impossible: cannot invoke `objectIdFields` unless SpanComponentsV3 is initialized with an `object_id`"
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
switch (this.data.object_type) {
|
|
677
|
+
case 1 /* EXPERIMENT */:
|
|
678
|
+
return { experiment_id: this.data.object_id };
|
|
679
|
+
case 2 /* PROJECT_LOGS */:
|
|
680
|
+
return { project_id: this.data.object_id, log_id: "g" };
|
|
681
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
682
|
+
return { prompt_session_id: this.data.object_id, log_id: "x" };
|
|
683
|
+
default:
|
|
684
|
+
const _ = this.data.object_type;
|
|
685
|
+
throw new Error("Impossible");
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
async export() {
|
|
689
|
+
return this.toStr();
|
|
690
|
+
}
|
|
691
|
+
static fromJsonObj(jsonObj) {
|
|
692
|
+
return new _SpanComponentsV3(spanComponentsV3Schema.parse(jsonObj));
|
|
693
|
+
}
|
|
694
|
+
};
|
|
100
695
|
|
|
696
|
+
// util/type_util.ts
|
|
697
|
+
function isObject(value) {
|
|
698
|
+
return value instanceof Object && !(value instanceof Array);
|
|
699
|
+
}
|
|
700
|
+
function isArray(value) {
|
|
701
|
+
return value instanceof Array;
|
|
702
|
+
}
|
|
703
|
+
function isObjectOrArray(value) {
|
|
704
|
+
return value instanceof Object;
|
|
705
|
+
}
|
|
101
706
|
|
|
707
|
+
// util/object_util.ts
|
|
708
|
+
function mergeDictsWithPaths({
|
|
709
|
+
mergeInto,
|
|
710
|
+
mergeFrom,
|
|
711
|
+
mergePaths
|
|
712
|
+
}) {
|
|
713
|
+
const mergePathsSerialized = new Set(
|
|
714
|
+
mergePaths.map((p) => JSON.stringify(p))
|
|
715
|
+
);
|
|
716
|
+
return mergeDictsWithPathsHelper({
|
|
717
|
+
mergeInto,
|
|
718
|
+
mergeFrom,
|
|
719
|
+
path: [],
|
|
720
|
+
mergePaths: mergePathsSerialized
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
function mergeDictsWithPathsHelper({
|
|
724
|
+
mergeInto,
|
|
725
|
+
mergeFrom,
|
|
726
|
+
path,
|
|
727
|
+
mergePaths
|
|
728
|
+
}) {
|
|
729
|
+
Object.entries(mergeFrom).forEach(([k, mergeFromV]) => {
|
|
730
|
+
const fullPath = path.concat([k]);
|
|
731
|
+
const fullPathSerialized = JSON.stringify(fullPath);
|
|
732
|
+
const mergeIntoV = recordFind(mergeInto, k);
|
|
733
|
+
if (isObject(mergeIntoV) && isObject(mergeFromV) && !mergePaths.has(fullPathSerialized)) {
|
|
734
|
+
mergeDictsWithPathsHelper({
|
|
735
|
+
mergeInto: mergeIntoV,
|
|
736
|
+
mergeFrom: mergeFromV,
|
|
737
|
+
path: fullPath,
|
|
738
|
+
mergePaths
|
|
739
|
+
});
|
|
740
|
+
} else {
|
|
741
|
+
mergeInto[k] = mergeFromV;
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
return mergeInto;
|
|
745
|
+
}
|
|
746
|
+
function mergeDicts(mergeInto, mergeFrom) {
|
|
747
|
+
return mergeDictsWithPaths({ mergeInto, mergeFrom, mergePaths: [] });
|
|
748
|
+
}
|
|
749
|
+
function mapAt(m, k) {
|
|
750
|
+
const ret = m.get(k);
|
|
751
|
+
if (ret === void 0) {
|
|
752
|
+
throw new Error(`Map does not contain key ${k}`);
|
|
753
|
+
}
|
|
754
|
+
return ret;
|
|
755
|
+
}
|
|
756
|
+
function recordFind(m, k) {
|
|
757
|
+
return m[k];
|
|
758
|
+
}
|
|
759
|
+
function getObjValueByPath(row, path) {
|
|
760
|
+
let curr = row;
|
|
761
|
+
for (const p of path) {
|
|
762
|
+
if (!isObjectOrArray(curr)) {
|
|
763
|
+
return null;
|
|
764
|
+
}
|
|
765
|
+
curr = curr[p];
|
|
766
|
+
}
|
|
767
|
+
return curr;
|
|
768
|
+
}
|
|
102
769
|
|
|
770
|
+
// util/graph_util.ts
|
|
771
|
+
function depthFirstSearch(args) {
|
|
772
|
+
const { graph, firstVisitF, lastVisitF } = args;
|
|
773
|
+
for (const vs of graph.values()) {
|
|
774
|
+
for (const v of vs.values()) {
|
|
775
|
+
if (!graph.has(v)) {
|
|
776
|
+
throw new Error(`Outgoing vertex ${v} must be a key in the graph`);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
const firstVisitedVertices = /* @__PURE__ */ new Set();
|
|
781
|
+
const visitationOrder = _nullishCoalesce(args.visitationOrder, () => ( [...graph.keys()]));
|
|
782
|
+
const events = visitationOrder.map((vertex) => ({ eventType: "first", vertex, extras: {} })).reverse();
|
|
783
|
+
while (events.length) {
|
|
784
|
+
const { eventType, vertex, extras } = events.pop();
|
|
785
|
+
if (eventType === "last") {
|
|
786
|
+
_optionalChain([lastVisitF, 'optionalCall', _8 => _8(vertex)]);
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
if (firstVisitedVertices.has(vertex)) {
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
firstVisitedVertices.add(vertex);
|
|
793
|
+
_optionalChain([firstVisitF, 'optionalCall', _9 => _9(vertex, { parentVertex: extras.parentVertex })]);
|
|
794
|
+
events.push({ eventType: "last", vertex, extras: {} });
|
|
795
|
+
mapAt(graph, vertex).forEach((child) => {
|
|
796
|
+
events.push({
|
|
797
|
+
eventType: "first",
|
|
798
|
+
vertex: child,
|
|
799
|
+
extras: { parentVertex: vertex }
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function undirectedConnectedComponents(graph) {
|
|
805
|
+
const directedGraph = new Map(
|
|
806
|
+
[...graph.vertices].map((v) => [v, /* @__PURE__ */ new Set()])
|
|
807
|
+
);
|
|
808
|
+
for (const [i, j] of graph.edges) {
|
|
809
|
+
mapAt(directedGraph, i).add(j);
|
|
810
|
+
mapAt(directedGraph, j).add(i);
|
|
811
|
+
}
|
|
812
|
+
let labelCounter = 0;
|
|
813
|
+
const vertexLabels = /* @__PURE__ */ new Map();
|
|
814
|
+
const firstVisitF = (vertex, args) => {
|
|
815
|
+
const label = _optionalChain([args, 'optionalAccess', _10 => _10.parentVertex]) !== void 0 ? mapAt(vertexLabels, _optionalChain([args, 'optionalAccess', _11 => _11.parentVertex])) : labelCounter++;
|
|
816
|
+
vertexLabels.set(vertex, label);
|
|
817
|
+
};
|
|
818
|
+
depthFirstSearch({ graph: directedGraph, firstVisitF });
|
|
819
|
+
const output = Array.from({ length: labelCounter }).map(() => []);
|
|
820
|
+
for (const [vertex, label] of vertexLabels.entries()) {
|
|
821
|
+
output[label].push(vertex);
|
|
822
|
+
}
|
|
823
|
+
return output;
|
|
824
|
+
}
|
|
825
|
+
function topologicalSort(graph, visitationOrder) {
|
|
826
|
+
const reverseOrdering = [];
|
|
827
|
+
const lastVisitF = (vertex) => {
|
|
828
|
+
reverseOrdering.push(vertex);
|
|
829
|
+
};
|
|
830
|
+
depthFirstSearch({ graph, lastVisitF, visitationOrder });
|
|
831
|
+
return reverseOrdering.reverse();
|
|
832
|
+
}
|
|
103
833
|
|
|
834
|
+
// util/merge_row_batch.ts
|
|
835
|
+
function generateMergedRowKey(row, useParentIdForId) {
|
|
836
|
+
return JSON.stringify(
|
|
837
|
+
[
|
|
838
|
+
"org_id",
|
|
839
|
+
"project_id",
|
|
840
|
+
"experiment_id",
|
|
841
|
+
"dataset_id",
|
|
842
|
+
"prompt_session_id",
|
|
843
|
+
"log_id",
|
|
844
|
+
_nullishCoalesce(useParentIdForId, () => ( false)) ? PARENT_ID_FIELD : "id"
|
|
845
|
+
].map((k) => row[k])
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
var MERGE_ROW_SKIP_FIELDS = [
|
|
849
|
+
"created",
|
|
850
|
+
"span_id",
|
|
851
|
+
"root_span_id",
|
|
852
|
+
"span_parents",
|
|
853
|
+
"_parent_id"
|
|
854
|
+
// TODO: handle merge paths.
|
|
855
|
+
];
|
|
856
|
+
function popMergeRowSkipFields(row) {
|
|
857
|
+
const popped = {};
|
|
858
|
+
for (const field of MERGE_ROW_SKIP_FIELDS) {
|
|
859
|
+
if (field in row) {
|
|
860
|
+
popped[field] = row[field];
|
|
861
|
+
delete row[field];
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return popped;
|
|
865
|
+
}
|
|
866
|
+
function restoreMergeRowSkipFields(row, skipFields) {
|
|
867
|
+
for (const field of MERGE_ROW_SKIP_FIELDS) {
|
|
868
|
+
delete row[field];
|
|
869
|
+
if (field in skipFields) {
|
|
870
|
+
row[field] = skipFields[field];
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
function mergeRowBatch(rows) {
|
|
875
|
+
for (const row of rows) {
|
|
876
|
+
if (row.id === void 0) {
|
|
877
|
+
throw new Error(
|
|
878
|
+
"Logged row is missing an id. This is an internal braintrust error. Please contact us at info@braintrust.dev for help"
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
const rowGroups = /* @__PURE__ */ new Map();
|
|
883
|
+
for (const row of rows) {
|
|
884
|
+
const key = generateMergedRowKey(row);
|
|
885
|
+
const existingRow = rowGroups.get(key);
|
|
886
|
+
if (existingRow !== void 0 && row[IS_MERGE_FIELD]) {
|
|
887
|
+
const skipFields = popMergeRowSkipFields(existingRow);
|
|
888
|
+
const preserveNoMerge = !existingRow[IS_MERGE_FIELD];
|
|
889
|
+
mergeDicts(existingRow, row);
|
|
890
|
+
restoreMergeRowSkipFields(existingRow, skipFields);
|
|
891
|
+
if (preserveNoMerge) {
|
|
892
|
+
delete existingRow[IS_MERGE_FIELD];
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
rowGroups.set(key, row);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
const merged = [...rowGroups.values()];
|
|
899
|
+
const rowToLabel = new Map(
|
|
900
|
+
merged.map((r, i) => [generateMergedRowKey(r), i])
|
|
901
|
+
);
|
|
902
|
+
const graph = new Map(
|
|
903
|
+
Array.from({ length: merged.length }).map((_, i) => [i, /* @__PURE__ */ new Set()])
|
|
904
|
+
);
|
|
905
|
+
merged.forEach((r, i) => {
|
|
906
|
+
const parentId = r[PARENT_ID_FIELD];
|
|
907
|
+
if (!parentId) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const parentRowKey = generateMergedRowKey(
|
|
911
|
+
r,
|
|
912
|
+
true
|
|
913
|
+
/* useParentIdForId */
|
|
914
|
+
);
|
|
915
|
+
const parentLabel = rowToLabel.get(parentRowKey);
|
|
916
|
+
if (parentLabel !== void 0) {
|
|
917
|
+
mapAt(graph, parentLabel).add(i);
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
const connectedComponents = undirectedConnectedComponents({
|
|
921
|
+
vertices: new Set(graph.keys()),
|
|
922
|
+
edges: new Set(
|
|
923
|
+
[...graph.entries()].flatMap(
|
|
924
|
+
([k, vs]) => [...vs].map((v) => {
|
|
925
|
+
const ret = [k, v];
|
|
926
|
+
return ret;
|
|
927
|
+
})
|
|
928
|
+
)
|
|
929
|
+
)
|
|
930
|
+
});
|
|
931
|
+
const buckets = connectedComponents.map(
|
|
932
|
+
(cc) => topologicalSort(
|
|
933
|
+
graph,
|
|
934
|
+
cc
|
|
935
|
+
/* visitationOrder */
|
|
936
|
+
)
|
|
937
|
+
);
|
|
938
|
+
return buckets.map((bucket) => bucket.map((i) => merged[i]));
|
|
939
|
+
}
|
|
940
|
+
function batchItems(args) {
|
|
941
|
+
let { items } = args;
|
|
942
|
+
const batchMaxNumItems = _nullishCoalesce(args.batchMaxNumItems, () => ( Number.POSITIVE_INFINITY));
|
|
943
|
+
const batchMaxNumBytes = _nullishCoalesce(args.batchMaxNumBytes, () => ( Number.POSITIVE_INFINITY));
|
|
944
|
+
const output = [];
|
|
945
|
+
let nextItems = [];
|
|
946
|
+
let batchSet = [];
|
|
947
|
+
let batch = [];
|
|
948
|
+
let batchLen = 0;
|
|
949
|
+
function addToBatch(item) {
|
|
950
|
+
batch.push(item);
|
|
951
|
+
batchLen += item.length;
|
|
952
|
+
}
|
|
953
|
+
function flushBatch() {
|
|
954
|
+
batchSet.push(batch);
|
|
955
|
+
batch = [];
|
|
956
|
+
batchLen = 0;
|
|
957
|
+
}
|
|
958
|
+
while (items.length) {
|
|
959
|
+
for (const bucket of items) {
|
|
960
|
+
let i = 0;
|
|
961
|
+
for (const item of bucket) {
|
|
962
|
+
if (batch.length === 0 || item.length + batchLen < batchMaxNumBytes && batch.length < batchMaxNumItems) {
|
|
963
|
+
addToBatch(item);
|
|
964
|
+
} else if (i === 0) {
|
|
965
|
+
flushBatch();
|
|
966
|
+
addToBatch(item);
|
|
967
|
+
} else {
|
|
968
|
+
break;
|
|
969
|
+
}
|
|
970
|
+
++i;
|
|
971
|
+
}
|
|
972
|
+
if (i < bucket.length) {
|
|
973
|
+
nextItems.push(bucket.slice(i));
|
|
974
|
+
}
|
|
975
|
+
if (batchLen >= batchMaxNumBytes || batch.length > batchMaxNumItems) {
|
|
976
|
+
flushBatch();
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
if (batch.length) {
|
|
980
|
+
flushBatch();
|
|
981
|
+
}
|
|
982
|
+
if (batchSet.length) {
|
|
983
|
+
output.push(batchSet);
|
|
984
|
+
batchSet = [];
|
|
985
|
+
}
|
|
986
|
+
items = nextItems;
|
|
987
|
+
nextItems = [];
|
|
988
|
+
}
|
|
989
|
+
return output;
|
|
990
|
+
}
|
|
104
991
|
|
|
992
|
+
// util/object.ts
|
|
993
|
+
var DEFAULT_IS_LEGACY_DATASET = false;
|
|
994
|
+
function ensureDatasetRecord(r, legacy) {
|
|
995
|
+
if (legacy) {
|
|
996
|
+
return ensureLegacyDatasetRecord(r);
|
|
997
|
+
} else {
|
|
998
|
+
return ensureNewDatasetRecord(r);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
function ensureLegacyDatasetRecord(r) {
|
|
1002
|
+
if ("output" in r) {
|
|
1003
|
+
return r;
|
|
1004
|
+
}
|
|
1005
|
+
const row = {
|
|
1006
|
+
...r,
|
|
1007
|
+
output: r.expected
|
|
1008
|
+
};
|
|
1009
|
+
delete row.expected;
|
|
1010
|
+
return row;
|
|
1011
|
+
}
|
|
1012
|
+
function ensureNewDatasetRecord(r) {
|
|
1013
|
+
if ("expected" in r) {
|
|
1014
|
+
return r;
|
|
1015
|
+
}
|
|
1016
|
+
const row = {
|
|
1017
|
+
...r,
|
|
1018
|
+
tags: null,
|
|
1019
|
+
expected: r.output
|
|
1020
|
+
};
|
|
1021
|
+
delete row.output;
|
|
1022
|
+
return row;
|
|
1023
|
+
}
|
|
105
1024
|
|
|
1025
|
+
// util/json_util.ts
|
|
1026
|
+
function constructJsonArray(items) {
|
|
1027
|
+
return `[${items.join(",")}]`;
|
|
1028
|
+
}
|
|
106
1029
|
|
|
1030
|
+
// util/string_util.ts
|
|
1031
|
+
function _urljoin(...parts) {
|
|
1032
|
+
return parts.map(
|
|
1033
|
+
(x, i) => x.replace(/^\//, "").replace(i < parts.length - 1 ? /\/$/ : "", "")
|
|
1034
|
+
).filter((x) => x.trim() !== "").join("/");
|
|
1035
|
+
}
|
|
107
1036
|
|
|
1037
|
+
// util/git_fields.ts
|
|
1038
|
+
function mergeGitMetadataSettings(s1, s2) {
|
|
1039
|
+
if (s1.collect === "all") {
|
|
1040
|
+
return s2;
|
|
1041
|
+
} else if (s2.collect === "all") {
|
|
1042
|
+
return s1;
|
|
1043
|
+
} else if (s1.collect === "none") {
|
|
1044
|
+
return s1;
|
|
1045
|
+
} else if (s2.collect === "none") {
|
|
1046
|
+
return s2;
|
|
1047
|
+
}
|
|
1048
|
+
const fields = (_nullishCoalesce(s1.fields, () => ( []))).filter((f) => (_nullishCoalesce(s2.fields, () => ( []))).includes(f));
|
|
1049
|
+
const collect = fields.length > 0 ? "some" : "none";
|
|
1050
|
+
return { collect, fields };
|
|
1051
|
+
}
|
|
108
1052
|
|
|
1053
|
+
// util/xact-ids.ts
|
|
1054
|
+
var TOP_BITS = BigInt("0x0DE1") << BigInt(48);
|
|
1055
|
+
var MOD = BigInt(1) << BigInt(64);
|
|
1056
|
+
var COPRIME = BigInt("205891132094649");
|
|
1057
|
+
var COPRIME_INVERSE = BigInt("1522336535492693385");
|
|
1058
|
+
function modularMultiply(value, prime) {
|
|
1059
|
+
return value * prime % MOD;
|
|
1060
|
+
}
|
|
1061
|
+
function prettifyXact(valueString) {
|
|
1062
|
+
const value = BigInt(valueString);
|
|
1063
|
+
const encoded = modularMultiply(value, COPRIME);
|
|
1064
|
+
return encoded.toString(16).padStart(16, "0");
|
|
1065
|
+
}
|
|
109
1066
|
|
|
1067
|
+
// util/zod_util.ts
|
|
110
1068
|
|
|
111
|
-
var _core = require('@braintrust/core');
|
|
112
1069
|
|
|
113
1070
|
// src/generated_types.ts
|
|
114
|
-
|
|
115
|
-
var AclObjectType =
|
|
116
|
-
|
|
1071
|
+
|
|
1072
|
+
var AclObjectType = _v3.z.union([
|
|
1073
|
+
_v3.z.enum([
|
|
117
1074
|
"organization",
|
|
118
1075
|
"project",
|
|
119
1076
|
"experiment",
|
|
@@ -126,9 +1083,9 @@ var AclObjectType = _zod.z.union([
|
|
|
126
1083
|
"project_log",
|
|
127
1084
|
"org_project"
|
|
128
1085
|
]),
|
|
129
|
-
|
|
1086
|
+
_v3.z.null()
|
|
130
1087
|
]);
|
|
131
|
-
var Permission =
|
|
1088
|
+
var Permission = _v3.z.enum([
|
|
132
1089
|
"create",
|
|
133
1090
|
"read",
|
|
134
1091
|
"update",
|
|
@@ -138,310 +1095,310 @@ var Permission = _zod.z.enum([
|
|
|
138
1095
|
"update_acls",
|
|
139
1096
|
"delete_acls"
|
|
140
1097
|
]);
|
|
141
|
-
var Acl =
|
|
142
|
-
id:
|
|
143
|
-
object_type: AclObjectType.and(
|
|
144
|
-
object_id:
|
|
145
|
-
user_id:
|
|
146
|
-
group_id:
|
|
147
|
-
permission: Permission.and(
|
|
148
|
-
restrict_object_type: AclObjectType.and(
|
|
149
|
-
role_id:
|
|
150
|
-
_object_org_id:
|
|
151
|
-
created:
|
|
1098
|
+
var Acl = _v3.z.object({
|
|
1099
|
+
id: _v3.z.string().uuid(),
|
|
1100
|
+
object_type: AclObjectType.and(_v3.z.string()),
|
|
1101
|
+
object_id: _v3.z.string().uuid(),
|
|
1102
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1103
|
+
group_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1104
|
+
permission: Permission.and(_v3.z.union([_v3.z.string(), _v3.z.null()])).optional(),
|
|
1105
|
+
restrict_object_type: AclObjectType.and(_v3.z.unknown()).optional(),
|
|
1106
|
+
role_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1107
|
+
_object_org_id: _v3.z.string().uuid(),
|
|
1108
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
152
1109
|
});
|
|
153
|
-
var AISecret =
|
|
154
|
-
id:
|
|
155
|
-
created:
|
|
156
|
-
updated_at:
|
|
157
|
-
org_id:
|
|
158
|
-
name:
|
|
159
|
-
type:
|
|
160
|
-
metadata:
|
|
161
|
-
preview_secret:
|
|
1110
|
+
var AISecret = _v3.z.object({
|
|
1111
|
+
id: _v3.z.string().uuid(),
|
|
1112
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1113
|
+
updated_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1114
|
+
org_id: _v3.z.string().uuid(),
|
|
1115
|
+
name: _v3.z.string(),
|
|
1116
|
+
type: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1117
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
|
|
1118
|
+
preview_secret: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
162
1119
|
});
|
|
163
|
-
var ResponseFormatJsonSchema =
|
|
164
|
-
name:
|
|
165
|
-
description:
|
|
166
|
-
schema:
|
|
167
|
-
strict:
|
|
1120
|
+
var ResponseFormatJsonSchema = _v3.z.object({
|
|
1121
|
+
name: _v3.z.string(),
|
|
1122
|
+
description: _v3.z.string().optional(),
|
|
1123
|
+
schema: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.string()]).optional(),
|
|
1124
|
+
strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
168
1125
|
});
|
|
169
|
-
var ResponseFormatNullish =
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
type:
|
|
1126
|
+
var ResponseFormatNullish = _v3.z.union([
|
|
1127
|
+
_v3.z.object({ type: _v3.z.literal("json_object") }),
|
|
1128
|
+
_v3.z.object({
|
|
1129
|
+
type: _v3.z.literal("json_schema"),
|
|
173
1130
|
json_schema: ResponseFormatJsonSchema
|
|
174
1131
|
}),
|
|
175
|
-
|
|
176
|
-
|
|
1132
|
+
_v3.z.object({ type: _v3.z.literal("text") }),
|
|
1133
|
+
_v3.z.null()
|
|
177
1134
|
]);
|
|
178
|
-
var AnyModelParams =
|
|
179
|
-
temperature:
|
|
180
|
-
top_p:
|
|
181
|
-
max_tokens:
|
|
182
|
-
max_completion_tokens:
|
|
183
|
-
frequency_penalty:
|
|
184
|
-
presence_penalty:
|
|
1135
|
+
var AnyModelParams = _v3.z.object({
|
|
1136
|
+
temperature: _v3.z.number().optional(),
|
|
1137
|
+
top_p: _v3.z.number().optional(),
|
|
1138
|
+
max_tokens: _v3.z.number(),
|
|
1139
|
+
max_completion_tokens: _v3.z.number().optional(),
|
|
1140
|
+
frequency_penalty: _v3.z.number().optional(),
|
|
1141
|
+
presence_penalty: _v3.z.number().optional(),
|
|
185
1142
|
response_format: ResponseFormatNullish.optional(),
|
|
186
|
-
tool_choice:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
type:
|
|
192
|
-
function:
|
|
1143
|
+
tool_choice: _v3.z.union([
|
|
1144
|
+
_v3.z.literal("auto"),
|
|
1145
|
+
_v3.z.literal("none"),
|
|
1146
|
+
_v3.z.literal("required"),
|
|
1147
|
+
_v3.z.object({
|
|
1148
|
+
type: _v3.z.literal("function"),
|
|
1149
|
+
function: _v3.z.object({ name: _v3.z.string() })
|
|
193
1150
|
})
|
|
194
1151
|
]).optional(),
|
|
195
|
-
function_call:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
1152
|
+
function_call: _v3.z.union([
|
|
1153
|
+
_v3.z.literal("auto"),
|
|
1154
|
+
_v3.z.literal("none"),
|
|
1155
|
+
_v3.z.object({ name: _v3.z.string() })
|
|
199
1156
|
]).optional(),
|
|
200
|
-
n:
|
|
201
|
-
stop:
|
|
202
|
-
reasoning_effort:
|
|
203
|
-
verbosity:
|
|
204
|
-
top_k:
|
|
205
|
-
stop_sequences:
|
|
206
|
-
max_tokens_to_sample:
|
|
207
|
-
maxOutputTokens:
|
|
208
|
-
topP:
|
|
209
|
-
topK:
|
|
210
|
-
use_cache:
|
|
1157
|
+
n: _v3.z.number().optional(),
|
|
1158
|
+
stop: _v3.z.array(_v3.z.string()).optional(),
|
|
1159
|
+
reasoning_effort: _v3.z.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
1160
|
+
verbosity: _v3.z.enum(["low", "medium", "high"]).optional(),
|
|
1161
|
+
top_k: _v3.z.number().optional(),
|
|
1162
|
+
stop_sequences: _v3.z.array(_v3.z.string()).optional(),
|
|
1163
|
+
max_tokens_to_sample: _v3.z.number().optional(),
|
|
1164
|
+
maxOutputTokens: _v3.z.number().optional(),
|
|
1165
|
+
topP: _v3.z.number().optional(),
|
|
1166
|
+
topK: _v3.z.number().optional(),
|
|
1167
|
+
use_cache: _v3.z.boolean().optional()
|
|
211
1168
|
});
|
|
212
|
-
var ApiKey =
|
|
213
|
-
id:
|
|
214
|
-
created:
|
|
215
|
-
name:
|
|
216
|
-
preview_name:
|
|
217
|
-
user_id:
|
|
218
|
-
user_email:
|
|
219
|
-
user_given_name:
|
|
220
|
-
user_family_name:
|
|
221
|
-
org_id:
|
|
1169
|
+
var ApiKey = _v3.z.object({
|
|
1170
|
+
id: _v3.z.string().uuid(),
|
|
1171
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1172
|
+
name: _v3.z.string(),
|
|
1173
|
+
preview_name: _v3.z.string(),
|
|
1174
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1175
|
+
user_email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1176
|
+
user_given_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1177
|
+
user_family_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1178
|
+
org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
222
1179
|
});
|
|
223
|
-
var AsyncScoringState =
|
|
224
|
-
|
|
225
|
-
status:
|
|
226
|
-
token:
|
|
227
|
-
function_ids:
|
|
228
|
-
skip_logging:
|
|
1180
|
+
var AsyncScoringState = _v3.z.union([
|
|
1181
|
+
_v3.z.object({
|
|
1182
|
+
status: _v3.z.literal("enabled"),
|
|
1183
|
+
token: _v3.z.string(),
|
|
1184
|
+
function_ids: _v3.z.array(_v3.z.unknown()).min(1),
|
|
1185
|
+
skip_logging: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
229
1186
|
}),
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
1187
|
+
_v3.z.object({ status: _v3.z.literal("disabled") }),
|
|
1188
|
+
_v3.z.null(),
|
|
1189
|
+
_v3.z.null()
|
|
233
1190
|
]);
|
|
234
|
-
var AsyncScoringControl =
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
1191
|
+
var AsyncScoringControl = _v3.z.union([
|
|
1192
|
+
_v3.z.object({ kind: _v3.z.literal("score_update"), token: _v3.z.string() }),
|
|
1193
|
+
_v3.z.object({ kind: _v3.z.literal("state_override"), state: AsyncScoringState }),
|
|
1194
|
+
_v3.z.object({ kind: _v3.z.literal("state_force_reselect") }),
|
|
1195
|
+
_v3.z.object({ kind: _v3.z.literal("state_enabled_force_rescore") })
|
|
239
1196
|
]);
|
|
240
|
-
var BraintrustAttachmentReference =
|
|
241
|
-
type:
|
|
242
|
-
filename:
|
|
243
|
-
content_type:
|
|
244
|
-
key:
|
|
1197
|
+
var BraintrustAttachmentReference = _v3.z.object({
|
|
1198
|
+
type: _v3.z.literal("braintrust_attachment"),
|
|
1199
|
+
filename: _v3.z.string().min(1),
|
|
1200
|
+
content_type: _v3.z.string().min(1),
|
|
1201
|
+
key: _v3.z.string().min(1)
|
|
245
1202
|
});
|
|
246
|
-
var ExternalAttachmentReference =
|
|
247
|
-
type:
|
|
248
|
-
filename:
|
|
249
|
-
content_type:
|
|
250
|
-
url:
|
|
1203
|
+
var ExternalAttachmentReference = _v3.z.object({
|
|
1204
|
+
type: _v3.z.literal("external_attachment"),
|
|
1205
|
+
filename: _v3.z.string().min(1),
|
|
1206
|
+
content_type: _v3.z.string().min(1),
|
|
1207
|
+
url: _v3.z.string().min(1)
|
|
251
1208
|
});
|
|
252
|
-
var AttachmentReference =
|
|
1209
|
+
var AttachmentReference = _v3.z.discriminatedUnion("type", [
|
|
253
1210
|
BraintrustAttachmentReference,
|
|
254
1211
|
ExternalAttachmentReference
|
|
255
1212
|
]);
|
|
256
|
-
var UploadStatus =
|
|
257
|
-
var AttachmentStatus =
|
|
1213
|
+
var UploadStatus = _v3.z.enum(["uploading", "done", "error"]);
|
|
1214
|
+
var AttachmentStatus = _v3.z.object({
|
|
258
1215
|
upload_status: UploadStatus,
|
|
259
|
-
error_message:
|
|
1216
|
+
error_message: _v3.z.string().optional()
|
|
260
1217
|
});
|
|
261
|
-
var BraintrustModelParams =
|
|
262
|
-
var CallEvent =
|
|
263
|
-
|
|
264
|
-
id:
|
|
265
|
-
data:
|
|
266
|
-
event:
|
|
1218
|
+
var BraintrustModelParams = _v3.z.object({ use_cache: _v3.z.boolean() }).partial();
|
|
1219
|
+
var CallEvent = _v3.z.union([
|
|
1220
|
+
_v3.z.object({
|
|
1221
|
+
id: _v3.z.string().optional(),
|
|
1222
|
+
data: _v3.z.string(),
|
|
1223
|
+
event: _v3.z.literal("text_delta")
|
|
267
1224
|
}),
|
|
268
|
-
|
|
269
|
-
id:
|
|
270
|
-
data:
|
|
271
|
-
event:
|
|
1225
|
+
_v3.z.object({
|
|
1226
|
+
id: _v3.z.string().optional(),
|
|
1227
|
+
data: _v3.z.string(),
|
|
1228
|
+
event: _v3.z.literal("reasoning_delta")
|
|
272
1229
|
}),
|
|
273
|
-
|
|
274
|
-
id:
|
|
275
|
-
data:
|
|
276
|
-
event:
|
|
1230
|
+
_v3.z.object({
|
|
1231
|
+
id: _v3.z.string().optional(),
|
|
1232
|
+
data: _v3.z.string(),
|
|
1233
|
+
event: _v3.z.literal("json_delta")
|
|
277
1234
|
}),
|
|
278
|
-
|
|
279
|
-
id:
|
|
280
|
-
data:
|
|
281
|
-
event:
|
|
1235
|
+
_v3.z.object({
|
|
1236
|
+
id: _v3.z.string().optional(),
|
|
1237
|
+
data: _v3.z.string(),
|
|
1238
|
+
event: _v3.z.literal("progress")
|
|
282
1239
|
}),
|
|
283
|
-
|
|
284
|
-
id:
|
|
285
|
-
data:
|
|
286
|
-
event:
|
|
1240
|
+
_v3.z.object({
|
|
1241
|
+
id: _v3.z.string().optional(),
|
|
1242
|
+
data: _v3.z.string(),
|
|
1243
|
+
event: _v3.z.literal("error")
|
|
287
1244
|
}),
|
|
288
|
-
|
|
289
|
-
id:
|
|
290
|
-
data:
|
|
291
|
-
event:
|
|
1245
|
+
_v3.z.object({
|
|
1246
|
+
id: _v3.z.string().optional(),
|
|
1247
|
+
data: _v3.z.string(),
|
|
1248
|
+
event: _v3.z.literal("console")
|
|
292
1249
|
}),
|
|
293
|
-
|
|
294
|
-
id:
|
|
295
|
-
event:
|
|
296
|
-
data:
|
|
1250
|
+
_v3.z.object({
|
|
1251
|
+
id: _v3.z.string().optional(),
|
|
1252
|
+
event: _v3.z.literal("start"),
|
|
1253
|
+
data: _v3.z.literal("")
|
|
297
1254
|
}),
|
|
298
|
-
|
|
299
|
-
id:
|
|
300
|
-
event:
|
|
301
|
-
data:
|
|
1255
|
+
_v3.z.object({
|
|
1256
|
+
id: _v3.z.string().optional(),
|
|
1257
|
+
event: _v3.z.literal("done"),
|
|
1258
|
+
data: _v3.z.literal("")
|
|
302
1259
|
})
|
|
303
1260
|
]);
|
|
304
|
-
var ChatCompletionContentPartTextWithTitle =
|
|
305
|
-
text:
|
|
306
|
-
type:
|
|
307
|
-
cache_control:
|
|
1261
|
+
var ChatCompletionContentPartTextWithTitle = _v3.z.object({
|
|
1262
|
+
text: _v3.z.string().default(""),
|
|
1263
|
+
type: _v3.z.literal("text"),
|
|
1264
|
+
cache_control: _v3.z.object({ type: _v3.z.literal("ephemeral") }).optional()
|
|
308
1265
|
});
|
|
309
|
-
var ChatCompletionContentPartImageWithTitle =
|
|
310
|
-
image_url:
|
|
311
|
-
url:
|
|
312
|
-
detail:
|
|
1266
|
+
var ChatCompletionContentPartImageWithTitle = _v3.z.object({
|
|
1267
|
+
image_url: _v3.z.object({
|
|
1268
|
+
url: _v3.z.string(),
|
|
1269
|
+
detail: _v3.z.union([_v3.z.literal("auto"), _v3.z.literal("low"), _v3.z.literal("high")]).optional()
|
|
313
1270
|
}),
|
|
314
|
-
type:
|
|
1271
|
+
type: _v3.z.literal("image_url")
|
|
315
1272
|
});
|
|
316
|
-
var ChatCompletionContentPart =
|
|
1273
|
+
var ChatCompletionContentPart = _v3.z.union([
|
|
317
1274
|
ChatCompletionContentPartTextWithTitle,
|
|
318
1275
|
ChatCompletionContentPartImageWithTitle
|
|
319
1276
|
]);
|
|
320
|
-
var ChatCompletionContentPartText =
|
|
321
|
-
text:
|
|
322
|
-
type:
|
|
323
|
-
cache_control:
|
|
1277
|
+
var ChatCompletionContentPartText = _v3.z.object({
|
|
1278
|
+
text: _v3.z.string().default(""),
|
|
1279
|
+
type: _v3.z.literal("text"),
|
|
1280
|
+
cache_control: _v3.z.object({ type: _v3.z.literal("ephemeral") }).optional()
|
|
324
1281
|
});
|
|
325
|
-
var ChatCompletionMessageToolCall =
|
|
326
|
-
id:
|
|
327
|
-
function:
|
|
328
|
-
type:
|
|
1282
|
+
var ChatCompletionMessageToolCall = _v3.z.object({
|
|
1283
|
+
id: _v3.z.string(),
|
|
1284
|
+
function: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }),
|
|
1285
|
+
type: _v3.z.literal("function")
|
|
329
1286
|
});
|
|
330
|
-
var ChatCompletionMessageReasoning =
|
|
331
|
-
var ChatCompletionMessageParam =
|
|
332
|
-
|
|
333
|
-
content:
|
|
334
|
-
role:
|
|
335
|
-
name:
|
|
1287
|
+
var ChatCompletionMessageReasoning = _v3.z.object({ id: _v3.z.string(), content: _v3.z.string() }).partial();
|
|
1288
|
+
var ChatCompletionMessageParam = _v3.z.union([
|
|
1289
|
+
_v3.z.object({
|
|
1290
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1291
|
+
role: _v3.z.literal("system"),
|
|
1292
|
+
name: _v3.z.string().optional()
|
|
336
1293
|
}),
|
|
337
|
-
|
|
338
|
-
content:
|
|
339
|
-
role:
|
|
340
|
-
name:
|
|
1294
|
+
_v3.z.object({
|
|
1295
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPart)]),
|
|
1296
|
+
role: _v3.z.literal("user"),
|
|
1297
|
+
name: _v3.z.string().optional()
|
|
341
1298
|
}),
|
|
342
|
-
|
|
343
|
-
role:
|
|
344
|
-
content:
|
|
345
|
-
function_call:
|
|
346
|
-
name:
|
|
347
|
-
tool_calls:
|
|
348
|
-
reasoning:
|
|
1299
|
+
_v3.z.object({
|
|
1300
|
+
role: _v3.z.literal("assistant"),
|
|
1301
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText), _v3.z.null()]).optional(),
|
|
1302
|
+
function_call: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }).optional(),
|
|
1303
|
+
name: _v3.z.string().optional(),
|
|
1304
|
+
tool_calls: _v3.z.array(ChatCompletionMessageToolCall).optional(),
|
|
1305
|
+
reasoning: _v3.z.array(ChatCompletionMessageReasoning).optional()
|
|
349
1306
|
}),
|
|
350
|
-
|
|
351
|
-
content:
|
|
352
|
-
role:
|
|
353
|
-
tool_call_id:
|
|
1307
|
+
_v3.z.object({
|
|
1308
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1309
|
+
role: _v3.z.literal("tool"),
|
|
1310
|
+
tool_call_id: _v3.z.string().default("")
|
|
354
1311
|
}),
|
|
355
|
-
|
|
356
|
-
content:
|
|
357
|
-
name:
|
|
358
|
-
role:
|
|
1312
|
+
_v3.z.object({
|
|
1313
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1314
|
+
name: _v3.z.string(),
|
|
1315
|
+
role: _v3.z.literal("function")
|
|
359
1316
|
}),
|
|
360
|
-
|
|
361
|
-
content:
|
|
362
|
-
role:
|
|
363
|
-
name:
|
|
1317
|
+
_v3.z.object({
|
|
1318
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1319
|
+
role: _v3.z.literal("developer"),
|
|
1320
|
+
name: _v3.z.string().optional()
|
|
364
1321
|
}),
|
|
365
|
-
|
|
366
|
-
role:
|
|
367
|
-
content:
|
|
1322
|
+
_v3.z.object({
|
|
1323
|
+
role: _v3.z.literal("model"),
|
|
1324
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
368
1325
|
})
|
|
369
1326
|
]);
|
|
370
|
-
var ChatCompletionOpenAIMessageParam =
|
|
371
|
-
|
|
372
|
-
content:
|
|
373
|
-
role:
|
|
374
|
-
name:
|
|
1327
|
+
var ChatCompletionOpenAIMessageParam = _v3.z.union([
|
|
1328
|
+
_v3.z.object({
|
|
1329
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1330
|
+
role: _v3.z.literal("system"),
|
|
1331
|
+
name: _v3.z.string().optional()
|
|
375
1332
|
}),
|
|
376
|
-
|
|
377
|
-
content:
|
|
378
|
-
role:
|
|
379
|
-
name:
|
|
1333
|
+
_v3.z.object({
|
|
1334
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPart)]),
|
|
1335
|
+
role: _v3.z.literal("user"),
|
|
1336
|
+
name: _v3.z.string().optional()
|
|
380
1337
|
}),
|
|
381
|
-
|
|
382
|
-
role:
|
|
383
|
-
content:
|
|
384
|
-
function_call:
|
|
385
|
-
name:
|
|
386
|
-
tool_calls:
|
|
387
|
-
reasoning:
|
|
1338
|
+
_v3.z.object({
|
|
1339
|
+
role: _v3.z.literal("assistant"),
|
|
1340
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText), _v3.z.null()]).optional(),
|
|
1341
|
+
function_call: _v3.z.object({ arguments: _v3.z.string(), name: _v3.z.string() }).optional(),
|
|
1342
|
+
name: _v3.z.string().optional(),
|
|
1343
|
+
tool_calls: _v3.z.array(ChatCompletionMessageToolCall).optional(),
|
|
1344
|
+
reasoning: _v3.z.array(ChatCompletionMessageReasoning).optional()
|
|
388
1345
|
}),
|
|
389
|
-
|
|
390
|
-
content:
|
|
391
|
-
role:
|
|
392
|
-
tool_call_id:
|
|
1346
|
+
_v3.z.object({
|
|
1347
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1348
|
+
role: _v3.z.literal("tool"),
|
|
1349
|
+
tool_call_id: _v3.z.string().default("")
|
|
393
1350
|
}),
|
|
394
|
-
|
|
395
|
-
content:
|
|
396
|
-
name:
|
|
397
|
-
role:
|
|
1351
|
+
_v3.z.object({
|
|
1352
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1353
|
+
name: _v3.z.string(),
|
|
1354
|
+
role: _v3.z.literal("function")
|
|
398
1355
|
}),
|
|
399
|
-
|
|
400
|
-
content:
|
|
401
|
-
role:
|
|
402
|
-
name:
|
|
1356
|
+
_v3.z.object({
|
|
1357
|
+
content: _v3.z.union([_v3.z.string(), _v3.z.array(ChatCompletionContentPartText)]),
|
|
1358
|
+
role: _v3.z.literal("developer"),
|
|
1359
|
+
name: _v3.z.string().optional()
|
|
403
1360
|
})
|
|
404
1361
|
]);
|
|
405
|
-
var ChatCompletionTool =
|
|
406
|
-
function:
|
|
407
|
-
name:
|
|
408
|
-
description:
|
|
409
|
-
parameters:
|
|
1362
|
+
var ChatCompletionTool = _v3.z.object({
|
|
1363
|
+
function: _v3.z.object({
|
|
1364
|
+
name: _v3.z.string(),
|
|
1365
|
+
description: _v3.z.string().optional(),
|
|
1366
|
+
parameters: _v3.z.object({}).partial().passthrough().optional()
|
|
410
1367
|
}),
|
|
411
|
-
type:
|
|
1368
|
+
type: _v3.z.literal("function")
|
|
412
1369
|
});
|
|
413
|
-
var CodeBundle =
|
|
414
|
-
runtime_context:
|
|
415
|
-
runtime:
|
|
416
|
-
version:
|
|
1370
|
+
var CodeBundle = _v3.z.object({
|
|
1371
|
+
runtime_context: _v3.z.object({
|
|
1372
|
+
runtime: _v3.z.enum(["node", "python"]),
|
|
1373
|
+
version: _v3.z.string()
|
|
417
1374
|
}),
|
|
418
|
-
location:
|
|
419
|
-
|
|
420
|
-
type:
|
|
421
|
-
eval_name:
|
|
422
|
-
position:
|
|
423
|
-
|
|
424
|
-
|
|
1375
|
+
location: _v3.z.union([
|
|
1376
|
+
_v3.z.object({
|
|
1377
|
+
type: _v3.z.literal("experiment"),
|
|
1378
|
+
eval_name: _v3.z.string(),
|
|
1379
|
+
position: _v3.z.union([
|
|
1380
|
+
_v3.z.object({ type: _v3.z.literal("task") }),
|
|
1381
|
+
_v3.z.object({ type: _v3.z.literal("scorer"), index: _v3.z.number().int().gte(0) })
|
|
425
1382
|
])
|
|
426
1383
|
}),
|
|
427
|
-
|
|
1384
|
+
_v3.z.object({ type: _v3.z.literal("function"), index: _v3.z.number().int().gte(0) })
|
|
428
1385
|
]),
|
|
429
|
-
bundle_id:
|
|
430
|
-
preview:
|
|
1386
|
+
bundle_id: _v3.z.string(),
|
|
1387
|
+
preview: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
431
1388
|
});
|
|
432
|
-
var Dataset =
|
|
433
|
-
id:
|
|
434
|
-
project_id:
|
|
435
|
-
name:
|
|
436
|
-
description:
|
|
437
|
-
created:
|
|
438
|
-
deleted_at:
|
|
439
|
-
user_id:
|
|
440
|
-
metadata:
|
|
1389
|
+
var Dataset = _v3.z.object({
|
|
1390
|
+
id: _v3.z.string().uuid(),
|
|
1391
|
+
project_id: _v3.z.string().uuid(),
|
|
1392
|
+
name: _v3.z.string(),
|
|
1393
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1394
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1395
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1396
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1397
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
|
|
441
1398
|
});
|
|
442
|
-
var ObjectReferenceNullish =
|
|
443
|
-
|
|
444
|
-
object_type:
|
|
1399
|
+
var ObjectReferenceNullish = _v3.z.union([
|
|
1400
|
+
_v3.z.object({
|
|
1401
|
+
object_type: _v3.z.enum([
|
|
445
1402
|
"project_logs",
|
|
446
1403
|
"experiment",
|
|
447
1404
|
"dataset",
|
|
@@ -449,399 +1406,399 @@ var ObjectReferenceNullish = _zod.z.union([
|
|
|
449
1406
|
"function",
|
|
450
1407
|
"prompt_session"
|
|
451
1408
|
]),
|
|
452
|
-
object_id:
|
|
453
|
-
id:
|
|
454
|
-
_xact_id:
|
|
455
|
-
created:
|
|
1409
|
+
object_id: _v3.z.string().uuid(),
|
|
1410
|
+
id: _v3.z.string(),
|
|
1411
|
+
_xact_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1412
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
456
1413
|
}),
|
|
457
|
-
|
|
1414
|
+
_v3.z.null()
|
|
458
1415
|
]);
|
|
459
|
-
var DatasetEvent =
|
|
460
|
-
id:
|
|
461
|
-
_xact_id:
|
|
462
|
-
created:
|
|
463
|
-
_pagination_key:
|
|
464
|
-
project_id:
|
|
465
|
-
dataset_id:
|
|
466
|
-
input:
|
|
467
|
-
expected:
|
|
468
|
-
metadata:
|
|
469
|
-
|
|
470
|
-
|
|
1416
|
+
var DatasetEvent = _v3.z.object({
|
|
1417
|
+
id: _v3.z.string(),
|
|
1418
|
+
_xact_id: _v3.z.string(),
|
|
1419
|
+
created: _v3.z.string().datetime({ offset: true }),
|
|
1420
|
+
_pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1421
|
+
project_id: _v3.z.string().uuid(),
|
|
1422
|
+
dataset_id: _v3.z.string().uuid(),
|
|
1423
|
+
input: _v3.z.unknown().optional(),
|
|
1424
|
+
expected: _v3.z.unknown().optional(),
|
|
1425
|
+
metadata: _v3.z.union([
|
|
1426
|
+
_v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
|
|
1427
|
+
_v3.z.null()
|
|
471
1428
|
]).optional(),
|
|
472
|
-
tags:
|
|
473
|
-
span_id:
|
|
474
|
-
root_span_id:
|
|
475
|
-
is_root:
|
|
1429
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1430
|
+
span_id: _v3.z.string(),
|
|
1431
|
+
root_span_id: _v3.z.string(),
|
|
1432
|
+
is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
476
1433
|
origin: ObjectReferenceNullish.optional()
|
|
477
1434
|
});
|
|
478
|
-
var EnvVar =
|
|
479
|
-
id:
|
|
480
|
-
object_type:
|
|
481
|
-
object_id:
|
|
482
|
-
name:
|
|
483
|
-
created:
|
|
484
|
-
used:
|
|
1435
|
+
var EnvVar = _v3.z.object({
|
|
1436
|
+
id: _v3.z.string().uuid(),
|
|
1437
|
+
object_type: _v3.z.enum(["organization", "project", "function"]),
|
|
1438
|
+
object_id: _v3.z.string().uuid(),
|
|
1439
|
+
name: _v3.z.string(),
|
|
1440
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1441
|
+
used: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
485
1442
|
});
|
|
486
|
-
var RepoInfo =
|
|
487
|
-
|
|
488
|
-
commit:
|
|
489
|
-
branch:
|
|
490
|
-
tag:
|
|
491
|
-
dirty:
|
|
492
|
-
author_name:
|
|
493
|
-
author_email:
|
|
494
|
-
commit_message:
|
|
495
|
-
commit_time:
|
|
496
|
-
git_diff:
|
|
1443
|
+
var RepoInfo = _v3.z.union([
|
|
1444
|
+
_v3.z.object({
|
|
1445
|
+
commit: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1446
|
+
branch: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1447
|
+
tag: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1448
|
+
dirty: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
1449
|
+
author_name: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1450
|
+
author_email: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1451
|
+
commit_message: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1452
|
+
commit_time: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1453
|
+
git_diff: _v3.z.union([_v3.z.string(), _v3.z.null()])
|
|
497
1454
|
}).partial(),
|
|
498
|
-
|
|
1455
|
+
_v3.z.null()
|
|
499
1456
|
]);
|
|
500
|
-
var Experiment =
|
|
501
|
-
id:
|
|
502
|
-
project_id:
|
|
503
|
-
name:
|
|
504
|
-
description:
|
|
505
|
-
created:
|
|
1457
|
+
var Experiment = _v3.z.object({
|
|
1458
|
+
id: _v3.z.string().uuid(),
|
|
1459
|
+
project_id: _v3.z.string().uuid(),
|
|
1460
|
+
name: _v3.z.string(),
|
|
1461
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1462
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
506
1463
|
repo_info: RepoInfo.optional(),
|
|
507
|
-
commit:
|
|
508
|
-
base_exp_id:
|
|
509
|
-
deleted_at:
|
|
510
|
-
dataset_id:
|
|
511
|
-
dataset_version:
|
|
512
|
-
public:
|
|
513
|
-
user_id:
|
|
514
|
-
metadata:
|
|
515
|
-
tags:
|
|
1464
|
+
commit: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1465
|
+
base_exp_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1466
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1467
|
+
dataset_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1468
|
+
dataset_version: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1469
|
+
public: _v3.z.boolean(),
|
|
1470
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1471
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
|
|
1472
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional()
|
|
516
1473
|
});
|
|
517
|
-
var SpanType =
|
|
518
|
-
|
|
519
|
-
|
|
1474
|
+
var SpanType = _v3.z.union([
|
|
1475
|
+
_v3.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
|
|
1476
|
+
_v3.z.null()
|
|
520
1477
|
]);
|
|
521
|
-
var SpanAttributes =
|
|
522
|
-
|
|
523
|
-
|
|
1478
|
+
var SpanAttributes = _v3.z.union([
|
|
1479
|
+
_v3.z.object({ name: _v3.z.union([_v3.z.string(), _v3.z.null()]), type: SpanType }).partial().passthrough(),
|
|
1480
|
+
_v3.z.null()
|
|
524
1481
|
]);
|
|
525
|
-
var ExperimentEvent =
|
|
526
|
-
id:
|
|
527
|
-
_xact_id:
|
|
528
|
-
created:
|
|
529
|
-
_pagination_key:
|
|
530
|
-
project_id:
|
|
531
|
-
experiment_id:
|
|
532
|
-
input:
|
|
533
|
-
output:
|
|
534
|
-
expected:
|
|
535
|
-
error:
|
|
536
|
-
scores:
|
|
537
|
-
metadata:
|
|
538
|
-
|
|
539
|
-
|
|
1482
|
+
var ExperimentEvent = _v3.z.object({
|
|
1483
|
+
id: _v3.z.string(),
|
|
1484
|
+
_xact_id: _v3.z.string(),
|
|
1485
|
+
created: _v3.z.string().datetime({ offset: true }),
|
|
1486
|
+
_pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1487
|
+
project_id: _v3.z.string().uuid(),
|
|
1488
|
+
experiment_id: _v3.z.string().uuid(),
|
|
1489
|
+
input: _v3.z.unknown().optional(),
|
|
1490
|
+
output: _v3.z.unknown().optional(),
|
|
1491
|
+
expected: _v3.z.unknown().optional(),
|
|
1492
|
+
error: _v3.z.unknown().optional(),
|
|
1493
|
+
scores: _v3.z.union([_v3.z.record(_v3.z.union([_v3.z.number(), _v3.z.null()])), _v3.z.null()]).optional(),
|
|
1494
|
+
metadata: _v3.z.union([
|
|
1495
|
+
_v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
|
|
1496
|
+
_v3.z.null()
|
|
540
1497
|
]).optional(),
|
|
541
|
-
tags:
|
|
542
|
-
metrics:
|
|
543
|
-
context:
|
|
544
|
-
|
|
545
|
-
caller_functionname:
|
|
546
|
-
caller_filename:
|
|
547
|
-
caller_lineno:
|
|
1498
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1499
|
+
metrics: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]).optional(),
|
|
1500
|
+
context: _v3.z.union([
|
|
1501
|
+
_v3.z.object({
|
|
1502
|
+
caller_functionname: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1503
|
+
caller_filename: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1504
|
+
caller_lineno: _v3.z.union([_v3.z.number(), _v3.z.null()])
|
|
548
1505
|
}).partial().passthrough(),
|
|
549
|
-
|
|
1506
|
+
_v3.z.null()
|
|
550
1507
|
]).optional(),
|
|
551
|
-
span_id:
|
|
552
|
-
span_parents:
|
|
553
|
-
root_span_id:
|
|
1508
|
+
span_id: _v3.z.string(),
|
|
1509
|
+
span_parents: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1510
|
+
root_span_id: _v3.z.string(),
|
|
554
1511
|
span_attributes: SpanAttributes.optional(),
|
|
555
|
-
is_root:
|
|
1512
|
+
is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
556
1513
|
origin: ObjectReferenceNullish.optional()
|
|
557
1514
|
});
|
|
558
|
-
var ExtendedSavedFunctionId =
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
type:
|
|
563
|
-
project_id:
|
|
564
|
-
slug:
|
|
1515
|
+
var ExtendedSavedFunctionId = _v3.z.union([
|
|
1516
|
+
_v3.z.object({ type: _v3.z.literal("function"), id: _v3.z.string() }),
|
|
1517
|
+
_v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() }),
|
|
1518
|
+
_v3.z.object({
|
|
1519
|
+
type: _v3.z.literal("slug"),
|
|
1520
|
+
project_id: _v3.z.string(),
|
|
1521
|
+
slug: _v3.z.string()
|
|
565
1522
|
})
|
|
566
1523
|
]);
|
|
567
|
-
var PromptBlockDataNullish =
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
type:
|
|
571
|
-
messages:
|
|
572
|
-
tools:
|
|
1524
|
+
var PromptBlockDataNullish = _v3.z.union([
|
|
1525
|
+
_v3.z.object({ type: _v3.z.literal("completion"), content: _v3.z.string() }),
|
|
1526
|
+
_v3.z.object({
|
|
1527
|
+
type: _v3.z.literal("chat"),
|
|
1528
|
+
messages: _v3.z.array(ChatCompletionMessageParam),
|
|
1529
|
+
tools: _v3.z.string().optional()
|
|
573
1530
|
}),
|
|
574
|
-
|
|
1531
|
+
_v3.z.null()
|
|
575
1532
|
]);
|
|
576
|
-
var ModelParams =
|
|
577
|
-
|
|
578
|
-
use_cache:
|
|
579
|
-
temperature:
|
|
580
|
-
top_p:
|
|
581
|
-
max_tokens:
|
|
582
|
-
max_completion_tokens:
|
|
583
|
-
frequency_penalty:
|
|
584
|
-
presence_penalty:
|
|
1533
|
+
var ModelParams = _v3.z.union([
|
|
1534
|
+
_v3.z.object({
|
|
1535
|
+
use_cache: _v3.z.boolean(),
|
|
1536
|
+
temperature: _v3.z.number(),
|
|
1537
|
+
top_p: _v3.z.number(),
|
|
1538
|
+
max_tokens: _v3.z.number(),
|
|
1539
|
+
max_completion_tokens: _v3.z.number(),
|
|
1540
|
+
frequency_penalty: _v3.z.number(),
|
|
1541
|
+
presence_penalty: _v3.z.number(),
|
|
585
1542
|
response_format: ResponseFormatNullish,
|
|
586
|
-
tool_choice:
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
type:
|
|
592
|
-
function:
|
|
1543
|
+
tool_choice: _v3.z.union([
|
|
1544
|
+
_v3.z.literal("auto"),
|
|
1545
|
+
_v3.z.literal("none"),
|
|
1546
|
+
_v3.z.literal("required"),
|
|
1547
|
+
_v3.z.object({
|
|
1548
|
+
type: _v3.z.literal("function"),
|
|
1549
|
+
function: _v3.z.object({ name: _v3.z.string() })
|
|
593
1550
|
})
|
|
594
1551
|
]),
|
|
595
|
-
function_call:
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
1552
|
+
function_call: _v3.z.union([
|
|
1553
|
+
_v3.z.literal("auto"),
|
|
1554
|
+
_v3.z.literal("none"),
|
|
1555
|
+
_v3.z.object({ name: _v3.z.string() })
|
|
599
1556
|
]),
|
|
600
|
-
n:
|
|
601
|
-
stop:
|
|
602
|
-
reasoning_effort:
|
|
603
|
-
verbosity:
|
|
1557
|
+
n: _v3.z.number(),
|
|
1558
|
+
stop: _v3.z.array(_v3.z.string()),
|
|
1559
|
+
reasoning_effort: _v3.z.enum(["minimal", "low", "medium", "high"]),
|
|
1560
|
+
verbosity: _v3.z.enum(["low", "medium", "high"])
|
|
604
1561
|
}).partial().passthrough(),
|
|
605
|
-
|
|
606
|
-
use_cache:
|
|
607
|
-
max_tokens:
|
|
608
|
-
temperature:
|
|
609
|
-
top_p:
|
|
610
|
-
top_k:
|
|
611
|
-
stop_sequences:
|
|
612
|
-
max_tokens_to_sample:
|
|
1562
|
+
_v3.z.object({
|
|
1563
|
+
use_cache: _v3.z.boolean().optional(),
|
|
1564
|
+
max_tokens: _v3.z.number(),
|
|
1565
|
+
temperature: _v3.z.number(),
|
|
1566
|
+
top_p: _v3.z.number().optional(),
|
|
1567
|
+
top_k: _v3.z.number().optional(),
|
|
1568
|
+
stop_sequences: _v3.z.array(_v3.z.string()).optional(),
|
|
1569
|
+
max_tokens_to_sample: _v3.z.number().optional()
|
|
613
1570
|
}).passthrough(),
|
|
614
|
-
|
|
615
|
-
use_cache:
|
|
616
|
-
temperature:
|
|
617
|
-
maxOutputTokens:
|
|
618
|
-
topP:
|
|
619
|
-
topK:
|
|
1571
|
+
_v3.z.object({
|
|
1572
|
+
use_cache: _v3.z.boolean(),
|
|
1573
|
+
temperature: _v3.z.number(),
|
|
1574
|
+
maxOutputTokens: _v3.z.number(),
|
|
1575
|
+
topP: _v3.z.number(),
|
|
1576
|
+
topK: _v3.z.number()
|
|
620
1577
|
}).partial().passthrough(),
|
|
621
|
-
|
|
622
|
-
use_cache:
|
|
623
|
-
temperature:
|
|
624
|
-
topK:
|
|
1578
|
+
_v3.z.object({
|
|
1579
|
+
use_cache: _v3.z.boolean(),
|
|
1580
|
+
temperature: _v3.z.number(),
|
|
1581
|
+
topK: _v3.z.number()
|
|
625
1582
|
}).partial().passthrough(),
|
|
626
|
-
|
|
1583
|
+
_v3.z.object({ use_cache: _v3.z.boolean() }).partial().passthrough()
|
|
627
1584
|
]);
|
|
628
|
-
var PromptOptionsNullish =
|
|
629
|
-
|
|
630
|
-
|
|
1585
|
+
var PromptOptionsNullish = _v3.z.union([
|
|
1586
|
+
_v3.z.object({ model: _v3.z.string(), params: ModelParams, position: _v3.z.string() }).partial(),
|
|
1587
|
+
_v3.z.null()
|
|
631
1588
|
]);
|
|
632
|
-
var PromptParserNullish =
|
|
633
|
-
|
|
634
|
-
type:
|
|
635
|
-
use_cot:
|
|
636
|
-
choice_scores:
|
|
1589
|
+
var PromptParserNullish = _v3.z.union([
|
|
1590
|
+
_v3.z.object({
|
|
1591
|
+
type: _v3.z.literal("llm_classifier"),
|
|
1592
|
+
use_cot: _v3.z.boolean(),
|
|
1593
|
+
choice_scores: _v3.z.record(_v3.z.number().gte(0).lte(1))
|
|
637
1594
|
}),
|
|
638
|
-
|
|
1595
|
+
_v3.z.null()
|
|
639
1596
|
]);
|
|
640
|
-
var SavedFunctionId =
|
|
641
|
-
|
|
642
|
-
|
|
1597
|
+
var SavedFunctionId = _v3.z.union([
|
|
1598
|
+
_v3.z.object({ type: _v3.z.literal("function"), id: _v3.z.string() }),
|
|
1599
|
+
_v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() })
|
|
643
1600
|
]);
|
|
644
|
-
var PromptDataNullish =
|
|
645
|
-
|
|
1601
|
+
var PromptDataNullish = _v3.z.union([
|
|
1602
|
+
_v3.z.object({
|
|
646
1603
|
prompt: PromptBlockDataNullish,
|
|
647
1604
|
options: PromptOptionsNullish,
|
|
648
1605
|
parser: PromptParserNullish,
|
|
649
|
-
tool_functions:
|
|
650
|
-
origin:
|
|
651
|
-
|
|
652
|
-
prompt_id:
|
|
653
|
-
project_id:
|
|
654
|
-
prompt_version:
|
|
1606
|
+
tool_functions: _v3.z.union([_v3.z.array(SavedFunctionId), _v3.z.null()]),
|
|
1607
|
+
origin: _v3.z.union([
|
|
1608
|
+
_v3.z.object({
|
|
1609
|
+
prompt_id: _v3.z.string(),
|
|
1610
|
+
project_id: _v3.z.string(),
|
|
1611
|
+
prompt_version: _v3.z.string()
|
|
655
1612
|
}).partial(),
|
|
656
|
-
|
|
1613
|
+
_v3.z.null()
|
|
657
1614
|
])
|
|
658
1615
|
}).partial(),
|
|
659
|
-
|
|
1616
|
+
_v3.z.null()
|
|
660
1617
|
]);
|
|
661
|
-
var FunctionTypeEnumNullish =
|
|
662
|
-
|
|
663
|
-
|
|
1618
|
+
var FunctionTypeEnumNullish = _v3.z.union([
|
|
1619
|
+
_v3.z.enum(["llm", "scorer", "task", "tool"]),
|
|
1620
|
+
_v3.z.null()
|
|
664
1621
|
]);
|
|
665
|
-
var FunctionIdRef =
|
|
666
|
-
var PromptBlockData =
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
type:
|
|
670
|
-
messages:
|
|
671
|
-
tools:
|
|
1622
|
+
var FunctionIdRef = _v3.z.object({}).partial().passthrough();
|
|
1623
|
+
var PromptBlockData = _v3.z.union([
|
|
1624
|
+
_v3.z.object({ type: _v3.z.literal("completion"), content: _v3.z.string() }),
|
|
1625
|
+
_v3.z.object({
|
|
1626
|
+
type: _v3.z.literal("chat"),
|
|
1627
|
+
messages: _v3.z.array(ChatCompletionMessageParam),
|
|
1628
|
+
tools: _v3.z.string().optional()
|
|
672
1629
|
})
|
|
673
1630
|
]);
|
|
674
|
-
var GraphNode =
|
|
675
|
-
|
|
676
|
-
description:
|
|
677
|
-
position:
|
|
678
|
-
type:
|
|
1631
|
+
var GraphNode = _v3.z.union([
|
|
1632
|
+
_v3.z.object({
|
|
1633
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1634
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1635
|
+
type: _v3.z.literal("function"),
|
|
679
1636
|
function: FunctionIdRef
|
|
680
1637
|
}),
|
|
681
|
-
|
|
682
|
-
description:
|
|
683
|
-
position:
|
|
684
|
-
type:
|
|
1638
|
+
_v3.z.object({
|
|
1639
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1640
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1641
|
+
type: _v3.z.literal("input")
|
|
685
1642
|
}),
|
|
686
|
-
|
|
687
|
-
description:
|
|
688
|
-
position:
|
|
689
|
-
type:
|
|
1643
|
+
_v3.z.object({
|
|
1644
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1645
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1646
|
+
type: _v3.z.literal("output")
|
|
690
1647
|
}),
|
|
691
|
-
|
|
692
|
-
description:
|
|
693
|
-
position:
|
|
694
|
-
type:
|
|
695
|
-
value:
|
|
1648
|
+
_v3.z.object({
|
|
1649
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1650
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1651
|
+
type: _v3.z.literal("literal"),
|
|
1652
|
+
value: _v3.z.unknown().optional()
|
|
696
1653
|
}),
|
|
697
|
-
|
|
698
|
-
description:
|
|
699
|
-
position:
|
|
700
|
-
type:
|
|
701
|
-
expr:
|
|
1654
|
+
_v3.z.object({
|
|
1655
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1656
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1657
|
+
type: _v3.z.literal("btql"),
|
|
1658
|
+
expr: _v3.z.string()
|
|
702
1659
|
}),
|
|
703
|
-
|
|
704
|
-
description:
|
|
705
|
-
position:
|
|
706
|
-
type:
|
|
707
|
-
condition:
|
|
1660
|
+
_v3.z.object({
|
|
1661
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1662
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1663
|
+
type: _v3.z.literal("gate"),
|
|
1664
|
+
condition: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
708
1665
|
}),
|
|
709
|
-
|
|
710
|
-
description:
|
|
711
|
-
position:
|
|
712
|
-
type:
|
|
1666
|
+
_v3.z.object({
|
|
1667
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1668
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1669
|
+
type: _v3.z.literal("aggregator")
|
|
713
1670
|
}),
|
|
714
|
-
|
|
715
|
-
description:
|
|
716
|
-
position:
|
|
717
|
-
type:
|
|
1671
|
+
_v3.z.object({
|
|
1672
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1673
|
+
position: _v3.z.union([_v3.z.object({ x: _v3.z.number(), y: _v3.z.number() }), _v3.z.null()]).optional(),
|
|
1674
|
+
type: _v3.z.literal("prompt_template"),
|
|
718
1675
|
prompt: PromptBlockData
|
|
719
1676
|
})
|
|
720
1677
|
]);
|
|
721
|
-
var GraphEdge =
|
|
722
|
-
source:
|
|
723
|
-
target:
|
|
724
|
-
purpose:
|
|
1678
|
+
var GraphEdge = _v3.z.object({
|
|
1679
|
+
source: _v3.z.object({ node: _v3.z.string().max(1024), variable: _v3.z.string() }),
|
|
1680
|
+
target: _v3.z.object({ node: _v3.z.string().max(1024), variable: _v3.z.string() }),
|
|
1681
|
+
purpose: _v3.z.enum(["control", "data", "messages"])
|
|
725
1682
|
});
|
|
726
|
-
var GraphData =
|
|
727
|
-
type:
|
|
728
|
-
nodes:
|
|
729
|
-
edges:
|
|
1683
|
+
var GraphData = _v3.z.object({
|
|
1684
|
+
type: _v3.z.literal("graph"),
|
|
1685
|
+
nodes: _v3.z.record(GraphNode),
|
|
1686
|
+
edges: _v3.z.record(GraphEdge)
|
|
730
1687
|
});
|
|
731
|
-
var FunctionData =
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
type:
|
|
735
|
-
data:
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
type:
|
|
739
|
-
runtime_context:
|
|
740
|
-
runtime:
|
|
741
|
-
version:
|
|
1688
|
+
var FunctionData = _v3.z.union([
|
|
1689
|
+
_v3.z.object({ type: _v3.z.literal("prompt") }),
|
|
1690
|
+
_v3.z.object({
|
|
1691
|
+
type: _v3.z.literal("code"),
|
|
1692
|
+
data: _v3.z.union([
|
|
1693
|
+
_v3.z.object({ type: _v3.z.literal("bundle") }).and(CodeBundle),
|
|
1694
|
+
_v3.z.object({
|
|
1695
|
+
type: _v3.z.literal("inline"),
|
|
1696
|
+
runtime_context: _v3.z.object({
|
|
1697
|
+
runtime: _v3.z.enum(["node", "python"]),
|
|
1698
|
+
version: _v3.z.string()
|
|
742
1699
|
}),
|
|
743
|
-
code:
|
|
1700
|
+
code: _v3.z.string()
|
|
744
1701
|
})
|
|
745
1702
|
])
|
|
746
1703
|
}),
|
|
747
1704
|
GraphData,
|
|
748
|
-
|
|
749
|
-
type:
|
|
750
|
-
endpoint:
|
|
751
|
-
eval_name:
|
|
752
|
-
parameters:
|
|
1705
|
+
_v3.z.object({
|
|
1706
|
+
type: _v3.z.literal("remote_eval"),
|
|
1707
|
+
endpoint: _v3.z.string(),
|
|
1708
|
+
eval_name: _v3.z.string(),
|
|
1709
|
+
parameters: _v3.z.object({}).partial().passthrough()
|
|
753
1710
|
}),
|
|
754
|
-
|
|
1711
|
+
_v3.z.object({ type: _v3.z.literal("global"), name: _v3.z.string() })
|
|
755
1712
|
]);
|
|
756
|
-
var Function =
|
|
757
|
-
id:
|
|
758
|
-
_xact_id:
|
|
759
|
-
project_id:
|
|
760
|
-
log_id:
|
|
761
|
-
org_id:
|
|
762
|
-
name:
|
|
763
|
-
slug:
|
|
764
|
-
description:
|
|
765
|
-
created:
|
|
1713
|
+
var Function = _v3.z.object({
|
|
1714
|
+
id: _v3.z.string().uuid(),
|
|
1715
|
+
_xact_id: _v3.z.string(),
|
|
1716
|
+
project_id: _v3.z.string().uuid(),
|
|
1717
|
+
log_id: _v3.z.literal("p"),
|
|
1718
|
+
org_id: _v3.z.string().uuid(),
|
|
1719
|
+
name: _v3.z.string(),
|
|
1720
|
+
slug: _v3.z.string(),
|
|
1721
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1722
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
766
1723
|
prompt_data: PromptDataNullish.optional(),
|
|
767
|
-
tags:
|
|
768
|
-
metadata:
|
|
1724
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1725
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
|
|
769
1726
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
770
1727
|
function_data: FunctionData,
|
|
771
|
-
origin:
|
|
772
|
-
|
|
773
|
-
object_type: AclObjectType.and(
|
|
774
|
-
object_id:
|
|
775
|
-
internal:
|
|
1728
|
+
origin: _v3.z.union([
|
|
1729
|
+
_v3.z.object({
|
|
1730
|
+
object_type: AclObjectType.and(_v3.z.string()),
|
|
1731
|
+
object_id: _v3.z.string().uuid(),
|
|
1732
|
+
internal: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
776
1733
|
}),
|
|
777
|
-
|
|
1734
|
+
_v3.z.null()
|
|
778
1735
|
]).optional(),
|
|
779
|
-
function_schema:
|
|
780
|
-
|
|
781
|
-
|
|
1736
|
+
function_schema: _v3.z.union([
|
|
1737
|
+
_v3.z.object({ parameters: _v3.z.unknown(), returns: _v3.z.unknown() }).partial(),
|
|
1738
|
+
_v3.z.null()
|
|
782
1739
|
]).optional()
|
|
783
1740
|
});
|
|
784
|
-
var FunctionFormat =
|
|
785
|
-
var PromptData =
|
|
1741
|
+
var FunctionFormat = _v3.z.enum(["llm", "code", "global", "graph"]);
|
|
1742
|
+
var PromptData = _v3.z.object({
|
|
786
1743
|
prompt: PromptBlockDataNullish,
|
|
787
1744
|
options: PromptOptionsNullish,
|
|
788
1745
|
parser: PromptParserNullish,
|
|
789
|
-
tool_functions:
|
|
790
|
-
origin:
|
|
791
|
-
|
|
792
|
-
prompt_id:
|
|
793
|
-
project_id:
|
|
794
|
-
prompt_version:
|
|
1746
|
+
tool_functions: _v3.z.union([_v3.z.array(SavedFunctionId), _v3.z.null()]),
|
|
1747
|
+
origin: _v3.z.union([
|
|
1748
|
+
_v3.z.object({
|
|
1749
|
+
prompt_id: _v3.z.string(),
|
|
1750
|
+
project_id: _v3.z.string(),
|
|
1751
|
+
prompt_version: _v3.z.string()
|
|
795
1752
|
}).partial(),
|
|
796
|
-
|
|
1753
|
+
_v3.z.null()
|
|
797
1754
|
])
|
|
798
1755
|
}).partial();
|
|
799
|
-
var FunctionTypeEnum =
|
|
800
|
-
var FunctionId =
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
project_name:
|
|
804
|
-
slug:
|
|
805
|
-
version:
|
|
1756
|
+
var FunctionTypeEnum = _v3.z.enum(["llm", "scorer", "task", "tool"]);
|
|
1757
|
+
var FunctionId = _v3.z.union([
|
|
1758
|
+
_v3.z.object({ function_id: _v3.z.string(), version: _v3.z.string().optional() }),
|
|
1759
|
+
_v3.z.object({
|
|
1760
|
+
project_name: _v3.z.string(),
|
|
1761
|
+
slug: _v3.z.string(),
|
|
1762
|
+
version: _v3.z.string().optional()
|
|
806
1763
|
}),
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
prompt_session_id:
|
|
810
|
-
prompt_session_function_id:
|
|
811
|
-
version:
|
|
1764
|
+
_v3.z.object({ global_function: _v3.z.string() }),
|
|
1765
|
+
_v3.z.object({
|
|
1766
|
+
prompt_session_id: _v3.z.string(),
|
|
1767
|
+
prompt_session_function_id: _v3.z.string(),
|
|
1768
|
+
version: _v3.z.string().optional()
|
|
812
1769
|
}),
|
|
813
|
-
|
|
814
|
-
inline_context:
|
|
815
|
-
runtime:
|
|
816
|
-
version:
|
|
1770
|
+
_v3.z.object({
|
|
1771
|
+
inline_context: _v3.z.object({
|
|
1772
|
+
runtime: _v3.z.enum(["node", "python"]),
|
|
1773
|
+
version: _v3.z.string()
|
|
817
1774
|
}),
|
|
818
|
-
code:
|
|
819
|
-
name:
|
|
1775
|
+
code: _v3.z.string(),
|
|
1776
|
+
name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
820
1777
|
}),
|
|
821
|
-
|
|
1778
|
+
_v3.z.object({
|
|
822
1779
|
inline_prompt: PromptData.optional(),
|
|
823
|
-
inline_function:
|
|
1780
|
+
inline_function: _v3.z.object({}).partial().passthrough(),
|
|
824
1781
|
function_type: FunctionTypeEnum.optional(),
|
|
825
|
-
name:
|
|
1782
|
+
name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
826
1783
|
}),
|
|
827
|
-
|
|
1784
|
+
_v3.z.object({
|
|
828
1785
|
inline_prompt: PromptData,
|
|
829
1786
|
function_type: FunctionTypeEnum.optional(),
|
|
830
|
-
name:
|
|
1787
|
+
name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
831
1788
|
})
|
|
832
1789
|
]);
|
|
833
|
-
var FunctionObjectType =
|
|
1790
|
+
var FunctionObjectType = _v3.z.enum([
|
|
834
1791
|
"prompt",
|
|
835
1792
|
"tool",
|
|
836
1793
|
"scorer",
|
|
837
1794
|
"task",
|
|
838
1795
|
"agent"
|
|
839
1796
|
]);
|
|
840
|
-
var FunctionOutputType =
|
|
841
|
-
var GitMetadataSettings =
|
|
842
|
-
collect:
|
|
843
|
-
fields:
|
|
844
|
-
|
|
1797
|
+
var FunctionOutputType = _v3.z.enum(["completion", "score", "any"]);
|
|
1798
|
+
var GitMetadataSettings = _v3.z.object({
|
|
1799
|
+
collect: _v3.z.enum(["all", "none", "some"]),
|
|
1800
|
+
fields: _v3.z.array(
|
|
1801
|
+
_v3.z.enum([
|
|
845
1802
|
"commit",
|
|
846
1803
|
"branch",
|
|
847
1804
|
"tag",
|
|
@@ -854,49 +1811,49 @@ var GitMetadataSettings = _zod.z.object({
|
|
|
854
1811
|
])
|
|
855
1812
|
).optional()
|
|
856
1813
|
});
|
|
857
|
-
var Group =
|
|
858
|
-
id:
|
|
859
|
-
org_id:
|
|
860
|
-
user_id:
|
|
861
|
-
created:
|
|
862
|
-
name:
|
|
863
|
-
description:
|
|
864
|
-
deleted_at:
|
|
865
|
-
member_users:
|
|
866
|
-
member_groups:
|
|
1814
|
+
var Group = _v3.z.object({
|
|
1815
|
+
id: _v3.z.string().uuid(),
|
|
1816
|
+
org_id: _v3.z.string().uuid(),
|
|
1817
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1818
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1819
|
+
name: _v3.z.string(),
|
|
1820
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1821
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1822
|
+
member_users: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional(),
|
|
1823
|
+
member_groups: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional()
|
|
867
1824
|
});
|
|
868
|
-
var IfExists =
|
|
869
|
-
var InvokeParent =
|
|
870
|
-
|
|
871
|
-
object_type:
|
|
872
|
-
object_id:
|
|
873
|
-
row_ids:
|
|
874
|
-
|
|
875
|
-
id:
|
|
876
|
-
span_id:
|
|
877
|
-
root_span_id:
|
|
1825
|
+
var IfExists = _v3.z.enum(["error", "ignore", "replace"]);
|
|
1826
|
+
var InvokeParent = _v3.z.union([
|
|
1827
|
+
_v3.z.object({
|
|
1828
|
+
object_type: _v3.z.enum(["project_logs", "experiment", "playground_logs"]),
|
|
1829
|
+
object_id: _v3.z.string(),
|
|
1830
|
+
row_ids: _v3.z.union([
|
|
1831
|
+
_v3.z.object({
|
|
1832
|
+
id: _v3.z.string(),
|
|
1833
|
+
span_id: _v3.z.string(),
|
|
1834
|
+
root_span_id: _v3.z.string()
|
|
878
1835
|
}),
|
|
879
|
-
|
|
1836
|
+
_v3.z.null()
|
|
880
1837
|
]).optional(),
|
|
881
|
-
propagated_event:
|
|
1838
|
+
propagated_event: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
|
|
882
1839
|
}),
|
|
883
|
-
|
|
1840
|
+
_v3.z.string()
|
|
884
1841
|
]);
|
|
885
|
-
var StreamingMode =
|
|
1842
|
+
var StreamingMode = _v3.z.union([_v3.z.enum(["auto", "parallel"]), _v3.z.null()]);
|
|
886
1843
|
var InvokeFunction = FunctionId.and(
|
|
887
|
-
|
|
888
|
-
input:
|
|
889
|
-
expected:
|
|
890
|
-
metadata:
|
|
891
|
-
tags:
|
|
892
|
-
messages:
|
|
1844
|
+
_v3.z.object({
|
|
1845
|
+
input: _v3.z.unknown(),
|
|
1846
|
+
expected: _v3.z.unknown(),
|
|
1847
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]),
|
|
1848
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]),
|
|
1849
|
+
messages: _v3.z.array(ChatCompletionMessageParam),
|
|
893
1850
|
parent: InvokeParent,
|
|
894
|
-
stream:
|
|
1851
|
+
stream: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
895
1852
|
mode: StreamingMode,
|
|
896
|
-
strict:
|
|
1853
|
+
strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()])
|
|
897
1854
|
}).partial()
|
|
898
1855
|
);
|
|
899
|
-
var MessageRole =
|
|
1856
|
+
var MessageRole = _v3.z.enum([
|
|
900
1857
|
"system",
|
|
901
1858
|
"user",
|
|
902
1859
|
"assistant",
|
|
@@ -905,8 +1862,8 @@ var MessageRole = _zod.z.enum([
|
|
|
905
1862
|
"model",
|
|
906
1863
|
"developer"
|
|
907
1864
|
]);
|
|
908
|
-
var ObjectReference =
|
|
909
|
-
object_type:
|
|
1865
|
+
var ObjectReference = _v3.z.object({
|
|
1866
|
+
object_type: _v3.z.enum([
|
|
910
1867
|
"project_logs",
|
|
911
1868
|
"experiment",
|
|
912
1869
|
"dataset",
|
|
@@ -914,146 +1871,146 @@ var ObjectReference = _zod.z.object({
|
|
|
914
1871
|
"function",
|
|
915
1872
|
"prompt_session"
|
|
916
1873
|
]),
|
|
917
|
-
object_id:
|
|
918
|
-
id:
|
|
919
|
-
_xact_id:
|
|
920
|
-
created:
|
|
1874
|
+
object_id: _v3.z.string().uuid(),
|
|
1875
|
+
id: _v3.z.string(),
|
|
1876
|
+
_xact_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1877
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
921
1878
|
});
|
|
922
|
-
var OnlineScoreConfig =
|
|
923
|
-
|
|
924
|
-
sampling_rate:
|
|
925
|
-
scorers:
|
|
926
|
-
btql_filter:
|
|
927
|
-
apply_to_root_span:
|
|
928
|
-
apply_to_span_names:
|
|
929
|
-
skip_logging:
|
|
1879
|
+
var OnlineScoreConfig = _v3.z.union([
|
|
1880
|
+
_v3.z.object({
|
|
1881
|
+
sampling_rate: _v3.z.number().gte(0).lte(1),
|
|
1882
|
+
scorers: _v3.z.array(SavedFunctionId),
|
|
1883
|
+
btql_filter: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1884
|
+
apply_to_root_span: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
1885
|
+
apply_to_span_names: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1886
|
+
skip_logging: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
930
1887
|
}),
|
|
931
|
-
|
|
1888
|
+
_v3.z.null()
|
|
932
1889
|
]);
|
|
933
|
-
var Organization =
|
|
934
|
-
id:
|
|
935
|
-
name:
|
|
936
|
-
api_url:
|
|
937
|
-
is_universal_api:
|
|
938
|
-
proxy_url:
|
|
939
|
-
realtime_url:
|
|
940
|
-
created:
|
|
1890
|
+
var Organization = _v3.z.object({
|
|
1891
|
+
id: _v3.z.string().uuid(),
|
|
1892
|
+
name: _v3.z.string(),
|
|
1893
|
+
api_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1894
|
+
is_universal_api: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
1895
|
+
proxy_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1896
|
+
realtime_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1897
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
941
1898
|
});
|
|
942
|
-
var ProjectSettings =
|
|
943
|
-
|
|
944
|
-
comparison_key:
|
|
945
|
-
baseline_experiment_id:
|
|
946
|
-
spanFieldOrder:
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
object_type:
|
|
950
|
-
column_id:
|
|
951
|
-
position:
|
|
952
|
-
layout:
|
|
1899
|
+
var ProjectSettings = _v3.z.union([
|
|
1900
|
+
_v3.z.object({
|
|
1901
|
+
comparison_key: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1902
|
+
baseline_experiment_id: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1903
|
+
spanFieldOrder: _v3.z.union([
|
|
1904
|
+
_v3.z.array(
|
|
1905
|
+
_v3.z.object({
|
|
1906
|
+
object_type: _v3.z.string(),
|
|
1907
|
+
column_id: _v3.z.string(),
|
|
1908
|
+
position: _v3.z.string(),
|
|
1909
|
+
layout: _v3.z.union([_v3.z.literal("full"), _v3.z.literal("two_column"), _v3.z.null()]).optional()
|
|
953
1910
|
})
|
|
954
1911
|
),
|
|
955
|
-
|
|
1912
|
+
_v3.z.null()
|
|
956
1913
|
]),
|
|
957
|
-
remote_eval_sources:
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
url:
|
|
961
|
-
name:
|
|
962
|
-
description:
|
|
1914
|
+
remote_eval_sources: _v3.z.union([
|
|
1915
|
+
_v3.z.array(
|
|
1916
|
+
_v3.z.object({
|
|
1917
|
+
url: _v3.z.string(),
|
|
1918
|
+
name: _v3.z.string(),
|
|
1919
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
963
1920
|
})
|
|
964
1921
|
),
|
|
965
|
-
|
|
1922
|
+
_v3.z.null()
|
|
966
1923
|
])
|
|
967
1924
|
}).partial(),
|
|
968
|
-
|
|
1925
|
+
_v3.z.null()
|
|
969
1926
|
]);
|
|
970
|
-
var Project =
|
|
971
|
-
id:
|
|
972
|
-
org_id:
|
|
973
|
-
name:
|
|
974
|
-
created:
|
|
975
|
-
deleted_at:
|
|
976
|
-
user_id:
|
|
1927
|
+
var Project = _v3.z.object({
|
|
1928
|
+
id: _v3.z.string().uuid(),
|
|
1929
|
+
org_id: _v3.z.string().uuid(),
|
|
1930
|
+
name: _v3.z.string(),
|
|
1931
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1932
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1933
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
977
1934
|
settings: ProjectSettings.optional()
|
|
978
1935
|
});
|
|
979
|
-
var RetentionObjectType =
|
|
1936
|
+
var RetentionObjectType = _v3.z.enum([
|
|
980
1937
|
"project_logs",
|
|
981
1938
|
"experiment",
|
|
982
1939
|
"dataset"
|
|
983
1940
|
]);
|
|
984
|
-
var ProjectAutomation =
|
|
985
|
-
id:
|
|
986
|
-
project_id:
|
|
987
|
-
user_id:
|
|
988
|
-
created:
|
|
989
|
-
name:
|
|
990
|
-
description:
|
|
991
|
-
config:
|
|
992
|
-
|
|
993
|
-
event_type:
|
|
994
|
-
btql_filter:
|
|
995
|
-
interval_seconds:
|
|
996
|
-
action:
|
|
1941
|
+
var ProjectAutomation = _v3.z.object({
|
|
1942
|
+
id: _v3.z.string().uuid(),
|
|
1943
|
+
project_id: _v3.z.string().uuid(),
|
|
1944
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1945
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1946
|
+
name: _v3.z.string(),
|
|
1947
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1948
|
+
config: _v3.z.union([
|
|
1949
|
+
_v3.z.object({
|
|
1950
|
+
event_type: _v3.z.literal("logs"),
|
|
1951
|
+
btql_filter: _v3.z.string(),
|
|
1952
|
+
interval_seconds: _v3.z.number().gte(1).lte(2592e3),
|
|
1953
|
+
action: _v3.z.object({ type: _v3.z.literal("webhook"), url: _v3.z.string() })
|
|
997
1954
|
}),
|
|
998
|
-
|
|
999
|
-
event_type:
|
|
1000
|
-
export_definition:
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1955
|
+
_v3.z.object({
|
|
1956
|
+
event_type: _v3.z.literal("btql_export"),
|
|
1957
|
+
export_definition: _v3.z.union([
|
|
1958
|
+
_v3.z.object({ type: _v3.z.literal("log_traces") }),
|
|
1959
|
+
_v3.z.object({ type: _v3.z.literal("log_spans") }),
|
|
1960
|
+
_v3.z.object({ type: _v3.z.literal("btql_query"), btql_query: _v3.z.string() })
|
|
1004
1961
|
]),
|
|
1005
|
-
export_path:
|
|
1006
|
-
format:
|
|
1007
|
-
interval_seconds:
|
|
1008
|
-
credentials:
|
|
1009
|
-
type:
|
|
1010
|
-
role_arn:
|
|
1011
|
-
external_id:
|
|
1962
|
+
export_path: _v3.z.string(),
|
|
1963
|
+
format: _v3.z.enum(["jsonl", "parquet"]),
|
|
1964
|
+
interval_seconds: _v3.z.number().gte(1).lte(2592e3),
|
|
1965
|
+
credentials: _v3.z.object({
|
|
1966
|
+
type: _v3.z.literal("aws_iam"),
|
|
1967
|
+
role_arn: _v3.z.string(),
|
|
1968
|
+
external_id: _v3.z.string()
|
|
1012
1969
|
}),
|
|
1013
|
-
batch_size:
|
|
1970
|
+
batch_size: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional()
|
|
1014
1971
|
}),
|
|
1015
|
-
|
|
1016
|
-
event_type:
|
|
1972
|
+
_v3.z.object({
|
|
1973
|
+
event_type: _v3.z.literal("retention"),
|
|
1017
1974
|
object_type: RetentionObjectType,
|
|
1018
|
-
retention_days:
|
|
1975
|
+
retention_days: _v3.z.number().gte(0)
|
|
1019
1976
|
})
|
|
1020
1977
|
])
|
|
1021
1978
|
});
|
|
1022
|
-
var ProjectLogsEvent =
|
|
1023
|
-
id:
|
|
1024
|
-
_xact_id:
|
|
1025
|
-
_pagination_key:
|
|
1026
|
-
created:
|
|
1027
|
-
org_id:
|
|
1028
|
-
project_id:
|
|
1029
|
-
log_id:
|
|
1030
|
-
input:
|
|
1031
|
-
output:
|
|
1032
|
-
expected:
|
|
1033
|
-
error:
|
|
1034
|
-
scores:
|
|
1035
|
-
metadata:
|
|
1036
|
-
|
|
1037
|
-
|
|
1979
|
+
var ProjectLogsEvent = _v3.z.object({
|
|
1980
|
+
id: _v3.z.string(),
|
|
1981
|
+
_xact_id: _v3.z.string(),
|
|
1982
|
+
_pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1983
|
+
created: _v3.z.string().datetime({ offset: true }),
|
|
1984
|
+
org_id: _v3.z.string().uuid(),
|
|
1985
|
+
project_id: _v3.z.string().uuid(),
|
|
1986
|
+
log_id: _v3.z.literal("g"),
|
|
1987
|
+
input: _v3.z.unknown().optional(),
|
|
1988
|
+
output: _v3.z.unknown().optional(),
|
|
1989
|
+
expected: _v3.z.unknown().optional(),
|
|
1990
|
+
error: _v3.z.unknown().optional(),
|
|
1991
|
+
scores: _v3.z.union([_v3.z.record(_v3.z.union([_v3.z.number(), _v3.z.null()])), _v3.z.null()]).optional(),
|
|
1992
|
+
metadata: _v3.z.union([
|
|
1993
|
+
_v3.z.object({ model: _v3.z.union([_v3.z.string(), _v3.z.null()]) }).partial().passthrough(),
|
|
1994
|
+
_v3.z.null()
|
|
1038
1995
|
]).optional(),
|
|
1039
|
-
tags:
|
|
1040
|
-
metrics:
|
|
1041
|
-
context:
|
|
1042
|
-
|
|
1043
|
-
caller_functionname:
|
|
1044
|
-
caller_filename:
|
|
1045
|
-
caller_lineno:
|
|
1996
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
1997
|
+
metrics: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]).optional(),
|
|
1998
|
+
context: _v3.z.union([
|
|
1999
|
+
_v3.z.object({
|
|
2000
|
+
caller_functionname: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2001
|
+
caller_filename: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2002
|
+
caller_lineno: _v3.z.union([_v3.z.number(), _v3.z.null()])
|
|
1046
2003
|
}).partial().passthrough(),
|
|
1047
|
-
|
|
2004
|
+
_v3.z.null()
|
|
1048
2005
|
]).optional(),
|
|
1049
|
-
span_id:
|
|
1050
|
-
span_parents:
|
|
1051
|
-
root_span_id:
|
|
1052
|
-
is_root:
|
|
2006
|
+
span_id: _v3.z.string(),
|
|
2007
|
+
span_parents: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
2008
|
+
root_span_id: _v3.z.string(),
|
|
2009
|
+
is_root: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
1053
2010
|
span_attributes: SpanAttributes.optional(),
|
|
1054
2011
|
origin: ObjectReferenceNullish.optional()
|
|
1055
2012
|
});
|
|
1056
|
-
var ProjectScoreType =
|
|
2013
|
+
var ProjectScoreType = _v3.z.enum([
|
|
1057
2014
|
"slider",
|
|
1058
2015
|
"categorical",
|
|
1059
2016
|
"weighted",
|
|
@@ -1062,172 +2019,172 @@ var ProjectScoreType = _zod.z.enum([
|
|
|
1062
2019
|
"online",
|
|
1063
2020
|
"free-form"
|
|
1064
2021
|
]);
|
|
1065
|
-
var ProjectScoreCategory =
|
|
1066
|
-
name:
|
|
1067
|
-
value:
|
|
2022
|
+
var ProjectScoreCategory = _v3.z.object({
|
|
2023
|
+
name: _v3.z.string(),
|
|
2024
|
+
value: _v3.z.number()
|
|
1068
2025
|
});
|
|
1069
|
-
var ProjectScoreCategories =
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
2026
|
+
var ProjectScoreCategories = _v3.z.union([
|
|
2027
|
+
_v3.z.array(ProjectScoreCategory),
|
|
2028
|
+
_v3.z.record(_v3.z.number()),
|
|
2029
|
+
_v3.z.array(_v3.z.string()),
|
|
2030
|
+
_v3.z.null()
|
|
1074
2031
|
]);
|
|
1075
|
-
var ProjectScoreConfig =
|
|
1076
|
-
|
|
1077
|
-
multi_select:
|
|
1078
|
-
destination:
|
|
2032
|
+
var ProjectScoreConfig = _v3.z.union([
|
|
2033
|
+
_v3.z.object({
|
|
2034
|
+
multi_select: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
2035
|
+
destination: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
1079
2036
|
online: OnlineScoreConfig
|
|
1080
2037
|
}).partial(),
|
|
1081
|
-
|
|
2038
|
+
_v3.z.null()
|
|
1082
2039
|
]);
|
|
1083
|
-
var ProjectScore =
|
|
1084
|
-
id:
|
|
1085
|
-
project_id:
|
|
1086
|
-
user_id:
|
|
1087
|
-
created:
|
|
1088
|
-
name:
|
|
1089
|
-
description:
|
|
2040
|
+
var ProjectScore = _v3.z.object({
|
|
2041
|
+
id: _v3.z.string().uuid(),
|
|
2042
|
+
project_id: _v3.z.string().uuid(),
|
|
2043
|
+
user_id: _v3.z.string().uuid(),
|
|
2044
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2045
|
+
name: _v3.z.string(),
|
|
2046
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1090
2047
|
score_type: ProjectScoreType,
|
|
1091
2048
|
categories: ProjectScoreCategories.optional(),
|
|
1092
2049
|
config: ProjectScoreConfig.optional(),
|
|
1093
|
-
position:
|
|
2050
|
+
position: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1094
2051
|
});
|
|
1095
|
-
var ProjectTag =
|
|
1096
|
-
id:
|
|
1097
|
-
project_id:
|
|
1098
|
-
user_id:
|
|
1099
|
-
created:
|
|
1100
|
-
name:
|
|
1101
|
-
description:
|
|
1102
|
-
color:
|
|
1103
|
-
position:
|
|
2052
|
+
var ProjectTag = _v3.z.object({
|
|
2053
|
+
id: _v3.z.string().uuid(),
|
|
2054
|
+
project_id: _v3.z.string().uuid(),
|
|
2055
|
+
user_id: _v3.z.string().uuid(),
|
|
2056
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2057
|
+
name: _v3.z.string(),
|
|
2058
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2059
|
+
color: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2060
|
+
position: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1104
2061
|
});
|
|
1105
|
-
var Prompt =
|
|
1106
|
-
id:
|
|
1107
|
-
_xact_id:
|
|
1108
|
-
project_id:
|
|
1109
|
-
log_id:
|
|
1110
|
-
org_id:
|
|
1111
|
-
name:
|
|
1112
|
-
slug:
|
|
1113
|
-
description:
|
|
1114
|
-
created:
|
|
2062
|
+
var Prompt = _v3.z.object({
|
|
2063
|
+
id: _v3.z.string().uuid(),
|
|
2064
|
+
_xact_id: _v3.z.string(),
|
|
2065
|
+
project_id: _v3.z.string().uuid(),
|
|
2066
|
+
log_id: _v3.z.literal("p"),
|
|
2067
|
+
org_id: _v3.z.string().uuid(),
|
|
2068
|
+
name: _v3.z.string(),
|
|
2069
|
+
slug: _v3.z.string(),
|
|
2070
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2071
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1115
2072
|
prompt_data: PromptDataNullish.optional(),
|
|
1116
|
-
tags:
|
|
1117
|
-
metadata:
|
|
2073
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional(),
|
|
2074
|
+
metadata: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional(),
|
|
1118
2075
|
function_type: FunctionTypeEnumNullish.optional()
|
|
1119
2076
|
});
|
|
1120
|
-
var PromptOptions =
|
|
1121
|
-
var PromptSessionEvent =
|
|
1122
|
-
id:
|
|
1123
|
-
_xact_id:
|
|
1124
|
-
created:
|
|
1125
|
-
_pagination_key:
|
|
1126
|
-
project_id:
|
|
1127
|
-
prompt_session_id:
|
|
1128
|
-
prompt_session_data:
|
|
1129
|
-
prompt_data:
|
|
1130
|
-
function_data:
|
|
2077
|
+
var PromptOptions = _v3.z.object({ model: _v3.z.string(), params: ModelParams, position: _v3.z.string() }).partial();
|
|
2078
|
+
var PromptSessionEvent = _v3.z.object({
|
|
2079
|
+
id: _v3.z.string(),
|
|
2080
|
+
_xact_id: _v3.z.string(),
|
|
2081
|
+
created: _v3.z.string().datetime({ offset: true }),
|
|
2082
|
+
_pagination_key: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2083
|
+
project_id: _v3.z.string().uuid(),
|
|
2084
|
+
prompt_session_id: _v3.z.string().uuid(),
|
|
2085
|
+
prompt_session_data: _v3.z.unknown().optional(),
|
|
2086
|
+
prompt_data: _v3.z.unknown().optional(),
|
|
2087
|
+
function_data: _v3.z.unknown().optional(),
|
|
1131
2088
|
function_type: FunctionTypeEnumNullish.optional(),
|
|
1132
|
-
object_data:
|
|
1133
|
-
completion:
|
|
1134
|
-
tags:
|
|
2089
|
+
object_data: _v3.z.unknown().optional(),
|
|
2090
|
+
completion: _v3.z.unknown().optional(),
|
|
2091
|
+
tags: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]).optional()
|
|
1135
2092
|
});
|
|
1136
|
-
var ResponseFormat =
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
type:
|
|
2093
|
+
var ResponseFormat = _v3.z.union([
|
|
2094
|
+
_v3.z.object({ type: _v3.z.literal("json_object") }),
|
|
2095
|
+
_v3.z.object({
|
|
2096
|
+
type: _v3.z.literal("json_schema"),
|
|
1140
2097
|
json_schema: ResponseFormatJsonSchema
|
|
1141
2098
|
}),
|
|
1142
|
-
|
|
2099
|
+
_v3.z.object({ type: _v3.z.literal("text") })
|
|
1143
2100
|
]);
|
|
1144
|
-
var Role =
|
|
1145
|
-
id:
|
|
1146
|
-
org_id:
|
|
1147
|
-
user_id:
|
|
1148
|
-
created:
|
|
1149
|
-
name:
|
|
1150
|
-
description:
|
|
1151
|
-
deleted_at:
|
|
1152
|
-
member_permissions:
|
|
1153
|
-
|
|
1154
|
-
|
|
2101
|
+
var Role = _v3.z.object({
|
|
2102
|
+
id: _v3.z.string().uuid(),
|
|
2103
|
+
org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2104
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2105
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2106
|
+
name: _v3.z.string(),
|
|
2107
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2108
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2109
|
+
member_permissions: _v3.z.union([
|
|
2110
|
+
_v3.z.array(
|
|
2111
|
+
_v3.z.object({
|
|
1155
2112
|
permission: Permission,
|
|
1156
2113
|
restrict_object_type: AclObjectType.optional()
|
|
1157
2114
|
})
|
|
1158
2115
|
),
|
|
1159
|
-
|
|
2116
|
+
_v3.z.null()
|
|
1160
2117
|
]).optional(),
|
|
1161
|
-
member_roles:
|
|
2118
|
+
member_roles: _v3.z.union([_v3.z.array(_v3.z.string().uuid()), _v3.z.null()]).optional()
|
|
1162
2119
|
});
|
|
1163
|
-
var RunEval =
|
|
1164
|
-
project_id:
|
|
1165
|
-
data:
|
|
1166
|
-
|
|
1167
|
-
dataset_id:
|
|
1168
|
-
_internal_btql:
|
|
2120
|
+
var RunEval = _v3.z.object({
|
|
2121
|
+
project_id: _v3.z.string(),
|
|
2122
|
+
data: _v3.z.union([
|
|
2123
|
+
_v3.z.object({
|
|
2124
|
+
dataset_id: _v3.z.string(),
|
|
2125
|
+
_internal_btql: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
|
|
1169
2126
|
}),
|
|
1170
|
-
|
|
1171
|
-
project_name:
|
|
1172
|
-
dataset_name:
|
|
1173
|
-
_internal_btql:
|
|
2127
|
+
_v3.z.object({
|
|
2128
|
+
project_name: _v3.z.string(),
|
|
2129
|
+
dataset_name: _v3.z.string(),
|
|
2130
|
+
_internal_btql: _v3.z.union([_v3.z.object({}).partial().passthrough(), _v3.z.null()]).optional()
|
|
1174
2131
|
}),
|
|
1175
|
-
|
|
2132
|
+
_v3.z.object({ data: _v3.z.array(_v3.z.unknown()) })
|
|
1176
2133
|
]),
|
|
1177
|
-
task: FunctionId.and(
|
|
1178
|
-
scores:
|
|
1179
|
-
experiment_name:
|
|
1180
|
-
metadata:
|
|
1181
|
-
parent: InvokeParent.and(
|
|
1182
|
-
stream:
|
|
1183
|
-
trial_count:
|
|
1184
|
-
is_public:
|
|
1185
|
-
timeout:
|
|
1186
|
-
max_concurrency:
|
|
1187
|
-
base_experiment_name:
|
|
1188
|
-
base_experiment_id:
|
|
2134
|
+
task: FunctionId.and(_v3.z.unknown()),
|
|
2135
|
+
scores: _v3.z.array(FunctionId),
|
|
2136
|
+
experiment_name: _v3.z.string().optional(),
|
|
2137
|
+
metadata: _v3.z.object({}).partial().passthrough().optional(),
|
|
2138
|
+
parent: InvokeParent.and(_v3.z.unknown()).optional(),
|
|
2139
|
+
stream: _v3.z.boolean().optional(),
|
|
2140
|
+
trial_count: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional(),
|
|
2141
|
+
is_public: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
2142
|
+
timeout: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional(),
|
|
2143
|
+
max_concurrency: _v3.z.union([_v3.z.number(), _v3.z.null()]).optional().default(10),
|
|
2144
|
+
base_experiment_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2145
|
+
base_experiment_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1189
2146
|
git_metadata_settings: GitMetadataSettings.and(
|
|
1190
|
-
|
|
2147
|
+
_v3.z.union([_v3.z.object({}).partial(), _v3.z.null()])
|
|
1191
2148
|
).optional(),
|
|
1192
|
-
repo_info: RepoInfo.and(
|
|
1193
|
-
strict:
|
|
1194
|
-
stop_token:
|
|
1195
|
-
extra_messages:
|
|
1196
|
-
tags:
|
|
2149
|
+
repo_info: RepoInfo.and(_v3.z.unknown()).optional(),
|
|
2150
|
+
strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional(),
|
|
2151
|
+
stop_token: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2152
|
+
extra_messages: _v3.z.string().optional(),
|
|
2153
|
+
tags: _v3.z.array(_v3.z.string()).optional()
|
|
1197
2154
|
});
|
|
1198
|
-
var ServiceToken =
|
|
1199
|
-
id:
|
|
1200
|
-
created:
|
|
1201
|
-
name:
|
|
1202
|
-
preview_name:
|
|
1203
|
-
service_account_id:
|
|
1204
|
-
service_account_email:
|
|
1205
|
-
service_account_name:
|
|
1206
|
-
org_id:
|
|
2155
|
+
var ServiceToken = _v3.z.object({
|
|
2156
|
+
id: _v3.z.string().uuid(),
|
|
2157
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2158
|
+
name: _v3.z.string(),
|
|
2159
|
+
preview_name: _v3.z.string(),
|
|
2160
|
+
service_account_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2161
|
+
service_account_email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2162
|
+
service_account_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2163
|
+
org_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1207
2164
|
});
|
|
1208
|
-
var SpanIFrame =
|
|
1209
|
-
id:
|
|
1210
|
-
project_id:
|
|
1211
|
-
user_id:
|
|
1212
|
-
created:
|
|
1213
|
-
deleted_at:
|
|
1214
|
-
name:
|
|
1215
|
-
description:
|
|
1216
|
-
url:
|
|
1217
|
-
post_message:
|
|
2165
|
+
var SpanIFrame = _v3.z.object({
|
|
2166
|
+
id: _v3.z.string().uuid(),
|
|
2167
|
+
project_id: _v3.z.string().uuid(),
|
|
2168
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2169
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2170
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2171
|
+
name: _v3.z.string(),
|
|
2172
|
+
description: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2173
|
+
url: _v3.z.string(),
|
|
2174
|
+
post_message: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
1218
2175
|
});
|
|
1219
|
-
var SSEConsoleEventData =
|
|
1220
|
-
stream:
|
|
1221
|
-
message:
|
|
2176
|
+
var SSEConsoleEventData = _v3.z.object({
|
|
2177
|
+
stream: _v3.z.enum(["stderr", "stdout"]),
|
|
2178
|
+
message: _v3.z.string()
|
|
1222
2179
|
});
|
|
1223
|
-
var SSEProgressEventData =
|
|
1224
|
-
id:
|
|
2180
|
+
var SSEProgressEventData = _v3.z.object({
|
|
2181
|
+
id: _v3.z.string(),
|
|
1225
2182
|
object_type: FunctionObjectType,
|
|
1226
|
-
origin: ObjectReferenceNullish.and(
|
|
2183
|
+
origin: ObjectReferenceNullish.and(_v3.z.unknown()).optional(),
|
|
1227
2184
|
format: FunctionFormat,
|
|
1228
2185
|
output_type: FunctionOutputType,
|
|
1229
|
-
name:
|
|
1230
|
-
event:
|
|
2186
|
+
name: _v3.z.string(),
|
|
2187
|
+
event: _v3.z.enum([
|
|
1231
2188
|
"reasoning_delta",
|
|
1232
2189
|
"text_delta",
|
|
1233
2190
|
"json_delta",
|
|
@@ -1237,110 +2194,110 @@ var SSEProgressEventData = _zod.z.object({
|
|
|
1237
2194
|
"done",
|
|
1238
2195
|
"progress"
|
|
1239
2196
|
]),
|
|
1240
|
-
data:
|
|
2197
|
+
data: _v3.z.string()
|
|
1241
2198
|
});
|
|
1242
|
-
var ToolFunctionDefinition =
|
|
1243
|
-
type:
|
|
1244
|
-
function:
|
|
1245
|
-
name:
|
|
1246
|
-
description:
|
|
1247
|
-
parameters:
|
|
1248
|
-
strict:
|
|
2199
|
+
var ToolFunctionDefinition = _v3.z.object({
|
|
2200
|
+
type: _v3.z.literal("function"),
|
|
2201
|
+
function: _v3.z.object({
|
|
2202
|
+
name: _v3.z.string(),
|
|
2203
|
+
description: _v3.z.string().optional(),
|
|
2204
|
+
parameters: _v3.z.object({}).partial().passthrough().optional(),
|
|
2205
|
+
strict: _v3.z.union([_v3.z.boolean(), _v3.z.null()]).optional()
|
|
1249
2206
|
})
|
|
1250
2207
|
});
|
|
1251
|
-
var User =
|
|
1252
|
-
id:
|
|
1253
|
-
given_name:
|
|
1254
|
-
family_name:
|
|
1255
|
-
email:
|
|
1256
|
-
avatar_url:
|
|
1257
|
-
created:
|
|
2208
|
+
var User = _v3.z.object({
|
|
2209
|
+
id: _v3.z.string().uuid(),
|
|
2210
|
+
given_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2211
|
+
family_name: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2212
|
+
email: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2213
|
+
avatar_url: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2214
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1258
2215
|
});
|
|
1259
|
-
var ViewDataSearch =
|
|
1260
|
-
|
|
1261
|
-
filter:
|
|
1262
|
-
tag:
|
|
1263
|
-
match:
|
|
1264
|
-
sort:
|
|
2216
|
+
var ViewDataSearch = _v3.z.union([
|
|
2217
|
+
_v3.z.object({
|
|
2218
|
+
filter: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
|
|
2219
|
+
tag: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
|
|
2220
|
+
match: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()]),
|
|
2221
|
+
sort: _v3.z.union([_v3.z.array(_v3.z.unknown()), _v3.z.null()])
|
|
1265
2222
|
}).partial(),
|
|
1266
|
-
|
|
2223
|
+
_v3.z.null()
|
|
1267
2224
|
]);
|
|
1268
|
-
var ViewData =
|
|
1269
|
-
|
|
1270
|
-
|
|
2225
|
+
var ViewData = _v3.z.union([
|
|
2226
|
+
_v3.z.object({ search: ViewDataSearch }).partial(),
|
|
2227
|
+
_v3.z.null()
|
|
1271
2228
|
]);
|
|
1272
|
-
var ViewOptions =
|
|
1273
|
-
|
|
1274
|
-
viewType:
|
|
1275
|
-
options:
|
|
1276
|
-
spanType:
|
|
1277
|
-
rangeValue:
|
|
1278
|
-
frameStart:
|
|
1279
|
-
frameEnd:
|
|
1280
|
-
tzUTC:
|
|
1281
|
-
chartVisibility:
|
|
1282
|
-
projectId:
|
|
1283
|
-
type:
|
|
1284
|
-
groupBy:
|
|
2229
|
+
var ViewOptions = _v3.z.union([
|
|
2230
|
+
_v3.z.object({
|
|
2231
|
+
viewType: _v3.z.literal("monitor"),
|
|
2232
|
+
options: _v3.z.object({
|
|
2233
|
+
spanType: _v3.z.union([_v3.z.enum(["range", "frame"]), _v3.z.null()]),
|
|
2234
|
+
rangeValue: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2235
|
+
frameStart: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2236
|
+
frameEnd: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2237
|
+
tzUTC: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
2238
|
+
chartVisibility: _v3.z.union([_v3.z.record(_v3.z.boolean()), _v3.z.null()]),
|
|
2239
|
+
projectId: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2240
|
+
type: _v3.z.union([_v3.z.enum(["project", "experiment"]), _v3.z.null()]),
|
|
2241
|
+
groupBy: _v3.z.union([_v3.z.string(), _v3.z.null()])
|
|
1285
2242
|
}).partial()
|
|
1286
2243
|
}),
|
|
1287
|
-
|
|
1288
|
-
columnVisibility:
|
|
1289
|
-
columnOrder:
|
|
1290
|
-
columnSizing:
|
|
1291
|
-
grouping:
|
|
1292
|
-
rowHeight:
|
|
1293
|
-
tallGroupRows:
|
|
1294
|
-
layout:
|
|
1295
|
-
chartHeight:
|
|
1296
|
-
excludedMeasures:
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
type:
|
|
1300
|
-
value:
|
|
2244
|
+
_v3.z.object({
|
|
2245
|
+
columnVisibility: _v3.z.union([_v3.z.record(_v3.z.boolean()), _v3.z.null()]),
|
|
2246
|
+
columnOrder: _v3.z.union([_v3.z.array(_v3.z.string()), _v3.z.null()]),
|
|
2247
|
+
columnSizing: _v3.z.union([_v3.z.record(_v3.z.number()), _v3.z.null()]),
|
|
2248
|
+
grouping: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2249
|
+
rowHeight: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2250
|
+
tallGroupRows: _v3.z.union([_v3.z.boolean(), _v3.z.null()]),
|
|
2251
|
+
layout: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2252
|
+
chartHeight: _v3.z.union([_v3.z.number(), _v3.z.null()]),
|
|
2253
|
+
excludedMeasures: _v3.z.union([
|
|
2254
|
+
_v3.z.array(
|
|
2255
|
+
_v3.z.object({
|
|
2256
|
+
type: _v3.z.enum(["none", "score", "metric", "metadata"]),
|
|
2257
|
+
value: _v3.z.string()
|
|
1301
2258
|
})
|
|
1302
2259
|
),
|
|
1303
|
-
|
|
2260
|
+
_v3.z.null()
|
|
1304
2261
|
]),
|
|
1305
|
-
yMetric:
|
|
1306
|
-
|
|
1307
|
-
type:
|
|
1308
|
-
value:
|
|
2262
|
+
yMetric: _v3.z.union([
|
|
2263
|
+
_v3.z.object({
|
|
2264
|
+
type: _v3.z.enum(["none", "score", "metric", "metadata"]),
|
|
2265
|
+
value: _v3.z.string()
|
|
1309
2266
|
}),
|
|
1310
|
-
|
|
2267
|
+
_v3.z.null()
|
|
1311
2268
|
]),
|
|
1312
|
-
xAxis:
|
|
1313
|
-
|
|
1314
|
-
type:
|
|
1315
|
-
value:
|
|
2269
|
+
xAxis: _v3.z.union([
|
|
2270
|
+
_v3.z.object({
|
|
2271
|
+
type: _v3.z.enum(["none", "score", "metric", "metadata"]),
|
|
2272
|
+
value: _v3.z.string()
|
|
1316
2273
|
}),
|
|
1317
|
-
|
|
2274
|
+
_v3.z.null()
|
|
1318
2275
|
]),
|
|
1319
|
-
symbolGrouping:
|
|
1320
|
-
|
|
1321
|
-
type:
|
|
1322
|
-
value:
|
|
2276
|
+
symbolGrouping: _v3.z.union([
|
|
2277
|
+
_v3.z.object({
|
|
2278
|
+
type: _v3.z.enum(["none", "score", "metric", "metadata"]),
|
|
2279
|
+
value: _v3.z.string()
|
|
1323
2280
|
}),
|
|
1324
|
-
|
|
2281
|
+
_v3.z.null()
|
|
1325
2282
|
]),
|
|
1326
|
-
xAxisAggregation:
|
|
1327
|
-
chartAnnotations:
|
|
1328
|
-
|
|
1329
|
-
|
|
2283
|
+
xAxisAggregation: _v3.z.union([_v3.z.string(), _v3.z.null()]),
|
|
2284
|
+
chartAnnotations: _v3.z.union([
|
|
2285
|
+
_v3.z.array(_v3.z.object({ id: _v3.z.string(), text: _v3.z.string() })),
|
|
2286
|
+
_v3.z.null()
|
|
1330
2287
|
]),
|
|
1331
|
-
timeRangeFilter:
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
2288
|
+
timeRangeFilter: _v3.z.union([
|
|
2289
|
+
_v3.z.string(),
|
|
2290
|
+
_v3.z.object({ from: _v3.z.string(), to: _v3.z.string() }),
|
|
2291
|
+
_v3.z.null()
|
|
1335
2292
|
])
|
|
1336
2293
|
}).partial(),
|
|
1337
|
-
|
|
2294
|
+
_v3.z.null()
|
|
1338
2295
|
]);
|
|
1339
|
-
var View =
|
|
1340
|
-
id:
|
|
1341
|
-
object_type: AclObjectType.and(
|
|
1342
|
-
object_id:
|
|
1343
|
-
view_type:
|
|
2296
|
+
var View = _v3.z.object({
|
|
2297
|
+
id: _v3.z.string().uuid(),
|
|
2298
|
+
object_type: AclObjectType.and(_v3.z.string()),
|
|
2299
|
+
object_id: _v3.z.string().uuid(),
|
|
2300
|
+
view_type: _v3.z.enum([
|
|
1344
2301
|
"projects",
|
|
1345
2302
|
"experiments",
|
|
1346
2303
|
"experiment",
|
|
@@ -1355,56 +2312,56 @@ var View = _zod.z.object({
|
|
|
1355
2312
|
"agents",
|
|
1356
2313
|
"monitor"
|
|
1357
2314
|
]),
|
|
1358
|
-
name:
|
|
1359
|
-
created:
|
|
2315
|
+
name: _v3.z.string(),
|
|
2316
|
+
created: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
1360
2317
|
view_data: ViewData.optional(),
|
|
1361
2318
|
options: ViewOptions.optional(),
|
|
1362
|
-
user_id:
|
|
1363
|
-
deleted_at:
|
|
2319
|
+
user_id: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional(),
|
|
2320
|
+
deleted_at: _v3.z.union([_v3.z.string(), _v3.z.null()]).optional()
|
|
1364
2321
|
});
|
|
1365
2322
|
|
|
1366
2323
|
// src/logger.ts
|
|
1367
2324
|
var _functions = require('@vercel/functions');
|
|
1368
2325
|
var _mustache = require('mustache'); var _mustache2 = _interopRequireDefault(_mustache);
|
|
1369
|
-
|
|
2326
|
+
var _zod = require('zod');
|
|
1370
2327
|
|
|
1371
2328
|
// src/functions/stream.ts
|
|
1372
2329
|
|
|
1373
2330
|
|
|
1374
2331
|
var _eventsourceparser = require('eventsource-parser');
|
|
1375
2332
|
|
|
1376
|
-
var braintrustStreamChunkSchema =
|
|
1377
|
-
|
|
1378
|
-
type:
|
|
1379
|
-
data:
|
|
2333
|
+
var braintrustStreamChunkSchema = _v3.z.union([
|
|
2334
|
+
_v3.z.object({
|
|
2335
|
+
type: _v3.z.literal("text_delta"),
|
|
2336
|
+
data: _v3.z.string()
|
|
1380
2337
|
}),
|
|
1381
|
-
|
|
1382
|
-
type:
|
|
1383
|
-
data:
|
|
2338
|
+
_v3.z.object({
|
|
2339
|
+
type: _v3.z.literal("reasoning_delta"),
|
|
2340
|
+
data: _v3.z.string()
|
|
1384
2341
|
}),
|
|
1385
|
-
|
|
1386
|
-
type:
|
|
1387
|
-
data:
|
|
2342
|
+
_v3.z.object({
|
|
2343
|
+
type: _v3.z.literal("json_delta"),
|
|
2344
|
+
data: _v3.z.string()
|
|
1388
2345
|
}),
|
|
1389
|
-
|
|
1390
|
-
type:
|
|
1391
|
-
data:
|
|
2346
|
+
_v3.z.object({
|
|
2347
|
+
type: _v3.z.literal("error"),
|
|
2348
|
+
data: _v3.z.string()
|
|
1392
2349
|
}),
|
|
1393
|
-
|
|
1394
|
-
type:
|
|
2350
|
+
_v3.z.object({
|
|
2351
|
+
type: _v3.z.literal("console"),
|
|
1395
2352
|
data: SSEConsoleEventData
|
|
1396
2353
|
}),
|
|
1397
|
-
|
|
1398
|
-
type:
|
|
2354
|
+
_v3.z.object({
|
|
2355
|
+
type: _v3.z.literal("progress"),
|
|
1399
2356
|
data: SSEProgressEventData
|
|
1400
2357
|
}),
|
|
1401
|
-
|
|
1402
|
-
type:
|
|
1403
|
-
data:
|
|
2358
|
+
_v3.z.object({
|
|
2359
|
+
type: _v3.z.literal("start"),
|
|
2360
|
+
data: _v3.z.string()
|
|
1404
2361
|
}),
|
|
1405
|
-
|
|
1406
|
-
type:
|
|
1407
|
-
data:
|
|
2362
|
+
_v3.z.object({
|
|
2363
|
+
type: _v3.z.literal("done"),
|
|
2364
|
+
data: _v3.z.string()
|
|
1408
2365
|
})
|
|
1409
2366
|
]);
|
|
1410
2367
|
var BraintrustStream = class _BraintrustStream {
|
|
@@ -1996,12 +2953,11 @@ function objectIsEmpty(obj) {
|
|
|
1996
2953
|
|
|
1997
2954
|
// src/mustache-utils.ts
|
|
1998
2955
|
|
|
1999
|
-
|
|
2000
2956
|
function lintTemplate(template, context) {
|
|
2001
2957
|
const variables = getMustacheVars(template);
|
|
2002
2958
|
for (const variable of variables) {
|
|
2003
2959
|
const arrPathsReplaced = variable[1].replaceAll(/\.\d+/g, ".0");
|
|
2004
|
-
const fieldExists =
|
|
2960
|
+
const fieldExists = getObjValueByPath(context, arrPathsReplaced.split(".")) !== void 0;
|
|
2005
2961
|
if (!fieldExists) {
|
|
2006
2962
|
throw new Error(`Variable '${variable[1]}' does not exist.`);
|
|
2007
2963
|
}
|
|
@@ -2012,13 +2968,12 @@ function getMustacheVars(prompt) {
|
|
|
2012
2968
|
return _mustache2.default.parse(prompt).filter(
|
|
2013
2969
|
(span) => span[0] === "name" || span[0] === "&"
|
|
2014
2970
|
);
|
|
2015
|
-
} catch (
|
|
2971
|
+
} catch (e4) {
|
|
2016
2972
|
return [];
|
|
2017
2973
|
}
|
|
2018
2974
|
}
|
|
2019
2975
|
|
|
2020
2976
|
// src/logger.ts
|
|
2021
|
-
|
|
2022
2977
|
var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
|
|
2023
2978
|
var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
|
|
2024
2979
|
var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
|
|
@@ -2079,7 +3034,7 @@ var NoopSpan = (_class4 = class {
|
|
|
2079
3034
|
return this;
|
|
2080
3035
|
}
|
|
2081
3036
|
end(args) {
|
|
2082
|
-
return _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
3037
|
+
return _nullishCoalesce(_optionalChain([args, 'optionalAccess', _12 => _12.endTime]), () => ( getCurrentUnixTimestamp()));
|
|
2083
3038
|
}
|
|
2084
3039
|
async export() {
|
|
2085
3040
|
return "";
|
|
@@ -2253,8 +3208,8 @@ var BraintrustState = (_class5 = class _BraintrustState {
|
|
|
2253
3208
|
setFetch(fetch2) {
|
|
2254
3209
|
this.loginParams.fetch = fetch2;
|
|
2255
3210
|
this.fetch = fetch2;
|
|
2256
|
-
_optionalChain([this, 'access',
|
|
2257
|
-
_optionalChain([this, 'access',
|
|
3211
|
+
_optionalChain([this, 'access', _13 => _13._apiConn, 'optionalAccess', _14 => _14.setFetch, 'call', _15 => _15(fetch2)]);
|
|
3212
|
+
_optionalChain([this, 'access', _16 => _16._appConn, 'optionalAccess', _17 => _17.setFetch, 'call', _18 => _18(fetch2)]);
|
|
2258
3213
|
}
|
|
2259
3214
|
setMaskingFunction(maskingFunction) {
|
|
2260
3215
|
this.bgLogger().setMaskingFunction(maskingFunction);
|
|
@@ -2335,7 +3290,7 @@ function useTestBackgroundLogger() {
|
|
|
2335
3290
|
return logger;
|
|
2336
3291
|
}
|
|
2337
3292
|
function clearTestBackgroundLogger() {
|
|
2338
|
-
_optionalChain([_internalGetGlobalState, 'call',
|
|
3293
|
+
_optionalChain([_internalGetGlobalState, 'call', _19 => _19(), 'optionalAccess', _20 => _20.setOverrideBgLogger, 'call', _21 => _21(null)]);
|
|
2339
3294
|
}
|
|
2340
3295
|
function initTestExperiment(experimentName, projectName) {
|
|
2341
3296
|
setInitialTestState();
|
|
@@ -2426,7 +3381,7 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
2426
3381
|
}
|
|
2427
3382
|
async get(path, params = void 0, config) {
|
|
2428
3383
|
const { headers, ...rest } = config || {};
|
|
2429
|
-
const url = new URL(
|
|
3384
|
+
const url = new URL(_urljoin(this.base_url, path));
|
|
2430
3385
|
url.search = new URLSearchParams(
|
|
2431
3386
|
params ? Object.entries(params).filter(([_, v]) => v !== void 0).flatMap(
|
|
2432
3387
|
([k, v]) => v !== void 0 ? typeof v === "string" ? [[k, v]] : v.map((x) => [k, x]) : []
|
|
@@ -2453,7 +3408,7 @@ var HTTPConnection = class _HTTPConnection {
|
|
|
2453
3408
|
const this_base_url = this.base_url;
|
|
2454
3409
|
const this_headers = this.headers;
|
|
2455
3410
|
return await checkResponse(
|
|
2456
|
-
await this_fetch(
|
|
3411
|
+
await this_fetch(_urljoin(this_base_url, path), {
|
|
2457
3412
|
method: "POST",
|
|
2458
3413
|
headers: {
|
|
2459
3414
|
Accept: "application/json",
|
|
@@ -2848,8 +3803,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2848
3803
|
source: inputSource
|
|
2849
3804
|
}) {
|
|
2850
3805
|
const source = _nullishCoalesce(inputSource, () => ( "external"));
|
|
2851
|
-
if (!
|
|
2852
|
-
throw new Error(`source must be one of ${
|
|
3806
|
+
if (!VALID_SOURCES.includes(source)) {
|
|
3807
|
+
throw new Error(`source must be one of ${VALID_SOURCES}`);
|
|
2853
3808
|
}
|
|
2854
3809
|
if (isEmpty(scores) && isEmpty(expected) && isEmpty(tags) && isEmpty(comment)) {
|
|
2855
3810
|
throw new Error(
|
|
@@ -2866,7 +3821,7 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2866
3821
|
updateEvent = Object.fromEntries(
|
|
2867
3822
|
Object.entries(updateEvent).filter(([_, v]) => !isEmpty(v))
|
|
2868
3823
|
);
|
|
2869
|
-
const parentIds = async () => new
|
|
3824
|
+
const parentIds = async () => new SpanComponentsV3({
|
|
2870
3825
|
object_type: parentObjectType,
|
|
2871
3826
|
object_id: await parentObjectId.get()
|
|
2872
3827
|
}).objectIdFields();
|
|
@@ -2876,9 +3831,9 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2876
3831
|
id,
|
|
2877
3832
|
...updateEvent,
|
|
2878
3833
|
...await parentIds(),
|
|
2879
|
-
[
|
|
2880
|
-
[
|
|
2881
|
-
[
|
|
3834
|
+
[AUDIT_SOURCE_FIELD]: source,
|
|
3835
|
+
[AUDIT_METADATA_FIELD]: metadata,
|
|
3836
|
+
[IS_MERGE_FIELD]: true
|
|
2882
3837
|
};
|
|
2883
3838
|
});
|
|
2884
3839
|
state.bgLogger().log([record]);
|
|
@@ -2897,8 +3852,8 @@ function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
|
2897
3852
|
text: comment
|
|
2898
3853
|
},
|
|
2899
3854
|
...await parentIds(),
|
|
2900
|
-
[
|
|
2901
|
-
[
|
|
3855
|
+
[AUDIT_SOURCE_FIELD]: source,
|
|
3856
|
+
[AUDIT_METADATA_FIELD]: metadata
|
|
2902
3857
|
};
|
|
2903
3858
|
});
|
|
2904
3859
|
state.bgLogger().log([record]);
|
|
@@ -2917,7 +3872,7 @@ function updateSpanImpl({
|
|
|
2917
3872
|
...event
|
|
2918
3873
|
})
|
|
2919
3874
|
);
|
|
2920
|
-
const parentIds = async () => new
|
|
3875
|
+
const parentIds = async () => new SpanComponentsV3({
|
|
2921
3876
|
object_type: parentObjectType,
|
|
2922
3877
|
object_id: await parentObjectId.get()
|
|
2923
3878
|
}).objectIdFields();
|
|
@@ -2925,7 +3880,7 @@ function updateSpanImpl({
|
|
|
2925
3880
|
id,
|
|
2926
3881
|
...updateEvent,
|
|
2927
3882
|
...await parentIds(),
|
|
2928
|
-
[
|
|
3883
|
+
[IS_MERGE_FIELD]: true
|
|
2929
3884
|
}));
|
|
2930
3885
|
state.bgLogger().log([record]);
|
|
2931
3886
|
}
|
|
@@ -2935,7 +3890,7 @@ function updateSpan({
|
|
|
2935
3890
|
...event
|
|
2936
3891
|
}) {
|
|
2937
3892
|
const resolvedState = _nullishCoalesce(state, () => ( _globalState));
|
|
2938
|
-
const components =
|
|
3893
|
+
const components = SpanComponentsV3.fromStr(exported);
|
|
2939
3894
|
if (!components.data.row_id) {
|
|
2940
3895
|
throw new Error("Exported span must have a row id");
|
|
2941
3896
|
}
|
|
@@ -2960,15 +3915,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
2960
3915
|
);
|
|
2961
3916
|
}
|
|
2962
3917
|
switch (components.data.object_type) {
|
|
2963
|
-
case
|
|
3918
|
+
case 1 /* EXPERIMENT */:
|
|
2964
3919
|
throw new Error(
|
|
2965
3920
|
"Impossible: computeObjectMetadataArgs not supported for experiments"
|
|
2966
3921
|
);
|
|
2967
|
-
case
|
|
3922
|
+
case 3 /* PLAYGROUND_LOGS */:
|
|
2968
3923
|
throw new Error(
|
|
2969
3924
|
"Impossible: computeObjectMetadataArgs not supported for prompt sessions"
|
|
2970
3925
|
);
|
|
2971
|
-
case
|
|
3926
|
+
case 2 /* PROJECT_LOGS */:
|
|
2972
3927
|
return async () => (await computeLoggerMetadata(state, {
|
|
2973
3928
|
...components.data.compute_object_metadata_args
|
|
2974
3929
|
})).project.id;
|
|
@@ -2997,9 +3952,9 @@ async function permalink(slug, opts) {
|
|
|
2997
3952
|
if (slug === "") {
|
|
2998
3953
|
return NOOP_SPAN_PERMALINK;
|
|
2999
3954
|
}
|
|
3000
|
-
const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
3955
|
+
const state = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _22 => _22.state]), () => ( _globalState));
|
|
3001
3956
|
const getOrgName = async () => {
|
|
3002
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
3957
|
+
if (_optionalChain([opts, 'optionalAccess', _23 => _23.orgName])) {
|
|
3003
3958
|
return opts.orgName;
|
|
3004
3959
|
}
|
|
3005
3960
|
await state.login({});
|
|
@@ -3009,7 +3964,7 @@ async function permalink(slug, opts) {
|
|
|
3009
3964
|
return state.orgName;
|
|
3010
3965
|
};
|
|
3011
3966
|
const getAppUrl = async () => {
|
|
3012
|
-
if (_optionalChain([opts, 'optionalAccess',
|
|
3967
|
+
if (_optionalChain([opts, 'optionalAccess', _24 => _24.appUrl])) {
|
|
3013
3968
|
return opts.appUrl;
|
|
3014
3969
|
}
|
|
3015
3970
|
await state.login({});
|
|
@@ -3019,8 +3974,8 @@ async function permalink(slug, opts) {
|
|
|
3019
3974
|
return state.appUrl;
|
|
3020
3975
|
};
|
|
3021
3976
|
try {
|
|
3022
|
-
const components =
|
|
3023
|
-
const object_type =
|
|
3977
|
+
const components = SpanComponentsV3.fromStr(slug);
|
|
3978
|
+
const object_type = spanObjectTypeV3ToString(components.data.object_type);
|
|
3024
3979
|
const [orgName, appUrl, object_id] = await Promise.all([
|
|
3025
3980
|
getOrgName(),
|
|
3026
3981
|
getAppUrl(),
|
|
@@ -3047,7 +4002,7 @@ function startSpanParentArgs(args) {
|
|
|
3047
4002
|
if (args.parentSpanIds) {
|
|
3048
4003
|
throw new Error("Cannot specify both parent and parentSpanIds");
|
|
3049
4004
|
}
|
|
3050
|
-
const parentComponents =
|
|
4005
|
+
const parentComponents = SpanComponentsV3.fromStr(args.parent);
|
|
3051
4006
|
if (args.parentObjectType !== parentComponents.data.object_type) {
|
|
3052
4007
|
throw new Error(
|
|
3053
4008
|
`Mismatch between expected span parent object type ${args.parentObjectType} and provided type ${parentComponents.data.object_type}`
|
|
@@ -3120,7 +4075,7 @@ var Logger = (_class6 = class {
|
|
|
3120
4075
|
return (async () => (await this.project).id)();
|
|
3121
4076
|
}
|
|
3122
4077
|
parentObjectType() {
|
|
3123
|
-
return
|
|
4078
|
+
return 2 /* PROJECT_LOGS */;
|
|
3124
4079
|
}
|
|
3125
4080
|
/**
|
|
3126
4081
|
* Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
|
|
@@ -3139,7 +4094,7 @@ var Logger = (_class6 = class {
|
|
|
3139
4094
|
* @returns The `id` of the logged event.
|
|
3140
4095
|
*/
|
|
3141
4096
|
log(event, options) {
|
|
3142
|
-
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess',
|
|
4097
|
+
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _25 => _25.allowConcurrentWithSpans])) {
|
|
3143
4098
|
throw new Error(
|
|
3144
4099
|
"Cannot run toplevel `log` method while using spans. To log to the span, call `logger.traced` and then log with `span.log`"
|
|
3145
4100
|
);
|
|
@@ -3207,14 +4162,14 @@ var Logger = (_class6 = class {
|
|
|
3207
4162
|
state: this.state,
|
|
3208
4163
|
...startSpanParentArgs({
|
|
3209
4164
|
state: this.state,
|
|
3210
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
4165
|
+
parent: _optionalChain([args, 'optionalAccess', _26 => _26.parent]),
|
|
3211
4166
|
parentObjectType: this.parentObjectType(),
|
|
3212
4167
|
parentObjectId: this.lazyId,
|
|
3213
4168
|
parentComputeObjectMetadataArgs: this.computeMetadataArgs,
|
|
3214
|
-
parentSpanIds: _optionalChain([args, 'optionalAccess',
|
|
3215
|
-
propagatedEvent: _optionalChain([args, 'optionalAccess',
|
|
4169
|
+
parentSpanIds: _optionalChain([args, 'optionalAccess', _27 => _27.parentSpanIds]),
|
|
4170
|
+
propagatedEvent: _optionalChain([args, 'optionalAccess', _28 => _28.propagatedEvent])
|
|
3216
4171
|
}),
|
|
3217
|
-
defaultRootType:
|
|
4172
|
+
defaultRootType: "task" /* TASK */
|
|
3218
4173
|
});
|
|
3219
4174
|
}
|
|
3220
4175
|
/**
|
|
@@ -3256,7 +4211,7 @@ var Logger = (_class6 = class {
|
|
|
3256
4211
|
* See {@link Span.startSpan} for more details.
|
|
3257
4212
|
*/
|
|
3258
4213
|
async export() {
|
|
3259
|
-
return new
|
|
4214
|
+
return new SpanComponentsV3({
|
|
3260
4215
|
object_type: this.parentObjectType(),
|
|
3261
4216
|
...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
|
|
3262
4217
|
}).toStr();
|
|
@@ -3281,7 +4236,7 @@ function castLogger(logger, asyncFlush) {
|
|
|
3281
4236
|
return logger;
|
|
3282
4237
|
}
|
|
3283
4238
|
function constructLogs3Data(items) {
|
|
3284
|
-
return `{"rows": ${
|
|
4239
|
+
return `{"rows": ${constructJsonArray(items)}, "api_version": 2}`;
|
|
3285
4240
|
}
|
|
3286
4241
|
function now() {
|
|
3287
4242
|
return (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -3307,7 +4262,7 @@ var TestBackgroundLogger = (_class7 = class {constructor() { _class7.prototype._
|
|
|
3307
4262
|
events.push(await event.get());
|
|
3308
4263
|
}
|
|
3309
4264
|
}
|
|
3310
|
-
const batch =
|
|
4265
|
+
const batch = mergeRowBatch(events);
|
|
3311
4266
|
let flatBatch = batch.flat();
|
|
3312
4267
|
if (this.maskingFunction) {
|
|
3313
4268
|
flatBatch = flatBatch.map((item) => {
|
|
@@ -3450,7 +4405,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
|
|
|
3450
4405
|
this.queue.clear();
|
|
3451
4406
|
return;
|
|
3452
4407
|
}
|
|
3453
|
-
const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4408
|
+
const batchSize = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _29 => _29.batchSize]), () => ( this.defaultBatchSize));
|
|
3454
4409
|
const wrappedItems = this.queue.drain();
|
|
3455
4410
|
const [allItems, attachments] = await this.unwrapLazyValues(wrappedItems);
|
|
3456
4411
|
if (allItems.length === 0) {
|
|
@@ -3459,7 +4414,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
|
|
|
3459
4414
|
const allItemsStr = allItems.map(
|
|
3460
4415
|
(bucket) => bucket.map((item) => JSON.stringify(item))
|
|
3461
4416
|
);
|
|
3462
|
-
const batchSets =
|
|
4417
|
+
const batchSets = batchItems({
|
|
3463
4418
|
items: allItemsStr,
|
|
3464
4419
|
batchMaxNumItems: batchSize,
|
|
3465
4420
|
batchMaxNumBytes: this.maxRequestSize / 2
|
|
@@ -3513,7 +4468,7 @@ var HTTPBackgroundLogger = (_class8 = class _HTTPBackgroundLogger {
|
|
|
3513
4468
|
const items = await Promise.all(wrappedItems.map((x) => x.get()));
|
|
3514
4469
|
const attachments = [];
|
|
3515
4470
|
items.forEach((item) => extractAttachments(item, attachments));
|
|
3516
|
-
let mergedItems =
|
|
4471
|
+
let mergedItems = mergeRowBatch(items);
|
|
3517
4472
|
if (this.maskingFunction) {
|
|
3518
4473
|
mergedItems = mergedItems.map(
|
|
3519
4474
|
(batch) => batch.map((item) => {
|
|
@@ -3699,10 +4654,10 @@ Error: ${errorText}`;
|
|
|
3699
4654
|
} catch (err) {
|
|
3700
4655
|
if (err instanceof AggregateError) {
|
|
3701
4656
|
for (const e of err.errors) {
|
|
3702
|
-
_optionalChain([this, 'access',
|
|
4657
|
+
_optionalChain([this, 'access', _30 => _30.onFlushError, 'optionalCall', _31 => _31(e)]);
|
|
3703
4658
|
}
|
|
3704
4659
|
} else {
|
|
3705
|
-
_optionalChain([this, 'access',
|
|
4660
|
+
_optionalChain([this, 'access', _32 => _32.onFlushError, 'optionalCall', _33 => _33(err)]);
|
|
3706
4661
|
}
|
|
3707
4662
|
this.activeFlushError = err;
|
|
3708
4663
|
} finally {
|
|
@@ -3832,7 +4787,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
3832
4787
|
}
|
|
3833
4788
|
};
|
|
3834
4789
|
if (gitMetadataSettings) {
|
|
3835
|
-
mergedGitMetadataSettings =
|
|
4790
|
+
mergedGitMetadataSettings = mergeGitMetadataSettings(
|
|
3836
4791
|
mergedGitMetadataSettings,
|
|
3837
4792
|
gitMetadataSettings
|
|
3838
4793
|
);
|
|
@@ -4257,7 +5212,7 @@ async function loginToState(options = {}) {
|
|
|
4257
5212
|
return state;
|
|
4258
5213
|
} else {
|
|
4259
5214
|
const resp = await checkResponse(
|
|
4260
|
-
await fetch2(
|
|
5215
|
+
await fetch2(_urljoin(state.appUrl, `/api/apikey/login`), {
|
|
4261
5216
|
method: "POST",
|
|
4262
5217
|
headers: {
|
|
4263
5218
|
"Content-Type": "application/json",
|
|
@@ -4315,23 +5270,25 @@ async function summarize(options = {}) {
|
|
|
4315
5270
|
return await e.summarize(options);
|
|
4316
5271
|
}
|
|
4317
5272
|
function currentExperiment(options) {
|
|
4318
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5273
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.state]), () => ( _globalState));
|
|
4319
5274
|
return state.currentExperiment;
|
|
4320
5275
|
}
|
|
4321
5276
|
function currentLogger(options) {
|
|
4322
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
4323
|
-
return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess',
|
|
5277
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _35 => _35.state]), () => ( _globalState));
|
|
5278
|
+
return castLogger(state.currentLogger, _optionalChain([options, 'optionalAccess', _36 => _36.asyncFlush]));
|
|
4324
5279
|
}
|
|
4325
5280
|
function currentSpan(options) {
|
|
4326
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5281
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _37 => _37.state]), () => ( _globalState));
|
|
4327
5282
|
return _nullishCoalesce(state.currentSpan.getStore(), () => ( NOOP_SPAN));
|
|
4328
5283
|
}
|
|
4329
5284
|
function getSpanParentObject(options) {
|
|
4330
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5285
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _38 => _38.state]), () => ( _globalState));
|
|
4331
5286
|
const parentSpan = currentSpan({ state });
|
|
4332
5287
|
if (!Object.is(parentSpan, NOOP_SPAN)) {
|
|
4333
5288
|
return parentSpan;
|
|
4334
5289
|
}
|
|
5290
|
+
const parentStr = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _39 => _39.parent]), () => ( state.currentParent.getStore()));
|
|
5291
|
+
if (parentStr) return SpanComponentsV3.fromStr(parentStr);
|
|
4335
5292
|
const experiment = currentExperiment();
|
|
4336
5293
|
if (experiment) {
|
|
4337
5294
|
return experiment;
|
|
@@ -4359,7 +5316,7 @@ function traced(callback, args) {
|
|
|
4359
5316
|
const { span, isSyncFlushLogger } = startSpanAndIsLogger(args);
|
|
4360
5317
|
const ret = runCatchFinally(
|
|
4361
5318
|
() => {
|
|
4362
|
-
if (_nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
5319
|
+
if (_nullishCoalesce(_optionalChain([args, 'optionalAccess', _40 => _40.setCurrent]), () => ( true))) {
|
|
4363
5320
|
return withCurrent(span, callback);
|
|
4364
5321
|
} else {
|
|
4365
5322
|
return callback(span);
|
|
@@ -4371,7 +5328,7 @@ function traced(callback, args) {
|
|
|
4371
5328
|
},
|
|
4372
5329
|
() => span.end()
|
|
4373
5330
|
);
|
|
4374
|
-
if (_optionalChain([args, 'optionalAccess',
|
|
5331
|
+
if (_optionalChain([args, 'optionalAccess', _41 => _41.asyncFlush]) === void 0 || _optionalChain([args, 'optionalAccess', _42 => _42.asyncFlush])) {
|
|
4375
5332
|
return ret;
|
|
4376
5333
|
} else {
|
|
4377
5334
|
return (async () => {
|
|
@@ -4495,14 +5452,14 @@ function wrapTraced(fn, args) {
|
|
|
4495
5452
|
};
|
|
4496
5453
|
const hasExplicitInput = args && args.event && "input" in args.event && args.event.input !== void 0;
|
|
4497
5454
|
const hasExplicitOutput = args && args.event && args.event.output !== void 0;
|
|
4498
|
-
const noTraceIO = _optionalChain([args, 'optionalAccess',
|
|
5455
|
+
const noTraceIO = _optionalChain([args, 'optionalAccess', _43 => _43.noTraceIO]) || hasExplicitInput || hasExplicitOutput;
|
|
4499
5456
|
if (isGeneratorFunction(fn)) {
|
|
4500
5457
|
return wrapTracedSyncGenerator(fn, spanArgs, !!noTraceIO);
|
|
4501
5458
|
}
|
|
4502
5459
|
if (isAsyncGeneratorFunction(fn)) {
|
|
4503
5460
|
return wrapTracedAsyncGenerator(fn, spanArgs, !!noTraceIO);
|
|
4504
5461
|
}
|
|
4505
|
-
if (_optionalChain([args, 'optionalAccess',
|
|
5462
|
+
if (_optionalChain([args, 'optionalAccess', _44 => _44.asyncFlush])) {
|
|
4506
5463
|
return (...fnArgs) => traced((span) => {
|
|
4507
5464
|
if (!hasExplicitInput) {
|
|
4508
5465
|
span.log({ input: fnArgs });
|
|
@@ -4540,43 +5497,43 @@ function startSpan(args) {
|
|
|
4540
5497
|
return startSpanAndIsLogger(args).span;
|
|
4541
5498
|
}
|
|
4542
5499
|
async function flush(options) {
|
|
4543
|
-
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
5500
|
+
const state = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.state]), () => ( _globalState));
|
|
4544
5501
|
return await state.bgLogger().flush();
|
|
4545
5502
|
}
|
|
4546
5503
|
function setFetch(fetch2) {
|
|
4547
5504
|
_globalState.setFetch(fetch2);
|
|
4548
5505
|
}
|
|
4549
5506
|
function startSpanAndIsLogger(args) {
|
|
4550
|
-
const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4551
|
-
const
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
5507
|
+
const state = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _46 => _46.state]), () => ( _globalState));
|
|
5508
|
+
const parentObject = getSpanParentObject({
|
|
5509
|
+
asyncFlush: _optionalChain([args, 'optionalAccess', _47 => _47.asyncFlush]),
|
|
5510
|
+
parent: _optionalChain([args, 'optionalAccess', _48 => _48.parent]),
|
|
5511
|
+
state
|
|
5512
|
+
});
|
|
5513
|
+
if (parentObject instanceof SpanComponentsV3) {
|
|
5514
|
+
const parentSpanIds = parentObject.data.row_id ? {
|
|
5515
|
+
spanId: parentObject.data.span_id,
|
|
5516
|
+
rootSpanId: parentObject.data.root_span_id
|
|
4557
5517
|
} : void 0;
|
|
4558
5518
|
const span = new SpanImpl({
|
|
4559
5519
|
state,
|
|
4560
5520
|
...args,
|
|
4561
|
-
parentObjectType:
|
|
5521
|
+
parentObjectType: parentObject.data.object_type,
|
|
4562
5522
|
parentObjectId: new LazyValue(
|
|
4563
|
-
spanComponentsToObjectIdLambda(state,
|
|
5523
|
+
spanComponentsToObjectIdLambda(state, parentObject)
|
|
4564
5524
|
),
|
|
4565
|
-
parentComputeObjectMetadataArgs: _nullishCoalesce(
|
|
5525
|
+
parentComputeObjectMetadataArgs: _nullishCoalesce(parentObject.data.compute_object_metadata_args, () => ( void 0)),
|
|
4566
5526
|
parentSpanIds,
|
|
4567
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4568
|
-
(_nullishCoalesce(
|
|
5527
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _49 => _49.propagatedEvent]), () => ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5528
|
+
(_nullishCoalesce(parentObject.data.propagated_event, () => ( void 0)))))
|
|
4569
5529
|
});
|
|
4570
5530
|
return {
|
|
4571
5531
|
span,
|
|
4572
|
-
isSyncFlushLogger:
|
|
5532
|
+
isSyncFlushLogger: parentObject.data.object_type === 2 /* PROJECT_LOGS */ && // Since there's no parent logger here, we're free to choose the async flush
|
|
4573
5533
|
// behavior, and therefore propagate along whatever we get from the arguments
|
|
4574
|
-
_optionalChain([args, 'optionalAccess',
|
|
5534
|
+
_optionalChain([args, 'optionalAccess', _50 => _50.asyncFlush]) === false
|
|
4575
5535
|
};
|
|
4576
5536
|
} else {
|
|
4577
|
-
const parentObject = getSpanParentObject({
|
|
4578
|
-
asyncFlush: _optionalChain([args, 'optionalAccess', _39 => _39.asyncFlush])
|
|
4579
|
-
});
|
|
4580
5537
|
const span = parentObject.startSpan(args);
|
|
4581
5538
|
return {
|
|
4582
5539
|
span,
|
|
@@ -4763,10 +5720,10 @@ function extractAttachments(event, attachments) {
|
|
|
4763
5720
|
event[key] = value.reference;
|
|
4764
5721
|
continue;
|
|
4765
5722
|
}
|
|
4766
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
5723
|
+
if (_optionalChain([value, 'optionalAccess', _51 => _51.type]) === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
|
|
4767
5724
|
continue;
|
|
4768
5725
|
}
|
|
4769
|
-
if (_optionalChain([value, 'optionalAccess',
|
|
5726
|
+
if (_optionalChain([value, 'optionalAccess', _52 => _52.reference, 'optionalAccess', _53 => _53.type]) === BRAINTRUST_ATTACHMENT && _optionalChain([value, 'optionalAccess', _54 => _54.uploader])) {
|
|
4770
5727
|
const attachment = new Attachment({
|
|
4771
5728
|
data: value.dataDebugString,
|
|
4772
5729
|
filename: value.reference.filename,
|
|
@@ -4904,7 +5861,7 @@ var ObjectFetcher = (_class9 = class {
|
|
|
4904
5861
|
throw new Error("Too many BTQL iterations");
|
|
4905
5862
|
}
|
|
4906
5863
|
}
|
|
4907
|
-
this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess',
|
|
5864
|
+
this._fetchedData = this.mutateRecord ? _optionalChain([data, 'optionalAccess', _55 => _55.map, 'call', _56 => _56(this.mutateRecord)]) : data;
|
|
4908
5865
|
}
|
|
4909
5866
|
return this._fetchedData || [];
|
|
4910
5867
|
}
|
|
@@ -4918,7 +5875,7 @@ var ObjectFetcher = (_class9 = class {
|
|
|
4918
5875
|
const fetchedData = await this.fetchedData();
|
|
4919
5876
|
let maxVersion = void 0;
|
|
4920
5877
|
for (const record of fetchedData) {
|
|
4921
|
-
const xactId = String(_nullishCoalesce(record[
|
|
5878
|
+
const xactId = String(_nullishCoalesce(record[TRANSACTION_ID_FIELD], () => ( "0")));
|
|
4922
5879
|
if (maxVersion === void 0 || xactId > maxVersion) {
|
|
4923
5880
|
maxVersion = xactId;
|
|
4924
5881
|
}
|
|
@@ -4961,7 +5918,7 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
|
|
|
4961
5918
|
})();
|
|
4962
5919
|
}
|
|
4963
5920
|
parentObjectType() {
|
|
4964
|
-
return
|
|
5921
|
+
return 1 /* EXPERIMENT */;
|
|
4965
5922
|
}
|
|
4966
5923
|
async getState() {
|
|
4967
5924
|
await this.lazyMetadata.get();
|
|
@@ -4985,7 +5942,7 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
|
|
|
4985
5942
|
* @returns The `id` of the logged event.
|
|
4986
5943
|
*/
|
|
4987
5944
|
log(event, options) {
|
|
4988
|
-
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess',
|
|
5945
|
+
if (this.calledStartSpan && !_optionalChain([options, 'optionalAccess', _57 => _57.allowConcurrentWithSpans])) {
|
|
4989
5946
|
throw new Error(
|
|
4990
5947
|
"Cannot run toplevel `log` method while using spans. To log to the span, call `experiment.traced` and then log with `span.log`"
|
|
4991
5948
|
);
|
|
@@ -5038,14 +5995,14 @@ var Experiment2 = (_class10 = class extends ObjectFetcher {
|
|
|
5038
5995
|
state: this.state,
|
|
5039
5996
|
...startSpanParentArgs({
|
|
5040
5997
|
state: this.state,
|
|
5041
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
5998
|
+
parent: _optionalChain([args, 'optionalAccess', _58 => _58.parent]),
|
|
5042
5999
|
parentObjectType: this.parentObjectType(),
|
|
5043
6000
|
parentObjectId: this.lazyId,
|
|
5044
6001
|
parentComputeObjectMetadataArgs: void 0,
|
|
5045
6002
|
parentSpanIds: void 0,
|
|
5046
|
-
propagatedEvent: _optionalChain([args, 'optionalAccess',
|
|
6003
|
+
propagatedEvent: _optionalChain([args, 'optionalAccess', _59 => _59.propagatedEvent])
|
|
5047
6004
|
}),
|
|
5048
|
-
defaultRootType:
|
|
6005
|
+
defaultRootType: "eval" /* EVAL */
|
|
5049
6006
|
});
|
|
5050
6007
|
}
|
|
5051
6008
|
async fetchBaseExperiment() {
|
|
@@ -5169,7 +6126,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
5169
6126
|
* See {@link Span.startSpan} for more details.
|
|
5170
6127
|
*/
|
|
5171
6128
|
async export() {
|
|
5172
|
-
return new
|
|
6129
|
+
return new SpanComponentsV3({
|
|
5173
6130
|
object_type: this.parentObjectType(),
|
|
5174
6131
|
object_id: await this.id
|
|
5175
6132
|
}).toStr();
|
|
@@ -5256,7 +6213,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5256
6213
|
this.parentComputeObjectMetadataArgs = args.parentComputeObjectMetadataArgs;
|
|
5257
6214
|
this.propagatedEvent = args.propagatedEvent;
|
|
5258
6215
|
if (this.propagatedEvent) {
|
|
5259
|
-
|
|
6216
|
+
mergeDicts(rawEvent, this.propagatedEvent);
|
|
5260
6217
|
}
|
|
5261
6218
|
const { id: eventId, ...event } = rawEvent;
|
|
5262
6219
|
const callerLocation = isomorph_default.getCallerLocation();
|
|
@@ -5333,12 +6290,12 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5333
6290
|
root_span_id: this._rootSpanId,
|
|
5334
6291
|
span_parents: this._spanParents,
|
|
5335
6292
|
...serializableInternalData,
|
|
5336
|
-
[
|
|
6293
|
+
[IS_MERGE_FIELD]: this.isMerge
|
|
5337
6294
|
});
|
|
5338
|
-
if (_optionalChain([partialRecord, 'access',
|
|
5339
|
-
this.loggedEndTime = _optionalChain([partialRecord, 'access',
|
|
6295
|
+
if (_optionalChain([partialRecord, 'access', _60 => _60.metrics, 'optionalAccess', _61 => _61.end])) {
|
|
6296
|
+
this.loggedEndTime = _optionalChain([partialRecord, 'access', _62 => _62.metrics, 'optionalAccess', _63 => _63.end]);
|
|
5340
6297
|
}
|
|
5341
|
-
if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access',
|
|
6298
|
+
if ((_nullishCoalesce(partialRecord.tags, () => ( []))).length > 0 && _optionalChain([this, 'access', _64 => _64._spanParents, 'optionalAccess', _65 => _65.length])) {
|
|
5342
6299
|
throw new Error("Tags can only be logged to the root span");
|
|
5343
6300
|
}
|
|
5344
6301
|
const computeRecord = async () => ({
|
|
@@ -5351,7 +6308,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5351
6308
|
])
|
|
5352
6309
|
)
|
|
5353
6310
|
),
|
|
5354
|
-
...new
|
|
6311
|
+
...new SpanComponentsV3({
|
|
5355
6312
|
object_type: this.parentObjectType,
|
|
5356
6313
|
object_id: await this.parentObjectId.get()
|
|
5357
6314
|
}).objectIdFields()
|
|
@@ -5383,18 +6340,18 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5383
6340
|
);
|
|
5384
6341
|
}
|
|
5385
6342
|
startSpan(args) {
|
|
5386
|
-
const parentSpanIds = _optionalChain([args, 'optionalAccess',
|
|
6343
|
+
const parentSpanIds = _optionalChain([args, 'optionalAccess', _66 => _66.parent]) ? void 0 : { spanId: this._spanId, rootSpanId: this._rootSpanId };
|
|
5387
6344
|
return new _SpanImpl({
|
|
5388
6345
|
state: this._state,
|
|
5389
6346
|
...args,
|
|
5390
6347
|
...startSpanParentArgs({
|
|
5391
6348
|
state: this._state,
|
|
5392
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
6349
|
+
parent: _optionalChain([args, 'optionalAccess', _67 => _67.parent]),
|
|
5393
6350
|
parentObjectType: this.parentObjectType,
|
|
5394
6351
|
parentObjectId: this.parentObjectId,
|
|
5395
6352
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
5396
6353
|
parentSpanIds,
|
|
5397
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6354
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _68 => _68.propagatedEvent]), () => ( this.propagatedEvent))
|
|
5398
6355
|
})
|
|
5399
6356
|
});
|
|
5400
6357
|
}
|
|
@@ -5408,12 +6365,12 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5408
6365
|
...args,
|
|
5409
6366
|
...startSpanParentArgs({
|
|
5410
6367
|
state: this._state,
|
|
5411
|
-
parent: _optionalChain([args, 'optionalAccess',
|
|
6368
|
+
parent: _optionalChain([args, 'optionalAccess', _69 => _69.parent]),
|
|
5412
6369
|
parentObjectType: this.parentObjectType,
|
|
5413
6370
|
parentObjectId: this.parentObjectId,
|
|
5414
6371
|
parentComputeObjectMetadataArgs: this.parentComputeObjectMetadataArgs,
|
|
5415
6372
|
parentSpanIds,
|
|
5416
|
-
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6373
|
+
propagatedEvent: _nullishCoalesce(_optionalChain([args, 'optionalAccess', _70 => _70.propagatedEvent]), () => ( this.propagatedEvent))
|
|
5417
6374
|
}),
|
|
5418
6375
|
spanId
|
|
5419
6376
|
});
|
|
@@ -5422,7 +6379,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5422
6379
|
let endTime;
|
|
5423
6380
|
let internalData = {};
|
|
5424
6381
|
if (!this.loggedEndTime) {
|
|
5425
|
-
endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
6382
|
+
endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _71 => _71.endTime]), () => ( getCurrentUnixTimestamp()));
|
|
5426
6383
|
internalData = { metrics: { end: endTime } };
|
|
5427
6384
|
} else {
|
|
5428
6385
|
endTime = this.loggedEndTime;
|
|
@@ -5431,7 +6388,7 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5431
6388
|
return endTime;
|
|
5432
6389
|
}
|
|
5433
6390
|
async export() {
|
|
5434
|
-
return new
|
|
6391
|
+
return new SpanComponentsV3({
|
|
5435
6392
|
object_type: this.parentObjectType,
|
|
5436
6393
|
...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
|
|
5437
6394
|
row_id: this.id,
|
|
@@ -5464,9 +6421,9 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5464
6421
|
const baseUrl = `${appUrl}/app/${orgName}`;
|
|
5465
6422
|
const args = this.parentComputeObjectMetadataArgs;
|
|
5466
6423
|
switch (this.parentObjectType) {
|
|
5467
|
-
case
|
|
5468
|
-
const projectID = _optionalChain([args, 'optionalAccess',
|
|
5469
|
-
const projectName = _optionalChain([args, 'optionalAccess',
|
|
6424
|
+
case 2 /* PROJECT_LOGS */: {
|
|
6425
|
+
const projectID = _optionalChain([args, 'optionalAccess', _72 => _72.project_id]) || this.parentObjectId.getSync().value;
|
|
6426
|
+
const projectName = _optionalChain([args, 'optionalAccess', _73 => _73.project_name]);
|
|
5470
6427
|
if (projectID) {
|
|
5471
6428
|
return `${baseUrl}/object?object_type=project_logs&object_id=${projectID}&id=${this._id}`;
|
|
5472
6429
|
} else if (projectName) {
|
|
@@ -5475,15 +6432,15 @@ var SpanImpl = (_class11 = class _SpanImpl {
|
|
|
5475
6432
|
return getErrPermlink("provide-project-name-or-id");
|
|
5476
6433
|
}
|
|
5477
6434
|
}
|
|
5478
|
-
case
|
|
5479
|
-
const expID = _optionalChain([args, 'optionalAccess',
|
|
6435
|
+
case 1 /* EXPERIMENT */: {
|
|
6436
|
+
const expID = _optionalChain([args, 'optionalAccess', _74 => _74.experiment_id]) || _optionalChain([this, 'access', _75 => _75.parentObjectId, 'optionalAccess', _76 => _76.getSync, 'call', _77 => _77(), 'optionalAccess', _78 => _78.value]);
|
|
5480
6437
|
if (!expID) {
|
|
5481
6438
|
return getErrPermlink("provide-experiment-id");
|
|
5482
6439
|
} else {
|
|
5483
6440
|
return `${baseUrl}/object?object_type=experiment&object_id=${expID}&id=${this._id}`;
|
|
5484
6441
|
}
|
|
5485
6442
|
}
|
|
5486
|
-
case
|
|
6443
|
+
case 3 /* PLAYGROUND_LOGS */: {
|
|
5487
6444
|
return NOOP_SPAN_PERMALINK;
|
|
5488
6445
|
}
|
|
5489
6446
|
default: {
|
|
@@ -5509,8 +6466,8 @@ function splitLoggingData({
|
|
|
5509
6466
|
}) {
|
|
5510
6467
|
const sanitized = validateAndSanitizeExperimentLogPartialArgs(_nullishCoalesce(event, () => ( {})));
|
|
5511
6468
|
const sanitizedAndInternalData = {};
|
|
5512
|
-
|
|
5513
|
-
|
|
6469
|
+
mergeDicts(sanitizedAndInternalData, internalData || {});
|
|
6470
|
+
mergeDicts(sanitizedAndInternalData, sanitized);
|
|
5514
6471
|
const serializableInternalData = {};
|
|
5515
6472
|
const lazyInternalData = {};
|
|
5516
6473
|
for (const [key, value] of Object.entries(sanitizedAndInternalData)) {
|
|
@@ -5535,7 +6492,7 @@ function splitLoggingData({
|
|
|
5535
6492
|
}
|
|
5536
6493
|
var Dataset2 = (_class12 = class extends ObjectFetcher {
|
|
5537
6494
|
constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
|
|
5538
|
-
const isLegacyDataset = _nullishCoalesce(legacy, () => (
|
|
6495
|
+
const isLegacyDataset = _nullishCoalesce(legacy, () => ( DEFAULT_IS_LEGACY_DATASET));
|
|
5539
6496
|
if (isLegacyDataset) {
|
|
5540
6497
|
console.warn(
|
|
5541
6498
|
`Records will be fetched from this dataset in the legacy format, with the "expected" field renamed to "output". Please update your code to use "expected", and use \`braintrust.initDataset()\` with \`{ useOutput: false }\`, which will become the default in a future version of Braintrust.`
|
|
@@ -5546,7 +6503,7 @@ var Dataset2 = (_class12 = class extends ObjectFetcher {
|
|
|
5546
6503
|
pinnedVersion,
|
|
5547
6504
|
(r) => (
|
|
5548
6505
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5549
|
-
|
|
6506
|
+
ensureDatasetRecord(
|
|
5550
6507
|
enrichAttachments(r, this.state),
|
|
5551
6508
|
isLegacyDataset
|
|
5552
6509
|
)
|
|
@@ -5622,7 +6579,7 @@ var Dataset2 = (_class12 = class extends ObjectFetcher {
|
|
|
5622
6579
|
//if we're merging/updating an event we will not add this ts
|
|
5623
6580
|
metadata,
|
|
5624
6581
|
...!!isMerge ? {
|
|
5625
|
-
[
|
|
6582
|
+
[IS_MERGE_FIELD]: true
|
|
5626
6583
|
} : {}
|
|
5627
6584
|
};
|
|
5628
6585
|
return args;
|
|
@@ -5783,7 +6740,7 @@ function renderMessage(render, message) {
|
|
|
5783
6740
|
case "text":
|
|
5784
6741
|
return { ...c, text: render(c.text) };
|
|
5785
6742
|
case "image_url":
|
|
5786
|
-
if (
|
|
6743
|
+
if (isObject(c.image_url.url)) {
|
|
5787
6744
|
throw new Error(
|
|
5788
6745
|
"Attachments must be replaced with URLs before calling `build()`"
|
|
5789
6746
|
);
|
|
@@ -5842,9 +6799,9 @@ function renderTemplatedObject(obj, args, options) {
|
|
|
5842
6799
|
}
|
|
5843
6800
|
}
|
|
5844
6801
|
});
|
|
5845
|
-
} else if (
|
|
6802
|
+
} else if (isArray(obj)) {
|
|
5846
6803
|
return obj.map((item) => renderTemplatedObject(item, args, options));
|
|
5847
|
-
} else if (
|
|
6804
|
+
} else if (isObject(obj)) {
|
|
5848
6805
|
return Object.fromEntries(
|
|
5849
6806
|
Object.entries(obj).map(([key, value]) => [
|
|
5850
6807
|
key,
|
|
@@ -5902,13 +6859,13 @@ var Prompt2 = (_class13 = class _Prompt {
|
|
|
5902
6859
|
return "slug" in this.metadata ? this.metadata.slug : this.metadata.id;
|
|
5903
6860
|
}
|
|
5904
6861
|
get prompt() {
|
|
5905
|
-
return _optionalChain([this, 'access',
|
|
6862
|
+
return _optionalChain([this, 'access', _79 => _79.getParsedPromptData, 'call', _80 => _80(), 'optionalAccess', _81 => _81.prompt]);
|
|
5906
6863
|
}
|
|
5907
6864
|
get version() {
|
|
5908
|
-
return this.metadata[
|
|
6865
|
+
return this.metadata[TRANSACTION_ID_FIELD];
|
|
5909
6866
|
}
|
|
5910
6867
|
get options() {
|
|
5911
|
-
return _optionalChain([this, 'access',
|
|
6868
|
+
return _optionalChain([this, 'access', _82 => _82.getParsedPromptData, 'call', _83 => _83(), 'optionalAccess', _84 => _84.options]) || {};
|
|
5912
6869
|
}
|
|
5913
6870
|
get promptData() {
|
|
5914
6871
|
return this.getParsedPromptData();
|
|
@@ -6059,7 +7016,7 @@ var Prompt2 = (_class13 = class _Prompt {
|
|
|
6059
7016
|
return {
|
|
6060
7017
|
type: "chat",
|
|
6061
7018
|
messages,
|
|
6062
|
-
..._optionalChain([prompt, 'access',
|
|
7019
|
+
..._optionalChain([prompt, 'access', _85 => _85.tools, 'optionalAccess', _86 => _86.trim, 'call', _87 => _87()]) ? {
|
|
6063
7020
|
tools: render(prompt.tools)
|
|
6064
7021
|
} : void 0
|
|
6065
7022
|
};
|
|
@@ -6169,9 +7126,9 @@ async function getPromptVersions(projectId, promptId) {
|
|
|
6169
7126
|
);
|
|
6170
7127
|
}
|
|
6171
7128
|
const result = await response.json();
|
|
6172
|
-
return _optionalChain([result, 'access',
|
|
6173
|
-
(entry) => ["upsert", "merge"].includes(_optionalChain([entry, 'access',
|
|
6174
|
-
), 'access',
|
|
7129
|
+
return _optionalChain([result, 'access', _88 => _88.data, 'optionalAccess', _89 => _89.filter, 'call', _90 => _90(
|
|
7130
|
+
(entry) => ["upsert", "merge"].includes(_optionalChain([entry, 'access', _91 => _91.audit_data, 'optionalAccess', _92 => _92.action]))
|
|
7131
|
+
), 'access', _93 => _93.map, 'call', _94 => _94((entry) => prettifyXact(entry._xact_id))]) || [];
|
|
6175
7132
|
}
|
|
6176
7133
|
var _exportsForTestingOnly = {
|
|
6177
7134
|
extractAttachments,
|
|
@@ -6196,7 +7153,7 @@ function configureBrowser() {
|
|
|
6196
7153
|
if (typeof AsyncLocalStorage !== "undefined") {
|
|
6197
7154
|
isomorph_default.newAsyncLocalStorage = () => new AsyncLocalStorage();
|
|
6198
7155
|
}
|
|
6199
|
-
} catch (
|
|
7156
|
+
} catch (e5) {
|
|
6200
7157
|
}
|
|
6201
7158
|
isomorph_default.getEnv = (name) => {
|
|
6202
7159
|
if (typeof process === "undefined" || typeof process.env === "undefined") {
|
|
@@ -6380,12 +7337,7 @@ function initFunction({
|
|
|
6380
7337
|
return f;
|
|
6381
7338
|
}
|
|
6382
7339
|
|
|
6383
|
-
// src/wrappers/oai.ts
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
7340
|
// src/wrappers/oai_responses.ts
|
|
6388
|
-
|
|
6389
7341
|
function responsesProxy(openai) {
|
|
6390
7342
|
if (!openai.responses) {
|
|
6391
7343
|
return openai;
|
|
@@ -6413,19 +7365,15 @@ function responsesCreateProxy(target) {
|
|
|
6413
7365
|
return proxyCreate(target, hooks);
|
|
6414
7366
|
}
|
|
6415
7367
|
function parseSpanFromResponseCreateParams(params) {
|
|
6416
|
-
const input = [{ role: "user", content: params.input }];
|
|
6417
|
-
if (params.instructions) {
|
|
6418
|
-
input.push({ role: "system", content: params.instructions });
|
|
6419
|
-
}
|
|
6420
7368
|
const spanArgs = {
|
|
6421
7369
|
name: "openai.responses.create",
|
|
6422
7370
|
spanAttributes: {
|
|
6423
7371
|
type: "llm"
|
|
6424
7372
|
},
|
|
6425
7373
|
event: {
|
|
6426
|
-
input,
|
|
7374
|
+
input: params.input,
|
|
6427
7375
|
metadata: {
|
|
6428
|
-
...filterFrom(params, ["input"
|
|
7376
|
+
...filterFrom(params, ["input"]),
|
|
6429
7377
|
provider: "openai"
|
|
6430
7378
|
}
|
|
6431
7379
|
},
|
|
@@ -6437,25 +7385,29 @@ function parseSpanFromResponseCreateParams(params) {
|
|
|
6437
7385
|
};
|
|
6438
7386
|
}
|
|
6439
7387
|
function parseEventFromResponseCreateResult(result) {
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
}
|
|
7388
|
+
const data = {};
|
|
7389
|
+
if (_optionalChain([result, 'optionalAccess', _95 => _95.output]) !== void 0) {
|
|
7390
|
+
data.output = result.output;
|
|
7391
|
+
}
|
|
7392
|
+
if (result) {
|
|
7393
|
+
const { output, usage, ...metadata } = result;
|
|
7394
|
+
if (Object.keys(metadata).length > 0) {
|
|
7395
|
+
data.metadata = metadata;
|
|
7396
|
+
}
|
|
7397
|
+
}
|
|
7398
|
+
data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _96 => _96.usage]));
|
|
7399
|
+
return data;
|
|
6444
7400
|
}
|
|
6445
7401
|
function parseSpanFromResponseParseParams(params) {
|
|
6446
|
-
const input = [{ role: "user", content: params.input }];
|
|
6447
|
-
if (params.instructions) {
|
|
6448
|
-
input.push({ role: "system", content: params.instructions });
|
|
6449
|
-
}
|
|
6450
7402
|
const spanArgs = {
|
|
6451
7403
|
name: "openai.responses.parse",
|
|
6452
7404
|
spanAttributes: {
|
|
6453
7405
|
type: "llm"
|
|
6454
7406
|
},
|
|
6455
7407
|
event: {
|
|
6456
|
-
input,
|
|
7408
|
+
input: params.input,
|
|
6457
7409
|
metadata: {
|
|
6458
|
-
...filterFrom(params, ["input"
|
|
7410
|
+
...filterFrom(params, ["input"]),
|
|
6459
7411
|
provider: "openai"
|
|
6460
7412
|
}
|
|
6461
7413
|
},
|
|
@@ -6467,10 +7419,18 @@ function parseSpanFromResponseParseParams(params) {
|
|
|
6467
7419
|
};
|
|
6468
7420
|
}
|
|
6469
7421
|
function parseEventFromResponseParseResult(result) {
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
}
|
|
7422
|
+
const data = {};
|
|
7423
|
+
if (_optionalChain([result, 'optionalAccess', _97 => _97.output]) !== void 0) {
|
|
7424
|
+
data.output = result.output;
|
|
7425
|
+
}
|
|
7426
|
+
if (result) {
|
|
7427
|
+
const { output, usage, ...metadata } = result;
|
|
7428
|
+
if (Object.keys(metadata).length > 0) {
|
|
7429
|
+
data.metadata = metadata;
|
|
7430
|
+
}
|
|
7431
|
+
}
|
|
7432
|
+
data.metrics = parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _98 => _98.usage]));
|
|
7433
|
+
return data;
|
|
6474
7434
|
}
|
|
6475
7435
|
function traceResponseCreateStream(stream, timedSpan) {
|
|
6476
7436
|
const span = timedSpan.span;
|
|
@@ -6486,7 +7446,7 @@ function traceResponseCreateStream(stream, timedSpan) {
|
|
|
6486
7446
|
return result;
|
|
6487
7447
|
}
|
|
6488
7448
|
const item = result.value;
|
|
6489
|
-
if (!item || !_optionalChain([item, 'optionalAccess',
|
|
7449
|
+
if (!item || !_optionalChain([item, 'optionalAccess', _99 => _99.type]) || !_optionalChain([item, 'optionalAccess', _100 => _100.response])) {
|
|
6490
7450
|
return result;
|
|
6491
7451
|
}
|
|
6492
7452
|
const event = parseLogFromItem(item);
|
|
@@ -6497,24 +7457,24 @@ function traceResponseCreateStream(stream, timedSpan) {
|
|
|
6497
7457
|
};
|
|
6498
7458
|
}
|
|
6499
7459
|
function parseLogFromItem(item) {
|
|
6500
|
-
if (!item || !_optionalChain([item, 'optionalAccess',
|
|
7460
|
+
if (!item || !_optionalChain([item, 'optionalAccess', _101 => _101.type]) || !_optionalChain([item, 'optionalAccess', _102 => _102.response])) {
|
|
6501
7461
|
return {};
|
|
6502
7462
|
}
|
|
6503
7463
|
const response = item.response;
|
|
6504
7464
|
switch (item.type) {
|
|
6505
7465
|
case "response.completed":
|
|
6506
|
-
const
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
7466
|
+
const data = {};
|
|
7467
|
+
if (_optionalChain([response, 'optionalAccess', _103 => _103.output]) !== void 0) {
|
|
7468
|
+
data.output = response.output;
|
|
7469
|
+
}
|
|
7470
|
+
if (response) {
|
|
7471
|
+
const { usage, output, ...metadata } = response;
|
|
7472
|
+
if (Object.keys(metadata).length > 0) {
|
|
7473
|
+
data.metadata = metadata;
|
|
6512
7474
|
}
|
|
6513
7475
|
}
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
metrics: parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _96 => _96.usage]))
|
|
6517
|
-
};
|
|
7476
|
+
data.metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _104 => _104.usage]));
|
|
7477
|
+
return data;
|
|
6518
7478
|
default:
|
|
6519
7479
|
return {};
|
|
6520
7480
|
}
|
|
@@ -6575,7 +7535,7 @@ function parseMetricsFromUsage(usage) {
|
|
|
6575
7535
|
const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
|
|
6576
7536
|
metrics[metricName] = value;
|
|
6577
7537
|
} else if (oai_name.endsWith("_tokens_details")) {
|
|
6578
|
-
if (!
|
|
7538
|
+
if (!isObject(value)) {
|
|
6579
7539
|
continue;
|
|
6580
7540
|
}
|
|
6581
7541
|
const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
|
|
@@ -6697,8 +7657,8 @@ function wrapOpenAIv4(openai) {
|
|
|
6697
7657
|
const embeddingProxy = createEndpointProxy(openai.embeddings, wrapEmbeddings);
|
|
6698
7658
|
const moderationProxy = createEndpointProxy(openai.moderations, wrapModerations);
|
|
6699
7659
|
let betaProxy;
|
|
6700
|
-
if (_optionalChain([openai, 'access',
|
|
6701
|
-
const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess',
|
|
7660
|
+
if (_optionalChain([openai, 'access', _105 => _105.beta, 'optionalAccess', _106 => _106.chat, 'optionalAccess', _107 => _107.completions, 'optionalAccess', _108 => _108.stream])) {
|
|
7661
|
+
const betaChatCompletionProxy = new Proxy(_optionalChain([openai, 'optionalAccess', _109 => _109.beta, 'optionalAccess', _110 => _110.chat, 'access', _111 => _111.completions]), {
|
|
6702
7662
|
get(target, name, receiver) {
|
|
6703
7663
|
const baseVal = Reflect.get(target, name, receiver);
|
|
6704
7664
|
if (name === "parse") {
|
|
@@ -6746,7 +7706,7 @@ function wrapOpenAIv4(openai) {
|
|
|
6746
7706
|
});
|
|
6747
7707
|
}
|
|
6748
7708
|
function logCompletionResponse(startTime, response, span) {
|
|
6749
|
-
const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess',
|
|
7709
|
+
const metrics = parseMetricsFromUsage(_optionalChain([response, 'optionalAccess', _112 => _112.usage]));
|
|
6750
7710
|
metrics.time_to_first_token = getCurrentUnixTimestamp() - startTime;
|
|
6751
7711
|
span.log({
|
|
6752
7712
|
output: response.choices,
|
|
@@ -6757,11 +7717,11 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
6757
7717
|
return async (allParams) => {
|
|
6758
7718
|
const { span_info: _, ...params } = allParams;
|
|
6759
7719
|
const span = startSpan(
|
|
6760
|
-
|
|
7720
|
+
mergeDicts(
|
|
6761
7721
|
{
|
|
6762
7722
|
name: "Chat Completion",
|
|
6763
7723
|
spanAttributes: {
|
|
6764
|
-
type:
|
|
7724
|
+
type: "llm" /* LLM */
|
|
6765
7725
|
}
|
|
6766
7726
|
},
|
|
6767
7727
|
parseChatCompletionParams(allParams)
|
|
@@ -6781,11 +7741,11 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
6781
7741
|
return (allParams) => {
|
|
6782
7742
|
const { span_info: _, ...params } = allParams;
|
|
6783
7743
|
const span = startSpan(
|
|
6784
|
-
|
|
7744
|
+
mergeDicts(
|
|
6785
7745
|
{
|
|
6786
7746
|
name: "Chat Completion",
|
|
6787
7747
|
spanAttributes: {
|
|
6788
|
-
type:
|
|
7748
|
+
type: "llm" /* LLM */
|
|
6789
7749
|
}
|
|
6790
7750
|
},
|
|
6791
7751
|
parseChatCompletionParams(allParams)
|
|
@@ -6841,55 +7801,83 @@ function logHeaders(response, span) {
|
|
|
6841
7801
|
}
|
|
6842
7802
|
}
|
|
6843
7803
|
function wrapChatCompletion(completion) {
|
|
6844
|
-
return
|
|
7804
|
+
return (allParams, options) => {
|
|
6845
7805
|
const { span_info: _, ...params } = allParams;
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
7806
|
+
let executionPromise = null;
|
|
7807
|
+
let dataPromise = null;
|
|
7808
|
+
const ensureExecuted = () => {
|
|
7809
|
+
if (!executionPromise) {
|
|
7810
|
+
executionPromise = (async () => {
|
|
7811
|
+
const span = startSpan(
|
|
7812
|
+
mergeDicts(
|
|
7813
|
+
{
|
|
7814
|
+
name: "Chat Completion",
|
|
7815
|
+
spanAttributes: {
|
|
7816
|
+
type: "llm" /* LLM */
|
|
7817
|
+
}
|
|
7818
|
+
},
|
|
7819
|
+
parseChatCompletionParams(allParams)
|
|
7820
|
+
)
|
|
7821
|
+
);
|
|
7822
|
+
const startTime = getCurrentUnixTimestamp();
|
|
7823
|
+
if (params.stream) {
|
|
7824
|
+
const { data: ret, response } = await completion(
|
|
7825
|
+
// We could get rid of this type coercion if we could somehow enforce
|
|
7826
|
+
// that `P extends ChatParams` BUT does not have the property
|
|
7827
|
+
// `span_info`.
|
|
7828
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
7829
|
+
params,
|
|
7830
|
+
options
|
|
7831
|
+
).withResponse();
|
|
7832
|
+
logHeaders(response, span);
|
|
7833
|
+
const wrapperStream = new WrapperStream(
|
|
7834
|
+
span,
|
|
7835
|
+
startTime,
|
|
7836
|
+
ret.iterator()
|
|
7837
|
+
);
|
|
7838
|
+
ret.iterator = () => wrapperStream[Symbol.asyncIterator]();
|
|
7839
|
+
return { data: ret, response };
|
|
7840
|
+
} else {
|
|
7841
|
+
try {
|
|
7842
|
+
const completionResponse = completion(
|
|
7843
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
7844
|
+
params,
|
|
7845
|
+
options
|
|
7846
|
+
);
|
|
7847
|
+
const { data: ret, response } = await completionResponse.withResponse();
|
|
7848
|
+
logHeaders(response, span);
|
|
7849
|
+
const { messages, ...rest } = params;
|
|
7850
|
+
span.log({
|
|
7851
|
+
input: messages,
|
|
7852
|
+
metadata: {
|
|
7853
|
+
...rest
|
|
7854
|
+
}
|
|
7855
|
+
});
|
|
7856
|
+
logCompletionResponse(startTime, ret, span);
|
|
7857
|
+
return { data: ret, response };
|
|
7858
|
+
} finally {
|
|
7859
|
+
span.end();
|
|
7860
|
+
}
|
|
6852
7861
|
}
|
|
6853
|
-
}
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
options
|
|
6866
|
-
).withResponse();
|
|
6867
|
-
logHeaders(response, span);
|
|
6868
|
-
const wrapperStream = new WrapperStream(span, startTime, ret.iterator());
|
|
6869
|
-
ret.iterator = () => wrapperStream[Symbol.asyncIterator]();
|
|
6870
|
-
return ret;
|
|
6871
|
-
} else {
|
|
6872
|
-
try {
|
|
6873
|
-
const completionResponse = completion(
|
|
6874
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
6875
|
-
params,
|
|
6876
|
-
options
|
|
6877
|
-
);
|
|
6878
|
-
const { data: ret, response } = await completionResponse.withResponse();
|
|
6879
|
-
logHeaders(response, span);
|
|
6880
|
-
const { messages, ...rest } = params;
|
|
6881
|
-
span.log({
|
|
6882
|
-
input: messages,
|
|
6883
|
-
metadata: {
|
|
6884
|
-
...rest
|
|
7862
|
+
})();
|
|
7863
|
+
}
|
|
7864
|
+
return executionPromise;
|
|
7865
|
+
};
|
|
7866
|
+
return new Proxy({}, {
|
|
7867
|
+
get(target, prop, receiver) {
|
|
7868
|
+
if (prop === "withResponse") {
|
|
7869
|
+
return () => ensureExecuted();
|
|
7870
|
+
}
|
|
7871
|
+
if (prop === "then" || prop === "catch" || prop === "finally" || prop in Promise.prototype) {
|
|
7872
|
+
if (!dataPromise) {
|
|
7873
|
+
dataPromise = ensureExecuted().then((result) => result.data);
|
|
6885
7874
|
}
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
span.end();
|
|
7875
|
+
const value = Reflect.get(dataPromise, prop, receiver);
|
|
7876
|
+
return typeof value === "function" ? value.bind(dataPromise) : value;
|
|
7877
|
+
}
|
|
7878
|
+
return Reflect.get(target, prop, receiver);
|
|
6891
7879
|
}
|
|
6892
|
-
}
|
|
7880
|
+
});
|
|
6893
7881
|
};
|
|
6894
7882
|
}
|
|
6895
7883
|
function parseBaseParams(allParams, inputField) {
|
|
@@ -6904,7 +7892,7 @@ function parseBaseParams(allParams, inputField) {
|
|
|
6904
7892
|
const input = params[inputField];
|
|
6905
7893
|
const paramsRest = { ...params, provider: "openai" };
|
|
6906
7894
|
delete paramsRest[inputField];
|
|
6907
|
-
return
|
|
7895
|
+
return mergeDicts(ret, { event: { input, metadata: paramsRest } });
|
|
6908
7896
|
}
|
|
6909
7897
|
function createApiWrapper(name, create, processResponse, parseParams) {
|
|
6910
7898
|
return async (allParams, options) => {
|
|
@@ -6919,11 +7907,11 @@ function createApiWrapper(name, create, processResponse, parseParams) {
|
|
|
6919
7907
|
processResponse(result, span);
|
|
6920
7908
|
return result;
|
|
6921
7909
|
},
|
|
6922
|
-
|
|
7910
|
+
mergeDicts(
|
|
6923
7911
|
{
|
|
6924
7912
|
name,
|
|
6925
7913
|
spanAttributes: {
|
|
6926
|
-
type:
|
|
7914
|
+
type: "llm" /* LLM */
|
|
6927
7915
|
}
|
|
6928
7916
|
},
|
|
6929
7917
|
parseParams(allParams)
|
|
@@ -6948,7 +7936,7 @@ function parseChatCompletionParams(params) {
|
|
|
6948
7936
|
function processEmbeddingResponse(result, span) {
|
|
6949
7937
|
span.log({
|
|
6950
7938
|
output: { embedding_length: result.data[0].embedding.length },
|
|
6951
|
-
metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess',
|
|
7939
|
+
metrics: parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _113 => _113.usage]))
|
|
6952
7940
|
});
|
|
6953
7941
|
}
|
|
6954
7942
|
function processModerationResponse(result, span) {
|
|
@@ -6978,10 +7966,10 @@ function postprocessStreamingResults(allResults) {
|
|
|
6978
7966
|
if (result.usage) {
|
|
6979
7967
|
metrics = {
|
|
6980
7968
|
...metrics,
|
|
6981
|
-
...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess',
|
|
7969
|
+
...parseMetricsFromUsage(_optionalChain([result, 'optionalAccess', _114 => _114.usage]))
|
|
6982
7970
|
};
|
|
6983
7971
|
}
|
|
6984
|
-
const delta = _optionalChain([result, 'access',
|
|
7972
|
+
const delta = _optionalChain([result, 'access', _115 => _115.choices, 'optionalAccess', _116 => _116[0], 'optionalAccess', _117 => _117.delta]);
|
|
6985
7973
|
if (!delta) {
|
|
6986
7974
|
continue;
|
|
6987
7975
|
}
|
|
@@ -7063,43 +8051,43 @@ var WrapperStream = class {
|
|
|
7063
8051
|
|
|
7064
8052
|
// dev/types.ts
|
|
7065
8053
|
|
|
7066
|
-
var evalBodySchema =
|
|
7067
|
-
name:
|
|
7068
|
-
parameters:
|
|
8054
|
+
var evalBodySchema = _v3.z.object({
|
|
8055
|
+
name: _v3.z.string(),
|
|
8056
|
+
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
7069
8057
|
data: RunEval.shape.data,
|
|
7070
|
-
scores:
|
|
7071
|
-
|
|
8058
|
+
scores: _v3.z.array(
|
|
8059
|
+
_v3.z.object({
|
|
7072
8060
|
function_id: FunctionId,
|
|
7073
|
-
name:
|
|
8061
|
+
name: _v3.z.string()
|
|
7074
8062
|
})
|
|
7075
8063
|
).nullish(),
|
|
7076
|
-
experiment_name:
|
|
7077
|
-
project_id:
|
|
8064
|
+
experiment_name: _v3.z.string().nullish(),
|
|
8065
|
+
project_id: _v3.z.string().nullish(),
|
|
7078
8066
|
parent: InvokeParent.optional(),
|
|
7079
|
-
stream:
|
|
8067
|
+
stream: _v3.z.boolean().optional()
|
|
7080
8068
|
});
|
|
7081
|
-
var evalParametersSerializedSchema =
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
type:
|
|
8069
|
+
var evalParametersSerializedSchema = _v3.z.record(
|
|
8070
|
+
_v3.z.string(),
|
|
8071
|
+
_v3.z.union([
|
|
8072
|
+
_v3.z.object({
|
|
8073
|
+
type: _v3.z.literal("prompt"),
|
|
7086
8074
|
default: PromptData.optional(),
|
|
7087
|
-
description:
|
|
8075
|
+
description: _v3.z.string().optional()
|
|
7088
8076
|
}),
|
|
7089
|
-
|
|
7090
|
-
type:
|
|
7091
|
-
schema:
|
|
8077
|
+
_v3.z.object({
|
|
8078
|
+
type: _v3.z.literal("data"),
|
|
8079
|
+
schema: _v3.z.record(_v3.z.unknown()),
|
|
7092
8080
|
// JSON Schema
|
|
7093
|
-
default:
|
|
7094
|
-
description:
|
|
8081
|
+
default: _v3.z.unknown().optional(),
|
|
8082
|
+
description: _v3.z.string().optional()
|
|
7095
8083
|
})
|
|
7096
8084
|
])
|
|
7097
8085
|
);
|
|
7098
|
-
var evaluatorDefinitionSchema =
|
|
8086
|
+
var evaluatorDefinitionSchema = _v3.z.object({
|
|
7099
8087
|
parameters: evalParametersSerializedSchema.optional()
|
|
7100
8088
|
});
|
|
7101
|
-
var evaluatorDefinitionsSchema =
|
|
7102
|
-
|
|
8089
|
+
var evaluatorDefinitionsSchema = _v3.z.record(
|
|
8090
|
+
_v3.z.string(),
|
|
7103
8091
|
evaluatorDefinitionSchema
|
|
7104
8092
|
);
|
|
7105
8093
|
|