langsmith 0.3.18 → 0.3.20

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.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;
@@ -386,7 +397,7 @@ export class Client {
386
397
  }
387
398
  return headers;
388
399
  }
389
- processInputs(inputs) {
400
+ async processInputs(inputs) {
390
401
  if (this.hideInputs === false) {
391
402
  return inputs;
392
403
  }
@@ -398,7 +409,7 @@ export class Client {
398
409
  }
399
410
  return inputs;
400
411
  }
401
- processOutputs(outputs) {
412
+ async processOutputs(outputs) {
402
413
  if (this.hideOutputs === false) {
403
414
  return outputs;
404
415
  }
@@ -410,20 +421,20 @@ export class Client {
410
421
  }
411
422
  return outputs;
412
423
  }
413
- prepareRunCreateOrUpdateInputs(run) {
424
+ async prepareRunCreateOrUpdateInputs(run) {
414
425
  const runParams = { ...run };
415
426
  if (runParams.inputs !== undefined) {
416
- runParams.inputs = this.processInputs(runParams.inputs);
427
+ runParams.inputs = await this.processInputs(runParams.inputs);
417
428
  }
418
429
  if (runParams.outputs !== undefined) {
419
- runParams.outputs = this.processOutputs(runParams.outputs);
430
+ runParams.outputs = await this.processOutputs(runParams.outputs);
420
431
  }
421
432
  return runParams;
422
433
  }
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) {
@@ -663,7 +680,7 @@ export class Client {
663
680
  const headers = { ...this.headers, "Content-Type": "application/json" };
664
681
  const session_name = run.project_name;
665
682
  delete run.project_name;
666
- const runCreate = this.prepareRunCreateOrUpdateInputs({
683
+ const runCreate = await this.prepareRunCreateOrUpdateInputs({
667
684
  session_name,
668
685
  ...run,
669
686
  start_time: run.start_time ?? Date.now(),
@@ -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),
@@ -695,8 +712,8 @@ export class Client {
695
712
  if (runCreates === undefined && runUpdates === undefined) {
696
713
  return;
697
714
  }
698
- let preparedCreateParams = runCreates?.map((create) => this.prepareRunCreateOrUpdateInputs(create)) ?? [];
699
- let preparedUpdateParams = runUpdates?.map((update) => this.prepareRunCreateOrUpdateInputs(update)) ?? [];
715
+ let preparedCreateParams = await Promise.all(runCreates?.map((create) => this.prepareRunCreateOrUpdateInputs(create)) ?? []);
716
+ let preparedUpdateParams = await Promise.all(runUpdates?.map((update) => this.prepareRunCreateOrUpdateInputs(update)) ?? []);
700
717
  if (preparedCreateParams.length > 0 && preparedUpdateParams.length > 0) {
701
718
  const createById = preparedCreateParams.reduce((params, run) => {
702
719
  if (!run.id) {
@@ -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,
@@ -772,7 +789,7 @@ export class Client {
772
789
  const allAttachments = {};
773
790
  let preparedCreateParams = [];
774
791
  for (const create of runCreates ?? []) {
775
- const preparedCreate = this.prepareRunCreateOrUpdateInputs(create);
792
+ const preparedCreate = await this.prepareRunCreateOrUpdateInputs(create);
776
793
  if (preparedCreate.id !== undefined &&
777
794
  preparedCreate.attachments !== undefined) {
778
795
  allAttachments[preparedCreate.id] = preparedCreate.attachments;
@@ -782,7 +799,7 @@ export class Client {
782
799
  }
783
800
  let preparedUpdateParams = [];
784
801
  for (const update of runUpdates ?? []) {
785
- preparedUpdateParams.push(this.prepareRunCreateOrUpdateInputs(update));
802
+ preparedUpdateParams.push(await this.prepareRunCreateOrUpdateInputs(update));
786
803
  }
787
804
  // require trace_id and dotted_order
788
805
  const invalidRunCreate = preparedCreateParams.find((runCreate) => {
@@ -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,
@@ -934,10 +951,10 @@ export class Client {
934
951
  async updateRun(runId, run) {
935
952
  assertUuid(runId);
936
953
  if (run.inputs) {
937
- run.inputs = this.processInputs(run.inputs);
954
+ run.inputs = await this.processInputs(run.inputs);
938
955
  }
939
956
  if (run.outputs) {
940
- run.outputs = this.processOutputs(run.outputs);
957
+ run.outputs = await this.processOutputs(run.outputs);
941
958
  }
942
959
  // TODO: Untangle types
943
960
  const data = { ...run, id: runId };
@@ -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