braintrust 0.2.3 → 0.2.4

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
@@ -481,15 +481,15 @@ function mergeTwoObjects(one, two, level = 0, objects) {
481
481
  for (let i = 0, j = two.length; i < j; i++) {
482
482
  result.push(takeValue(two[i]));
483
483
  }
484
- } else if (isObject2(two)) {
484
+ } else if (isObject3(two)) {
485
485
  const keys = Object.keys(two);
486
486
  for (let i = 0, j = keys.length; i < j; i++) {
487
487
  const key = keys[i];
488
488
  result[key] = takeValue(two[key]);
489
489
  }
490
490
  }
491
- } else if (isObject2(one)) {
492
- if (isObject2(two)) {
491
+ } else if (isObject3(one)) {
492
+ if (isObject3(two)) {
493
493
  if (!shouldMerge(one, two)) {
494
494
  return two;
495
495
  }
@@ -510,7 +510,7 @@ function mergeTwoObjects(one, two, level = 0, objects) {
510
510
  if (wasObjectReferenced(one, key, objects) || wasObjectReferenced(two, key, objects)) {
511
511
  delete result[key];
512
512
  } else {
513
- if (isObject2(obj1) && isObject2(obj2)) {
513
+ if (isObject3(obj1) && isObject3(obj2)) {
514
514
  const arr1 = objects.get(obj1) || [];
515
515
  const arr2 = objects.get(obj2) || [];
516
516
  arr1.push({ obj: one, key });
@@ -544,7 +544,7 @@ function isArray2(value) {
544
544
  function isFunction(value) {
545
545
  return typeof value === "function";
546
546
  }
547
- function isObject2(value) {
547
+ function isObject3(value) {
548
548
  return !isPrimitive(value) && !isArray2(value) && !isFunction(value) && typeof value === "object";
549
549
  }
550
550
  function isPrimitive(value) {
@@ -8397,7 +8397,7 @@ function initFunction({
8397
8397
  // src/framework.ts
8398
8398
 
8399
8399
 
8400
- // ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
8400
+ // ../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
8401
8401
  function initialParams(fn) {
8402
8402
  return function(...args) {
8403
8403
  var callback = args.pop();
@@ -10773,6 +10773,7 @@ var graph_framework_default = { createGraph };
10773
10773
 
10774
10774
 
10775
10775
  // src/wrappers/oai_responses.ts
10776
+
10776
10777
  function responsesProxy(openai) {
10777
10778
  if (!openai.responses) {
10778
10779
  return openai;
@@ -10962,11 +10963,11 @@ function parseMetricsFromUsage(usage) {
10962
10963
  const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
10963
10964
  metrics[metricName] = value;
10964
10965
  } else if (oai_name.endsWith("_tokens_details")) {
10965
- const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
10966
- const prefix = TOKEN_PREFIX_MAP[rawPrefix] || rawPrefix;
10967
- if (typeof value !== "object") {
10966
+ if (!_core.isObject.call(void 0, value)) {
10968
10967
  continue;
10969
10968
  }
10969
+ const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
10970
+ const prefix = TOKEN_PREFIX_MAP[rawPrefix] || rawPrefix;
10970
10971
  for (const [key, n] of Object.entries(value)) {
10971
10972
  if (typeof n !== "number") {
10972
10973
  continue;
package/dist/index.mjs CHANGED
@@ -481,15 +481,15 @@ function mergeTwoObjects(one, two, level = 0, objects) {
481
481
  for (let i = 0, j = two.length; i < j; i++) {
482
482
  result.push(takeValue(two[i]));
483
483
  }
484
- } else if (isObject2(two)) {
484
+ } else if (isObject3(two)) {
485
485
  const keys = Object.keys(two);
486
486
  for (let i = 0, j = keys.length; i < j; i++) {
487
487
  const key = keys[i];
488
488
  result[key] = takeValue(two[key]);
489
489
  }
490
490
  }
491
- } else if (isObject2(one)) {
492
- if (isObject2(two)) {
491
+ } else if (isObject3(one)) {
492
+ if (isObject3(two)) {
493
493
  if (!shouldMerge(one, two)) {
494
494
  return two;
495
495
  }
@@ -510,7 +510,7 @@ function mergeTwoObjects(one, two, level = 0, objects) {
510
510
  if (wasObjectReferenced(one, key, objects) || wasObjectReferenced(two, key, objects)) {
511
511
  delete result[key];
512
512
  } else {
513
- if (isObject2(obj1) && isObject2(obj2)) {
513
+ if (isObject3(obj1) && isObject3(obj2)) {
514
514
  const arr1 = objects.get(obj1) || [];
515
515
  const arr2 = objects.get(obj2) || [];
516
516
  arr1.push({ obj: one, key });
@@ -544,7 +544,7 @@ function isArray2(value) {
544
544
  function isFunction(value) {
545
545
  return typeof value === "function";
546
546
  }
547
- function isObject2(value) {
547
+ function isObject3(value) {
548
548
  return !isPrimitive(value) && !isArray2(value) && !isFunction(value) && typeof value === "object";
549
549
  }
550
550
  function isPrimitive(value) {
@@ -8397,7 +8397,7 @@ function initFunction({
8397
8397
  // src/framework.ts
8398
8398
  import { SpanTypeAttribute as SpanTypeAttribute2, mergeDicts as mergeDicts2 } from "@braintrust/core";
8399
8399
 
8400
- // ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
8400
+ // ../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
8401
8401
  function initialParams(fn) {
8402
8402
  return function(...args) {
8403
8403
  var callback = args.pop();
@@ -10773,6 +10773,7 @@ import { SpanTypeAttribute as SpanTypeAttribute3 } from "@braintrust/core";
10773
10773
  import { mergeDicts as mergeDicts3 } from "@braintrust/core";
10774
10774
 
10775
10775
  // src/wrappers/oai_responses.ts
10776
+ import { isObject as isObject2 } from "@braintrust/core";
10776
10777
  function responsesProxy(openai) {
10777
10778
  if (!openai.responses) {
10778
10779
  return openai;
@@ -10962,11 +10963,11 @@ function parseMetricsFromUsage(usage) {
10962
10963
  const metricName = TOKEN_NAME_MAP[oai_name] || oai_name;
10963
10964
  metrics[metricName] = value;
10964
10965
  } else if (oai_name.endsWith("_tokens_details")) {
10965
- const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
10966
- const prefix = TOKEN_PREFIX_MAP[rawPrefix] || rawPrefix;
10967
- if (typeof value !== "object") {
10966
+ if (!isObject2(value)) {
10968
10967
  continue;
10969
10968
  }
10969
+ const rawPrefix = oai_name.slice(0, -"_tokens_details".length);
10970
+ const prefix = TOKEN_PREFIX_MAP[rawPrefix] || rawPrefix;
10970
10971
  for (const [key, n] of Object.entries(value)) {
10971
10972
  if (typeof n !== "number") {
10972
10973
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braintrust",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "SDK for integrating Braintrust",
5
5
  "repository": {
6
6
  "type": "git",
@@ -62,6 +62,7 @@
62
62
  "author": "",
63
63
  "license": "MIT",
64
64
  "devDependencies": {
65
+ "@openai/agents": "^0.0.14",
65
66
  "ai": "^4.3.16",
66
67
  "@jest/globals": "^29.7.0",
67
68
  "@nodelib/fs.walk": "^1.2.8",