braintrust 0.0.96 → 0.0.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3648,7 +3648,6 @@ var require_pluralize = __commonJS({
3648
3648
  var src_exports = {};
3649
3649
  __export(src_exports, {
3650
3650
  BaseExperiment: () => BaseExperiment,
3651
- Dataset: () => Dataset,
3652
3651
  Eval: () => Eval,
3653
3652
  Experiment: () => Experiment,
3654
3653
  Logger: () => Logger,
@@ -3664,6 +3663,7 @@ __export(src_exports, {
3664
3663
  getSpanParentObject: () => getSpanParentObject,
3665
3664
  init: () => init,
3666
3665
  initDataset: () => initDataset,
3666
+ initExperiment: () => initExperiment,
3667
3667
  initLogger: () => initLogger,
3668
3668
  log: () => log,
3669
3669
  login: () => login,
@@ -3695,7 +3695,7 @@ var DefaultAsyncLocalStorage = class {
3695
3695
  }
3696
3696
  };
3697
3697
  var iso = {
3698
- getRepoStatus: async (_settings) => void 0,
3698
+ getRepoInfo: async (_settings) => void 0,
3699
3699
  getPastNAncestors: async () => [],
3700
3700
  getEnv: (_name) => void 0,
3701
3701
  getCallerLocation: () => void 0,
@@ -7734,11 +7734,11 @@ function truncateToByteLimit(s, byteLimit = 65536) {
7734
7734
  const truncated = encoded.subarray(0, byteLimit);
7735
7735
  return new TextDecoder().decode(truncated);
7736
7736
  }
7737
- async function getRepoStatus(settings) {
7737
+ async function getRepoInfo(settings) {
7738
7738
  if (settings && settings.collect === "none") {
7739
7739
  return void 0;
7740
7740
  }
7741
- const repo = await repoStatus();
7741
+ const repo = await repoInfo();
7742
7742
  if (!repo || !settings || settings.collect === "all") {
7743
7743
  return repo;
7744
7744
  }
@@ -7748,7 +7748,7 @@ async function getRepoStatus(settings) {
7748
7748
  });
7749
7749
  return sanitized;
7750
7750
  }
7751
- async function repoStatus() {
7751
+ async function repoInfo() {
7752
7752
  const git = await currentRepo();
7753
7753
  if (git === null) {
7754
7754
  return void 0;
@@ -7890,9 +7890,10 @@ function v4(options, buf, offset) {
7890
7890
  }
7891
7891
  var v4_default = v4;
7892
7892
 
7893
- // ../core/js/dist/index.mjs
7893
+ // ../core/js/dist/main/index.mjs
7894
7894
  var TRANSACTION_ID_FIELD = "_xact_id";
7895
7895
  var IS_MERGE_FIELD = "_is_merge";
7896
+ var MERGE_PATHS_FIELD = "_merge_paths";
7896
7897
  var AUDIT_SOURCE_FIELD = "_audit_source";
7897
7898
  var AUDIT_METADATA_FIELD = "_audit_metadata";
7898
7899
  var VALID_SOURCES = ["app", "api", "external"];
@@ -7951,6 +7952,54 @@ function mergeRowBatch(rows) {
7951
7952
  out.push(...Object.values(rowGroups));
7952
7953
  return out;
7953
7954
  }
7955
+ var DEFAULT_IS_LEGACY_DATASET = true;
7956
+ function ensureDatasetRecord(r, legacy) {
7957
+ if (legacy) {
7958
+ return ensureLegacyDatasetRecord(r);
7959
+ } else {
7960
+ return ensureNewDatasetRecord(r);
7961
+ }
7962
+ }
7963
+ function ensureLegacyDatasetRecord(r) {
7964
+ if ("output" in r) {
7965
+ return r;
7966
+ }
7967
+ const row = {
7968
+ ...r,
7969
+ output: r.expected
7970
+ };
7971
+ delete row.expected;
7972
+ return row;
7973
+ }
7974
+ function ensureNewDatasetRecord(r) {
7975
+ if ("expected" in r) {
7976
+ return r;
7977
+ }
7978
+ const row = {
7979
+ ...r,
7980
+ expected: r.output
7981
+ };
7982
+ delete row.output;
7983
+ return row;
7984
+ }
7985
+ function makeLegacyEvent(e) {
7986
+ if (!("dataset_id" in e) || !("expected" in e)) {
7987
+ return e;
7988
+ }
7989
+ const event = {
7990
+ ...e,
7991
+ output: e.expected
7992
+ };
7993
+ delete event.expected;
7994
+ if (MERGE_PATHS_FIELD in event) {
7995
+ for (const path2 of event[MERGE_PATHS_FIELD] || []) {
7996
+ if (path2.length > 0 && path2[0] === "expected") {
7997
+ path2[0] = "output";
7998
+ }
7999
+ }
8000
+ }
8001
+ return event;
8002
+ }
7954
8003
  var SpanTypeAttribute = /* @__PURE__ */ ((SpanTypeAttribute2) => {
7955
8004
  SpanTypeAttribute2["LLM"] = "llm";
7956
8005
  SpanTypeAttribute2["SCORE"] = "score";
@@ -8416,6 +8465,9 @@ var MaxRequestSize = 6 * 1024 * 1024;
8416
8465
  function constructJsonArray(items) {
8417
8466
  return `[${items.join(",")}]`;
8418
8467
  }
8468
+ function constructLogs3Data(items) {
8469
+ return `{"rows": ${constructJsonArray(items)}, "api_version": 2}`;
8470
+ }
8419
8471
  var DefaultBatchSize = 100;
8420
8472
  var NumRetries = 3;
8421
8473
  function now() {
@@ -8474,11 +8526,20 @@ var BackgroundLogger = class {
8474
8526
  }
8475
8527
  postPromises.push(
8476
8528
  (async () => {
8477
- const itemsS = constructJsonArray(items);
8529
+ const dataS = constructLogs3Data(items);
8478
8530
  for (let i = 0; i < NumRetries; i++) {
8479
8531
  const startTime = now();
8480
8532
  try {
8481
- return (await (await this.logConn.get()).post_json("logs", itemsS)).map((res) => res.id);
8533
+ try {
8534
+ return (await (await this.logConn.get()).post_json("logs3", dataS)).ids.map((res) => res.id);
8535
+ } catch (e) {
8536
+ const legacyDataS = constructJsonArray(
8537
+ items.map(
8538
+ (r) => JSON.stringify(makeLegacyEvent(JSON.parse(r)))
8539
+ )
8540
+ );
8541
+ return (await (await this.logConn.get()).post_json("logs", legacyDataS)).map((res) => res.id);
8542
+ }
8482
8543
  } catch (e) {
8483
8544
  const retryingText = i + 1 === NumRetries ? "" : " Retrying";
8484
8545
  const errMsg = (() => {
@@ -8489,7 +8550,7 @@ var BackgroundLogger = class {
8489
8550
  }
8490
8551
  })();
8491
8552
  console.warn(
8492
- `log request failed. Elapsed time: ${(now() - startTime) / 1e3} seconds. Payload size: ${itemsS.length}. Error: ${errMsg}.${retryingText}`
8553
+ `log request failed. Elapsed time: ${(now() - startTime) / 1e3} seconds. Payload size: ${dataS.length}. Error: ${errMsg}.${retryingText}`
8493
8554
  );
8494
8555
  }
8495
8556
  }
@@ -8517,8 +8578,21 @@ var BackgroundLogger = class {
8517
8578
  }
8518
8579
  }
8519
8580
  };
8520
- function init(project, options = {}) {
8581
+ function init(projectOrOptions, optionalOptions) {
8582
+ const options = (() => {
8583
+ if (typeof projectOrOptions === "string") {
8584
+ return { ...optionalOptions, project: projectOrOptions };
8585
+ } else {
8586
+ if (optionalOptions !== void 0) {
8587
+ throw new Error(
8588
+ "Cannot specify options struct as both parameters. Must call either init(project, options) or init(options)."
8589
+ );
8590
+ }
8591
+ return projectOrOptions;
8592
+ }
8593
+ })();
8521
8594
  const {
8595
+ project,
8522
8596
  experiment,
8523
8597
  description,
8524
8598
  dataset,
@@ -8530,42 +8604,66 @@ function init(project, options = {}) {
8530
8604
  apiKey,
8531
8605
  orgName,
8532
8606
  metadata,
8533
- gitMetadataSettings
8534
- } = options || {};
8535
- if (open) {
8607
+ gitMetadataSettings,
8608
+ projectId,
8609
+ baseExperimentId,
8610
+ repoInfo: repoInfo2
8611
+ } = options;
8612
+ if (open && update) {
8613
+ throw new Error("Cannot open and update an experiment at the same time");
8614
+ }
8615
+ if (open || update) {
8536
8616
  if (isEmpty(experiment)) {
8537
- throw new Error("Cannot open an experiment without specifying its name");
8538
- }
8539
- if (update) {
8540
- throw new Error("Cannot open and update an experiment at the same time");
8617
+ const action = open ? "open" : "update";
8618
+ throw new Error(
8619
+ `Cannot ${action} an experiment without specifying its name`
8620
+ );
8541
8621
  }
8542
- const lazyMetadata2 = new LazyValue(async () => {
8543
- await login({
8544
- orgName,
8545
- apiKey,
8546
- appUrl
8547
- });
8548
- const args = {
8549
- project_name: project,
8550
- org_name: _state.orgName,
8551
- experiment_name: experiment
8552
- };
8553
- const response = await _state.apiConn().post_json("api/experiment/get", args);
8554
- if (response.length === 0) {
8555
- throw new Error(
8556
- `Experiment ${experiment} not found in project ${project}.`
8557
- );
8622
+ const lazyMetadata2 = new LazyValue(
8623
+ async () => {
8624
+ await login({
8625
+ orgName,
8626
+ apiKey,
8627
+ appUrl
8628
+ });
8629
+ const args = {
8630
+ project_name: project,
8631
+ project_id: projectId,
8632
+ org_name: _state.orgName,
8633
+ experiment_name: experiment
8634
+ };
8635
+ const response = await _state.apiConn().post_json("api/experiment/get", args);
8636
+ if (response.length === 0) {
8637
+ throw new Error(
8638
+ `Experiment ${experiment} not found in project ${projectId ?? project}.`
8639
+ );
8640
+ }
8641
+ const info = response[0];
8642
+ return {
8643
+ project: {
8644
+ id: info.project_id,
8645
+ name: "",
8646
+ fullInfo: {}
8647
+ },
8648
+ experiment: {
8649
+ id: info.id,
8650
+ name: info.name,
8651
+ fullInfo: info
8652
+ }
8653
+ };
8558
8654
  }
8559
- const info = response[0];
8560
- return {
8561
- id: info.id,
8562
- name: info.name,
8563
- fullInfo: info
8564
- };
8565
- });
8566
- return new ReadonlyExperiment(
8567
- lazyMetadata2
8568
8655
  );
8656
+ if (open) {
8657
+ return new ReadonlyExperiment(
8658
+ lazyMetadata2
8659
+ );
8660
+ } else {
8661
+ const ret2 = new Experiment(lazyMetadata2, dataset);
8662
+ if (options.setCurrent ?? true) {
8663
+ _state.currentExperiment = ret2;
8664
+ }
8665
+ return ret2;
8666
+ }
8569
8667
  }
8570
8668
  const lazyMetadata = new LazyValue(
8571
8669
  async () => {
@@ -8576,6 +8674,7 @@ function init(project, options = {}) {
8576
8674
  });
8577
8675
  const args = {
8578
8676
  project_name: project,
8677
+ project_id: projectId,
8579
8678
  org_id: _state.orgId
8580
8679
  };
8581
8680
  if (experiment) {
@@ -8584,25 +8683,29 @@ function init(project, options = {}) {
8584
8683
  if (description) {
8585
8684
  args["description"] = description;
8586
8685
  }
8587
- if (update) {
8588
- args["update"] = update;
8589
- }
8590
- let mergedGitMetadataSettings = {
8591
- ..._state.gitMetadataSettings || {
8592
- collect: "all"
8686
+ const repoInfoArg = await (async () => {
8687
+ if (repoInfo2) {
8688
+ return repoInfo2;
8593
8689
  }
8594
- };
8595
- if (gitMetadataSettings) {
8596
- mergedGitMetadataSettings = mergeGitMetadataSettings(
8597
- mergedGitMetadataSettings,
8598
- gitMetadataSettings
8599
- );
8600
- }
8601
- const repoStatus2 = await isomorph_default.getRepoStatus(gitMetadataSettings);
8602
- if (repoStatus2) {
8603
- args["repo_info"] = repoStatus2;
8690
+ let mergedGitMetadataSettings = {
8691
+ ..._state.gitMetadataSettings || {
8692
+ collect: "all"
8693
+ }
8694
+ };
8695
+ if (gitMetadataSettings) {
8696
+ mergedGitMetadataSettings = mergeGitMetadataSettings(
8697
+ mergedGitMetadataSettings,
8698
+ gitMetadataSettings
8699
+ );
8700
+ }
8701
+ return await isomorph_default.getRepoInfo(mergedGitMetadataSettings);
8702
+ })();
8703
+ if (repoInfoArg) {
8704
+ args["repo_info"] = repoInfoArg;
8604
8705
  }
8605
- if (baseExperiment) {
8706
+ if (baseExperimentId) {
8707
+ args["base_exp_id"] = baseExperimentId;
8708
+ } else if (baseExperiment) {
8606
8709
  args["base_experiment"] = baseExperiment;
8607
8710
  } else {
8608
8711
  args["ancestor_commits"] = await isomorph_default.getPastNAncestors();
@@ -8653,6 +8756,21 @@ function init(project, options = {}) {
8653
8756
  }
8654
8757
  return ret;
8655
8758
  }
8759
+ function initExperiment(projectOrOptions, optionalOptions) {
8760
+ const options = (() => {
8761
+ if (typeof projectOrOptions === "string") {
8762
+ return { ...optionalOptions, project: projectOrOptions };
8763
+ } else {
8764
+ if (optionalOptions !== void 0) {
8765
+ throw new Error(
8766
+ "Cannot specify options struct as both parameters. Must call either init(project, options) or init(options)."
8767
+ );
8768
+ }
8769
+ return projectOrOptions;
8770
+ }
8771
+ })();
8772
+ return init(options);
8773
+ }
8656
8774
  function withExperiment(project, callback, options = {}) {
8657
8775
  console.warn(
8658
8776
  "withExperiment is deprecated and will be removed in a future version of braintrust. Simply create the experiment with `init`."
@@ -8667,8 +8785,30 @@ function withLogger(callback, options = {}) {
8667
8785
  const logger = initLogger(options);
8668
8786
  return callback(logger);
8669
8787
  }
8670
- function initDataset(project, options = {}) {
8671
- const { dataset, description, version, appUrl, apiKey, orgName } = options || {};
8788
+ function initDataset(projectOrOptions, optionalOptions) {
8789
+ const options = (() => {
8790
+ if (typeof projectOrOptions === "string") {
8791
+ return { ...optionalOptions, project: projectOrOptions };
8792
+ } else {
8793
+ if (optionalOptions !== void 0) {
8794
+ throw new Error(
8795
+ "Cannot specify options struct as both parameters. Must call either initDataset(project, options) or initDataset(options)."
8796
+ );
8797
+ }
8798
+ return projectOrOptions;
8799
+ }
8800
+ })();
8801
+ const {
8802
+ project,
8803
+ dataset,
8804
+ description,
8805
+ version,
8806
+ appUrl,
8807
+ apiKey,
8808
+ orgName,
8809
+ projectId,
8810
+ useOutput: legacy
8811
+ } = options;
8672
8812
  const lazyMetadata = new LazyValue(
8673
8813
  async () => {
8674
8814
  await login({
@@ -8679,6 +8819,7 @@ function initDataset(project, options = {}) {
8679
8819
  const args = {
8680
8820
  org_id: _state.orgId,
8681
8821
  project_name: project,
8822
+ project_id: projectId,
8682
8823
  dataset_name: dataset,
8683
8824
  description
8684
8825
  };
@@ -8697,7 +8838,7 @@ function initDataset(project, options = {}) {
8697
8838
  };
8698
8839
  }
8699
8840
  );
8700
- return new Dataset(lazyMetadata, version);
8841
+ return new Dataset(lazyMetadata, version, legacy);
8701
8842
  }
8702
8843
  function withDataset(project, callback, options = {}) {
8703
8844
  console.warn(
@@ -8767,15 +8908,27 @@ function initLogger(options = {}) {
8767
8908
  return ret;
8768
8909
  }
8769
8910
  async function login(options = {}) {
8911
+ let { forceLogin = false } = options || {};
8912
+ if (_state.loggedIn && !forceLogin) {
8913
+ let checkUpdatedParam2 = function(varname, arg, orig) {
8914
+ if (!isEmpty(arg) && !isEmpty(orig) && arg !== orig) {
8915
+ throw new Error(
8916
+ `Re-logging in with different ${varname} (${arg}) than original (${orig}). To force re-login, pass \`forceLogin: true\``
8917
+ );
8918
+ }
8919
+ };
8920
+ var checkUpdatedParam = checkUpdatedParam2;
8921
+ ;
8922
+ checkUpdatedParam2("appUrl", options.appUrl, _state.appUrl);
8923
+ checkUpdatedParam2("apiKey", options.apiKey ? HTTPConnection.sanitize_token(options.apiKey) : void 0, _state.loginToken);
8924
+ checkUpdatedParam2("orgName", options.orgName, _state.orgName);
8925
+ return;
8926
+ }
8770
8927
  const {
8771
8928
  appUrl = isomorph_default.getEnv("BRAINTRUST_APP_URL") || "https://www.braintrustdata.com",
8772
8929
  apiKey = isomorph_default.getEnv("BRAINTRUST_API_KEY"),
8773
8930
  orgName = isomorph_default.getEnv("BRAINTRUST_ORG_NAME")
8774
8931
  } = options || {};
8775
- let { forceLogin = false } = options || {};
8776
- if (_state.loggedIn && !forceLogin) {
8777
- return;
8778
- }
8779
8932
  _state.resetLoginInfo();
8780
8933
  _state.appUrl = appUrl;
8781
8934
  let conn = null;
@@ -8984,9 +9137,10 @@ function validateAndSanitizeExperimentLogFullArgs(event, hasDataset) {
8984
9137
  return event;
8985
9138
  }
8986
9139
  var ObjectFetcher = class {
8987
- constructor(objectType, pinnedVersion) {
9140
+ constructor(objectType, pinnedVersion, mutateRecord) {
8988
9141
  this.objectType = objectType;
8989
9142
  this.pinnedVersion = pinnedVersion;
9143
+ this.mutateRecord = mutateRecord;
8990
9144
  this._fetchedData = void 0;
8991
9145
  }
8992
9146
  get id() {
@@ -9001,18 +9155,30 @@ var ObjectFetcher = class {
9001
9155
  yield record;
9002
9156
  }
9003
9157
  }
9004
- [Symbol.iterator]() {
9158
+ [Symbol.asyncIterator]() {
9005
9159
  return this.fetch();
9006
9160
  }
9007
9161
  async fetchedData() {
9008
9162
  if (this._fetchedData === void 0) {
9009
9163
  const state = await this.getState();
9010
- const resp = await state.logConn().get(`object/${this.objectType}`, {
9011
- id: await this.id,
9012
- fmt: "json2",
9013
- version: this.pinnedVersion
9014
- });
9015
- this._fetchedData = await resp.json();
9164
+ let data = void 0;
9165
+ try {
9166
+ const resp = await state.logConn().get(`object3/${this.objectType}`, {
9167
+ id: await this.id,
9168
+ fmt: "json2",
9169
+ version: this.pinnedVersion,
9170
+ api_version: "2"
9171
+ });
9172
+ data = await resp.json();
9173
+ } catch (e) {
9174
+ const resp = await state.logConn().get(`object/${this.objectType}`, {
9175
+ id: await this.id,
9176
+ fmt: "json2",
9177
+ version: this.pinnedVersion
9178
+ });
9179
+ data = await resp.json();
9180
+ }
9181
+ this._fetchedData = this.mutateRecord ? data?.map(this.mutateRecord) : data;
9016
9182
  }
9017
9183
  return this._fetchedData || [];
9018
9184
  }
@@ -9243,12 +9409,12 @@ var ReadonlyExperiment = class extends ObjectFetcher {
9243
9409
  }
9244
9410
  get id() {
9245
9411
  return (async () => {
9246
- return (await this.lazyMetadata.get()).id;
9412
+ return (await this.lazyMetadata.get()).experiment.id;
9247
9413
  })();
9248
9414
  }
9249
9415
  get name() {
9250
9416
  return (async () => {
9251
- return (await this.lazyMetadata.get()).name;
9417
+ return (await this.lazyMetadata.get()).experiment.name;
9252
9418
  })();
9253
9419
  }
9254
9420
  async getState() {
@@ -9261,11 +9427,18 @@ var ReadonlyExperiment = class extends ObjectFetcher {
9261
9427
  if (record.root_span_id !== record.span_id) {
9262
9428
  continue;
9263
9429
  }
9264
- const { output, expected } = record;
9265
- yield {
9266
- input: record.input,
9267
- expected: expected ?? output
9268
- };
9430
+ const { output, expected: expectedRecord } = record;
9431
+ const expected = expectedRecord ?? output;
9432
+ if (isEmpty(expected)) {
9433
+ yield {
9434
+ input: record.input
9435
+ };
9436
+ } else {
9437
+ yield {
9438
+ input: record.input,
9439
+ expected
9440
+ };
9441
+ }
9269
9442
  }
9270
9443
  }
9271
9444
  };
@@ -9398,8 +9571,18 @@ var SpanImpl = class _SpanImpl {
9398
9571
  }
9399
9572
  };
9400
9573
  var Dataset = class extends ObjectFetcher {
9401
- constructor(lazyMetadata, pinnedVersion) {
9402
- super("dataset", pinnedVersion);
9574
+ constructor(lazyMetadata, pinnedVersion, legacy) {
9575
+ const isLegacyDataset = legacy ?? DEFAULT_IS_LEGACY_DATASET;
9576
+ if (isLegacyDataset) {
9577
+ console.warn(
9578
+ `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.`
9579
+ );
9580
+ }
9581
+ super(
9582
+ "dataset",
9583
+ pinnedVersion,
9584
+ (r) => ensureDatasetRecord(r, isLegacyDataset)
9585
+ );
9403
9586
  this.lazyMetadata = lazyMetadata;
9404
9587
  const logConn = new LazyValue(
9405
9588
  () => this.getState().then((state) => state.logConn())
@@ -9431,19 +9614,21 @@ var Dataset = class extends ObjectFetcher {
9431
9614
  *
9432
9615
  * @param event The event to log.
9433
9616
  * @param event.input The argument that uniquely define an input case (an arbitrary, JSON serializable object).
9434
- * @param event.output The output of your application, including post-processing (an arbitrary, JSON serializable object).
9617
+ * @param event.expected The output of your application, including post-processing (an arbitrary, JSON serializable object).
9435
9618
  * @param event.metadata (Optional) a dictionary with additional data about the test example, model outputs, or just
9436
9619
  * about anything else that's relevant, that you can use to help find and analyze examples later. For example, you could log the
9437
9620
  * `prompt`, example's `id`, or anything else that would be useful to slice/dice later. The values in `metadata` can be any
9438
9621
  * JSON-serializable type, but its keys must be strings.
9439
9622
  * @param event.id (Optional) a unique identifier for the event. If you don't provide one, Braintrust will generate one for you.
9623
+ * @param event.output: (Deprecated) The output of your application. Use `expected` instead.
9440
9624
  * @returns The `id` of the logged record.
9441
9625
  */
9442
9626
  insert({
9443
9627
  input,
9444
- output,
9628
+ expected,
9445
9629
  metadata,
9446
- id
9630
+ id,
9631
+ output
9447
9632
  }) {
9448
9633
  if (metadata !== void 0) {
9449
9634
  for (const key of Object.keys(metadata)) {
@@ -9452,11 +9637,16 @@ var Dataset = class extends ObjectFetcher {
9452
9637
  }
9453
9638
  }
9454
9639
  }
9640
+ if (expected && output) {
9641
+ throw new Error(
9642
+ "Only one of expected or output (deprecated) can be specified. Prefer expected."
9643
+ );
9644
+ }
9455
9645
  const rowId = id || v4_default();
9456
9646
  const args = new LazyValue(async () => ({
9457
9647
  id: rowId,
9458
- inputs: input,
9459
- output,
9648
+ input,
9649
+ expected: expected === void 0 ? output : expected,
9460
9650
  project_id: (await this.project).id,
9461
9651
  dataset_id: await this.id,
9462
9652
  created: (/* @__PURE__ */ new Date()).toISOString(),
@@ -9527,7 +9717,7 @@ var Dataset = class extends ObjectFetcher {
9527
9717
 
9528
9718
  // src/node.ts
9529
9719
  function configureNode() {
9530
- isomorph_default.getRepoStatus = getRepoStatus;
9720
+ isomorph_default.getRepoInfo = getRepoInfo;
9531
9721
  isomorph_default.getPastNAncestors = getPastNAncestors;
9532
9722
  isomorph_default.getEnv = (name) => process.env[name];
9533
9723
  isomorph_default.getCallerLocation = getCallerLocation;
@@ -9589,7 +9779,7 @@ function makeEvalName(projectName, experimentName) {
9589
9779
  }
9590
9780
  return out;
9591
9781
  }
9592
- function initExperiment(projectName, options = {}) {
9782
+ function initExperiment2(projectName, options = {}) {
9593
9783
  return init(projectName, {
9594
9784
  ...options,
9595
9785
  setCurrent: false
@@ -9615,7 +9805,7 @@ async function Eval(name, evaluator) {
9615
9805
  }
9616
9806
  const progressReporter = new BarProgressReporter();
9617
9807
  try {
9618
- const experiment = initExperiment(name, {
9808
+ const experiment = initExperiment2(name, {
9619
9809
  experiment: evaluator.experimentName,
9620
9810
  metadata: evaluator.metadata,
9621
9811
  isPublic: evaluator.isPublic
@@ -9677,7 +9867,7 @@ async function runEvaluator(experiment, evaluator, progressReporter, filters) {
9677
9867
  }
9678
9868
  name = baseExperiment.name;
9679
9869
  }
9680
- dataResult = initExperiment(evaluator.projectName, {
9870
+ dataResult = initExperiment2(evaluator.projectName, {
9681
9871
  experiment: name,
9682
9872
  open: true
9683
9873
  }).asDataset();
@@ -9698,7 +9888,7 @@ async function runEvaluator(experiment, evaluator, progressReporter, filters) {
9698
9888
  );
9699
9889
  progressReporter.start(evaluator.evalName, data.length);
9700
9890
  const evals = data.map(async (datum) => {
9701
- let metadata = { ...datum.metadata };
9891
+ let metadata = { ..."metadata" in datum ? datum.metadata : {} };
9702
9892
  let output = void 0;
9703
9893
  let error2 = void 0;
9704
9894
  let scores = {};
@@ -9785,7 +9975,7 @@ async function runEvaluator(experiment, evaluator, progressReporter, filters) {
9785
9975
  },
9786
9976
  event: {
9787
9977
  input: datum.input,
9788
- expected: datum.expected
9978
+ expected: "expected" in datum ? datum.expected : void 0
9789
9979
  }
9790
9980
  });
9791
9981
  }
@@ -10105,7 +10295,6 @@ configureNode();
10105
10295
  // Annotate the CommonJS export names for ESM import in node:
10106
10296
  0 && (module.exports = {
10107
10297
  BaseExperiment,
10108
- Dataset,
10109
10298
  Eval,
10110
10299
  Experiment,
10111
10300
  Logger,
@@ -10121,6 +10310,7 @@ configureNode();
10121
10310
  getSpanParentObject,
10122
10311
  init,
10123
10312
  initDataset,
10313
+ initExperiment,
10124
10314
  initLogger,
10125
10315
  log,
10126
10316
  login,
@@ -1,4 +1,4 @@
1
- import { GitMetadataSettings, RepoStatus } from "@braintrust/core";
1
+ import { GitMetadataSettings, RepoInfo } from "@braintrust/core";
2
2
  export interface CallerLocation {
3
3
  caller_functionname: string;
4
4
  caller_filename: string;
@@ -10,7 +10,7 @@ export interface IsoAsyncLocalStorage<T> {
10
10
  getStore(): T | undefined;
11
11
  }
12
12
  export interface Common {
13
- getRepoStatus: (settings?: GitMetadataSettings) => Promise<RepoStatus | undefined>;
13
+ getRepoInfo: (settings?: GitMetadataSettings) => Promise<RepoInfo | undefined>;
14
14
  getPastNAncestors: () => Promise<string[]>;
15
15
  getEnv: (name: string) => string | undefined;
16
16
  getCallerLocation: () => CallerLocation | undefined;