braintrust 0.0.183 → 0.0.184

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.
@@ -13,7 +13,7 @@ declare class LazyValue<T> {
13
13
  private value;
14
14
  constructor(callable: () => Promise<T>);
15
15
  get(): Promise<T>;
16
- get hasComputed(): boolean;
16
+ get hasSucceeded(): boolean;
17
17
  }
18
18
 
19
19
  /**
package/dist/browser.d.ts CHANGED
@@ -13,7 +13,7 @@ declare class LazyValue<T> {
13
13
  private value;
14
14
  constructor(callable: () => Promise<T>);
15
15
  get(): Promise<T>;
16
- get hasComputed(): boolean;
16
+ get hasSucceeded(): boolean;
17
17
  }
18
18
 
19
19
  /**
package/dist/browser.js CHANGED
@@ -148,20 +148,28 @@ function isEmpty(a) {
148
148
  var LazyValue = class {
149
149
  callable;
150
150
  value = {
151
- hasComputed: false
151
+ computedState: "uninitialized"
152
152
  };
153
153
  constructor(callable) {
154
154
  this.callable = callable;
155
155
  }
156
156
  get() {
157
- if (this.value.hasComputed) {
157
+ if (this.value.computedState !== "uninitialized") {
158
158
  return this.value.val;
159
159
  }
160
- this.value = { hasComputed: true, val: this.callable() };
160
+ this.value = {
161
+ computedState: "in_progress",
162
+ val: this.callable().then((x) => {
163
+ this.value.computedState = "succeeded";
164
+ return x;
165
+ })
166
+ };
161
167
  return this.value.val;
162
168
  }
163
- get hasComputed() {
164
- return this.value.hasComputed;
169
+ // If this is true, the caller should be able to obtain the LazyValue without
170
+ // it throwing.
171
+ get hasSucceeded() {
172
+ return this.value.computedState === "succeeded";
165
173
  }
166
174
  };
167
175
 
@@ -1636,7 +1644,7 @@ var Logger = class {
1636
1644
  async export() {
1637
1645
  return new import_core.SpanComponentsV3({
1638
1646
  object_type: this.parentObjectType(),
1639
- ...this.computeMetadataArgs && !this.lazyId.hasComputed ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
1647
+ ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
1640
1648
  }).toStr();
1641
1649
  }
1642
1650
  /*
@@ -3371,7 +3379,7 @@ var SpanImpl = class _SpanImpl {
3371
3379
  async export() {
3372
3380
  return new import_core.SpanComponentsV3({
3373
3381
  object_type: this.parentObjectType,
3374
- ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasComputed ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
3382
+ ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
3375
3383
  row_id: this.id,
3376
3384
  span_id: this.spanId,
3377
3385
  root_span_id: this.rootSpanId,
package/dist/browser.mjs CHANGED
@@ -90,20 +90,28 @@ function isEmpty(a) {
90
90
  var LazyValue = class {
91
91
  callable;
92
92
  value = {
93
- hasComputed: false
93
+ computedState: "uninitialized"
94
94
  };
95
95
  constructor(callable) {
96
96
  this.callable = callable;
97
97
  }
98
98
  get() {
99
- if (this.value.hasComputed) {
99
+ if (this.value.computedState !== "uninitialized") {
100
100
  return this.value.val;
101
101
  }
102
- this.value = { hasComputed: true, val: this.callable() };
102
+ this.value = {
103
+ computedState: "in_progress",
104
+ val: this.callable().then((x) => {
105
+ this.value.computedState = "succeeded";
106
+ return x;
107
+ })
108
+ };
103
109
  return this.value.val;
104
110
  }
105
- get hasComputed() {
106
- return this.value.hasComputed;
111
+ // If this is true, the caller should be able to obtain the LazyValue without
112
+ // it throwing.
113
+ get hasSucceeded() {
114
+ return this.value.computedState === "succeeded";
107
115
  }
108
116
  };
109
117
 
@@ -1584,7 +1592,7 @@ var Logger = class {
1584
1592
  async export() {
1585
1593
  return new SpanComponentsV3({
1586
1594
  object_type: this.parentObjectType(),
1587
- ...this.computeMetadataArgs && !this.lazyId.hasComputed ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
1595
+ ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
1588
1596
  }).toStr();
1589
1597
  }
1590
1598
  /*
@@ -3319,7 +3327,7 @@ var SpanImpl = class _SpanImpl {
3319
3327
  async export() {
3320
3328
  return new SpanComponentsV3({
3321
3329
  object_type: this.parentObjectType,
3322
- ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasComputed ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
3330
+ ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
3323
3331
  row_id: this.id,
3324
3332
  span_id: this.spanId,
3325
3333
  root_span_id: this.rootSpanId,
package/dist/cli.js CHANGED
@@ -1236,7 +1236,7 @@ var require_package = __commonJS({
1236
1236
  "package.json"(exports2, module2) {
1237
1237
  module2.exports = {
1238
1238
  name: "braintrust",
1239
- version: "0.0.183",
1239
+ version: "0.0.184",
1240
1240
  description: "SDK for integrating Braintrust",
1241
1241
  repository: {
1242
1242
  type: "git",
@@ -1311,7 +1311,7 @@ var require_package = __commonJS({
1311
1311
  },
1312
1312
  dependencies: {
1313
1313
  "@ai-sdk/provider": "^1.0.1",
1314
- "@braintrust/core": "0.0.77",
1314
+ "@braintrust/core": "0.0.78",
1315
1315
  "@next/env": "^14.2.3",
1316
1316
  "@vercel/functions": "^1.0.2",
1317
1317
  ai: "^3.2.16",
@@ -1416,20 +1416,28 @@ function isEmpty(a) {
1416
1416
  var LazyValue = class {
1417
1417
  callable;
1418
1418
  value = {
1419
- hasComputed: false
1419
+ computedState: "uninitialized"
1420
1420
  };
1421
1421
  constructor(callable) {
1422
1422
  this.callable = callable;
1423
1423
  }
1424
1424
  get() {
1425
- if (this.value.hasComputed) {
1425
+ if (this.value.computedState !== "uninitialized") {
1426
1426
  return this.value.val;
1427
1427
  }
1428
- this.value = { hasComputed: true, val: this.callable() };
1428
+ this.value = {
1429
+ computedState: "in_progress",
1430
+ val: this.callable().then((x) => {
1431
+ this.value.computedState = "succeeded";
1432
+ return x;
1433
+ })
1434
+ };
1429
1435
  return this.value.val;
1430
1436
  }
1431
- get hasComputed() {
1432
- return this.value.hasComputed;
1437
+ // If this is true, the caller should be able to obtain the LazyValue without
1438
+ // it throwing.
1439
+ get hasSucceeded() {
1440
+ return this.value.computedState === "succeeded";
1433
1441
  }
1434
1442
  };
1435
1443
 
@@ -2884,7 +2892,7 @@ var Logger = class {
2884
2892
  async export() {
2885
2893
  return new import_core.SpanComponentsV3({
2886
2894
  object_type: this.parentObjectType(),
2887
- ...this.computeMetadataArgs && !this.lazyId.hasComputed ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
2895
+ ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
2888
2896
  }).toStr();
2889
2897
  }
2890
2898
  /*
@@ -4338,7 +4346,7 @@ var SpanImpl = class _SpanImpl {
4338
4346
  async export() {
4339
4347
  return new import_core.SpanComponentsV3({
4340
4348
  object_type: this.parentObjectType,
4341
- ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasComputed ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
4349
+ ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
4342
4350
  row_id: this.id,
4343
4351
  span_id: this.spanId,
4344
4352
  root_span_id: this.rootSpanId,
package/dist/index.d.mts CHANGED
@@ -15,7 +15,7 @@ declare class LazyValue<T> {
15
15
  private value;
16
16
  constructor(callable: () => Promise<T>);
17
17
  get(): Promise<T>;
18
- get hasComputed(): boolean;
18
+ get hasSucceeded(): boolean;
19
19
  }
20
20
 
21
21
  /**
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ declare class LazyValue<T> {
15
15
  private value;
16
16
  constructor(callable: () => Promise<T>);
17
17
  get(): Promise<T>;
18
- get hasComputed(): boolean;
18
+ get hasSucceeded(): boolean;
19
19
  }
20
20
 
21
21
  /**
package/dist/index.js CHANGED
@@ -384,20 +384,28 @@ function isEmpty(a) {
384
384
  var LazyValue = class {
385
385
  callable;
386
386
  value = {
387
- hasComputed: false
387
+ computedState: "uninitialized"
388
388
  };
389
389
  constructor(callable) {
390
390
  this.callable = callable;
391
391
  }
392
392
  get() {
393
- if (this.value.hasComputed) {
393
+ if (this.value.computedState !== "uninitialized") {
394
394
  return this.value.val;
395
395
  }
396
- this.value = { hasComputed: true, val: this.callable() };
396
+ this.value = {
397
+ computedState: "in_progress",
398
+ val: this.callable().then((x) => {
399
+ this.value.computedState = "succeeded";
400
+ return x;
401
+ })
402
+ };
397
403
  return this.value.val;
398
404
  }
399
- get hasComputed() {
400
- return this.value.hasComputed;
405
+ // If this is true, the caller should be able to obtain the LazyValue without
406
+ // it throwing.
407
+ get hasSucceeded() {
408
+ return this.value.computedState === "succeeded";
401
409
  }
402
410
  };
403
411
 
@@ -1872,7 +1880,7 @@ var Logger = class {
1872
1880
  async export() {
1873
1881
  return new import_core.SpanComponentsV3({
1874
1882
  object_type: this.parentObjectType(),
1875
- ...this.computeMetadataArgs && !this.lazyId.hasComputed ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
1883
+ ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
1876
1884
  }).toStr();
1877
1885
  }
1878
1886
  /*
@@ -3607,7 +3615,7 @@ var SpanImpl = class _SpanImpl {
3607
3615
  async export() {
3608
3616
  return new import_core.SpanComponentsV3({
3609
3617
  object_type: this.parentObjectType,
3610
- ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasComputed ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
3618
+ ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
3611
3619
  row_id: this.id,
3612
3620
  span_id: this.spanId,
3613
3621
  root_span_id: this.rootSpanId,
@@ -6780,14 +6788,16 @@ function postProcessPrompt(prompt) {
6780
6788
  {
6781
6789
  role: "assistant",
6782
6790
  content: textPart?.text,
6783
- tool_calls: toolCallParts.map((part) => ({
6784
- id: part.toolCallId,
6785
- function: {
6786
- name: part.toolName,
6787
- arguments: JSON.stringify(part.args)
6788
- },
6789
- type: "function"
6790
- }))
6791
+ ...toolCallParts.length > 0 ? {
6792
+ tool_calls: toolCallParts.map((part) => ({
6793
+ id: part.toolCallId,
6794
+ function: {
6795
+ name: part.toolName,
6796
+ arguments: JSON.stringify(part.args)
6797
+ },
6798
+ type: "function"
6799
+ }))
6800
+ } : {}
6791
6801
  }
6792
6802
  ];
6793
6803
  case "user":
package/dist/index.mjs CHANGED
@@ -310,20 +310,28 @@ function isEmpty(a) {
310
310
  var LazyValue = class {
311
311
  callable;
312
312
  value = {
313
- hasComputed: false
313
+ computedState: "uninitialized"
314
314
  };
315
315
  constructor(callable) {
316
316
  this.callable = callable;
317
317
  }
318
318
  get() {
319
- if (this.value.hasComputed) {
319
+ if (this.value.computedState !== "uninitialized") {
320
320
  return this.value.val;
321
321
  }
322
- this.value = { hasComputed: true, val: this.callable() };
322
+ this.value = {
323
+ computedState: "in_progress",
324
+ val: this.callable().then((x) => {
325
+ this.value.computedState = "succeeded";
326
+ return x;
327
+ })
328
+ };
323
329
  return this.value.val;
324
330
  }
325
- get hasComputed() {
326
- return this.value.hasComputed;
331
+ // If this is true, the caller should be able to obtain the LazyValue without
332
+ // it throwing.
333
+ get hasSucceeded() {
334
+ return this.value.computedState === "succeeded";
327
335
  }
328
336
  };
329
337
 
@@ -1804,7 +1812,7 @@ var Logger = class {
1804
1812
  async export() {
1805
1813
  return new SpanComponentsV3({
1806
1814
  object_type: this.parentObjectType(),
1807
- ...this.computeMetadataArgs && !this.lazyId.hasComputed ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
1815
+ ...this.computeMetadataArgs && !this.lazyId.hasSucceeded ? { compute_object_metadata_args: this.computeMetadataArgs } : { object_id: await this.lazyId.get() }
1808
1816
  }).toStr();
1809
1817
  }
1810
1818
  /*
@@ -3539,7 +3547,7 @@ var SpanImpl = class _SpanImpl {
3539
3547
  async export() {
3540
3548
  return new SpanComponentsV3({
3541
3549
  object_type: this.parentObjectType,
3542
- ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasComputed ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
3550
+ ...this.parentComputeObjectMetadataArgs && !this.parentObjectId.hasSucceeded ? { compute_object_metadata_args: this.parentComputeObjectMetadataArgs } : { object_id: await this.parentObjectId.get() },
3543
3551
  row_id: this.id,
3544
3552
  span_id: this.spanId,
3545
3553
  root_span_id: this.rootSpanId,
@@ -6716,14 +6724,16 @@ function postProcessPrompt(prompt) {
6716
6724
  {
6717
6725
  role: "assistant",
6718
6726
  content: textPart?.text,
6719
- tool_calls: toolCallParts.map((part) => ({
6720
- id: part.toolCallId,
6721
- function: {
6722
- name: part.toolName,
6723
- arguments: JSON.stringify(part.args)
6724
- },
6725
- type: "function"
6726
- }))
6727
+ ...toolCallParts.length > 0 ? {
6728
+ tool_calls: toolCallParts.map((part) => ({
6729
+ id: part.toolCallId,
6730
+ function: {
6731
+ name: part.toolName,
6732
+ arguments: JSON.stringify(part.args)
6733
+ },
6734
+ type: "function"
6735
+ }))
6736
+ } : {}
6727
6737
  }
6728
6738
  ];
6729
6739
  case "user":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braintrust",
3
- "version": "0.0.183",
3
+ "version": "0.0.184",
4
4
  "description": "SDK for integrating Braintrust",
5
5
  "repository": {
6
6
  "type": "git",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@ai-sdk/provider": "^1.0.1",
78
- "@braintrust/core": "0.0.77",
78
+ "@braintrust/core": "0.0.78",
79
79
  "@next/env": "^14.2.3",
80
80
  "@vercel/functions": "^1.0.2",
81
81
  "ai": "^3.2.16",