langsmith 0.3.18 → 0.3.19

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
@@ -332,6 +332,12 @@ class Client {
332
332
  writable: true,
333
333
  value: false
334
334
  });
335
+ Object.defineProperty(this, "debug", {
336
+ enumerable: true,
337
+ configurable: true,
338
+ writable: true,
339
+ value: (0, env_js_1.getEnvironmentVariable)("LANGSMITH_DEBUG") === "true"
340
+ });
335
341
  const defaultConfig = Client.getDefaultClientConfig();
336
342
  this.tracingSampleRate = getTracingSamplingRate(config.tracingSamplingRate);
337
343
  this.apiUrl = trimQuotes(config.apiUrl ?? defaultConfig.apiUrl) ?? "";
@@ -344,17 +350,22 @@ class Client {
344
350
  this.webUrl = this.webUrl.slice(0, -1);
345
351
  }
346
352
  this.timeout_ms = config.timeout_ms ?? 90_000;
347
- this.caller = new async_caller_js_1.AsyncCaller(config.callerOptions ?? {});
353
+ this.caller = new async_caller_js_1.AsyncCaller({
354
+ ...(config.callerOptions ?? {}),
355
+ debug: config.debug ?? this.debug,
356
+ });
348
357
  this.traceBatchConcurrency =
349
358
  config.traceBatchConcurrency ?? this.traceBatchConcurrency;
350
359
  if (this.traceBatchConcurrency < 1) {
351
360
  throw new Error("Trace batch concurrency must be positive.");
352
361
  }
362
+ this.debug = config.debug ?? this.debug;
353
363
  this.batchIngestCaller = new async_caller_js_1.AsyncCaller({
354
364
  maxRetries: 2,
355
365
  maxConcurrency: this.traceBatchConcurrency,
356
366
  ...(config.callerOptions ?? {}),
357
367
  onFailedResponseHook: handle429,
368
+ debug: config.debug ?? this.debug,
358
369
  });
359
370
  this.hideInputs =
360
371
  config.hideInputs ?? config.anonymizer ?? defaultConfig.hideInputs;
