langsmith 0.2.1 → 0.2.2-rc.0

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
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Client = exports.DEFAULT_BATCH_SIZE_LIMIT_BYTES = exports.Queue = exports.mergeRuntimeEnvIntoRunCreate = void 0;
26
+ exports.Client = exports.DEFAULT_BATCH_SIZE_LIMIT_BYTES = exports.AutoBatchQueue = exports.mergeRuntimeEnvIntoRunCreate = void 0;
27
27
  const uuid = __importStar(require("uuid"));
28
28
  const async_caller_js_1 = require("./utils/async_caller.cjs");
29
29
  const messages_js_1 = require("./utils/messages.cjs");
@@ -102,7 +102,7 @@ const handle429 = async (response) => {
102
102
  // Fall back to existing status checks
103
103
  return false;
104
104
  };
105
- class Queue {
105
+ class AutoBatchQueue {
106
106
  constructor() {
107
107
  Object.defineProperty(this, "items", {
108
108
  enumerable: true,
@@ -169,7 +169,7 @@ class Queue {
169
169
  ];
170
170
  }
171
171
  }
172
- exports.Queue = Queue;
172
+ exports.AutoBatchQueue = AutoBatchQueue;
173
173
  // 20 MB
174
174
  exports.DEFAULT_BATCH_SIZE_LIMIT_BYTES = 20_971_520;
175
175
  const SERVER_INFO_REQUEST_TIMEOUT = 1000;
@@ -251,7 +251,7 @@ class Client {
251
251
  enumerable: true,
252
252
  configurable: true,
253
253
  writable: true,
254
- value: new Queue()
254
+ value: new AutoBatchQueue()
255
255
  });
256
256
  Object.defineProperty(this, "autoBatchTimeout", {
257
257
  enumerable: true,
@@ -539,20 +539,17 @@ class Client {
539
539
  serverInfo.batch_ingest_config?.size_limit_bytes ??
540
540
  exports.DEFAULT_BATCH_SIZE_LIMIT_BYTES);
541
541
  }
542
- async drainAutoBatchQueue() {
543
- const batchSizeLimit = await this._getBatchSizeLimitBytes();
542
+ drainAutoBatchQueue(batchSizeLimit) {
544
543
  while (this.autoBatchQueue.items.length > 0) {
545
- for (let i = 0; i < this.traceBatchConcurrency; i++) {
546
- const [batch, done] = this.autoBatchQueue.pop(batchSizeLimit);
547
- if (!batch.length) {
548
- done();
549
- break;
550
- }
551
- await this.processBatch(batch, done);
544
+ const [batch, done] = this.autoBatchQueue.pop(batchSizeLimit);
545
+ if (!batch.length) {
546
+ done();
547
+ break;
552
548
  }
549
+ void this._processBatch(batch, done).catch(console.error);
553
550
  }
554
551
  }
555
- async processBatch(batch, done) {
552
+ async _processBatch(batch, done) {
556
553
  if (!batch.length) {
557
554
  done();
558
555
  return;
@@ -578,7 +575,7 @@ class Client {
578
575
  done();
579
576
  }
580
577
  }
581
- async processRunOperation(item, immediatelyTriggerBatch) {
578
+ async processRunOperation(item) {
582
579
  const oldTimeout = this.autoBatchTimeout;
583
580
  clearTimeout(this.autoBatchTimeout);
584
581
  this.autoBatchTimeout = undefined;
@@ -587,16 +584,13 @@ class Client {
587
584
  }
588
585
  const itemPromise = this.autoBatchQueue.push(item);
589
586
  const sizeLimitBytes = await this._getBatchSizeLimitBytes();
590
- if (immediatelyTriggerBatch ||
591
- this.autoBatchQueue.sizeBytes > sizeLimitBytes) {
592
- await this.drainAutoBatchQueue().catch(console.error);
587
+ if (this.autoBatchQueue.sizeBytes > sizeLimitBytes) {
588
+ this.drainAutoBatchQueue(sizeLimitBytes);
593
589
  }
594
590
  if (this.autoBatchQueue.items.length > 0) {
595
591
  this.autoBatchTimeout = setTimeout(() => {
596
592
  this.autoBatchTimeout = undefined;
597
- // This error would happen in the background and is uncatchable
598
- // from the outside. So just log instead.
599
- void this.drainAutoBatchQueue().catch(console.error);
593
+ this.drainAutoBatchQueue(sizeLimitBytes);
600
594
  }, oldTimeout
601
595
  ? this.autoBatchAggregationDelayMs
602
596
  : this.autoBatchInitialDelayMs);
@@ -921,9 +915,9 @@ class Client {
921
915
  if (run.end_time !== undefined &&
922
916
  data.parent_run_id === undefined &&
923
917
  this.blockOnRootRunFinalization) {
924
- // Trigger a batch as soon as a root trace ends and block to ensure trace finishes
918
+ // Trigger batches as soon as a root trace ends and wait to ensure trace finishes
925
919
  // in serverless environments.
926
- await this.processRunOperation({ action: "update", item: data }, true);
920
+ await this.processRunOperation({ action: "update", item: data }).catch(console.error);
927
921
  return;
928
922
  }
929
923
  else {
package/dist/client.d.ts CHANGED
@@ -164,7 +164,7 @@ type AutoBatchQueueItem = {
164
164
  item: RunCreate | RunUpdate;
165
165
  };
166
166
  export declare function mergeRuntimeEnvIntoRunCreate(run: RunCreate): RunCreate;
167
- export declare class Queue {
167
+ export declare class AutoBatchQueue {
168
168
  items: {
169
169
  action: "create" | "update";
170
170
  payload: RunCreate | RunUpdate;
@@ -228,7 +228,7 @@ export declare class Client {
228
228
  private _filterForSampling;
229
229
  private _getBatchSizeLimitBytes;
230
230
  private drainAutoBatchQueue;
231
- private processBatch;
231
+ private _processBatch;
232
232
  private processRunOperation;
233
233
  protected _getServerInfo(): Promise<any>;
234
234
  protected _ensureServerInfo(): Promise<Record<string, any>>;
package/dist/client.js CHANGED
@@ -75,7 +75,7 @@ const handle429 = async (response) => {
75
75
  // Fall back to existing status checks
76
76
  return false;
77
77
  };
78
- export class Queue {
78
+ export class AutoBatchQueue {
79
79
  constructor() {
80
80
  Object.defineProperty(this, "items", {
81
81
  enumerable: true,
@@ -223,7 +223,7 @@ export class Client {
223
223
  enumerable: true,
224
224
  configurable: true,
225
225
  writable: true,
226
- value: new Queue()
226
+ value: new AutoBatchQueue()
227
227
  });
228
228
  Object.defineProperty(this, "autoBatchTimeout", {
229
229
  enumerable: true,
@@ -511,20 +511,17 @@ export class Client {
511
511
  serverInfo.batch_ingest_config?.size_limit_bytes ??
512
512
  DEFAULT_BATCH_SIZE_LIMIT_BYTES);
513
513
  }
514
- async drainAutoBatchQueue() {
515
- const batchSizeLimit = await this._getBatchSizeLimitBytes();
514
+ drainAutoBatchQueue(batchSizeLimit) {
516
515
  while (this.autoBatchQueue.items.length > 0) {
517
- for (let i = 0; i < this.traceBatchConcurrency; i++) {
518
- const [batch, done] = this.autoBatchQueue.pop(batchSizeLimit);
519
- if (!batch.length) {
520
- done();
521
- break;
522
- }
523
- await this.processBatch(batch, done);
516
+ const [batch, done] = this.autoBatchQueue.pop(batchSizeLimit);
517
+ if (!batch.length) {
518
+ done();
519
+ break;
524
520
  }
521
+ void this._processBatch(batch, done).catch(console.error);
525
522
  }
526
523
  }
527
- async processBatch(batch, done) {
524
+ async _processBatch(batch, done) {
528
525
  if (!batch.length) {
529
526
  done();
530
527
  return;
@@ -550,7 +547,7 @@ export class Client {
550
547
  done();
551
548
  }
552
549
  }
553
- async processRunOperation(item, immediatelyTriggerBatch) {
550
+ async processRunOperation(item) {
554
551
  const oldTimeout = this.autoBatchTimeout;
555
552
  clearTimeout(this.autoBatchTimeout);
556
553
  this.autoBatchTimeout = undefined;
@@ -559,16 +556,13 @@ export class Client {
559
556
  }
560
557
  const itemPromise = this.autoBatchQueue.push(item);
561
558
  const sizeLimitBytes = await this._getBatchSizeLimitBytes();
562
- if (immediatelyTriggerBatch ||
563
- this.autoBatchQueue.sizeBytes > sizeLimitBytes) {
564
- await this.drainAutoBatchQueue().catch(console.error);
559
+ if (this.autoBatchQueue.sizeBytes > sizeLimitBytes) {
560
+ this.drainAutoBatchQueue(sizeLimitBytes);
565
561
  }
566
562
  if (this.autoBatchQueue.items.length > 0) {
567
563
  this.autoBatchTimeout = setTimeout(() => {
568
564
  this.autoBatchTimeout = undefined;
569
- // This error would happen in the background and is uncatchable
570
- // from the outside. So just log instead.
571
- void this.drainAutoBatchQueue().catch(console.error);
565
+ this.drainAutoBatchQueue(sizeLimitBytes);
572
566
  }, oldTimeout
573
567
  ? this.autoBatchAggregationDelayMs
574
568
  : this.autoBatchInitialDelayMs);
@@ -893,9 +887,9 @@ export class Client {
893
887
  if (run.end_time !== undefined &&
894
888
  data.parent_run_id === undefined &&
895
889
  this.blockOnRootRunFinalization) {
896
- // Trigger a batch as soon as a root trace ends and block to ensure trace finishes
890
+ // Trigger batches as soon as a root trace ends and wait to ensure trace finishes
897
891
  // in serverless environments.
898
- await this.processRunOperation({ action: "update", item: data }, true);
892
+ await this.processRunOperation({ action: "update", item: data }).catch(console.error);
899
893
  return;
900
894
  }
901
895
  else {
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.1";
11
+ exports.__version__ = "0.2.2-rc.0";
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.1";
5
+ export declare const __version__ = "0.2.2-rc.0";
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.1";
5
+ export const __version__ = "0.2.2-rc.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.2.1",
3
+ "version": "0.2.2-rc.0",
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": [