langsmith 0.3.17 → 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;