@@ -461,7 +472,7 @@ class Client {
461
472
  async _getResponse(path, queryParams) {
462
473
  const paramsString = queryParams?.toString() ?? "";
463
474
  const url = `${this.apiUrl}${path}?${paramsString}`;
464
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), url, {
475
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), url, {
465
476
  method: "GET",
466
477
  headers: this.headers,
467
478
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -481,7 +492,7 @@ class Client {
481
492
  queryParams.set("offset", String(offset));
482
493
  queryParams.set("limit", String(limit));
483
494
  const url = `${this.apiUrl}${path}?${queryParams}`;
484
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), url, {
495
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), url, {
485
496
  method: "GET",
486
497
  headers: this.headers,
487
498
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -504,7 +515,7 @@ class Client {
504
515
  async *_getCursorPaginatedList(path, body = null, requestMethod = "POST", dataKey = "runs") {
505
516
  const bodyParams = body ? { ...body } : {};
506
517
  while (true) {
507
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}${path}`, {
518
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}${path}`, {
508
519
  method: requestMethod,
509
520
  headers: { ...this.headers, "Content-Type": "application/json" },
510
521
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -651,14 +662,20 @@ class Client {
651
662
  return itemPromise;
652
663
  }
653
664
  async _getServerInfo() {
654
- const response = await (0, fetch_js_1._getFetchImplementation)()(`${this.apiUrl}/info`, {
665
+ const response = await (0, fetch_js_1._getFetchImplementation)(this.debug)(`${this.apiUrl}/info`, {
655
666
  method: "GET",
656
667
  headers: { Accept: "application/json" },
657
668
  signal: AbortSignal.timeout(SERVER_INFO_REQUEST_TIMEOUT),
658
669
  ...this.fetchOptions,
659
670
  });
660
671
  await (0, error_js_1.raiseForStatus)(response, "get server info");
661
- return response.json();
672
+ const json = await response.json();
673
+ if (this.debug) {
674
+ console.log("\n=== LangSmith Server Configuration ===\n" +
675
+ JSON.stringify(json, null, 2) +
676
+ "\n");
677
+ }
678
+ return json;
662
679
  }
663
680
  async _ensureServerInfo() {
664
681
  if (this._getServerInfoPromise === undefined) {
@@ -716,7 +733,7 @@ class Client {
716
733
  return;
717
734
  }
718
735
  const mergedRunCreateParam = mergeRuntimeEnvIntoRunCreate(runCreate);
719
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs`, {
736
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/runs`, {
720
737
  method: "POST",
721
738
  headers,
722
739
  body: (0, index_js_2.serialize)(mergedRunCreateParam),
@@ -789,7 +806,7 @@ class Client {
789
806
  "Content-Type": "application/json",
790
807
  Accept: "application/json",
791
808
  };
792
- const response = await this.batchIngestCaller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/batch`, {
809
+ const response = await this.batchIngestCaller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/runs/batch`, {
793
810
  method: "POST",
794
811
  headers,
795
812
  body: body,
@@ -952,7 +969,7 @@ class Client {
952
969
  const body = new Blob(chunks);
953
970
  // Convert Blob to ArrayBuffer for compatibility
954
971
  const arrayBuffer = await body.arrayBuffer();
955
- const res = await this.batchIngestCaller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/multipart`, {
972
+ const res = await this.batchIngestCaller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/runs/multipart`, {
956
973
  method: "POST",
957
974
  headers: {
958
975
  ...this.headers,
@@ -1000,7 +1017,7 @@ class Client {
1000
1017
  return;
1001
1018
  }
1002
1019
  const headers = { ...this.headers, "Content-Type": "application/json" };
1003
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/${runId}`, {
1020
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/runs/${runId}`, {
1004
1021
  method: "PATCH",
1005
1022
  headers,
1006
1023
  body: (0, index_js_2.serialize)(run),
@@ -1264,7 +1281,7 @@ class Client {
1264
1281
  };
1265
1282
  // Remove undefined values from the payload
1266
1283
  const filteredPayload = Object.fromEntries(Object.entries(payload).filter(([_, value]) => value !== undefined));
1267
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/stats`, {
1284
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/runs/stats`, {
1268
1285
  method: "POST",
1269
1286
  headers: this.headers,
1270
1287
  body: JSON.stringify(filteredPayload),
@@ -1280,7 +1297,7 @@ class Client {
1280
1297
  share_token: shareId || uuid.v4(),
1281
1298
  };
1282
1299
  (0, _uuid_js_1.assertUuid)(runId);
1283
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/${runId}/share`, {
1300
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/runs/${runId}/share`, {
1284
1301
  method: "PUT",
1285
1302
  headers: this.headers,
1286
1303
  body: JSON.stringify(data),
@@ -1295,7 +1312,7 @@ class Client {
1295
1312
  }
1296
1313
  async unshareRun(runId) {
1297
1314
  (0, _uuid_js_1.assertUuid)(runId);
1298
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/${runId}/share`, {
1315
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/runs/${runId}/share`, {
1299
1316
  method: "DELETE",
1300
1317
  headers: this.headers,
1301
1318
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1305,7 +1322,7 @@ class Client {
1305
1322
  }
1306
1323
  async readRunSharedLink(runId) {
1307
1324
  (0, _uuid_js_1.assertUuid)(runId);
1308
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/runs/${runId}/share`, {
1325
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/runs/${runId}/share`, {
1309
1326
  method: "GET",
1310
1327
  headers: this.headers,
1311
1328
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1327,7 +1344,7 @@ class Client {
1327
1344
  }
1328
1345
  }
1329
1346
  (0, _uuid_js_1.assertUuid)(shareToken);
1330
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
1347
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
1331
1348
  method: "GET",
1332
1349
  headers: this.headers,
1333
1350
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1345,7 +1362,7 @@ class Client {
1345
1362
  datasetId = dataset.id;
1346
1363
  }
1347
1364
  (0, _uuid_js_1.assertUuid)(datasetId);
1348
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${datasetId}/share`, {
1365
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${datasetId}/share`, {
1349
1366
  method: "GET",
1350
1367
  headers: this.headers,
1351
1368
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1367,7 +1384,7 @@ class Client {
1367
1384
  dataset_id: datasetId,
1368
1385
  };
1369
1386
  (0, _uuid_js_1.assertUuid)(datasetId);
1370
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${datasetId}/share`, {
1387
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${datasetId}/share`, {
1371
1388
  method: "PUT",
1372
1389
  headers: this.headers,
1373
1390
  body: JSON.stringify(data),
@@ -1380,7 +1397,7 @@ class Client {
1380
1397
  }
1381
1398
  async unshareDataset(datasetId) {
1382
1399
  (0, _uuid_js_1.assertUuid)(datasetId);
1383
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${datasetId}/share`, {
1400
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${datasetId}/share`, {
1384
1401
  method: "DELETE",
1385
1402
  headers: this.headers,
1386
1403
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1390,7 +1407,7 @@ class Client {
1390
1407
  }
1391
1408
  async readSharedDataset(shareToken) {
1392
1409
  (0, _uuid_js_1.assertUuid)(shareToken);
1393
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/public/${shareToken}/datasets`, {
1410
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/public/${shareToken}/datasets`, {
1394
1411
  method: "GET",
1395
1412
  headers: this.headers,
1396
1413
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1421,7 +1438,7 @@ class Client {
1421
1438
  urlParams.append(key, value);
1422
1439
  }
1423
1440
  });
1424
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/public/${shareToken}/examples?${urlParams.toString()}`, {
1441
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/public/${shareToken}/examples?${urlParams.toString()}`, {
1425
1442
  method: "GET",
1426
1443
  headers: this.headers,
1427
1444
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1454,7 +1471,7 @@ class Client {
1454
1471
  if (referenceDatasetId !== null) {
1455
1472
  body["reference_dataset_id"] = referenceDatasetId;
1456
1473
  }
1457
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), endpoint, {
1474
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), endpoint, {
1458
1475
  method: "POST",
1459
1476
  headers: { ...this.headers, "Content-Type": "application/json" },
1460
1477
  body: JSON.stringify(body),
@@ -1477,7 +1494,7 @@ class Client {
1477
1494
  description,
1478
1495
  end_time: endTime ? new Date(endTime).toISOString() : null,
1479
1496
  };
1480
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), endpoint, {
1497
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), endpoint, {
1481
1498
  method: "PATCH",
1482
1499
  headers: { ...this.headers, "Content-Type": "application/json" },
1483
1500
  body: JSON.stringify(body),
@@ -1505,7 +1522,7 @@ class Client {
1505
1522
  else {
1506
1523
  throw new Error("Must provide projectName or projectId");
1507
1524
  }
1508
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}${path}?${params}`, {
1525
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}${path}?${params}`, {
1509
1526
  method: "GET",
1510
1527
  headers: this.headers,
1511
1528
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1635,7 +1652,7 @@ class Client {
1635
1652
  projectId_ = projectId;
1636
1653
  }
1637
1654
  (0, _uuid_js_1.assertUuid)(projectId_);
1638
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/sessions/${projectId_}`, {
1655
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/sessions/${projectId_}`, {
1639
1656
  method: "DELETE",
1640
1657
  headers: this.headers,
1641
1658
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1662,7 +1679,7 @@ class Client {
1662
1679
  if (name) {
1663
1680
  formData.append("name", name);
1664
1681
  }
1665
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), url, {
1682
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), url, {
1666
1683
  method: "POST",
1667
1684
  headers: this.headers,
1668
1685
  body: formData,
@@ -1688,7 +1705,7 @@ class Client {
1688
1705
  if (outputsSchema) {
1689
1706
  body.outputs_schema_definition = outputsSchema;
1690
1707
  }
1691
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets`, {
1708
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets`, {
1692
1709
  method: "POST",
1693
1710
  headers: { ...this.headers, "Content-Type": "application/json" },
1694
1711
  body: JSON.stringify(body),
@@ -1820,7 +1837,7 @@ class Client {
1820
1837
  }
1821
1838
  const _datasetId = datasetId ?? (await this.readDataset({ datasetName })).id;
1822
1839
  (0, _uuid_js_1.assertUuid)(_datasetId);
1823
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${_datasetId}`, {
1840
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${_datasetId}`, {
1824
1841
  method: "PATCH",
1825
1842
  headers: { ...this.headers, "Content-Type": "application/json" },
1826
1843
  body: JSON.stringify(update),
@@ -1852,7 +1869,7 @@ class Client {
1852
1869
  }
1853
1870
  const _datasetId = datasetId ?? (await this.readDataset({ datasetName })).id;
1854
1871
  (0, _uuid_js_1.assertUuid)(_datasetId);
1855
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${_datasetId}/tags`, {
1872
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${_datasetId}/tags`, {
1856
1873
  method: "PUT",
1857
1874
  headers: { ...this.headers, "Content-Type": "application/json" },
1858
1875
  body: JSON.stringify({
@@ -1881,7 +1898,7 @@ class Client {
1881
1898
  else {
1882
1899
  throw new Error("Must provide datasetName or datasetId");
1883
1900
  }
1884
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), this.apiUrl + path, {
1901
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), this.apiUrl + path, {
1885
1902
  method: "DELETE",
1886
1903
  headers: this.headers,
1887
1904
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1906,7 +1923,7 @@ class Client {
1906
1923
  const data = {
1907
1924
  tag: tag,
1908
1925
  };
1909
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${datasetId_}/index`, {
1926
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${datasetId_}/index`, {
1910
1927
  method: "POST",
1911
1928
  headers: { ...this.headers, "Content-Type": "application/json" },
1912
1929
  body: JSON.stringify(data),
@@ -1955,7 +1972,7 @@ class Client {
1955
1972
  data["filter"] = filter;
1956
1973
  }
1957
1974
  (0, _uuid_js_1.assertUuid)(datasetId);
1958
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${datasetId}/search`, {
1975
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${datasetId}/search`, {
1959
1976
  method: "POST",
1960
1977
  headers: { ...this.headers, "Content-Type": "application/json" },
1961
1978
  body: JSON.stringify(data),
@@ -2174,7 +2191,7 @@ class Client {
2174
2191
  async deleteExample(exampleId) {
2175
2192
  (0, _uuid_js_1.assertUuid)(exampleId);
2176
2193
  const path = `/examples/${exampleId}`;
2177
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), this.apiUrl + path, {
2194
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), this.apiUrl + path, {
2178
2195
  method: "DELETE",
2179
2196
  headers: this.headers,
2180
2197
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2253,7 +2270,7 @@ class Client {
2253
2270
  if (tag !== undefined) {
2254
2271
  params.append("tag", tag);
2255
2272
  }
2256
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
2273
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
2257
2274
  method: "GET",
2258
2275
  headers: { ...this.headers },
2259
2276
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2314,7 +2331,7 @@ class Client {
2314
2331
  }),
2315
2332
  remove,
2316
2333
  };
2317
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${datasetId_}/splits`, {
2334
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/${datasetId_}/splits`, {
2318
2335
  method: "PUT",
2319
2336
  headers: { ...this.headers, "Content-Type": "application/json" },
2320
2337
  body: JSON.stringify(data),
@@ -2380,7 +2397,7 @@ class Client {
2380
2397
  session_id: projectId,
2381
2398
  };
2382
2399
  const url = `${this.apiUrl}/feedback`;
2383
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), url, {
2400
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), url, {
2384
2401
  method: "POST",
2385
2402
  headers: { ...this.headers, "Content-Type": "application/json" },
2386
2403
  body: JSON.stringify(feedback),
@@ -2405,7 +2422,7 @@ class Client {
2405
2422
  feedbackUpdate["comment"] = comment;
2406
2423
  }
2407
2424
  (0, _uuid_js_1.assertUuid)(feedbackId);
2408
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/feedback/${feedbackId}`, {
2425
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/feedback/${feedbackId}`, {
2409
2426
  method: "PATCH",
2410
2427
  headers: { ...this.headers, "Content-Type": "application/json" },
2411
2428
  body: JSON.stringify(feedbackUpdate),
@@ -2423,7 +2440,7 @@ class Client {
2423
2440
  async deleteFeedback(feedbackId) {
2424
2441
  (0, _uuid_js_1.assertUuid)(feedbackId);
2425
2442
  const path = `/feedback/${feedbackId}`;
2426
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), this.apiUrl + path, {
2443
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), this.apiUrl + path, {
2427
2444
  method: "DELETE",
2428
2445
  headers: this.headers,
2429
2446
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2485,7 +2502,7 @@ class Client {
2485
2502
  hours: 3,
2486
2503
  };
2487
2504
  }
2488
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/feedback/tokens`, {
2505
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/feedback/tokens`, {
2489
2506
  method: "POST",
2490
2507
  headers: { ...this.headers, "Content-Type": "application/json" },
2491
2508
  body: JSON.stringify(body),
@@ -2518,7 +2535,7 @@ class Client {
2518
2535
  };
2519
2536
  if (metadata)
2520
2537
  body.extra["metadata"] = metadata;
2521
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/comparative`, {
2538
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/datasets/comparative`, {
2522
2539
  method: "POST",
2523
2540
  headers: { ...this.headers, "Content-Type": "application/json" },
2524
2541
  body: JSON.stringify(body),
@@ -2633,7 +2650,7 @@ class Client {
2633
2650
  description,
2634
2651
  id: queueId || uuid.v4(),
2635
2652
  };
2636
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/annotation-queues`, {
2653
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues`, {
2637
2654
  method: "POST",
2638
2655
  headers: { ...this.headers, "Content-Type": "application/json" },
2639
2656
  body: JSON.stringify(Object.fromEntries(Object.entries(body).filter(([_, v]) => v !== undefined))),
@@ -2668,7 +2685,7 @@ class Client {
2668
2685
  */
2669
2686
  async updateAnnotationQueue(queueId, options) {
2670
2687
  const { name, description } = options;
2671
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
2688
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
2672
2689
  method: "PATCH",
2673
2690
  headers: { ...this.headers, "Content-Type": "application/json" },
2674
2691
  body: JSON.stringify({ name, description }),
@@ -2682,7 +2699,7 @@ class Client {
2682
2699
  * @param queueId - The ID of the annotation queue to delete
2683
2700
  */
2684
2701
  async deleteAnnotationQueue(queueId) {
2685
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
2702
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
2686
2703
  method: "DELETE",
2687
2704
  headers: { ...this.headers, Accept: "application/json" },
2688
2705
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2696,7 +2713,7 @@ class Client {
2696
2713
  * @param runIds - The IDs of the runs to be added to the annotation queue
2697
2714
  */
2698
2715
  async addRunsToAnnotationQueue(queueId, runIds) {
2699
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs`, {
2716
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs`, {
2700
2717
  method: "POST",
2701
2718
  headers: { ...this.headers, "Content-Type": "application/json" },
2702
2719
  body: JSON.stringify(runIds.map((id, i) => (0, _uuid_js_1.assertUuid)(id, `runIds[${i}]`).toString())),
@@ -2714,7 +2731,7 @@ class Client {
2714
2731
  */
2715
2732
  async getRunFromAnnotationQueue(queueId, index) {
2716
2733
  const baseUrl = `/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/run`;
2717
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}${baseUrl}/${index}`, {
2734
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}${baseUrl}/${index}`, {
2718
2735
  method: "GET",
2719
2736
  headers: this.headers,
2720
2737
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2729,7 +2746,7 @@ class Client {
2729
2746
  * @param queueRunId - The ID of the run to delete from the annotation queue
2730
2747
  */
2731
2748
  async deleteRunFromAnnotationQueue(queueId, queueRunId) {
2732
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs/${(0, _uuid_js_1.assertUuid)(queueRunId, "queueRunId")}`, {
2749
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs/${(0, _uuid_js_1.assertUuid)(queueRunId, "queueRunId")}`, {
2733
2750
  method: "DELETE",
2734
2751
  headers: { ...this.headers, Accept: "application/json" },
2735
2752
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2742,7 +2759,7 @@ class Client {
2742
2759
  * @param queueId - The ID of the annotation queue
2743
2760
  */
2744
2761
  async getSizeFromAnnotationQueue(queueId) {
2745
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/size`, {
2762
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/size`, {
2746
2763
  method: "GET",
2747
2764
  headers: this.headers,
2748
2765
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2762,7 +2779,7 @@ class Client {
2762
2779
  Requested tenant: ${owner}`);
2763
2780
  }
2764
2781
  async _getLatestCommitHash(promptOwnerAndName) {
2765
- const res = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/commits/${promptOwnerAndName}/?limit=${1}&offset=${0}`, {
2782
+ const res = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/commits/${promptOwnerAndName}/?limit=${1}&offset=${0}`, {
2766
2783
  method: "GET",
2767
2784
  headers: this.headers,
2768
2785
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2785,7 +2802,7 @@ class Client {
2785
2802
  }
2786
2803
  async _likeOrUnlikePrompt(promptIdentifier, like) {
2787
2804
  const [owner, promptName, _] = (0, prompts_js_1.parsePromptIdentifier)(promptIdentifier);
2788
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/likes/${owner}/${promptName}`, {
2805
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/likes/${owner}/${promptName}`, {
2789
2806
  method: "POST",
2790
2807
  body: JSON.stringify({ like: like }),
2791
2808
  headers: { ...this.headers, "Content-Type": "application/json" },
@@ -2847,7 +2864,7 @@ class Client {
2847
2864
  }
2848
2865
  async getPrompt(promptIdentifier) {
2849
2866
  const [owner, promptName, _] = (0, prompts_js_1.parsePromptIdentifier)(promptIdentifier);
2850
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/repos/${owner}/${promptName}`, {
2867
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/repos/${owner}/${promptName}`, {
2851
2868
  method: "GET",
2852
2869
  headers: this.headers,
2853
2870
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2884,7 +2901,7 @@ class Client {
2884
2901
  ...(options?.tags && { tags: options.tags }),
2885
2902
  is_public: !!options?.isPublic,
2886
2903
  };
2887
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/repos/`, {
2904
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/repos/`, {
2888
2905
  method: "POST",
2889
2906
  headers: { ...this.headers, "Content-Type": "application/json" },
2890
2907
  body: JSON.stringify(data),
@@ -2907,7 +2924,7 @@ class Client {
2907
2924
  manifest: JSON.parse(JSON.stringify(object)),
2908
2925
  parent_commit: resolvedParentCommitHash,
2909
2926
  };
2910
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/commits/${owner}/${promptName}`, {
2927
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/commits/${owner}/${promptName}`, {
2911
2928
  method: "POST",
2912
2929
  headers: { ...this.headers, "Content-Type": "application/json" },
2913
2930
  body: JSON.stringify(payload),
@@ -2987,7 +3004,7 @@ class Client {
2987
3004
  }
2988
3005
  }
2989
3006
  const datasetIdToUse = datasetId ?? updates[0]?.dataset_id;
2990
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/v1/platform/datasets/${datasetIdToUse}/examples`, {
3007
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/v1/platform/datasets/${datasetIdToUse}/examples`, {
2991
3008
  method: "PATCH",
2992
3009
  headers: this.headers,
2993
3010
  body: formData,
@@ -3065,7 +3082,7 @@ class Client {
3065
3082
  }
3066
3083
  }
3067
3084
  }
3068
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/v1/platform/datasets/${datasetId}/examples`, {
3085
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/v1/platform/datasets/${datasetId}/examples`, {
3069
3086
  method: "POST",
3070
3087
  headers: this.headers,
3071
3088
  body: formData,
@@ -3097,7 +3114,7 @@ class Client {
3097
3114
  if (Object.keys(payload).length === 0) {
3098
3115
  throw new Error("No valid update options provided");
3099
3116
  }
3100
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/repos/${owner}/${promptName}`, {
3117
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/repos/${owner}/${promptName}`, {
3101
3118
  method: "PATCH",
3102
3119
  body: JSON.stringify(payload),
3103
3120
  headers: {
@@ -3118,7 +3135,7 @@ class Client {
3118
3135
  if (!(await this._currentTenantIsOwner(owner))) {
3119
3136
  throw await this._ownerConflictError("delete a prompt", owner);
3120
3137
  }
3121
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/repos/${owner}/${promptName}`, {
3138
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/repos/${owner}/${promptName}`, {
3122
3139
  method: "DELETE",
3123
3140
  headers: this.headers,
3124
3141
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -3128,7 +3145,7 @@ class Client {
3128
3145
  }
3129
3146
  async pullPromptCommit(promptIdentifier, options) {
3130
3147
  const [owner, promptName, commitHash] = (0, prompts_js_1.parsePromptIdentifier)(promptIdentifier);
3131
- const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/commits/${owner}/${promptName}/${commitHash}${options?.includeModel ? "?include_model=true" : ""}`, {
3148
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/commits/${owner}/${promptName}/${commitHash}${options?.includeModel ? "?include_model=true" : ""}`, {
3132
3149
  method: "GET",
3133
3150
  headers: this.headers,
3134
3151
  signal: AbortSignal.timeout(this.timeout_ms),
package/dist/client.d.ts CHANGED
@@ -21,6 +21,10 @@ export interface ClientConfig {
21
21
  */
22
22
  manualFlushMode?: boolean;
23
23
  tracingSamplingRate?: number;
24
+ /**
25
+ * Enable debug mode for the client. If set, all sent HTTP requests will be logged.
26
+ */
27
+ debug?: boolean;
24
28
  }
25
29
  /**
26
30
  * Represents the parameters for listing runs (spans) from the Langsmith server.
@@ -228,6 +232,7 @@ export declare class Client implements LangSmithTracingClientInterface {
228
232
  private _serverInfo;
229
233
  private _getServerInfoPromise?;
230
234
  private manualFlushMode;
235
+ debug: boolean;
231
236
  constructor(config?: ClientConfig);
232
237
  static getDefaultClientConfig(): {
233
238
  apiUrl: string;
package/dist/client.js CHANGED
@@ -294,6 +294,12 @@ export class Client {
294
294
  writable: true,
295
295
  value: false
296
296
  });
297
+ Object.defineProperty(this, "debug", {
298
+ enumerable: true,
299
+ configurable: true,
300
+ writable: true,
301
+ value: getEnvironmentVariable("LANGSMITH_DEBUG") === "true"
302
+ });
297
303
  const defaultConfig = Client.getDefaultClientConfig();
298
304
  this.tracingSampleRate = getTracingSamplingRate(config.tracingSamplingRate);
299
305
  this.apiUrl = trimQuotes(config.apiUrl ?? defaultConfig.apiUrl) ?? "";
@@ -306,17 +312,22 @@ export class Client {
306
312
  this.webUrl = this.webUrl.slice(0, -1);
307
313
  }
308
314
  this.timeout_ms = config.timeout_ms ?? 90_000;
309
- this.caller = new AsyncCaller(config.callerOptions ?? {});
315
+ this.caller = new AsyncCaller({
316
+ ...(config.callerOptions ?? {}),
317
+ debug: config.debug ?? this.debug,
318
+ });
310
319
  this.traceBatchConcurrency =
311
320
  config.traceBatchConcurrency ?? this.traceBatchConcurrency;
312
321
  if (this.traceBatchConcurrency < 1) {
313
322
  throw new Error("Trace batch concurrency must be positive.");
314
323
  }
324
+ this.debug = config.debug ?? this.debug;
315
325
  this.batchIngestCaller = new AsyncCaller({
316
326
  maxRetries: 2,
317
327
  maxConcurrency: this.traceBatchConcurrency,
318
328
  ...(config.callerOptions ?? {}),
319
329
  onFailedResponseHook: handle429,
330
+ debug: config.debug ?? this.debug,
320
331
  });
321
332
  this.hideInputs =
322
333
  config.hideInputs ?? config.anonymizer ?? defaultConfig.hideInputs;
@@ -423,7 +434,7 @@ export class Client {
423
434
  async _getResponse(path, queryParams) {
424
435
  const paramsString = queryParams?.toString() ?? "";
425
436
  const url = `${this.apiUrl}${path}?${paramsString}`;
426
- const response = await this.caller.call(_getFetchImplementation(), url, {
437
+ const response = await this.caller.call(_getFetchImplementation(this.debug), url, {
427
438
  method: "GET",
428
439
  headers: this.headers,
429
440
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -443,7 +454,7 @@ export class Client {
443
454
  queryParams.set("offset", String(offset));
444
455
  queryParams.set("limit", String(limit));
445
456
  const url = `${this.apiUrl}${path}?${queryParams}`;
446
- const response = await this.caller.call(_getFetchImplementation(), url, {
457
+ const response = await this.caller.call(_getFetchImplementation(this.debug), url, {
447
458
  method: "GET",
448
459
  headers: this.headers,
449
460
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -466,7 +477,7 @@ export class Client {
466
477
  async *_getCursorPaginatedList(path, body = null, requestMethod = "POST", dataKey = "runs") {
467
478
  const bodyParams = body ? { ...body } : {};
468
479
  while (true) {
469
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}${path}`, {
480
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}${path}`, {
470
481
  method: requestMethod,
471
482
  headers: { ...this.headers, "Content-Type": "application/json" },
472
483
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -613,14 +624,20 @@ export class Client {
613
624
  return itemPromise;
614
625
  }
615
626
  async _getServerInfo() {
616
- const response = await _getFetchImplementation()(`${this.apiUrl}/info`, {
627
+ const response = await _getFetchImplementation(this.debug)(`${this.apiUrl}/info`, {
617
628
  method: "GET",
618
629
  headers: { Accept: "application/json" },
619
630
  signal: AbortSignal.timeout(SERVER_INFO_REQUEST_TIMEOUT),
620
631
  ...this.fetchOptions,
621
632
  });
622
633
  await raiseForStatus(response, "get server info");
623
- return response.json();
634
+ const json = await response.json();
635
+ if (this.debug) {
636
+ console.log("\n=== LangSmith Server Configuration ===\n" +
637
+ JSON.stringify(json, null, 2) +
638
+ "\n");
639
+ }
640
+ return json;
624
641
  }
625
642
  async _ensureServerInfo() {
626
643
  if (this._getServerInfoPromise === undefined) {
@@ -678,7 +695,7 @@ export class Client {
678
695
  return;
679
696
  }
680
697
  const mergedRunCreateParam = mergeRuntimeEnvIntoRunCreate(runCreate);
681
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/runs`, {
698
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/runs`, {
682
699
  method: "POST",
683
700
  headers,
684
701
  body: serializePayloadForTracing(mergedRunCreateParam),
@@ -751,7 +768,7 @@ export class Client {
751
768
  "Content-Type": "application/json",
752
769
  Accept: "application/json",
753
770
  };
754
- const response = await this.batchIngestCaller.call(_getFetchImplementation(), `${this.apiUrl}/runs/batch`, {
771
+ const response = await this.batchIngestCaller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/runs/batch`, {
755
772
  method: "POST",
756
773
  headers,
757
774
  body: body,
@@ -914,7 +931,7 @@ export class Client {
914
931
  const body = new Blob(chunks);
915
932
  // Convert Blob to ArrayBuffer for compatibility
916
933
  const arrayBuffer = await body.arrayBuffer();
917
- const res = await this.batchIngestCaller.call(_getFetchImplementation(), `${this.apiUrl}/runs/multipart`, {
934
+ const res = await this.batchIngestCaller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/runs/multipart`, {
918
935
  method: "POST",
919
936
  headers: {
920
937
  ...this.headers,
@@ -962,7 +979,7 @@ export class Client {
962
979
  return;
963
980
  }
964
981
  const headers = { ...this.headers, "Content-Type": "application/json" };
965
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/runs/${runId}`, {
982
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/runs/${runId}`, {
966
983
  method: "PATCH",
967
984
  headers,
968
985
  body: serializePayloadForTracing(run),
@@ -1226,7 +1243,7 @@ export class Client {
1226
1243
  };
1227
1244
  // Remove undefined values from the payload
1228
1245
  const filteredPayload = Object.fromEntries(Object.entries(payload).filter(([_, value]) => value !== undefined));
1229
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/runs/stats`, {
1246
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/runs/stats`, {
1230
1247
  method: "POST",
1231
1248
  headers: this.headers,
1232
1249
  body: JSON.stringify(filteredPayload),
@@ -1242,7 +1259,7 @@ export class Client {
1242
1259
  share_token: shareId || uuid.v4(),
1243
1260
  };
1244
1261
  assertUuid(runId);
1245
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/runs/${runId}/share`, {
1262
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/runs/${runId}/share`, {
1246
1263
  method: "PUT",
1247
1264
  headers: this.headers,
1248
1265
  body: JSON.stringify(data),
@@ -1257,7 +1274,7 @@ export class Client {
1257
1274
  }
1258
1275
  async unshareRun(runId) {
1259
1276
  assertUuid(runId);
1260
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/runs/${runId}/share`, {
1277
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/runs/${runId}/share`, {
1261
1278
  method: "DELETE",
1262
1279
  headers: this.headers,
1263
1280
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1267,7 +1284,7 @@ export class Client {
1267
1284
  }
1268
1285
  async readRunSharedLink(runId) {
1269
1286
  assertUuid(runId);
1270
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/runs/${runId}/share`, {
1287
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/runs/${runId}/share`, {
1271
1288
  method: "GET",
1272
1289
  headers: this.headers,
1273
1290
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1289,7 +1306,7 @@ export class Client {
1289
1306
  }
1290
1307
  }
1291
1308
  assertUuid(shareToken);
1292
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
1309
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
1293
1310
  method: "GET",
1294
1311
  headers: this.headers,
1295
1312
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1307,7 +1324,7 @@ export class Client {
1307
1324
  datasetId = dataset.id;
1308
1325
  }
1309
1326
  assertUuid(datasetId);
1310
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${datasetId}/share`, {
1327
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${datasetId}/share`, {
1311
1328
  method: "GET",
1312
1329
  headers: this.headers,
1313
1330
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1329,7 +1346,7 @@ export class Client {
1329
1346
  dataset_id: datasetId,
1330
1347
  };
1331
1348
  assertUuid(datasetId);
1332
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${datasetId}/share`, {
1349
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${datasetId}/share`, {
1333
1350
  method: "PUT",
1334
1351
  headers: this.headers,
1335
1352
  body: JSON.stringify(data),
@@ -1342,7 +1359,7 @@ export class Client {
1342
1359
  }
1343
1360
  async unshareDataset(datasetId) {
1344
1361
  assertUuid(datasetId);
1345
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${datasetId}/share`, {
1362
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${datasetId}/share`, {
1346
1363
  method: "DELETE",
1347
1364
  headers: this.headers,
1348
1365
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1352,7 +1369,7 @@ export class Client {
1352
1369
  }
1353
1370
  async readSharedDataset(shareToken) {
1354
1371
  assertUuid(shareToken);
1355
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/public/${shareToken}/datasets`, {
1372
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/public/${shareToken}/datasets`, {
1356
1373
  method: "GET",
1357
1374
  headers: this.headers,
1358
1375
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1383,7 +1400,7 @@ export class Client {
1383
1400
  urlParams.append(key, value);
1384
1401
  }
1385
1402
  });
1386
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/public/${shareToken}/examples?${urlParams.toString()}`, {
1403
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/public/${shareToken}/examples?${urlParams.toString()}`, {
1387
1404
  method: "GET",
1388
1405
  headers: this.headers,
1389
1406
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1416,7 +1433,7 @@ export class Client {
1416
1433
  if (referenceDatasetId !== null) {
1417
1434
  body["reference_dataset_id"] = referenceDatasetId;
1418
1435
  }
1419
- const response = await this.caller.call(_getFetchImplementation(), endpoint, {
1436
+ const response = await this.caller.call(_getFetchImplementation(this.debug), endpoint, {
1420
1437
  method: "POST",
1421
1438
  headers: { ...this.headers, "Content-Type": "application/json" },
1422
1439
  body: JSON.stringify(body),
@@ -1439,7 +1456,7 @@ export class Client {
1439
1456
  description,
1440
1457
  end_time: endTime ? new Date(endTime).toISOString() : null,
1441
1458
  };
1442
- const response = await this.caller.call(_getFetchImplementation(), endpoint, {
1459
+ const response = await this.caller.call(_getFetchImplementation(this.debug), endpoint, {
1443
1460
  method: "PATCH",
1444
1461
  headers: { ...this.headers, "Content-Type": "application/json" },
1445
1462
  body: JSON.stringify(body),
@@ -1467,7 +1484,7 @@ export class Client {
1467
1484
  else {
1468
1485
  throw new Error("Must provide projectName or projectId");
1469
1486
  }
1470
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}${path}?${params}`, {
1487
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}${path}?${params}`, {
1471
1488
  method: "GET",
1472
1489
  headers: this.headers,
1473
1490
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1597,7 +1614,7 @@ export class Client {
1597
1614
  projectId_ = projectId;
1598
1615
  }
1599
1616
  assertUuid(projectId_);
1600
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/sessions/${projectId_}`, {
1617
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/sessions/${projectId_}`, {
1601
1618
  method: "DELETE",
1602
1619
  headers: this.headers,
1603
1620
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1624,7 +1641,7 @@ export class Client {
1624
1641
  if (name) {
1625
1642
  formData.append("name", name);
1626
1643
  }
1627
- const response = await this.caller.call(_getFetchImplementation(), url, {
1644
+ const response = await this.caller.call(_getFetchImplementation(this.debug), url, {
1628
1645
  method: "POST",
1629
1646
  headers: this.headers,
1630
1647
  body: formData,
@@ -1650,7 +1667,7 @@ export class Client {
1650
1667
  if (outputsSchema) {
1651
1668
  body.outputs_schema_definition = outputsSchema;
1652
1669
  }
1653
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets`, {
1670
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets`, {
1654
1671
  method: "POST",
1655
1672
  headers: { ...this.headers, "Content-Type": "application/json" },
1656
1673
  body: JSON.stringify(body),
@@ -1782,7 +1799,7 @@ export class Client {
1782
1799
  }
1783
1800
  const _datasetId = datasetId ?? (await this.readDataset({ datasetName })).id;
1784
1801
  assertUuid(_datasetId);
1785
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${_datasetId}`, {
1802
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${_datasetId}`, {
1786
1803
  method: "PATCH",
1787
1804
  headers: { ...this.headers, "Content-Type": "application/json" },
1788
1805
  body: JSON.stringify(update),
@@ -1814,7 +1831,7 @@ export class Client {
1814
1831
  }
1815
1832
  const _datasetId = datasetId ?? (await this.readDataset({ datasetName })).id;
1816
1833
  assertUuid(_datasetId);
1817
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${_datasetId}/tags`, {
1834
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${_datasetId}/tags`, {
1818
1835
  method: "PUT",
1819
1836
  headers: { ...this.headers, "Content-Type": "application/json" },
1820
1837
  body: JSON.stringify({
@@ -1843,7 +1860,7 @@ export class Client {
1843
1860
  else {
1844
1861
  throw new Error("Must provide datasetName or datasetId");
1845
1862
  }
1846
- const response = await this.caller.call(_getFetchImplementation(), this.apiUrl + path, {
1863
+ const response = await this.caller.call(_getFetchImplementation(this.debug), this.apiUrl + path, {
1847
1864
  method: "DELETE",
1848
1865
  headers: this.headers,
1849
1866
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -1868,7 +1885,7 @@ export class Client {
1868
1885
  const data = {
1869
1886
  tag: tag,
1870
1887
  };
1871
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${datasetId_}/index`, {
1888
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${datasetId_}/index`, {
1872
1889
  method: "POST",
1873
1890
  headers: { ...this.headers, "Content-Type": "application/json" },
1874
1891
  body: JSON.stringify(data),
@@ -1917,7 +1934,7 @@ export class Client {
1917
1934
  data["filter"] = filter;
1918
1935
  }
1919
1936
  assertUuid(datasetId);
1920
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${datasetId}/search`, {
1937
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${datasetId}/search`, {
1921
1938
  method: "POST",
1922
1939
  headers: { ...this.headers, "Content-Type": "application/json" },
1923
1940
  body: JSON.stringify(data),
@@ -2136,7 +2153,7 @@ export class Client {
2136
2153
  async deleteExample(exampleId) {
2137
2154
  assertUuid(exampleId);
2138
2155
  const path = `/examples/${exampleId}`;
2139
- const response = await this.caller.call(_getFetchImplementation(), this.apiUrl + path, {
2156
+ const response = await this.caller.call(_getFetchImplementation(this.debug), this.apiUrl + path, {
2140
2157
  method: "DELETE",
2141
2158
  headers: this.headers,
2142
2159
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2215,7 +2232,7 @@ export class Client {
2215
2232
  if (tag !== undefined) {
2216
2233
  params.append("tag", tag);
2217
2234
  }
2218
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
2235
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
2219
2236
  method: "GET",
2220
2237
  headers: { ...this.headers },
2221
2238
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2276,7 +2293,7 @@ export class Client {
2276
2293
  }),
2277
2294
  remove,
2278
2295
  };
2279
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${datasetId_}/splits`, {
2296
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/${datasetId_}/splits`, {
2280
2297
  method: "PUT",
2281
2298
  headers: { ...this.headers, "Content-Type": "application/json" },
2282
2299
  body: JSON.stringify(data),
@@ -2342,7 +2359,7 @@ export class Client {
2342
2359
  session_id: projectId,
2343
2360
  };
2344
2361
  const url = `${this.apiUrl}/feedback`;
2345
- const response = await this.caller.call(_getFetchImplementation(), url, {
2362
+ const response = await this.caller.call(_getFetchImplementation(this.debug), url, {
2346
2363
  method: "POST",
2347
2364
  headers: { ...this.headers, "Content-Type": "application/json" },
2348
2365
  body: JSON.stringify(feedback),
@@ -2367,7 +2384,7 @@ export class Client {
2367
2384
  feedbackUpdate["comment"] = comment;
2368
2385
  }
2369
2386
  assertUuid(feedbackId);
2370
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/feedback/${feedbackId}`, {
2387
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/feedback/${feedbackId}`, {
2371
2388
  method: "PATCH",
2372
2389
  headers: { ...this.headers, "Content-Type": "application/json" },
2373
2390
  body: JSON.stringify(feedbackUpdate),
@@ -2385,7 +2402,7 @@ export class Client {
2385
2402
  async deleteFeedback(feedbackId) {
2386
2403
  assertUuid(feedbackId);
2387
2404
  const path = `/feedback/${feedbackId}`;
2388
- const response = await this.caller.call(_getFetchImplementation(), this.apiUrl + path, {
2405
+ const response = await this.caller.call(_getFetchImplementation(this.debug), this.apiUrl + path, {
2389
2406
  method: "DELETE",
2390
2407
  headers: this.headers,
2391
2408
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2447,7 +2464,7 @@ export class Client {
2447
2464
  hours: 3,
2448
2465
  };
2449
2466
  }
2450
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/feedback/tokens`, {
2467
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/feedback/tokens`, {
2451
2468
  method: "POST",
2452
2469
  headers: { ...this.headers, "Content-Type": "application/json" },
2453
2470
  body: JSON.stringify(body),
@@ -2480,7 +2497,7 @@ export class Client {
2480
2497
  };
2481
2498
  if (metadata)
2482
2499
  body.extra["metadata"] = metadata;
2483
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/comparative`, {
2500
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/datasets/comparative`, {
2484
2501
  method: "POST",
2485
2502
  headers: { ...this.headers, "Content-Type": "application/json" },
2486
2503
  body: JSON.stringify(body),
@@ -2595,7 +2612,7 @@ export class Client {
2595
2612
  description,
2596
2613
  id: queueId || uuid.v4(),
2597
2614
  };
2598
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/annotation-queues`, {
2615
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues`, {
2599
2616
  method: "POST",
2600
2617
  headers: { ...this.headers, "Content-Type": "application/json" },
2601
2618
  body: JSON.stringify(Object.fromEntries(Object.entries(body).filter(([_, v]) => v !== undefined))),
@@ -2630,7 +2647,7 @@ export class Client {
2630
2647
  */
2631
2648
  async updateAnnotationQueue(queueId, options) {
2632
2649
  const { name, description } = options;
2633
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}`, {
2650
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}`, {
2634
2651
  method: "PATCH",
2635
2652
  headers: { ...this.headers, "Content-Type": "application/json" },
2636
2653
  body: JSON.stringify({ name, description }),
@@ -2644,7 +2661,7 @@ export class Client {
2644
2661
  * @param queueId - The ID of the annotation queue to delete
2645
2662
  */
2646
2663
  async deleteAnnotationQueue(queueId) {
2647
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}`, {
2664
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}`, {
2648
2665
  method: "DELETE",
2649
2666
  headers: { ...this.headers, Accept: "application/json" },
2650
2667
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2658,7 +2675,7 @@ export class Client {
2658
2675
  * @param runIds - The IDs of the runs to be added to the annotation queue
2659
2676
  */
2660
2677
  async addRunsToAnnotationQueue(queueId, runIds) {
2661
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/runs`, {
2678
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/runs`, {
2662
2679
  method: "POST",
2663
2680
  headers: { ...this.headers, "Content-Type": "application/json" },
2664
2681
  body: JSON.stringify(runIds.map((id, i) => assertUuid(id, `runIds[${i}]`).toString())),
@@ -2676,7 +2693,7 @@ export class Client {
2676
2693
  */
2677
2694
  async getRunFromAnnotationQueue(queueId, index) {
2678
2695
  const baseUrl = `/annotation-queues/${assertUuid(queueId, "queueId")}/run`;
2679
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}${baseUrl}/${index}`, {
2696
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}${baseUrl}/${index}`, {
2680
2697
  method: "GET",
2681
2698
  headers: this.headers,
2682
2699
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2691,7 +2708,7 @@ export class Client {
2691
2708
  * @param queueRunId - The ID of the run to delete from the annotation queue
2692
2709
  */
2693
2710
  async deleteRunFromAnnotationQueue(queueId, queueRunId) {
2694
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/runs/${assertUuid(queueRunId, "queueRunId")}`, {
2711
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/runs/${assertUuid(queueRunId, "queueRunId")}`, {
2695
2712
  method: "DELETE",
2696
2713
  headers: { ...this.headers, Accept: "application/json" },
2697
2714
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2704,7 +2721,7 @@ export class Client {
2704
2721
  * @param queueId - The ID of the annotation queue
2705
2722
  */
2706
2723
  async getSizeFromAnnotationQueue(queueId) {
2707
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/size`, {
2724
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/size`, {
2708
2725
  method: "GET",
2709
2726
  headers: this.headers,
2710
2727
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2724,7 +2741,7 @@ export class Client {
2724
2741
  Requested tenant: ${owner}`);
2725
2742
  }
2726
2743
  async _getLatestCommitHash(promptOwnerAndName) {
2727
- const res = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/commits/${promptOwnerAndName}/?limit=${1}&offset=${0}`, {
2744
+ const res = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/commits/${promptOwnerAndName}/?limit=${1}&offset=${0}`, {
2728
2745
  method: "GET",
2729
2746
  headers: this.headers,
2730
2747
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2747,7 +2764,7 @@ export class Client {
2747
2764
  }
2748
2765
  async _likeOrUnlikePrompt(promptIdentifier, like) {
2749
2766
  const [owner, promptName, _] = parsePromptIdentifier(promptIdentifier);
2750
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/likes/${owner}/${promptName}`, {
2767
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/likes/${owner}/${promptName}`, {
2751
2768
  method: "POST",
2752
2769
  body: JSON.stringify({ like: like }),
2753
2770
  headers: { ...this.headers, "Content-Type": "application/json" },
@@ -2809,7 +2826,7 @@ export class Client {
2809
2826
  }
2810
2827
  async getPrompt(promptIdentifier) {
2811
2828
  const [owner, promptName, _] = parsePromptIdentifier(promptIdentifier);
2812
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/repos/${owner}/${promptName}`, {
2829
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/repos/${owner}/${promptName}`, {
2813
2830
  method: "GET",
2814
2831
  headers: this.headers,
2815
2832
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -2846,7 +2863,7 @@ export class Client {
2846
2863
  ...(options?.tags && { tags: options.tags }),
2847
2864
  is_public: !!options?.isPublic,
2848
2865
  };
2849
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/repos/`, {
2866
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/repos/`, {
2850
2867
  method: "POST",
2851
2868
  headers: { ...this.headers, "Content-Type": "application/json" },
2852
2869
  body: JSON.stringify(data),
@@ -2869,7 +2886,7 @@ export class Client {
2869
2886
  manifest: JSON.parse(JSON.stringify(object)),
2870
2887
  parent_commit: resolvedParentCommitHash,
2871
2888
  };
2872
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/commits/${owner}/${promptName}`, {
2889
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/commits/${owner}/${promptName}`, {
2873
2890
  method: "POST",
2874
2891
  headers: { ...this.headers, "Content-Type": "application/json" },
2875
2892
  body: JSON.stringify(payload),
@@ -2949,7 +2966,7 @@ export class Client {
2949
2966
  }
2950
2967
  }
2951
2968
  const datasetIdToUse = datasetId ?? updates[0]?.dataset_id;
2952
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/v1/platform/datasets/${datasetIdToUse}/examples`, {
2969
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/v1/platform/datasets/${datasetIdToUse}/examples`, {
2953
2970
  method: "PATCH",
2954
2971
  headers: this.headers,
2955
2972
  body: formData,
@@ -3027,7 +3044,7 @@ export class Client {
3027
3044
  }
3028
3045
  }
3029
3046
  }
3030
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/v1/platform/datasets/${datasetId}/examples`, {
3047
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/v1/platform/datasets/${datasetId}/examples`, {
3031
3048
  method: "POST",
3032
3049
  headers: this.headers,
3033
3050
  body: formData,
@@ -3059,7 +3076,7 @@ export class Client {
3059
3076
  if (Object.keys(payload).length === 0) {
3060
3077
  throw new Error("No valid update options provided");
3061
3078
  }
3062
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/repos/${owner}/${promptName}`, {
3079
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/repos/${owner}/${promptName}`, {
3063
3080
  method: "PATCH",
3064
3081
  body: JSON.stringify(payload),
3065
3082
  headers: {
@@ -3080,7 +3097,7 @@ export class Client {
3080
3097
  if (!(await this._currentTenantIsOwner(owner))) {
3081
3098
  throw await this._ownerConflictError("delete a prompt", owner);
3082
3099
  }
3083
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/repos/${owner}/${promptName}`, {
3100
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/repos/${owner}/${promptName}`, {
3084
3101
  method: "DELETE",
3085
3102
  headers: this.headers,
3086
3103
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -3090,7 +3107,7 @@ export class Client {
3090
3107
  }
3091
3108
  async pullPromptCommit(promptIdentifier, options) {
3092
3109
  const [owner, promptName, commitHash] = parsePromptIdentifier(promptIdentifier);
3093
- const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/commits/${owner}/${promptName}/${commitHash}${options?.includeModel ? "?include_model=true" : ""}`, {
3110
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/commits/${owner}/${promptName}/${commitHash}${options?.includeModel ? "?include_model=true" : ""}`, {
3094
3111
  method: "GET",
3095
3112
  headers: this.headers,
3096
3113
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -408,6 +408,7 @@ class _ExperimentManager {
408
408
  else {
409
409
  const caller = new async_caller_js_1.AsyncCaller({
410
410
  maxConcurrency,
411
+ debug: this.client.debug,
411
412
  });
412
413
  const futures = [];
413
414
  for await (const example of examples) {
@@ -468,6 +469,7 @@ class _ExperimentManager {
468
469
  else {
469
470
  const caller = new async_caller_js_1.AsyncCaller({
470
471
  maxConcurrency,
472
+ debug: this.client.debug,
471
473
  });
472
474
  const futures = [];
473
475
  for await (const currentResults of this.getResults()) {
@@ -404,6 +404,7 @@ export class _ExperimentManager {
404
404
  else {
405
405
  const caller = new AsyncCaller({
406
406
  maxConcurrency,
407
+ debug: this.client.debug,
407
408
  });
408
409
  const futures = [];
409
410
  for await (const example of examples) {
@@ -464,6 +465,7 @@ export class _ExperimentManager {
464
465
  else {
465
466
  const caller = new AsyncCaller({
466
467
  maxConcurrency,
468
+ debug: this.client.debug,
467
469
  });
468
470
  const futures = [];
469
471
  for await (const currentResults of this.getResults()) {
@@ -159,7 +159,10 @@ async function evaluateComparative(experiments, options) {
159
159
  runMapByExampleId[run.reference_example_id].push(run);
160
160
  }
161
161
  }
162
- const caller = new async_caller_js_1.AsyncCaller({ maxConcurrency: options.maxConcurrency });
162
+ const caller = new async_caller_js_1.AsyncCaller({
163
+ maxConcurrency: options.maxConcurrency,
164
+ debug: client.debug,
165
+ });
163
166
  async function evaluateAndSubmitFeedback(runs, example, evaluator) {
164
167
  const expectedRunIds = new Set(runs.map((r) => r.id));
165
168
  // Check if evaluator expects an object parameter
@@ -153,7 +153,10 @@ export async function evaluateComparative(experiments, options) {
153
153
  runMapByExampleId[run.reference_example_id].push(run);
154
154
  }
155
155
  }
156
- const caller = new AsyncCaller({ maxConcurrency: options.maxConcurrency });
156
+ const caller = new AsyncCaller({
157
+ maxConcurrency: options.maxConcurrency,
158
+ debug: client.debug,
159
+ });
157
160
  async function evaluateAndSubmitFeedback(runs, example, evaluator) {
158
161
  const expectedRunIds = new Set(runs.map((r) => r.id));
159
162
  // Check if evaluator expects an object parameter
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.18";
11
+ exports.__version__ = "0.3.19";
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.18";
5
+ export declare const __version__ = "0.3.19";
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.18";
5
+ export const __version__ = "0.3.19";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._getFetchImplementation = exports.overrideFetchImplementation = void 0;
4
+ const env_js_1 = require("../utils/env.cjs");
4
5
  // Wrap the default fetch call due to issues with illegal invocations
5
6
  // in some environments:
6
7
  // https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err
@@ -20,8 +21,18 @@ exports.overrideFetchImplementation = overrideFetchImplementation;
20
21
  /**
21
22
  * @internal
22
23
  */
23
- const _getFetchImplementation = () => {
24
- return (globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??
25
- DEFAULT_FETCH_IMPLEMENTATION);
24
+ const _getFetchImplementation = (debug) => {
25
+ return async (...args) => {
26
+ if (debug || (0, env_js_1.getLangSmithEnvironmentVariable)("DEBUG") === "true") {
27
+ const [url, options] = args;
28
+ console.log(`→ ${options?.method || "GET"} ${url}`);
29
+ }
30
+ const res = await (globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??
31
+ DEFAULT_FETCH_IMPLEMENTATION)(...args);
32
+ if (debug || (0, env_js_1.getLangSmithEnvironmentVariable)("DEBUG") === "true") {
33
+ console.log(`← ${res.status} ${res.statusText} ${res.url}`);
34
+ }
35
+ return res;
36
+ };
26
37
  };
27
38
  exports._getFetchImplementation = _getFetchImplementation;
@@ -1,3 +1,4 @@
1
+ import { getLangSmithEnvironmentVariable } from "../utils/env.js";
1
2
  // Wrap the default fetch call due to issues with illegal invocations
2
3
  // in some environments:
3
4
  // https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err
@@ -16,7 +17,17 @@ export const overrideFetchImplementation = (fetch) => {
16
17
  /**
17
18
  * @internal
18
19
  */
19
- export const _getFetchImplementation = () => {
20
- return (globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??
21
- DEFAULT_FETCH_IMPLEMENTATION);
20
+ export const _getFetchImplementation = (debug) => {
21
+ return async (...args) => {
22
+ if (debug || getLangSmithEnvironmentVariable("DEBUG") === "true") {
23
+ const [url, options] = args;
24
+ console.log(`→ ${options?.method || "GET"} ${url}`);
25
+ }
26
+ const res = await (globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??
27
+ DEFAULT_FETCH_IMPLEMENTATION)(...args);
28
+ if (debug || getLangSmithEnvironmentVariable("DEBUG") === "true") {
29
+ console.log(`← ${res.status} ${res.statusText} ${res.url}`);
30
+ }
31
+ return res;
32
+ };
22
33
  };
@@ -59,8 +59,15 @@ class AsyncCaller {
59
59
  writable: true,
60
60
  value: void 0
61
61
  });
62
+ Object.defineProperty(this, "debug", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true,
66
+ value: void 0
67
+ });
62
68
  this.maxConcurrency = params.maxConcurrency ?? Infinity;
63
69
  this.maxRetries = params.maxRetries ?? 6;
70
+ this.debug = params.debug;
64
71
  if ("default" in p_queue_1.default) {
65
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
73
  this.queue = new p_queue_1.default.default({
@@ -133,7 +140,7 @@ class AsyncCaller {
133
140
  return this.call(callable, ...args);
134
141
  }
135
142
  fetch(...args) {
136
- return this.call(() => (0, fetch_js_1._getFetchImplementation)()(...args).then((res) => res.ok ? res : Promise.reject(res)));
143
+ return this.call(() => (0, fetch_js_1._getFetchImplementation)(this.debug)(...args).then((res) => res.ok ? res : Promise.reject(res)));
137
144
  }
138
145
  }
139
146
  exports.AsyncCaller = AsyncCaller;
@@ -11,6 +11,7 @@ export interface AsyncCallerParams {
11
11
  */
12
12
  maxRetries?: number;
13
13
  onFailedResponseHook?: ResponseCallback;
14
+ debug?: boolean;
14
15
  }
15
16
  export interface AsyncCallerCallOptions {
16
17
  signal?: AbortSignal;
@@ -33,6 +34,7 @@ export declare class AsyncCaller {
33
34
  protected maxRetries: AsyncCallerParams["maxRetries"];
34
35
  queue: typeof import("p-queue")["default"]["prototype"];
35
36
  private onFailedResponseHook?;
37
+ private debug?;
36
38
  constructor(params: AsyncCallerParams);
37
39
  call<A extends any[], T extends (...args: A) => Promise<any>>(callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
38
40
  callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(options: AsyncCallerCallOptions, callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
@@ -53,8 +53,15 @@ export class AsyncCaller {
53
53
  writable: true,
54
54
  value: void 0
55
55
  });
56
+ Object.defineProperty(this, "debug", {
57
+ enumerable: true,
58
+ configurable: true,
59
+ writable: true,
60
+ value: void 0
61
+ });
56
62
  this.maxConcurrency = params.maxConcurrency ?? Infinity;
57
63
  this.maxRetries = params.maxRetries ?? 6;
64
+ this.debug = params.debug;
58
65
  if ("default" in PQueueMod) {
59
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
67
  this.queue = new PQueueMod.default({
@@ -127,6 +134,6 @@ export class AsyncCaller {
127
134
  return this.call(callable, ...args);
128
135
  }
129
136
  fetch(...args) {
130
- return this.call(() => _getFetchImplementation()(...args).then((res) => res.ok ? res : Promise.reject(res)));
137
+ return this.call(() => _getFetchImplementation(this.debug)(...args).then((res) => res.ok ? res : Promise.reject(res)));
131
138
  }
132
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.18",
3
+ "version": "0.3.19",
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": [