langsmith 0.2.5 → 0.2.7

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/client.cjs CHANGED
@@ -606,7 +606,7 @@ class Client {
606
606
  this._serverInfo = await this._getServerInfo();
607
607
  }
608
608
  catch (e) {
609
- console.warn(`[WARNING]: LangSmith failed to fetch info on supported operations. Falling back to single calls and default limits.`);
609
+ console.warn(`[WARNING]: LangSmith failed to fetch info on supported operations. Falling back to batch operations and default limits.`);
610
610
  }
611
611
  }
612
612
  return this._serverInfo ?? {};
@@ -696,19 +696,6 @@ class Client {
696
696
  if (!rawBatch.post.length && !rawBatch.patch.length) {
697
697
  return;
698
698
  }
699
- const serverInfo = await this._ensureServerInfo();
700
- if (serverInfo.version === undefined) {
701
- this.autoBatchTracing = false;
702
- for (const preparedCreateParam of rawBatch.post) {
703
- await this.createRun(preparedCreateParam);
704
- }
705
- for (const preparedUpdateParam of rawBatch.patch) {
706
- if (preparedUpdateParam.id !== undefined) {
707
- await this.updateRun(preparedUpdateParam.id, preparedUpdateParam);
708
- }
709
- }
710
- return;
711
- }
712
699
  const batchChunks = {
713
700
  post: [],
714
701
  patch: [],
@@ -867,31 +854,40 @@ class Client {
867
854
  }
868
855
  async _sendMultipartRequest(parts, context) {
869
856
  try {
870
- const formData = new FormData();
857
+ // Create multipart form data manually using Blobs
858
+ const boundary = "----LangSmithFormBoundary" + Math.random().toString(36).slice(2);
859
+ const chunks = [];
871
860
  for (const part of parts) {
872
- formData.append(part.name, part.payload);
873
- }
874
- // Log the form data
875
- await this.batchIngestCaller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/multipart`, {
861
+ // Add field boundary
862
+ chunks.push(new Blob([`--${boundary}\r\n`]));
863
+ chunks.push(new Blob([
864
+ `Content-Disposition: form-data; name="${part.name}"\r\n`,
865
+ `Content-Type: ${part.payload.type}\r\n\r\n`,
866
+ ]));
867
+ chunks.push(part.payload);
868
+ chunks.push(new Blob(["\r\n"]));
869
+ }
870
+ // Add final boundary
871
+ chunks.push(new Blob([`--${boundary}--\r\n`]));
872
+ // Combine all chunks into a single Blob
873
+ const body = new Blob(chunks);
874
+ // Convert Blob to ArrayBuffer for compatibility
875
+ const arrayBuffer = await body.arrayBuffer();
876
+ const res = await this.batchIngestCaller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/multipart`, {
876
877
  method: "POST",
877
878
  headers: {
878
879
  ...this.headers,
880
+ "Content-Type": `multipart/form-data; boundary=${boundary}`,
879
881
  },
880
- body: formData,
882
+ body: arrayBuffer,
881
883
  signal: AbortSignal.timeout(this.timeout_ms),
882
884
  ...this.fetchOptions,
883
885
  });
886
+ await (0, error_js_1.raiseForStatus)(res, "ingest multipart runs", true);
887
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
884
888
  }
885
889
  catch (e) {
886
- let errorMessage = "Failed to multipart ingest runs";
887
- // eslint-disable-next-line no-instanceof/no-instanceof
888
- if (e instanceof Error) {
889
- errorMessage += `: ${e.stack || e.message}`;
890
- }
891
- else {
892
- errorMessage += `: ${String(e)}`;
893
- }
894
- console.warn(`${errorMessage.trim()}\n\nContext: ${context}`);
890
+ console.warn(`${e.message.trim()}\n\nContext: ${context}`);
895
891
  }
896
892
  }
897
893
  async updateRun(runId, run) {
package/dist/client.js CHANGED
@@ -578,7 +578,7 @@ export class Client {
578
578
  this._serverInfo = await this._getServerInfo();
579
579
  }
580
580
  catch (e) {
581
- console.warn(`[WARNING]: LangSmith failed to fetch info on supported operations. Falling back to single calls and default limits.`);
581
+ console.warn(`[WARNING]: LangSmith failed to fetch info on supported operations. Falling back to batch operations and default limits.`);
582
582
  }
583
583
  }
584
584
  return this._serverInfo ?? {};
@@ -668,19 +668,6 @@ export class Client {
668
668
  if (!rawBatch.post.length && !rawBatch.patch.length) {
669
669
  return;
670
670
  }
671
- const serverInfo = await this._ensureServerInfo();
672
- if (serverInfo.version === undefined) {
673
- this.autoBatchTracing = false;
674
- for (const preparedCreateParam of rawBatch.post) {
675
- await this.createRun(preparedCreateParam);
676
- }
677
- for (const preparedUpdateParam of rawBatch.patch) {
678
- if (preparedUpdateParam.id !== undefined) {
679
- await this.updateRun(preparedUpdateParam.id, preparedUpdateParam);
680
- }
681
- }
682
- return;
683
- }
684
671
  const batchChunks = {
685
672
  post: [],
686
673
  patch: [],
@@ -839,31 +826,40 @@ export class Client {
839
826
  }
840
827
  async _sendMultipartRequest(parts, context) {
841
828
  try {
842
- const formData = new FormData();
829
+ // Create multipart form data manually using Blobs
830
+ const boundary = "----LangSmithFormBoundary" + Math.random().toString(36).slice(2);
831
+ const chunks = [];
843
832
  for (const part of parts) {
844
- formData.append(part.name, part.payload);
845
- }
846
- // Log the form data
847
- await this.batchIngestCaller.call(_getFetchImplementation(), `${this.apiUrl}/runs/multipart`, {
833
+ // Add field boundary
834
+ chunks.push(new Blob([`--${boundary}\r\n`]));
835
+ chunks.push(new Blob([
836
+ `Content-Disposition: form-data; name="${part.name}"\r\n`,
837
+ `Content-Type: ${part.payload.type}\r\n\r\n`,
838
+ ]));
839
+ chunks.push(part.payload);
840
+ chunks.push(new Blob(["\r\n"]));
841
+ }
842
+ // Add final boundary
843
+ chunks.push(new Blob([`--${boundary}--\r\n`]));
844
+ // Combine all chunks into a single Blob
845
+ const body = new Blob(chunks);
846
+ // Convert Blob to ArrayBuffer for compatibility
847
+ const arrayBuffer = await body.arrayBuffer();
848
+ const res = await this.batchIngestCaller.call(_getFetchImplementation(), `${this.apiUrl}/runs/multipart`, {
848
849
  method: "POST",
849
850
  headers: {
850
851
  ...this.headers,
852
+ "Content-Type": `multipart/form-data; boundary=${boundary}`,
851
853
  },
852
- body: formData,
854
+ body: arrayBuffer,
853
855
  signal: AbortSignal.timeout(this.timeout_ms),
854
856
  ...this.fetchOptions,
855
857
  });
858
+ await raiseForStatus(res, "ingest multipart runs", true);
859
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
856
860
  }
857
861
  catch (e) {
858
- let errorMessage = "Failed to multipart ingest runs";
859
- // eslint-disable-next-line no-instanceof/no-instanceof
860
- if (e instanceof Error) {
861
- errorMessage += `: ${e.stack || e.message}`;
862
- }
863
- else {
864
- errorMessage += `: ${String(e)}`;
865
- }
866
- console.warn(`${errorMessage.trim()}\n\nContext: ${context}`);
862
+ console.warn(`${e.message.trim()}\n\nContext: ${context}`);
867
863
  }
868
864
  }
869
865
  async updateRun(runId, run) {
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.2.4";
11
+ exports.__version__ = "0.2.7";
package/dist/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export { Client, type ClientConfig } from "./client.js";
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.2.4";
5
+ export declare const __version__ = "0.2.7";
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.2.4";
5
+ export const __version__ = "0.2.7";
@@ -109,9 +109,14 @@ function getLangChainEnvVarsMetadata() {
109
109
  "LANGCHAIN_TRACING_V2",
110
110
  "LANGCHAIN_PROJECT",
111
111
  "LANGCHAIN_SESSION",
112
+ "LANGSMITH_API_KEY",
113
+ "LANGSMITH_ENDPOINT",
114
+ "LANGSMITH_TRACING_V2",
115
+ "LANGSMITH_PROJECT",
116
+ "LANGSMITH_SESSION",
112
117
  ];
113
118
  for (const [key, value] of Object.entries(allEnvVars)) {
114
- if (key.startsWith("LANGCHAIN_") &&
119
+ if ((key.startsWith("LANGCHAIN_") || key.startsWith("LANGSMITH_")) &&
115
120
  typeof value === "string" &&
116
121
  !excluded.includes(key) &&
117
122
  !key.toLowerCase().includes("key") &&
package/dist/utils/env.js CHANGED
@@ -98,9 +98,14 @@ export function getLangChainEnvVarsMetadata() {
98
98
  "LANGCHAIN_TRACING_V2",
99
99
  "LANGCHAIN_PROJECT",
100
100
  "LANGCHAIN_SESSION",
101
+ "LANGSMITH_API_KEY",
102
+ "LANGSMITH_ENDPOINT",
103
+ "LANGSMITH_TRACING_V2",
104
+ "LANGSMITH_PROJECT",
105
+ "LANGSMITH_SESSION",
101
106
  ];
102
107
  for (const [key, value] of Object.entries(allEnvVars)) {
103
- if (key.startsWith("LANGCHAIN_") &&
108
+ if ((key.startsWith("LANGCHAIN_") || key.startsWith("LANGSMITH_")) &&
104
109
  typeof value === "string" &&
105
110
  !excluded.includes(key) &&
106
111
  !key.toLowerCase().includes("key") &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
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": [
@@ -114,7 +114,7 @@
114
114
  "@faker-js/faker": "^8.4.1",
115
115
  "@jest/globals": "^29.5.0",
116
116
  "@langchain/core": "^0.3.14",
117
- "@langchain/langgraph": "^0.2.18",
117
+ "@langchain/langgraph": "^0.2.20",
118
118
  "@langchain/openai": "^0.3.11",
119
119
  "@opentelemetry/sdk-trace-base": "^1.26.0",
120
120
  "@opentelemetry/sdk-trace-node": "^1.26.0",
@@ -133,6 +133,7 @@
133
133
  "eslint-plugin-prettier": "^4.2.1",
134
134
  "jest": "^29.5.0",
135
135
  "langchain": "^0.3.3",
136
+ "node-fetch": "^2.7.0",
136
137
  "openai": "^4.67.3",
137
138
  "prettier": "^2.8.8",
138
139
  "ts-jest": "^29.1.0",