langsmith 0.3.24 → 0.3.26

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.cjs CHANGED
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () {
8
8
  var fetch_js_1 = require("./singletons/fetch.cjs");
9
9
  Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true, get: function () { return fetch_js_1.overrideFetchImplementation; } });
10
10
  // Update using yarn bump-version
11
- exports.__version__ = "0.3.24";
11
+ exports.__version__ = "0.3.26";
package/dist/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export { Client, type ClientConfig, type LangSmithTracingClientInterface, } from
2
2
  export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, } from "./schemas.js";
3
3
  export { RunTree, type RunTreeConfig } from "./run_trees.js";
4
4
  export { overrideFetchImplementation } from "./singletons/fetch.js";
5
- export declare const __version__ = "0.3.24";
5
+ export declare const __version__ = "0.3.26";
package/dist/index.js CHANGED
@@ -2,4 +2,4 @@ export { Client, } from "./client.js";
2
2
  export { RunTree } from "./run_trees.js";
3
3
  export { overrideFetchImplementation } from "./singletons/fetch.js";
4
4
  // Update using yarn bump-version
5
- export const __version__ = "0.3.24";
5
+ export const __version__ = "0.3.26";
@@ -24,9 +24,7 @@ function wrapEvaluator(evaluator) {
24
24
  }
25
25
  const evalRunId = config?.runId ?? config?.id ?? (0, uuid_1.v4)();
26
26
  let evalResult;
27
- let currentRunTree;
28
27
  if ((0, globals_js_1.trackingEnabled)(context)) {
29
- currentRunTree = (0, traceable_js_1.getCurrentRunTree)();
30
28
  const wrappedEvaluator = (0, traceable_js_1.traceable)(async (_runTree, params) => {
31
29
  return evaluator(params);
32
30
  }, {
@@ -57,7 +55,7 @@ function wrapEvaluator(evaluator) {
57
55
  exampleId: context?.currentExample?.id,
58
56
  feedback: result,
59
57
  context,
60
- runTree: currentRunTree,
58
+ runTree: context.testRootRunTree,
61
59
  client: context.client,
62
60
  sourceRunId: evalRunId,
63
61
  });
@@ -1,4 +1,4 @@
1
- import { getCurrentRunTree, ROOT, traceable } from "../../../traceable.js";
1
+ import { ROOT, traceable } from "../../../traceable.js";
2
2
  import { testWrapperAsyncLocalStorageInstance, _logTestFeedback, trackingEnabled, } from "../globals.js";
3
3
  import { v4 } from "uuid";
4
4
  function isEvaluationResult(x) {
@@ -20,9 +20,7 @@ export function wrapEvaluator(evaluator) {
20
20
  }
21
21
  const evalRunId = config?.runId ?? config?.id ?? v4();
22
22
  let evalResult;
23
- let currentRunTree;
24
23
  if (trackingEnabled(context)) {
25
- currentRunTree = getCurrentRunTree();
26
24
  const wrappedEvaluator = traceable(async (_runTree, params) => {
27
25
  return evaluator(params);
28
26
  }, {
@@ -53,7 +51,7 @@ export function wrapEvaluator(evaluator) {
53
51
  exampleId: context?.currentExample?.id,
54
52
  feedback: result,
55
53
  context,
56
- runTree: currentRunTree,
54
+ runTree: context.testRootRunTree,
57
55
  client: context.client,
58
56
  sourceRunId: evalRunId,
59
57
  });
package/dist/vercel.cjs CHANGED
@@ -61,9 +61,36 @@ function convertCoreToSmith(message) {
61
61
  };
62
62
  }
63
63
  if (part.type === "image") {
64
+ let imageUrl = part.image;
65
+ if (typeof imageUrl !== "string") {
66
+ let uint8Array;
67
+ if (imageUrl != null &&
68
+ typeof imageUrl === "object" &&
69
+ "type" in imageUrl &&
70
+ "data" in imageUrl) {
71
+ // Typing is wrong here if a buffer is passed in
72
+ uint8Array = new Uint8Array(imageUrl.data);
73
+ }
74
+ else if (imageUrl != null &&
75
+ typeof imageUrl === "object" &&
76
+ Object.keys(imageUrl).every((key) => !isNaN(Number(key)))) {
77
+ // ArrayBuffers get turned into objects with numeric keys for some reason
78
+ uint8Array = new Uint8Array(Array.from({
79
+ ...imageUrl,
80
+ length: Object.keys(imageUrl).length,
81
+ }));
82
+ }
83
+ if (uint8Array) {
84
+ let binary = "";
85
+ for (let i = 0; i < uint8Array.length; i++) {
86
+ binary += String.fromCharCode(uint8Array[i]);
87
+ }
88
+ imageUrl = btoa(binary);
89
+ }
90
+ }
64
91
  return {
65
92
  type: "image_url",
66
- image_url: part.image,
93
+ image_url: imageUrl,
67
94
  ...part.experimental_providerMetadata,
68
95
  };
69
96
  }
package/dist/vercel.js CHANGED
@@ -58,9 +58,36 @@ function convertCoreToSmith(message) {
58
58
  };
59
59
  }
60
60
  if (part.type === "image") {
61
+ let imageUrl = part.image;
62
+ if (typeof imageUrl !== "string") {
63
+ let uint8Array;
64
+ if (imageUrl != null &&
65
+ typeof imageUrl === "object" &&
66
+ "type" in imageUrl &&
67
+ "data" in imageUrl) {
68
+ // Typing is wrong here if a buffer is passed in
69
+ uint8Array = new Uint8Array(imageUrl.data);
70
+ }
71
+ else if (imageUrl != null &&
72
+ typeof imageUrl === "object" &&
73
+ Object.keys(imageUrl).every((key) => !isNaN(Number(key)))) {
74
+ // ArrayBuffers get turned into objects with numeric keys for some reason
75
+ uint8Array = new Uint8Array(Array.from({
76
+ ...imageUrl,
77
+ length: Object.keys(imageUrl).length,
78
+ }));
79
+ }
80
+ if (uint8Array) {
81
+ let binary = "";
82
+ for (let i = 0; i < uint8Array.length; i++) {
83
+ binary += String.fromCharCode(uint8Array[i]);
84
+ }
85
+ imageUrl = btoa(binary);
86
+ }
87
+ }
61
88
  return {
62
89
  type: "image_url",
63
- image_url: part.image,
90
+ image_url: imageUrl,
64
91
  ...part.experimental_providerMetadata,
65
92
  };
66
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "packageManager": "yarn@1.22.19",
6
6
  "files": [