braintrust 2.2.1 → 2.2.2
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.js +27 -5
- package/dev/dist/index.mjs +27 -5
- package/dist/browser.d.mts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +29 -5
- package/dist/browser.mjs +29 -5
- package/dist/cli.js +28 -6
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -5
- package/dist/index.mjs +29 -5
- package/package.json +1 -1
package/dev/dist/index.js
CHANGED
|
@@ -5274,12 +5274,19 @@ function updateSpanImpl({
|
|
|
5274
5274
|
parentObjectType,
|
|
5275
5275
|
parentObjectId,
|
|
5276
5276
|
id,
|
|
5277
|
+
root_span_id,
|
|
5278
|
+
span_id,
|
|
5277
5279
|
event
|
|
5278
5280
|
}) {
|
|
5281
|
+
if (isEmpty2(root_span_id) !== isEmpty2(span_id)) {
|
|
5282
|
+
throw new Error("both root_span_id and span_id must be set, or neither");
|
|
5283
|
+
}
|
|
5284
|
+
const hasExplicitSpanIds = root_span_id !== void 0 && span_id !== void 0;
|
|
5279
5285
|
const updateEvent = deepCopyEvent(
|
|
5280
5286
|
validateAndSanitizeExperimentLogPartialArgs({
|
|
5287
|
+
...event,
|
|
5281
5288
|
id,
|
|
5282
|
-
...
|
|
5289
|
+
...hasExplicitSpanIds ? { root_span_id, span_id } : {}
|
|
5283
5290
|
})
|
|
5284
5291
|
);
|
|
5285
5292
|
const parentIds = async () => new SpanComponentsV3({
|
|
@@ -5602,7 +5609,7 @@ var Logger = (_class7 = class {
|
|
|
5602
5609
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
5603
5610
|
*/
|
|
5604
5611
|
updateSpan(event) {
|
|
5605
|
-
const { id, ...eventRest } = event;
|
|
5612
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
5606
5613
|
if (!id) {
|
|
5607
5614
|
throw new Error("Span id is required to update a span");
|
|
5608
5615
|
}
|
|
@@ -5611,6 +5618,8 @@ var Logger = (_class7 = class {
|
|
|
5611
5618
|
parentObjectType: this.parentObjectType(),
|
|
5612
5619
|
parentObjectId: this.lazyId,
|
|
5613
5620
|
id,
|
|
5621
|
+
root_span_id,
|
|
5622
|
+
span_id,
|
|
5614
5623
|
event: eventRest
|
|
5615
5624
|
});
|
|
5616
5625
|
}
|
|
@@ -7294,7 +7303,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7294
7303
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
7295
7304
|
*/
|
|
7296
7305
|
updateSpan(event) {
|
|
7297
|
-
const { id, ...eventRest } = event;
|
|
7306
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
7298
7307
|
if (!id) {
|
|
7299
7308
|
throw new Error("Span id is required to update a span");
|
|
7300
7309
|
}
|
|
@@ -7303,6 +7312,8 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7303
7312
|
parentObjectType: this.parentObjectType(),
|
|
7304
7313
|
parentObjectId: this.lazyId,
|
|
7305
7314
|
id,
|
|
7315
|
+
root_span_id,
|
|
7316
|
+
span_id,
|
|
7306
7317
|
event: eventRest
|
|
7307
7318
|
});
|
|
7308
7319
|
}
|
|
@@ -11343,6 +11354,7 @@ var CodeParameters = class {
|
|
|
11343
11354
|
this.metadata = opts.metadata;
|
|
11344
11355
|
}
|
|
11345
11356
|
async toFunctionDefinition(projectNameToId) {
|
|
11357
|
+
const schema = serializeEvalParameterstoParametersSchema(this.schema);
|
|
11346
11358
|
return {
|
|
11347
11359
|
project_id: await projectNameToId.resolve(this.project),
|
|
11348
11360
|
name: this.name,
|
|
@@ -11351,8 +11363,8 @@ var CodeParameters = class {
|
|
|
11351
11363
|
function_type: "parameters",
|
|
11352
11364
|
function_data: {
|
|
11353
11365
|
type: "parameters",
|
|
11354
|
-
data:
|
|
11355
|
-
__schema:
|
|
11366
|
+
data: getDefaultDataFromParametersSchema(schema),
|
|
11367
|
+
__schema: schema
|
|
11356
11368
|
},
|
|
11357
11369
|
if_exists: this.ifExists,
|
|
11358
11370
|
metadata: this.metadata
|
|
@@ -11434,6 +11446,16 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
11434
11446
|
additionalProperties: true
|
|
11435
11447
|
};
|
|
11436
11448
|
}
|
|
11449
|
+
function getDefaultDataFromParametersSchema(schema) {
|
|
11450
|
+
return Object.fromEntries(
|
|
11451
|
+
Object.entries(schema.properties).flatMap(([name, value]) => {
|
|
11452
|
+
if (!("default" in value)) {
|
|
11453
|
+
return [];
|
|
11454
|
+
}
|
|
11455
|
+
return [[name, value.default]];
|
|
11456
|
+
})
|
|
11457
|
+
);
|
|
11458
|
+
}
|
|
11437
11459
|
function serializeRemoteEvalParametersContainer(parameters) {
|
|
11438
11460
|
if (RemoteEvalParameters.isParameters(parameters)) {
|
|
11439
11461
|
return {
|
package/dev/dist/index.mjs
CHANGED
|
@@ -5274,12 +5274,19 @@ function updateSpanImpl({
|
|
|
5274
5274
|
parentObjectType,
|
|
5275
5275
|
parentObjectId,
|
|
5276
5276
|
id,
|
|
5277
|
+
root_span_id,
|
|
5278
|
+
span_id,
|
|
5277
5279
|
event
|
|
5278
5280
|
}) {
|
|
5281
|
+
if (isEmpty2(root_span_id) !== isEmpty2(span_id)) {
|
|
5282
|
+
throw new Error("both root_span_id and span_id must be set, or neither");
|
|
5283
|
+
}
|
|
5284
|
+
const hasExplicitSpanIds = root_span_id !== void 0 && span_id !== void 0;
|
|
5279
5285
|
const updateEvent = deepCopyEvent(
|
|
5280
5286
|
validateAndSanitizeExperimentLogPartialArgs({
|
|
5287
|
+
...event,
|
|
5281
5288
|
id,
|
|
5282
|
-
...
|
|
5289
|
+
...hasExplicitSpanIds ? { root_span_id, span_id } : {}
|
|
5283
5290
|
})
|
|
5284
5291
|
);
|
|
5285
5292
|
const parentIds = async () => new SpanComponentsV3({
|
|
@@ -5602,7 +5609,7 @@ var Logger = class {
|
|
|
5602
5609
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
5603
5610
|
*/
|
|
5604
5611
|
updateSpan(event) {
|
|
5605
|
-
const { id, ...eventRest } = event;
|
|
5612
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
5606
5613
|
if (!id) {
|
|
5607
5614
|
throw new Error("Span id is required to update a span");
|
|
5608
5615
|
}
|
|
@@ -5611,6 +5618,8 @@ var Logger = class {
|
|
|
5611
5618
|
parentObjectType: this.parentObjectType(),
|
|
5612
5619
|
parentObjectId: this.lazyId,
|
|
5613
5620
|
id,
|
|
5621
|
+
root_span_id,
|
|
5622
|
+
span_id,
|
|
5614
5623
|
event: eventRest
|
|
5615
5624
|
});
|
|
5616
5625
|
}
|
|
@@ -7294,7 +7303,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7294
7303
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
7295
7304
|
*/
|
|
7296
7305
|
updateSpan(event) {
|
|
7297
|
-
const { id, ...eventRest } = event;
|
|
7306
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
7298
7307
|
if (!id) {
|
|
7299
7308
|
throw new Error("Span id is required to update a span");
|
|
7300
7309
|
}
|
|
@@ -7303,6 +7312,8 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7303
7312
|
parentObjectType: this.parentObjectType(),
|
|
7304
7313
|
parentObjectId: this.lazyId,
|
|
7305
7314
|
id,
|
|
7315
|
+
root_span_id,
|
|
7316
|
+
span_id,
|
|
7306
7317
|
event: eventRest
|
|
7307
7318
|
});
|
|
7308
7319
|
}
|
|
@@ -11343,6 +11354,7 @@ var CodeParameters = class {
|
|
|
11343
11354
|
this.metadata = opts.metadata;
|
|
11344
11355
|
}
|
|
11345
11356
|
async toFunctionDefinition(projectNameToId) {
|
|
11357
|
+
const schema = serializeEvalParameterstoParametersSchema(this.schema);
|
|
11346
11358
|
return {
|
|
11347
11359
|
project_id: await projectNameToId.resolve(this.project),
|
|
11348
11360
|
name: this.name,
|
|
@@ -11351,8 +11363,8 @@ var CodeParameters = class {
|
|
|
11351
11363
|
function_type: "parameters",
|
|
11352
11364
|
function_data: {
|
|
11353
11365
|
type: "parameters",
|
|
11354
|
-
data:
|
|
11355
|
-
__schema:
|
|
11366
|
+
data: getDefaultDataFromParametersSchema(schema),
|
|
11367
|
+
__schema: schema
|
|
11356
11368
|
},
|
|
11357
11369
|
if_exists: this.ifExists,
|
|
11358
11370
|
metadata: this.metadata
|
|
@@ -11434,6 +11446,16 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
11434
11446
|
additionalProperties: true
|
|
11435
11447
|
};
|
|
11436
11448
|
}
|
|
11449
|
+
function getDefaultDataFromParametersSchema(schema) {
|
|
11450
|
+
return Object.fromEntries(
|
|
11451
|
+
Object.entries(schema.properties).flatMap(([name, value]) => {
|
|
11452
|
+
if (!("default" in value)) {
|
|
11453
|
+
return [];
|
|
11454
|
+
}
|
|
11455
|
+
return [[name, value.default]];
|
|
11456
|
+
})
|
|
11457
|
+
);
|
|
11458
|
+
}
|
|
11437
11459
|
function serializeRemoteEvalParametersContainer(parameters) {
|
|
11438
11460
|
if (RemoteEvalParameters.isParameters(parameters)) {
|
|
11439
11461
|
return {
|
package/dist/browser.d.mts
CHANGED
|
@@ -19558,7 +19558,7 @@ declare class JSONAttachment extends Attachment {
|
|
|
19558
19558
|
*/
|
|
19559
19559
|
declare function updateSpan({ exported, state, ...event }: {
|
|
19560
19560
|
exported: string;
|
|
19561
|
-
} & Omit<Partial<ExperimentEvent>, "id"> & OptionalStateArg): void;
|
|
19561
|
+
} & Omit<Partial<ExperimentEvent>, "id" | "root_span_id" | "span_id"> & OptionalStateArg): void;
|
|
19562
19562
|
interface ParentSpanIds {
|
|
19563
19563
|
spanId: string;
|
|
19564
19564
|
rootSpanId: string;
|
package/dist/browser.d.ts
CHANGED
|
@@ -19558,7 +19558,7 @@ declare class JSONAttachment extends Attachment {
|
|
|
19558
19558
|
*/
|
|
19559
19559
|
declare function updateSpan({ exported, state, ...event }: {
|
|
19560
19560
|
exported: string;
|
|
19561
|
-
} & Omit<Partial<ExperimentEvent>, "id"> & OptionalStateArg): void;
|
|
19561
|
+
} & Omit<Partial<ExperimentEvent>, "id" | "root_span_id" | "span_id"> & OptionalStateArg): void;
|
|
19562
19562
|
interface ParentSpanIds {
|
|
19563
19563
|
spanId: string;
|
|
19564
19564
|
rootSpanId: string;
|
package/dist/browser.js
CHANGED
|
@@ -5188,12 +5188,19 @@ function updateSpanImpl({
|
|
|
5188
5188
|
parentObjectType,
|
|
5189
5189
|
parentObjectId,
|
|
5190
5190
|
id,
|
|
5191
|
+
root_span_id,
|
|
5192
|
+
span_id,
|
|
5191
5193
|
event
|
|
5192
5194
|
}) {
|
|
5195
|
+
if (isEmpty2(root_span_id) !== isEmpty2(span_id)) {
|
|
5196
|
+
throw new Error("both root_span_id and span_id must be set, or neither");
|
|
5197
|
+
}
|
|
5198
|
+
const hasExplicitSpanIds = root_span_id !== void 0 && span_id !== void 0;
|
|
5193
5199
|
const updateEvent = deepCopyEvent(
|
|
5194
5200
|
validateAndSanitizeExperimentLogPartialArgs({
|
|
5201
|
+
...event,
|
|
5195
5202
|
id,
|
|
5196
|
-
...
|
|
5203
|
+
...hasExplicitSpanIds ? { root_span_id, span_id } : {}
|
|
5197
5204
|
})
|
|
5198
5205
|
);
|
|
5199
5206
|
const parentIds = async () => new SpanComponentsV3({
|
|
@@ -5225,6 +5232,8 @@ function updateSpan({
|
|
|
5225
5232
|
spanComponentsToObjectIdLambda(resolvedState, components)
|
|
5226
5233
|
),
|
|
5227
5234
|
id: components.data.row_id,
|
|
5235
|
+
root_span_id: components.data.root_span_id,
|
|
5236
|
+
span_id: components.data.span_id,
|
|
5228
5237
|
event
|
|
5229
5238
|
});
|
|
5230
5239
|
}
|
|
@@ -5536,7 +5545,7 @@ var Logger = (_class7 = class {
|
|
|
5536
5545
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
5537
5546
|
*/
|
|
5538
5547
|
updateSpan(event) {
|
|
5539
|
-
const { id, ...eventRest } = event;
|
|
5548
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
5540
5549
|
if (!id) {
|
|
5541
5550
|
throw new Error("Span id is required to update a span");
|
|
5542
5551
|
}
|
|
@@ -5545,6 +5554,8 @@ var Logger = (_class7 = class {
|
|
|
5545
5554
|
parentObjectType: this.parentObjectType(),
|
|
5546
5555
|
parentObjectId: this.lazyId,
|
|
5547
5556
|
id,
|
|
5557
|
+
root_span_id,
|
|
5558
|
+
span_id,
|
|
5548
5559
|
event: eventRest
|
|
5549
5560
|
});
|
|
5550
5561
|
}
|
|
@@ -7827,7 +7838,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7827
7838
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
7828
7839
|
*/
|
|
7829
7840
|
updateSpan(event) {
|
|
7830
|
-
const { id, ...eventRest } = event;
|
|
7841
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
7831
7842
|
if (!id) {
|
|
7832
7843
|
throw new Error("Span id is required to update a span");
|
|
7833
7844
|
}
|
|
@@ -7836,6 +7847,8 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7836
7847
|
parentObjectType: this.parentObjectType(),
|
|
7837
7848
|
parentObjectId: this.lazyId,
|
|
7838
7849
|
id,
|
|
7850
|
+
root_span_id,
|
|
7851
|
+
span_id,
|
|
7839
7852
|
event: eventRest
|
|
7840
7853
|
});
|
|
7841
7854
|
}
|
|
@@ -16468,6 +16481,7 @@ var CodeParameters = class {
|
|
|
16468
16481
|
this.metadata = opts.metadata;
|
|
16469
16482
|
}
|
|
16470
16483
|
async toFunctionDefinition(projectNameToId) {
|
|
16484
|
+
const schema = serializeEvalParameterstoParametersSchema(this.schema);
|
|
16471
16485
|
return {
|
|
16472
16486
|
project_id: await projectNameToId.resolve(this.project),
|
|
16473
16487
|
name: this.name,
|
|
@@ -16476,8 +16490,8 @@ var CodeParameters = class {
|
|
|
16476
16490
|
function_type: "parameters",
|
|
16477
16491
|
function_data: {
|
|
16478
16492
|
type: "parameters",
|
|
16479
|
-
data:
|
|
16480
|
-
__schema:
|
|
16493
|
+
data: getDefaultDataFromParametersSchema(schema),
|
|
16494
|
+
__schema: schema
|
|
16481
16495
|
},
|
|
16482
16496
|
if_exists: this.ifExists,
|
|
16483
16497
|
metadata: this.metadata
|
|
@@ -16532,6 +16546,16 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
16532
16546
|
additionalProperties: true
|
|
16533
16547
|
};
|
|
16534
16548
|
}
|
|
16549
|
+
function getDefaultDataFromParametersSchema(schema) {
|
|
16550
|
+
return Object.fromEntries(
|
|
16551
|
+
Object.entries(schema.properties).flatMap(([name, value]) => {
|
|
16552
|
+
if (!("default" in value)) {
|
|
16553
|
+
return [];
|
|
16554
|
+
}
|
|
16555
|
+
return [[name, value.default]];
|
|
16556
|
+
})
|
|
16557
|
+
);
|
|
16558
|
+
}
|
|
16535
16559
|
var ProjectNameIdMap = (_class23 = class {constructor() { _class23.prototype.__init75.call(this);_class23.prototype.__init76.call(this); }
|
|
16536
16560
|
__init75() {this.nameToId = {}}
|
|
16537
16561
|
__init76() {this.idToName = {}}
|
package/dist/browser.mjs
CHANGED
|
@@ -5188,12 +5188,19 @@ function updateSpanImpl({
|
|
|
5188
5188
|
parentObjectType,
|
|
5189
5189
|
parentObjectId,
|
|
5190
5190
|
id,
|
|
5191
|
+
root_span_id,
|
|
5192
|
+
span_id,
|
|
5191
5193
|
event
|
|
5192
5194
|
}) {
|
|
5195
|
+
if (isEmpty2(root_span_id) !== isEmpty2(span_id)) {
|
|
5196
|
+
throw new Error("both root_span_id and span_id must be set, or neither");
|
|
5197
|
+
}
|
|
5198
|
+
const hasExplicitSpanIds = root_span_id !== void 0 && span_id !== void 0;
|
|
5193
5199
|
const updateEvent = deepCopyEvent(
|
|
5194
5200
|
validateAndSanitizeExperimentLogPartialArgs({
|
|
5201
|
+
...event,
|
|
5195
5202
|
id,
|
|
5196
|
-
...
|
|
5203
|
+
...hasExplicitSpanIds ? { root_span_id, span_id } : {}
|
|
5197
5204
|
})
|
|
5198
5205
|
);
|
|
5199
5206
|
const parentIds = async () => new SpanComponentsV3({
|
|
@@ -5225,6 +5232,8 @@ function updateSpan({
|
|
|
5225
5232
|
spanComponentsToObjectIdLambda(resolvedState, components)
|
|
5226
5233
|
),
|
|
5227
5234
|
id: components.data.row_id,
|
|
5235
|
+
root_span_id: components.data.root_span_id,
|
|
5236
|
+
span_id: components.data.span_id,
|
|
5228
5237
|
event
|
|
5229
5238
|
});
|
|
5230
5239
|
}
|
|
@@ -5536,7 +5545,7 @@ var Logger = class {
|
|
|
5536
5545
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
5537
5546
|
*/
|
|
5538
5547
|
updateSpan(event) {
|
|
5539
|
-
const { id, ...eventRest } = event;
|
|
5548
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
5540
5549
|
if (!id) {
|
|
5541
5550
|
throw new Error("Span id is required to update a span");
|
|
5542
5551
|
}
|
|
@@ -5545,6 +5554,8 @@ var Logger = class {
|
|
|
5545
5554
|
parentObjectType: this.parentObjectType(),
|
|
5546
5555
|
parentObjectId: this.lazyId,
|
|
5547
5556
|
id,
|
|
5557
|
+
root_span_id,
|
|
5558
|
+
span_id,
|
|
5548
5559
|
event: eventRest
|
|
5549
5560
|
});
|
|
5550
5561
|
}
|
|
@@ -7827,7 +7838,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7827
7838
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
7828
7839
|
*/
|
|
7829
7840
|
updateSpan(event) {
|
|
7830
|
-
const { id, ...eventRest } = event;
|
|
7841
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
7831
7842
|
if (!id) {
|
|
7832
7843
|
throw new Error("Span id is required to update a span");
|
|
7833
7844
|
}
|
|
@@ -7836,6 +7847,8 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
7836
7847
|
parentObjectType: this.parentObjectType(),
|
|
7837
7848
|
parentObjectId: this.lazyId,
|
|
7838
7849
|
id,
|
|
7850
|
+
root_span_id,
|
|
7851
|
+
span_id,
|
|
7839
7852
|
event: eventRest
|
|
7840
7853
|
});
|
|
7841
7854
|
}
|
|
@@ -16468,6 +16481,7 @@ var CodeParameters = class {
|
|
|
16468
16481
|
this.metadata = opts.metadata;
|
|
16469
16482
|
}
|
|
16470
16483
|
async toFunctionDefinition(projectNameToId) {
|
|
16484
|
+
const schema = serializeEvalParameterstoParametersSchema(this.schema);
|
|
16471
16485
|
return {
|
|
16472
16486
|
project_id: await projectNameToId.resolve(this.project),
|
|
16473
16487
|
name: this.name,
|
|
@@ -16476,8 +16490,8 @@ var CodeParameters = class {
|
|
|
16476
16490
|
function_type: "parameters",
|
|
16477
16491
|
function_data: {
|
|
16478
16492
|
type: "parameters",
|
|
16479
|
-
data:
|
|
16480
|
-
__schema:
|
|
16493
|
+
data: getDefaultDataFromParametersSchema(schema),
|
|
16494
|
+
__schema: schema
|
|
16481
16495
|
},
|
|
16482
16496
|
if_exists: this.ifExists,
|
|
16483
16497
|
metadata: this.metadata
|
|
@@ -16532,6 +16546,16 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
16532
16546
|
additionalProperties: true
|
|
16533
16547
|
};
|
|
16534
16548
|
}
|
|
16549
|
+
function getDefaultDataFromParametersSchema(schema) {
|
|
16550
|
+
return Object.fromEntries(
|
|
16551
|
+
Object.entries(schema.properties).flatMap(([name, value]) => {
|
|
16552
|
+
if (!("default" in value)) {
|
|
16553
|
+
return [];
|
|
16554
|
+
}
|
|
16555
|
+
return [[name, value.default]];
|
|
16556
|
+
})
|
|
16557
|
+
);
|
|
16558
|
+
}
|
|
16535
16559
|
var ProjectNameIdMap = class {
|
|
16536
16560
|
nameToId = {};
|
|
16537
16561
|
idToName = {};
|
package/dist/cli.js
CHANGED
|
@@ -1275,7 +1275,7 @@ var require_package = __commonJS({
|
|
|
1275
1275
|
"package.json"(exports2, module2) {
|
|
1276
1276
|
module2.exports = {
|
|
1277
1277
|
name: "braintrust",
|
|
1278
|
-
version: "2.2.
|
|
1278
|
+
version: "2.2.2",
|
|
1279
1279
|
description: "SDK for integrating Braintrust",
|
|
1280
1280
|
repository: {
|
|
1281
1281
|
type: "git",
|
|
@@ -6508,12 +6508,19 @@ function updateSpanImpl({
|
|
|
6508
6508
|
parentObjectType,
|
|
6509
6509
|
parentObjectId,
|
|
6510
6510
|
id,
|
|
6511
|
+
root_span_id,
|
|
6512
|
+
span_id,
|
|
6511
6513
|
event
|
|
6512
6514
|
}) {
|
|
6515
|
+
if (isEmpty2(root_span_id) !== isEmpty2(span_id)) {
|
|
6516
|
+
throw new Error("both root_span_id and span_id must be set, or neither");
|
|
6517
|
+
}
|
|
6518
|
+
const hasExplicitSpanIds = root_span_id !== void 0 && span_id !== void 0;
|
|
6513
6519
|
const updateEvent = deepCopyEvent(
|
|
6514
6520
|
validateAndSanitizeExperimentLogPartialArgs({
|
|
6521
|
+
...event,
|
|
6515
6522
|
id,
|
|
6516
|
-
...
|
|
6523
|
+
...hasExplicitSpanIds ? { root_span_id, span_id } : {}
|
|
6517
6524
|
})
|
|
6518
6525
|
);
|
|
6519
6526
|
const parentIds = async () => new SpanComponentsV3({
|
|
@@ -6836,7 +6843,7 @@ var Logger = class {
|
|
|
6836
6843
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
6837
6844
|
*/
|
|
6838
6845
|
updateSpan(event) {
|
|
6839
|
-
const { id, ...eventRest } = event;
|
|
6846
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
6840
6847
|
if (!id) {
|
|
6841
6848
|
throw new Error("Span id is required to update a span");
|
|
6842
6849
|
}
|
|
@@ -6845,6 +6852,8 @@ var Logger = class {
|
|
|
6845
6852
|
parentObjectType: this.parentObjectType(),
|
|
6846
6853
|
parentObjectId: this.lazyId,
|
|
6847
6854
|
id,
|
|
6855
|
+
root_span_id,
|
|
6856
|
+
span_id,
|
|
6848
6857
|
event: eventRest
|
|
6849
6858
|
});
|
|
6850
6859
|
}
|
|
@@ -8528,7 +8537,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
8528
8537
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
8529
8538
|
*/
|
|
8530
8539
|
updateSpan(event) {
|
|
8531
|
-
const { id, ...eventRest } = event;
|
|
8540
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
8532
8541
|
if (!id) {
|
|
8533
8542
|
throw new Error("Span id is required to update a span");
|
|
8534
8543
|
}
|
|
@@ -8537,6 +8546,8 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
8537
8546
|
parentObjectType: this.parentObjectType(),
|
|
8538
8547
|
parentObjectId: this.lazyId,
|
|
8539
8548
|
id,
|
|
8549
|
+
root_span_id,
|
|
8550
|
+
span_id,
|
|
8540
8551
|
event: eventRest
|
|
8541
8552
|
});
|
|
8542
8553
|
}
|
|
@@ -13028,6 +13039,7 @@ var CodeParameters = class {
|
|
|
13028
13039
|
this.metadata = opts.metadata;
|
|
13029
13040
|
}
|
|
13030
13041
|
async toFunctionDefinition(projectNameToId) {
|
|
13042
|
+
const schema = serializeEvalParameterstoParametersSchema(this.schema);
|
|
13031
13043
|
return {
|
|
13032
13044
|
project_id: await projectNameToId.resolve(this.project),
|
|
13033
13045
|
name: this.name,
|
|
@@ -13036,8 +13048,8 @@ var CodeParameters = class {
|
|
|
13036
13048
|
function_type: "parameters",
|
|
13037
13049
|
function_data: {
|
|
13038
13050
|
type: "parameters",
|
|
13039
|
-
data:
|
|
13040
|
-
__schema:
|
|
13051
|
+
data: getDefaultDataFromParametersSchema(schema),
|
|
13052
|
+
__schema: schema
|
|
13041
13053
|
},
|
|
13042
13054
|
if_exists: this.ifExists,
|
|
13043
13055
|
metadata: this.metadata
|
|
@@ -13119,6 +13131,16 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
13119
13131
|
additionalProperties: true
|
|
13120
13132
|
};
|
|
13121
13133
|
}
|
|
13134
|
+
function getDefaultDataFromParametersSchema(schema) {
|
|
13135
|
+
return Object.fromEntries(
|
|
13136
|
+
Object.entries(schema.properties).flatMap(([name, value]) => {
|
|
13137
|
+
if (!("default" in value)) {
|
|
13138
|
+
return [];
|
|
13139
|
+
}
|
|
13140
|
+
return [[name, value.default]];
|
|
13141
|
+
})
|
|
13142
|
+
);
|
|
13143
|
+
}
|
|
13122
13144
|
function serializeRemoteEvalParametersContainer(parameters) {
|
|
13123
13145
|
if (RemoteEvalParameters.isParameters(parameters)) {
|
|
13124
13146
|
return {
|
package/dist/index.d.mts
CHANGED
|
@@ -19558,7 +19558,7 @@ declare class JSONAttachment extends Attachment {
|
|
|
19558
19558
|
*/
|
|
19559
19559
|
declare function updateSpan({ exported, state, ...event }: {
|
|
19560
19560
|
exported: string;
|
|
19561
|
-
} & Omit<Partial<ExperimentEvent>, "id"> & OptionalStateArg): void;
|
|
19561
|
+
} & Omit<Partial<ExperimentEvent>, "id" | "root_span_id" | "span_id"> & OptionalStateArg): void;
|
|
19562
19562
|
interface ParentSpanIds {
|
|
19563
19563
|
spanId: string;
|
|
19564
19564
|
rootSpanId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -19558,7 +19558,7 @@ declare class JSONAttachment extends Attachment {
|
|
|
19558
19558
|
*/
|
|
19559
19559
|
declare function updateSpan({ exported, state, ...event }: {
|
|
19560
19560
|
exported: string;
|
|
19561
|
-
} & Omit<Partial<ExperimentEvent>, "id"> & OptionalStateArg): void;
|
|
19561
|
+
} & Omit<Partial<ExperimentEvent>, "id" | "root_span_id" | "span_id"> & OptionalStateArg): void;
|
|
19562
19562
|
interface ParentSpanIds {
|
|
19563
19563
|
spanId: string;
|
|
19564
19564
|
rootSpanId: string;
|
package/dist/index.js
CHANGED
|
@@ -5410,12 +5410,19 @@ function updateSpanImpl({
|
|
|
5410
5410
|
parentObjectType,
|
|
5411
5411
|
parentObjectId,
|
|
5412
5412
|
id,
|
|
5413
|
+
root_span_id,
|
|
5414
|
+
span_id,
|
|
5413
5415
|
event
|
|
5414
5416
|
}) {
|
|
5417
|
+
if (isEmpty2(root_span_id) !== isEmpty2(span_id)) {
|
|
5418
|
+
throw new Error("both root_span_id and span_id must be set, or neither");
|
|
5419
|
+
}
|
|
5420
|
+
const hasExplicitSpanIds = root_span_id !== void 0 && span_id !== void 0;
|
|
5415
5421
|
const updateEvent = deepCopyEvent(
|
|
5416
5422
|
validateAndSanitizeExperimentLogPartialArgs({
|
|
5423
|
+
...event,
|
|
5417
5424
|
id,
|
|
5418
|
-
...
|
|
5425
|
+
...hasExplicitSpanIds ? { root_span_id, span_id } : {}
|
|
5419
5426
|
})
|
|
5420
5427
|
);
|
|
5421
5428
|
const parentIds = async () => new SpanComponentsV3({
|
|
@@ -5447,6 +5454,8 @@ function updateSpan({
|
|
|
5447
5454
|
spanComponentsToObjectIdLambda(resolvedState, components)
|
|
5448
5455
|
),
|
|
5449
5456
|
id: components.data.row_id,
|
|
5457
|
+
root_span_id: components.data.root_span_id,
|
|
5458
|
+
span_id: components.data.span_id,
|
|
5450
5459
|
event
|
|
5451
5460
|
});
|
|
5452
5461
|
}
|
|
@@ -5758,7 +5767,7 @@ var Logger = (_class7 = class {
|
|
|
5758
5767
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
5759
5768
|
*/
|
|
5760
5769
|
updateSpan(event) {
|
|
5761
|
-
const { id, ...eventRest } = event;
|
|
5770
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
5762
5771
|
if (!id) {
|
|
5763
5772
|
throw new Error("Span id is required to update a span");
|
|
5764
5773
|
}
|
|
@@ -5767,6 +5776,8 @@ var Logger = (_class7 = class {
|
|
|
5767
5776
|
parentObjectType: this.parentObjectType(),
|
|
5768
5777
|
parentObjectId: this.lazyId,
|
|
5769
5778
|
id,
|
|
5779
|
+
root_span_id,
|
|
5780
|
+
span_id,
|
|
5770
5781
|
event: eventRest
|
|
5771
5782
|
});
|
|
5772
5783
|
}
|
|
@@ -8049,7 +8060,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
8049
8060
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
8050
8061
|
*/
|
|
8051
8062
|
updateSpan(event) {
|
|
8052
|
-
const { id, ...eventRest } = event;
|
|
8063
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
8053
8064
|
if (!id) {
|
|
8054
8065
|
throw new Error("Span id is required to update a span");
|
|
8055
8066
|
}
|
|
@@ -8058,6 +8069,8 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
8058
8069
|
parentObjectType: this.parentObjectType(),
|
|
8059
8070
|
parentObjectId: this.lazyId,
|
|
8060
8071
|
id,
|
|
8072
|
+
root_span_id,
|
|
8073
|
+
span_id,
|
|
8061
8074
|
event: eventRest
|
|
8062
8075
|
});
|
|
8063
8076
|
}
|
|
@@ -16695,6 +16708,7 @@ var CodeParameters = class {
|
|
|
16695
16708
|
this.metadata = opts.metadata;
|
|
16696
16709
|
}
|
|
16697
16710
|
async toFunctionDefinition(projectNameToId) {
|
|
16711
|
+
const schema = serializeEvalParameterstoParametersSchema(this.schema);
|
|
16698
16712
|
return {
|
|
16699
16713
|
project_id: await projectNameToId.resolve(this.project),
|
|
16700
16714
|
name: this.name,
|
|
@@ -16703,8 +16717,8 @@ var CodeParameters = class {
|
|
|
16703
16717
|
function_type: "parameters",
|
|
16704
16718
|
function_data: {
|
|
16705
16719
|
type: "parameters",
|
|
16706
|
-
data:
|
|
16707
|
-
__schema:
|
|
16720
|
+
data: getDefaultDataFromParametersSchema(schema),
|
|
16721
|
+
__schema: schema
|
|
16708
16722
|
},
|
|
16709
16723
|
if_exists: this.ifExists,
|
|
16710
16724
|
metadata: this.metadata
|
|
@@ -16759,6 +16773,16 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
16759
16773
|
additionalProperties: true
|
|
16760
16774
|
};
|
|
16761
16775
|
}
|
|
16776
|
+
function getDefaultDataFromParametersSchema(schema) {
|
|
16777
|
+
return Object.fromEntries(
|
|
16778
|
+
Object.entries(schema.properties).flatMap(([name, value]) => {
|
|
16779
|
+
if (!("default" in value)) {
|
|
16780
|
+
return [];
|
|
16781
|
+
}
|
|
16782
|
+
return [[name, value.default]];
|
|
16783
|
+
})
|
|
16784
|
+
);
|
|
16785
|
+
}
|
|
16762
16786
|
var ProjectNameIdMap = (_class23 = class {constructor() { _class23.prototype.__init75.call(this);_class23.prototype.__init76.call(this); }
|
|
16763
16787
|
__init75() {this.nameToId = {}}
|
|
16764
16788
|
__init76() {this.idToName = {}}
|
package/dist/index.mjs
CHANGED
|
@@ -5410,12 +5410,19 @@ function updateSpanImpl({
|
|
|
5410
5410
|
parentObjectType,
|
|
5411
5411
|
parentObjectId,
|
|
5412
5412
|
id,
|
|
5413
|
+
root_span_id,
|
|
5414
|
+
span_id,
|
|
5413
5415
|
event
|
|
5414
5416
|
}) {
|
|
5417
|
+
if (isEmpty2(root_span_id) !== isEmpty2(span_id)) {
|
|
5418
|
+
throw new Error("both root_span_id and span_id must be set, or neither");
|
|
5419
|
+
}
|
|
5420
|
+
const hasExplicitSpanIds = root_span_id !== void 0 && span_id !== void 0;
|
|
5415
5421
|
const updateEvent = deepCopyEvent(
|
|
5416
5422
|
validateAndSanitizeExperimentLogPartialArgs({
|
|
5423
|
+
...event,
|
|
5417
5424
|
id,
|
|
5418
|
-
...
|
|
5425
|
+
...hasExplicitSpanIds ? { root_span_id, span_id } : {}
|
|
5419
5426
|
})
|
|
5420
5427
|
);
|
|
5421
5428
|
const parentIds = async () => new SpanComponentsV3({
|
|
@@ -5447,6 +5454,8 @@ function updateSpan({
|
|
|
5447
5454
|
spanComponentsToObjectIdLambda(resolvedState, components)
|
|
5448
5455
|
),
|
|
5449
5456
|
id: components.data.row_id,
|
|
5457
|
+
root_span_id: components.data.root_span_id,
|
|
5458
|
+
span_id: components.data.span_id,
|
|
5450
5459
|
event
|
|
5451
5460
|
});
|
|
5452
5461
|
}
|
|
@@ -5758,7 +5767,7 @@ var Logger = class {
|
|
|
5758
5767
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
5759
5768
|
*/
|
|
5760
5769
|
updateSpan(event) {
|
|
5761
|
-
const { id, ...eventRest } = event;
|
|
5770
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
5762
5771
|
if (!id) {
|
|
5763
5772
|
throw new Error("Span id is required to update a span");
|
|
5764
5773
|
}
|
|
@@ -5767,6 +5776,8 @@ var Logger = class {
|
|
|
5767
5776
|
parentObjectType: this.parentObjectType(),
|
|
5768
5777
|
parentObjectId: this.lazyId,
|
|
5769
5778
|
id,
|
|
5779
|
+
root_span_id,
|
|
5780
|
+
span_id,
|
|
5770
5781
|
event: eventRest
|
|
5771
5782
|
});
|
|
5772
5783
|
}
|
|
@@ -8049,7 +8060,7 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
8049
8060
|
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
8050
8061
|
*/
|
|
8051
8062
|
updateSpan(event) {
|
|
8052
|
-
const { id, ...eventRest } = event;
|
|
8063
|
+
const { id, root_span_id, span_id, ...eventRest } = event;
|
|
8053
8064
|
if (!id) {
|
|
8054
8065
|
throw new Error("Span id is required to update a span");
|
|
8055
8066
|
}
|
|
@@ -8058,6 +8069,8 @@ View complete results in Braintrust or run experiment.summarize() again.`
|
|
|
8058
8069
|
parentObjectType: this.parentObjectType(),
|
|
8059
8070
|
parentObjectId: this.lazyId,
|
|
8060
8071
|
id,
|
|
8072
|
+
root_span_id,
|
|
8073
|
+
span_id,
|
|
8061
8074
|
event: eventRest
|
|
8062
8075
|
});
|
|
8063
8076
|
}
|
|
@@ -16695,6 +16708,7 @@ var CodeParameters = class {
|
|
|
16695
16708
|
this.metadata = opts.metadata;
|
|
16696
16709
|
}
|
|
16697
16710
|
async toFunctionDefinition(projectNameToId) {
|
|
16711
|
+
const schema = serializeEvalParameterstoParametersSchema(this.schema);
|
|
16698
16712
|
return {
|
|
16699
16713
|
project_id: await projectNameToId.resolve(this.project),
|
|
16700
16714
|
name: this.name,
|
|
@@ -16703,8 +16717,8 @@ var CodeParameters = class {
|
|
|
16703
16717
|
function_type: "parameters",
|
|
16704
16718
|
function_data: {
|
|
16705
16719
|
type: "parameters",
|
|
16706
|
-
data:
|
|
16707
|
-
__schema:
|
|
16720
|
+
data: getDefaultDataFromParametersSchema(schema),
|
|
16721
|
+
__schema: schema
|
|
16708
16722
|
},
|
|
16709
16723
|
if_exists: this.ifExists,
|
|
16710
16724
|
metadata: this.metadata
|
|
@@ -16759,6 +16773,16 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
16759
16773
|
additionalProperties: true
|
|
16760
16774
|
};
|
|
16761
16775
|
}
|
|
16776
|
+
function getDefaultDataFromParametersSchema(schema) {
|
|
16777
|
+
return Object.fromEntries(
|
|
16778
|
+
Object.entries(schema.properties).flatMap(([name, value]) => {
|
|
16779
|
+
if (!("default" in value)) {
|
|
16780
|
+
return [];
|
|
16781
|
+
}
|
|
16782
|
+
return [[name, value.default]];
|
|
16783
|
+
})
|
|
16784
|
+
);
|
|
16785
|
+
}
|
|
16762
16786
|
var ProjectNameIdMap = class {
|
|
16763
16787
|
nameToId = {};
|
|
16764
16788
|
idToName = {};
|