langsmith 0.3.68 → 0.3.70

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
@@ -165,7 +165,7 @@ class AutoBatchQueue {
165
165
  this.sizeBytes += size;
166
166
  return itemPromise;
167
167
  }
168
- pop(upToSizeBytes) {
168
+ pop({ upToSizeBytes, upToSize, }) {
169
169
  if (upToSizeBytes < 1) {
170
170
  throw new Error("Number of bytes to pop off may not be less than 1.");
171
171
  }
@@ -173,7 +173,8 @@ class AutoBatchQueue {
173
173
  let poppedSizeBytes = 0;
174
174
  // Pop items until we reach or exceed the size limit
175
175
  while (poppedSizeBytes + (this.peek()?.size ?? 0) < upToSizeBytes &&
176
- this.items.length > 0) {
176
+ this.items.length > 0 &&
177
+ popped.length < upToSize) {
177
178
  const item = this.items.shift();
178
179
  if (item) {
179
180
  popped.push(item);
@@ -204,6 +205,8 @@ class AutoBatchQueue {
204
205
  exports.AutoBatchQueue = AutoBatchQueue;
205
206
  exports.DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES = 24 * 1024 * 1024;
206
207
  const SERVER_INFO_REQUEST_TIMEOUT_MS = 10000;
208
+ /** Maximum number of operations to batch in a single request. */
209
+ const DEFAULT_BATCH_SIZE_LIMIT = 100;
207
210
  const DEFAULT_API_URL = "https://api.smith.langchain.com";
208
211
  class Client {
209
212
  get _fetch() {
@@ -312,6 +315,12 @@ class Client {
312
315
  writable: true,
313
316
  value: void 0
314
317
  });
318
+ Object.defineProperty(this, "batchSizeLimit", {
319
+ enumerable: true,
320
+ configurable: true,
321
+ writable: true,
322
+ value: void 0
323
+ });
315
324
  Object.defineProperty(this, "fetchOptions", {
316
325
  enumerable: true,
317
326
  configurable: true,
@@ -419,6 +428,7 @@ class Client {
419
428
  this.blockOnRootRunFinalization =
420
429
  config.blockOnRootRunFinalization ?? this.blockOnRootRunFinalization;
421
430
  this.batchSizeBytesLimit = config.batchSizeBytesLimit;
431
+ this.batchSizeLimit = config.batchSizeLimit;
422
432
  this.fetchOptions = config.fetchOptions || {};
423
433
  this.manualFlushMode = config.manualFlushMode ?? this.manualFlushMode;
424
434
  if ((0, env_js_1.getOtelEnabled)()) {
@@ -660,14 +670,27 @@ class Client {
660
670
  serverInfo.batch_ingest_config?.size_limit_bytes ??
661
671
  exports.DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES);
662
672
  }
673
+ /**
674
+ * Get the maximum number of operations to batch in a single request.
675
+ */
676
+ async _getBatchSizeLimit() {
677
+ const serverInfo = await this._ensureServerInfo();
678
+ return (this.batchSizeLimit ??
679
+ serverInfo.batch_ingest_config?.size_limit ??
680
+ DEFAULT_BATCH_SIZE_LIMIT);
681
+ }
663
682
  async _getDatasetExamplesMultiPartSupport() {
664
683
  const serverInfo = await this._ensureServerInfo();
665
684
  return (serverInfo.instance_flags?.dataset_examples_multipart_enabled ?? false);
666
685
  }
667
- drainAutoBatchQueue(batchSizeLimit) {
686
+ drainAutoBatchQueue({ batchSizeLimitBytes, batchSizeLimit, }) {
668
687
  const promises = [];
669
688
  while (this.autoBatchQueue.items.length > 0) {
670
- const [batch, done] = this.autoBatchQueue.pop(batchSizeLimit);
689
+ const [batch, done] = this.autoBatchQueue.pop({
690
+ upToSizeBytes: batchSizeLimitBytes,
691
+ upToSize: batchSizeLimit,
692
+ });
693
+ console.log("batch", batch?.length);
671
694
  if (!batch.length) {
672
695
  done();
673
696
  break;
@@ -766,13 +789,21 @@ class Client {
766
789
  return itemPromise;
767
790
  }
768
791
  const sizeLimitBytes = await this._getBatchSizeLimitBytes();
769
- if (this.autoBatchQueue.sizeBytes > sizeLimitBytes) {
770
- void this.drainAutoBatchQueue(sizeLimitBytes);
792
+ const sizeLimit = await this._getBatchSizeLimit();
793
+ if (this.autoBatchQueue.sizeBytes > sizeLimitBytes ||
794
+ this.autoBatchQueue.items.length > sizeLimit) {
795
+ void this.drainAutoBatchQueue({
796
+ batchSizeLimitBytes: sizeLimitBytes,
797
+ batchSizeLimit: sizeLimit,
798
+ });
771
799
  }
772
800
  if (this.autoBatchQueue.items.length > 0) {
773
801
  this.autoBatchTimeout = setTimeout(() => {
774
802
  this.autoBatchTimeout = undefined;
775
- void this.drainAutoBatchQueue(sizeLimitBytes);
803
+ void this.drainAutoBatchQueue({
804
+ batchSizeLimitBytes: sizeLimitBytes,
805
+ batchSizeLimit: sizeLimit,
806
+ });
776
807
  }, this.autoBatchAggregationDelayMs);
777
808
  }
778
809
  return itemPromise;
@@ -828,7 +859,11 @@ class Client {
828
859
  */
829
860
  async flush() {
830
861
  const sizeLimitBytes = await this._getBatchSizeLimitBytes();
831
- await this.drainAutoBatchQueue(sizeLimitBytes);
862
+ const sizeLimit = await this._getBatchSizeLimit();
863
+ await this.drainAutoBatchQueue({
864
+ batchSizeLimitBytes: sizeLimitBytes,
865
+ batchSizeLimit: sizeLimit,
866
+ });
832
867
  }
833
868
  _cloneCurrentOTELContext() {
834
869
  const otel_trace = (0, otel_js_1.getOTELTrace)();
package/dist/client.d.ts CHANGED
@@ -12,7 +12,10 @@ export interface ClientConfig {
12
12
  hideInputs?: boolean | ((inputs: KVMap) => KVMap | Promise<KVMap>);
13
13
  hideOutputs?: boolean | ((outputs: KVMap) => KVMap | Promise<KVMap>);
14
14
  autoBatchTracing?: boolean;
15
+ /** Maximum size of a batch of runs in bytes. */
15
16
  batchSizeBytesLimit?: number;
17
+ /** Maximum number of operations to batch in a single request. */
18
+ batchSizeLimit?: number;
16
19
  blockOnRootRunFinalization?: boolean;
17
20
  traceBatchConcurrency?: number;
18
21
  fetchOptions?: RequestInit;
@@ -292,7 +295,10 @@ export declare class AutoBatchQueue {
292
295
  apiUrl?: string;
293
296
  };
294
297
  push(item: AutoBatchQueueItem): Promise<void>;
295
- pop(upToSizeBytes: number): [AutoBatchQueueItem[], () => void];
298
+ pop({ upToSizeBytes, upToSize, }: {
299
+ upToSizeBytes: number;
300
+ upToSize: number;
301
+ }): [AutoBatchQueueItem[], () => void];
296
302
  }
297
303
  export declare const DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES: number;
298
304
  export declare class Client implements LangSmithTracingClientInterface {
@@ -313,6 +319,7 @@ export declare class Client implements LangSmithTracingClientInterface {
313
319
  private autoBatchTimeout;
314
320
  private autoBatchAggregationDelayMs;
315
321
  private batchSizeBytesLimit?;
322
+ private batchSizeLimit?;
316
323
  private fetchOptions;
317
324
  private settings;
318
325
  private blockOnRootRunFinalization;
@@ -346,6 +353,10 @@ export declare class Client implements LangSmithTracingClientInterface {
346
353
  private _shouldSample;
347
354
  private _filterForSampling;
348
355
  private _getBatchSizeLimitBytes;
356
+ /**
357
+ * Get the maximum number of operations to batch in a single request.
358
+ */
359
+ private _getBatchSizeLimit;
349
360
  private _getDatasetExamplesMultiPartSupport;
350
361
  private drainAutoBatchQueue;
351
362
  private _processBatch;
package/dist/client.js CHANGED
@@ -128,7 +128,7 @@ export class AutoBatchQueue {
128
128
  this.sizeBytes += size;
129
129
  return itemPromise;
130
130
  }
131
- pop(upToSizeBytes) {
131
+ pop({ upToSizeBytes, upToSize, }) {
132
132
  if (upToSizeBytes < 1) {
133
133
  throw new Error("Number of bytes to pop off may not be less than 1.");
134
134
  }
@@ -136,7 +136,8 @@ export class AutoBatchQueue {
136
136
  let poppedSizeBytes = 0;
137
137
  // Pop items until we reach or exceed the size limit
138
138
  while (poppedSizeBytes + (this.peek()?.size ?? 0) < upToSizeBytes &&
139
- this.items.length > 0) {
139
+ this.items.length > 0 &&
140
+ popped.length < upToSize) {
140
141
  const item = this.items.shift();
141
142
  if (item) {
142
143
  popped.push(item);
@@ -166,6 +167,8 @@ export class AutoBatchQueue {
166
167
  }
167
168
  export const DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES = 24 * 1024 * 1024;
168
169
  const SERVER_INFO_REQUEST_TIMEOUT_MS = 10000;
170
+ /** Maximum number of operations to batch in a single request. */
171
+ const DEFAULT_BATCH_SIZE_LIMIT = 100;
169
172
  const DEFAULT_API_URL = "https://api.smith.langchain.com";
170
173
  export class Client {
171
174
  get _fetch() {
@@ -274,6 +277,12 @@ export class Client {
274
277
  writable: true,
275
278
  value: void 0
276
279
  });
280
+ Object.defineProperty(this, "batchSizeLimit", {
281
+ enumerable: true,
282
+ configurable: true,
283
+ writable: true,
284
+ value: void 0
285
+ });
277
286
  Object.defineProperty(this, "fetchOptions", {
278
287
  enumerable: true,
279
288
  configurable: true,
@@ -381,6 +390,7 @@ export class Client {
381
390
  this.blockOnRootRunFinalization =
382
391
  config.blockOnRootRunFinalization ?? this.blockOnRootRunFinalization;
383
392
  this.batchSizeBytesLimit = config.batchSizeBytesLimit;
393
+ this.batchSizeLimit = config.batchSizeLimit;
384
394
  this.fetchOptions = config.fetchOptions || {};
385
395
  this.manualFlushMode = config.manualFlushMode ?? this.manualFlushMode;
386
396
  if (getOtelEnabled()) {
@@ -622,14 +632,27 @@ export class Client {
622
632
  serverInfo.batch_ingest_config?.size_limit_bytes ??
623
633
  DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES);
624
634
  }
635
+ /**
636
+ * Get the maximum number of operations to batch in a single request.
637
+ */
638
+ async _getBatchSizeLimit() {
639
+ const serverInfo = await this._ensureServerInfo();
640
+ return (this.batchSizeLimit ??
641
+ serverInfo.batch_ingest_config?.size_limit ??
642
+ DEFAULT_BATCH_SIZE_LIMIT);
643
+ }
625
644
  async _getDatasetExamplesMultiPartSupport() {
626
645
  const serverInfo = await this._ensureServerInfo();
627
646
  return (serverInfo.instance_flags?.dataset_examples_multipart_enabled ?? false);
628
647
  }
629
- drainAutoBatchQueue(batchSizeLimit) {
648
+ drainAutoBatchQueue({ batchSizeLimitBytes, batchSizeLimit, }) {
630
649
  const promises = [];
631
650
  while (this.autoBatchQueue.items.length > 0) {
632
- const [batch, done] = this.autoBatchQueue.pop(batchSizeLimit);
651
+ const [batch, done] = this.autoBatchQueue.pop({
652
+ upToSizeBytes: batchSizeLimitBytes,
653
+ upToSize: batchSizeLimit,
654
+ });
655
+ console.log("batch", batch?.length);
633
656
  if (!batch.length) {
634
657
  done();
635
658
  break;
@@ -728,13 +751,21 @@ export class Client {
728
751
  return itemPromise;
729
752
  }
730
753
  const sizeLimitBytes = await this._getBatchSizeLimitBytes();
731
- if (this.autoBatchQueue.sizeBytes > sizeLimitBytes) {
732
- void this.drainAutoBatchQueue(sizeLimitBytes);
754
+ const sizeLimit = await this._getBatchSizeLimit();
755
+ if (this.autoBatchQueue.sizeBytes > sizeLimitBytes ||
756
+ this.autoBatchQueue.items.length > sizeLimit) {
757
+ void this.drainAutoBatchQueue({
758
+ batchSizeLimitBytes: sizeLimitBytes,
759
+ batchSizeLimit: sizeLimit,
760
+ });
733
761
  }
734
762
  if (this.autoBatchQueue.items.length > 0) {
735
763
  this.autoBatchTimeout = setTimeout(() => {
736
764
  this.autoBatchTimeout = undefined;
737
- void this.drainAutoBatchQueue(sizeLimitBytes);
765
+ void this.drainAutoBatchQueue({
766
+ batchSizeLimitBytes: sizeLimitBytes,
767
+ batchSizeLimit: sizeLimit,
768
+ });
738
769
  }, this.autoBatchAggregationDelayMs);
739
770
  }
740
771
  return itemPromise;
@@ -790,7 +821,11 @@ export class Client {
790
821
  */
791
822
  async flush() {
792
823
  const sizeLimitBytes = await this._getBatchSizeLimitBytes();
793
- await this.drainAutoBatchQueue(sizeLimitBytes);
824
+ const sizeLimit = await this._getBatchSizeLimit();
825
+ await this.drainAutoBatchQueue({
826
+ batchSizeLimitBytes: sizeLimitBytes,
827
+ batchSizeLimit: sizeLimit,
828
+ });
794
829
  }
795
830
  _cloneCurrentOTELContext() {
796
831
  const otel_trace = getOTELTrace();
@@ -325,32 +325,34 @@ const wrapAISDK = ({ wrapLanguageModel, generateText, streamText, streamObject,
325
325
  return inputFormatter(inputs);
326
326
  },
327
327
  processOutputs: async (outputs) => {
328
- if (resolvedLsConfig?.processOutputs) {
329
- return resolvedLsConfig.processOutputs(outputs);
330
- }
331
- if (outputs.outputs == null || typeof outputs.outputs !== "object") {
332
- return outputs;
333
- }
334
- let content;
335
- if ("content" in outputs.outputs && outputs.outputs.content != null) {
336
- content = await outputs.outputs.content;
337
- }
338
- else if ("text" in outputs.outputs &&
339
- outputs.outputs.text != null) {
340
- // AI SDK 4 shim
341
- content = await outputs.outputs.text;
342
- }
343
- else {
344
- return outputs;
328
+ try {
329
+ if (resolvedLsConfig?.processOutputs) {
330
+ return resolvedLsConfig.processOutputs(outputs);
331
+ }
332
+ if (outputs.outputs == null ||
333
+ typeof outputs.outputs !== "object") {
334
+ return outputs;
335
+ }
336
+ // Important: Even accessing this property creates a promise.
337
+ // This must be awaited.
338
+ let content = await outputs.outputs.content;
339
+ if (content == null) {
340
+ // AI SDK 4 shim
341
+ content = await outputs.outputs.text;
342
+ }
343
+ if (content == null ||
344
+ !["object", "string"].includes(typeof content)) {
345
+ return outputs;
346
+ }
347
+ return (0, utils_js_1.convertMessageToTracedFormat)({
348
+ content,
349
+ role: "assistant",
350
+ });
345
351
  }
346
- if (content == null ||
347
- !["object", "string"].includes(typeof content)) {
352
+ catch (e) {
353
+ // Handle parsing failures without a log
348
354
  return outputs;
349
355
  }
350
- return (0, utils_js_1.convertMessageToTracedFormat)({
351
- content,
352
- role: "assistant",
353
- });
354
356
  },
355
357
  });
356
358
  return traceableFunc(...args);
@@ -405,17 +407,24 @@ const wrapAISDK = ({ wrapLanguageModel, generateText, streamText, streamObject,
405
407
  return inputFormatter(inputs);
406
408
  },
407
409
  processOutputs: async (outputs) => {
408
- if (resolvedLsConfig?.processOutputs) {
409
- return resolvedLsConfig.processOutputs(outputs);
410
- }
411
- if (outputs.outputs == null || typeof outputs.outputs !== "object") {
412
- return outputs;
410
+ try {
411
+ if (resolvedLsConfig?.processOutputs) {
412
+ return resolvedLsConfig.processOutputs(outputs);
413
+ }
414
+ if (outputs.outputs == null ||
415
+ typeof outputs.outputs !== "object") {
416
+ return outputs;
417
+ }
418
+ const object = await outputs.outputs.object;
419
+ if (object == null || typeof object !== "object") {
420
+ return outputs;
421
+ }
422
+ return object;
413
423
  }
414
- const object = await outputs.outputs.object;
415
- if (object == null || typeof object !== "object") {
424
+ catch (e) {
425
+ // Handle parsing failures without a log
416
426
  return outputs;
417
427
  }
418
- return object;
419
428
  },
420
429
  });
421
430
  return traceableFunc(...args);
@@ -321,32 +321,34 @@ const wrapAISDK = ({ wrapLanguageModel, generateText, streamText, streamObject,
321
321
  return inputFormatter(inputs);
322
322
  },
323
323
  processOutputs: async (outputs) => {
324
- if (resolvedLsConfig?.processOutputs) {
325
- return resolvedLsConfig.processOutputs(outputs);
326
- }
327
- if (outputs.outputs == null || typeof outputs.outputs !== "object") {
328
- return outputs;
329
- }
330
- let content;
331
- if ("content" in outputs.outputs && outputs.outputs.content != null) {
332
- content = await outputs.outputs.content;
333
- }
334
- else if ("text" in outputs.outputs &&
335
- outputs.outputs.text != null) {
336
- // AI SDK 4 shim
337
- content = await outputs.outputs.text;
338
- }
339
- else {
340
- return outputs;
324
+ try {
325
+ if (resolvedLsConfig?.processOutputs) {
326
+ return resolvedLsConfig.processOutputs(outputs);
327
+ }
328
+ if (outputs.outputs == null ||
329
+ typeof outputs.outputs !== "object") {
330
+ return outputs;
331
+ }
332
+ // Important: Even accessing this property creates a promise.
333
+ // This must be awaited.
334
+ let content = await outputs.outputs.content;
335
+ if (content == null) {
336
+ // AI SDK 4 shim
337
+ content = await outputs.outputs.text;
338
+ }
339
+ if (content == null ||
340
+ !["object", "string"].includes(typeof content)) {
341
+ return outputs;
342
+ }
343
+ return convertMessageToTracedFormat({
344
+ content,
345
+ role: "assistant",
346
+ });
341
347
  }
342
- if (content == null ||
343
- !["object", "string"].includes(typeof content)) {
348
+ catch (e) {
349
+ // Handle parsing failures without a log
344
350
  return outputs;
345
351
  }
346
- return convertMessageToTracedFormat({
347
- content,
348
- role: "assistant",
349
- });
350
352
  },
351
353
  });
352
354
  return traceableFunc(...args);
@@ -401,17 +403,24 @@ const wrapAISDK = ({ wrapLanguageModel, generateText, streamText, streamObject,
401
403
  return inputFormatter(inputs);
402
404
  },
403
405
  processOutputs: async (outputs) => {
404
- if (resolvedLsConfig?.processOutputs) {
405
- return resolvedLsConfig.processOutputs(outputs);
406
- }
407
- if (outputs.outputs == null || typeof outputs.outputs !== "object") {
408
- return outputs;
406
+ try {
407
+ if (resolvedLsConfig?.processOutputs) {
408
+ return resolvedLsConfig.processOutputs(outputs);
409
+ }
410
+ if (outputs.outputs == null ||
411
+ typeof outputs.outputs !== "object") {
412
+ return outputs;
413
+ }
414
+ const object = await outputs.outputs.object;
415
+ if (object == null || typeof object !== "object") {
416
+ return outputs;
417
+ }
418
+ return object;
409
419
  }
410
- const object = await outputs.outputs.object;
411
- if (object == null || typeof object !== "object") {
420
+ catch (e) {
421
+ // Handle parsing failures without a log
412
422
  return outputs;
413
423
  }
414
- return object;
415
424
  },
416
425
  });
417
426
  return traceableFunc(...args);
@@ -204,7 +204,7 @@ function LangSmithMiddleware(config) {
204
204
  tool_calls: [],
205
205
  });
206
206
  const outputFormatter = lsConfig?.processOutputs ?? utils_js_1.convertMessageToTracedFormat;
207
- const formattedOutputs = outputFormatter(output);
207
+ const formattedOutputs = await outputFormatter(output);
208
208
  await runTree?.end(formattedOutputs);
209
209
  }
210
210
  catch (error) {
@@ -22,6 +22,6 @@ export declare function LangSmithMiddleware(config?: {
22
22
  modelId?: string;
23
23
  lsConfig?: Partial<Omit<RunTreeConfig, "inputs" | "outputs" | "run_type">> & {
24
24
  processInputs?: (inputs: Record<string, unknown>) => Record<string, unknown>;
25
- processOutputs?: (outputs: Record<string, unknown>) => Record<string, unknown>;
25
+ processOutputs?: (outputs: Record<string, unknown>) => Record<string, unknown> | Promise<Record<string, unknown>>;
26
26
  };
27
27
  }): LanguageModelV2Middleware;
@@ -201,7 +201,7 @@ export function LangSmithMiddleware(config) {
201
201
  tool_calls: [],
202
202
  });
203
203
  const outputFormatter = lsConfig?.processOutputs ?? convertMessageToTracedFormat;
204
- const formattedOutputs = outputFormatter(output);
204
+ const formattedOutputs = await outputFormatter(output);
205
205
  await runTree?.end(formattedOutputs);
206
206
  }
207
207
  catch (error) {
package/dist/index.cjs CHANGED
@@ -10,4 +10,4 @@ Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true
10
10
  var project_js_1 = require("./utils/project.cjs");
11
11
  Object.defineProperty(exports, "getDefaultProjectName", { enumerable: true, get: function () { return project_js_1.getDefaultProjectName; } });
12
12
  // Update using yarn bump-version
13
- exports.__version__ = "0.3.68";
13
+ exports.__version__ = "0.3.70";
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, }
3
3
  export { RunTree, type RunTreeConfig } from "./run_trees.js";
4
4
  export { overrideFetchImplementation } from "./singletons/fetch.js";
5
5
  export { getDefaultProjectName } from "./utils/project.js";
6
- export declare const __version__ = "0.3.68";
6
+ export declare const __version__ = "0.3.70";
package/dist/index.js CHANGED
@@ -3,4 +3,4 @@ export { RunTree } from "./run_trees.js";
3
3
  export { overrideFetchImplementation } from "./singletons/fetch.js";
4
4
  export { getDefaultProjectName } from "./utils/project.js";
5
5
  // Update using yarn bump-version
6
- export const __version__ = "0.3.68";
6
+ export const __version__ = "0.3.70";
@@ -166,10 +166,20 @@ async function handleRunOutputs(params) {
166
166
  })
167
167
  .catch(async (e) => {
168
168
  console.error("Error occurred during processOutputs. Sending unprocessed outputs:", e);
169
- await runTree?.end(outputs);
169
+ try {
170
+ await runTree?.end(outputs);
171
+ }
172
+ catch (e) {
173
+ console.error("Error occurred during runTree?.end.", e);
174
+ }
170
175
  })
171
176
  .finally(async () => {
172
- await handleEnd({ runTree, postRunPromise, on_end, excludeInputs });
177
+ try {
178
+ await handleEnd({ runTree, postRunPromise, on_end, excludeInputs });
179
+ }
180
+ catch (e) {
181
+ console.error("Error occurred during handleEnd.", e);
182
+ }
173
183
  });
174
184
  return;
175
185
  }
package/dist/traceable.js CHANGED
@@ -162,10 +162,20 @@ async function handleRunOutputs(params) {
162
162
  })
163
163
  .catch(async (e) => {
164
164
  console.error("Error occurred during processOutputs. Sending unprocessed outputs:", e);
165
- await runTree?.end(outputs);
165
+ try {
166
+ await runTree?.end(outputs);
167
+ }
168
+ catch (e) {
169
+ console.error("Error occurred during runTree?.end.", e);
170
+ }
166
171
  })
167
172
  .finally(async () => {
168
- await handleEnd({ runTree, postRunPromise, on_end, excludeInputs });
173
+ try {
174
+ await handleEnd({ runTree, postRunPromise, on_end, excludeInputs });
175
+ }
176
+ catch (e) {
177
+ console.error("Error occurred during handleEnd.", e);
178
+ }
169
179
  });
170
180
  return;
171
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.68",
3
+ "version": "0.3.70",
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,6 +114,7 @@
114
114
  "test:integration": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000",
115
115
  "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
116
116
  "watch:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --watch --config jest.config.cjs --testTimeout 100000",
117
+ "test:vitest": "vitest run --config vitest.config.ts",
117
118
  "test:eval:vitest": "vitest run --config ls.vitest.config.ts",
118
119
  "lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
119
120
  "lint:fix": "yarn lint --fix",
@@ -148,7 +149,7 @@
148
149
  "uuid": "^10.0.0"
149
150
  },
150
151
  "devDependencies": {
151
- "@ai-sdk/anthropic": "^2.0.1",
152
+ "@ai-sdk/anthropic": "^2.0.17",
152
153
  "@ai-sdk/openai": "^2.0.23",
153
154
  "@babel/preset-env": "^7.22.4",
154
155
  "@faker-js/faker": "^8.4.1",
@@ -167,7 +168,7 @@
167
168
  "@types/node-fetch": "^2.6.12",
168
169
  "@typescript-eslint/eslint-plugin": "^5.59.8",
169
170
  "@typescript-eslint/parser": "^5.59.8",
170
- "ai": "^5.0.10",
171
+ "ai": "^5.0.44",
171
172
  "babel-jest": "^29.5.0",
172
173
  "cross-env": "^7.0.3",
173
174
  "dotenv": "^16.1.3",
@@ -178,6 +179,7 @@
178
179
  "eslint-plugin-prettier": "^4.2.1",
179
180
  "jest": "^29.5.0",
180
181
  "langchain": "^0.3.29",
182
+ "msw": "^2.11.2",
181
183
  "node-fetch": "^2.7.0",
182
184
  "openai": "^5.8.2",
183
185
  "prettier": "^2.8.8",