langsmith 0.5.15 → 0.5.17

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.
Files changed (99) hide show
  1. package/README.md +2 -2
  2. package/dist/client.cjs +116 -143
  3. package/dist/client.d.ts +19 -40
  4. package/dist/client.js +116 -143
  5. package/dist/experimental/anthropic/index.cjs +4 -1
  6. package/dist/experimental/anthropic/index.js +4 -1
  7. package/dist/experimental/vercel/index.cjs +1 -0
  8. package/dist/experimental/vercel/index.js +1 -0
  9. package/dist/experimental/vercel/middleware.cjs +2 -0
  10. package/dist/experimental/vercel/middleware.js +2 -0
  11. package/dist/index.cjs +2 -2
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +2 -2
  14. package/dist/schemas.d.ts +1 -3
  15. package/dist/utils/chalk/source/index.cjs +187 -0
  16. package/dist/utils/chalk/source/index.d.ts +19 -0
  17. package/dist/utils/chalk/source/index.js +173 -0
  18. package/dist/utils/chalk/source/utilities.cjs +35 -0
  19. package/dist/utils/chalk/source/utilities.d.ts +2 -0
  20. package/dist/utils/chalk/source/utilities.js +31 -0
  21. package/dist/utils/chalk/source/vendor/ansi-styles/index.cjs +193 -0
  22. package/dist/utils/chalk/source/vendor/ansi-styles/index.d.ts +58 -0
  23. package/dist/utils/chalk/source/vendor/ansi-styles/index.js +190 -0
  24. package/dist/utils/chalk/source/vendor/supports-color/browser.cjs +31 -0
  25. package/dist/utils/chalk/source/vendor/supports-color/browser.d.ts +15 -0
  26. package/dist/utils/chalk/source/vendor/supports-color/browser.js +29 -0
  27. package/dist/utils/chalk/source/vendor/supports-color/index.cjs +155 -0
  28. package/dist/utils/chalk/source/vendor/supports-color/index.d.ts +21 -0
  29. package/dist/utils/chalk/source/vendor/supports-color/index.js +149 -0
  30. package/dist/utils/console-table-printer/index.cjs +11 -0
  31. package/dist/utils/console-table-printer/index.d.ts +4 -0
  32. package/dist/utils/console-table-printer/index.js +3 -0
  33. package/dist/utils/console-table-printer/src/console-table-printer.cjs +42 -0
  34. package/dist/utils/console-table-printer/src/console-table-printer.d.ts +14 -0
  35. package/dist/utils/console-table-printer/src/console-table-printer.js +36 -0
  36. package/dist/utils/console-table-printer/src/internalTable/input-converter.cjs +25 -0
  37. package/dist/utils/console-table-printer/src/internalTable/input-converter.d.ts +6 -0
  38. package/dist/utils/console-table-printer/src/internalTable/input-converter.js +20 -0
  39. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.cjs +142 -0
  40. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.d.ts +6 -0
  41. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.js +133 -0
  42. package/dist/utils/console-table-printer/src/internalTable/internal-table.cjs +186 -0
  43. package/dist/utils/console-table-printer/src/internalTable/internal-table.d.ts +31 -0
  44. package/dist/utils/console-table-printer/src/internalTable/internal-table.js +184 -0
  45. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.cjs +53 -0
  46. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.d.ts +3 -0
  47. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.js +48 -0
  48. package/dist/utils/console-table-printer/src/models/common.cjs +2 -0
  49. package/dist/utils/console-table-printer/src/models/common.d.ts +14 -0
  50. package/dist/utils/console-table-printer/src/models/common.js +1 -0
  51. package/dist/utils/console-table-printer/src/models/external-table.cjs +2 -0
  52. package/dist/utils/console-table-printer/src/models/external-table.d.ts +99 -0
  53. package/dist/utils/console-table-printer/src/models/external-table.js +1 -0
  54. package/dist/utils/console-table-printer/src/models/internal-table.cjs +2 -0
  55. package/dist/utils/console-table-printer/src/models/internal-table.d.ts +24 -0
  56. package/dist/utils/console-table-printer/src/models/internal-table.js +1 -0
  57. package/dist/utils/console-table-printer/src/utils/colored-console-line.cjs +43 -0
  58. package/dist/utils/console-table-printer/src/utils/colored-console-line.d.ts +12 -0
  59. package/dist/utils/console-table-printer/src/utils/colored-console-line.js +39 -0
  60. package/dist/utils/console-table-printer/src/utils/console-utils.cjs +23 -0
  61. package/dist/utils/console-table-printer/src/utils/console-utils.d.ts +3 -0
  62. package/dist/utils/console-table-printer/src/utils/console-utils.js +18 -0
  63. package/dist/utils/console-table-printer/src/utils/string-utils.cjs +68 -0
  64. package/dist/utils/console-table-printer/src/utils/string-utils.d.ts +4 -0
  65. package/dist/utils/console-table-printer/src/utils/string-utils.js +62 -0
  66. package/dist/utils/console-table-printer/src/utils/table-constants.cjs +55 -0
  67. package/dist/utils/console-table-printer/src/utils/table-constants.d.ts +11 -0
  68. package/dist/utils/console-table-printer/src/utils/table-constants.js +52 -0
  69. package/dist/utils/console-table-printer/src/utils/table-helpers.cjs +101 -0
  70. package/dist/utils/console-table-printer/src/utils/table-helpers.d.ts +29 -0
  71. package/dist/utils/console-table-printer/src/utils/table-helpers.js +88 -0
  72. package/dist/utils/fs.d.ts +1 -1
  73. package/dist/utils/jestlike/reporter.cjs +23 -23
  74. package/dist/utils/jestlike/reporter.js +2 -2
  75. package/dist/utils/prompts.cjs +0 -10
  76. package/dist/utils/prompts.d.ts +0 -1
  77. package/dist/utils/prompts.js +0 -9
  78. package/dist/utils/simple-wcswidth/index.cjs +10 -0
  79. package/dist/utils/simple-wcswidth/index.d.ts +3 -0
  80. package/dist/utils/simple-wcswidth/index.js +3 -0
  81. package/dist/utils/simple-wcswidth/src/binary-search.cjs +24 -0
  82. package/dist/utils/simple-wcswidth/src/binary-search.d.ts +3 -0
  83. package/dist/utils/simple-wcswidth/src/binary-search.js +22 -0
  84. package/dist/utils/simple-wcswidth/src/models.cjs +2 -0
  85. package/dist/utils/simple-wcswidth/src/models.d.ts +4 -0
  86. package/dist/utils/simple-wcswidth/src/models.js +1 -0
  87. package/dist/utils/simple-wcswidth/src/non-spacing-chars.cjs +149 -0
  88. package/dist/utils/simple-wcswidth/src/non-spacing-chars.d.ts +3 -0
  89. package/dist/utils/simple-wcswidth/src/non-spacing-chars.js +147 -0
  90. package/dist/utils/simple-wcswidth/src/wcswidth.cjs +20 -0
  91. package/dist/utils/simple-wcswidth/src/wcswidth.d.ts +2 -0
  92. package/dist/utils/simple-wcswidth/src/wcswidth.js +15 -0
  93. package/dist/utils/simple-wcswidth/src/wcwidth.cjs +67 -0
  94. package/dist/utils/simple-wcswidth/src/wcwidth.d.ts +2 -0
  95. package/dist/utils/simple-wcswidth/src/wcwidth.js +62 -0
  96. package/dist/wrappers/anthropic.cjs +4 -0
  97. package/dist/wrappers/anthropic.d.ts +1 -0
  98. package/dist/wrappers/anthropic.js +4 -0
  99. package/package.json +20 -19
package/dist/client.cjs CHANGED
@@ -468,6 +468,12 @@ class Client {
468
468
  writable: true,
469
469
  value: 100 * 1024 * 1024
470
470
  });
471
+ Object.defineProperty(this, "_customHeaders", {
472
+ enumerable: true,
473
+ configurable: true,
474
+ writable: true,
475
+ value: {}
476
+ });
471
477
  Object.defineProperty(this, "debug", {
472
478
  enumerable: true,
473
479
  configurable: true,
@@ -564,6 +570,8 @@ class Client {
564
570
  // Use the global singleton instance
565
571
  this._promptCache = index_js_2.promptCacheSingleton;
566
572
  }
573
+ // Initialize custom headers
574
+ this._customHeaders = config.headers ?? {};
567
575
  }
568
576
  static getDefaultClientConfig() {
569
577
  const apiKey = (0, env_js_1.getLangSmithEnvironmentVariable)("API_KEY");
@@ -603,6 +611,10 @@ class Client {
603
611
  this.webUrl = "https://eu.smith.langchain.com";
604
612
  return this.webUrl;
605
613
  }
614
+ else if (this.apiUrl.split(".", 1)[0].includes("aws")) {
615
+ this.webUrl = "https://aws.smith.langchain.com";
616
+ return this.webUrl;
617
+ }
606
618
  else if (this.apiUrl.split(".", 1)[0].includes("beta")) {
607
619
  this.webUrl = "https://beta.smith.langchain.com";
608
620
  return this.webUrl;
@@ -612,10 +624,13 @@ class Client {
612
624
  return this.webUrl;
613
625
  }
614
626
  }
615
- get headers() {
627
+ get _mergedHeaders() {
628
+ // Start with custom headers so they don't override required headers
616
629
  const headers = {
617
630
  "User-Agent": `langsmith-js/${index_js_1.__version__}`,
631
+ ...this._customHeaders,
618
632
  };
633
+ // Required headers that should not be overridden
619
634
  if (this.apiKey) {
620
635
  headers["x-api-key"] = `${this.apiKey}`;
621
636
  }
@@ -624,6 +639,17 @@ class Client {
624
639
  }
625
640
  return headers;
626
641
  }
642
+ /**
643
+ * Get or set custom headers for the client.
644
+ * Custom headers are merged with default headers (User-Agent, x-api-key, x-tenant-id).
645
+ * Custom headers will not override the default required headers.
646
+ */
647
+ get headers() {
648
+ return this._customHeaders;
649
+ }
650
+ set headers(value) {
651
+ this._customHeaders = value ?? {};
652
+ }
627
653
  _getPlatformEndpointPath(path) {
628
654
  // Check if apiUrl already ends with /v1 or /v1/ to avoid double /v1/v1/ paths
629
655
  const needsV1Prefix = this.apiUrl.slice(-3) !== "/v1" && this.apiUrl.slice(-4) !== "/v1/";
@@ -669,7 +695,7 @@ class Client {
669
695
  const response = await this.caller.call(async () => {
670
696
  const res = await this._fetch(url, {
671
697
  method: "GET",
672
- headers: this.headers,
698
+ headers: this._mergedHeaders,
673
699
  signal: AbortSignal.timeout(this.timeout_ms),
674
700
  ...this.fetchOptions,
675
701
  });
@@ -692,7 +718,7 @@ class Client {
692
718
  const response = await this.caller.call(async () => {
693
719
  const res = await this._fetch(url, {
694
720
  method: "GET",
695
- headers: this.headers,
721
+ headers: this._mergedHeaders,
696
722
  signal: AbortSignal.timeout(this.timeout_ms),
697
723
  ...this.fetchOptions,
698
724
  });
@@ -719,7 +745,10 @@ class Client {
719
745
  const response = await this.caller.call(async () => {
720
746
  const res = await this._fetch(`${this.apiUrl}${path}`, {
721
747
  method: requestMethod,
722
- headers: { ...this.headers, "Content-Type": "application/json" },
748
+ headers: {
749
+ ...this._mergedHeaders,
750
+ "Content-Type": "application/json",
751
+ },
723
752
  signal: AbortSignal.timeout(this.timeout_ms),
724
753
  ...this.fetchOptions,
725
754
  body,
@@ -1096,7 +1125,7 @@ class Client {
1096
1125
  return;
1097
1126
  }
1098
1127
  const headers = {
1099
- ...this.headers,
1128
+ ...this._mergedHeaders,
1100
1129
  "Content-Type": "application/json",
1101
1130
  };
1102
1131
  const session_name = run.project_name;
@@ -1203,7 +1232,7 @@ class Client {
1203
1232
  }
1204
1233
  async _postBatchIngestRuns(body, options) {
1205
1234
  const headers = {
1206
- ...this.headers,
1235
+ ...this._mergedHeaders,
1207
1236
  "Content-Type": "application/json",
1208
1237
  Accept: "application/json",
1209
1238
  };
@@ -1427,7 +1456,7 @@ class Client {
1427
1456
  return this.batchIngestCaller.callWithOptions({ sizeBytes: options?.sizeBytes }, async () => {
1428
1457
  const body = await bodyFactory();
1429
1458
  const headers = {
1430
- ...this.headers,
1459
+ ...this._mergedHeaders,
1431
1460
  "Content-Type": `multipart/form-data; boundary=${boundary}`,
1432
1461
  };
1433
1462
  if (options?.apiKey !== undefined) {
@@ -1538,7 +1567,7 @@ class Client {
1538
1567
  return;
1539
1568
  }
1540
1569
  const headers = {
1541
- ...this.headers,
1570
+ ...this._mergedHeaders,
1542
1571
  "Content-Type": "application/json",
1543
1572
  };
1544
1573
  if (options?.apiKey !== undefined) {
@@ -1824,7 +1853,10 @@ class Client {
1824
1853
  const response = await this.caller.call(async () => {
1825
1854
  const res = await this._fetch(url, {
1826
1855
  method: "POST",
1827
- headers: { ...this.headers, "Content-Type": "application/json" },
1856
+ headers: {
1857
+ ...this._mergedHeaders,
1858
+ "Content-Type": "application/json",
1859
+ },
1828
1860
  signal: AbortSignal.timeout(this.timeout_ms),
1829
1861
  ...this.fetchOptions,
1830
1862
  body,
@@ -2000,7 +2032,7 @@ class Client {
2000
2032
  const response = await this.caller.call(async () => {
2001
2033
  const res = await this._fetch(`${this.apiUrl}/runs/stats`, {
2002
2034
  method: "POST",
2003
- headers: { ...this.headers, "Content-Type": "application/json" },
2035
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2004
2036
  signal: AbortSignal.timeout(this.timeout_ms),
2005
2037
  ...this.fetchOptions,
2006
2038
  body,
@@ -2021,7 +2053,7 @@ class Client {
2021
2053
  const response = await this.caller.call(async () => {
2022
2054
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
2023
2055
  method: "PUT",
2024
- headers: this.headers,
2056
+ headers: this._mergedHeaders,
2025
2057
  signal: AbortSignal.timeout(this.timeout_ms),
2026
2058
  ...this.fetchOptions,
2027
2059
  body,
@@ -2040,7 +2072,7 @@ class Client {
2040
2072
  await this.caller.call(async () => {
2041
2073
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
2042
2074
  method: "DELETE",
2043
- headers: this.headers,
2075
+ headers: this._mergedHeaders,
2044
2076
  signal: AbortSignal.timeout(this.timeout_ms),
2045
2077
  ...this.fetchOptions,
2046
2078
  });
@@ -2053,7 +2085,7 @@ class Client {
2053
2085
  const response = await this.caller.call(async () => {
2054
2086
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
2055
2087
  method: "GET",
2056
- headers: this.headers,
2088
+ headers: this._mergedHeaders,
2057
2089
  signal: AbortSignal.timeout(this.timeout_ms),
2058
2090
  ...this.fetchOptions,
2059
2091
  });
@@ -2079,7 +2111,7 @@ class Client {
2079
2111
  const response = await this.caller.call(async () => {
2080
2112
  const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
2081
2113
  method: "GET",
2082
- headers: this.headers,
2114
+ headers: this._mergedHeaders,
2083
2115
  signal: AbortSignal.timeout(this.timeout_ms),
2084
2116
  ...this.fetchOptions,
2085
2117
  });
@@ -2101,7 +2133,7 @@ class Client {
2101
2133
  const response = await this.caller.call(async () => {
2102
2134
  const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
2103
2135
  method: "GET",
2104
- headers: this.headers,
2136
+ headers: this._mergedHeaders,
2105
2137
  signal: AbortSignal.timeout(this.timeout_ms),
2106
2138
  ...this.fetchOptions,
2107
2139
  });
@@ -2128,7 +2160,7 @@ class Client {
2128
2160
  const response = await this.caller.call(async () => {
2129
2161
  const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
2130
2162
  method: "PUT",
2131
- headers: this.headers,
2163
+ headers: this._mergedHeaders,
2132
2164
  signal: AbortSignal.timeout(this.timeout_ms),
2133
2165
  ...this.fetchOptions,
2134
2166
  body,
@@ -2145,7 +2177,7 @@ class Client {
2145
2177
  await this.caller.call(async () => {
2146
2178
  const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
2147
2179
  method: "DELETE",
2148
- headers: this.headers,
2180
+ headers: this._mergedHeaders,
2149
2181
  signal: AbortSignal.timeout(this.timeout_ms),
2150
2182
  ...this.fetchOptions,
2151
2183
  });
@@ -2158,7 +2190,7 @@ class Client {
2158
2190
  const response = await this.caller.call(async () => {
2159
2191
  const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/datasets`, {
2160
2192
  method: "GET",
2161
- headers: this.headers,
2193
+ headers: this._mergedHeaders,
2162
2194
  signal: AbortSignal.timeout(this.timeout_ms),
2163
2195
  ...this.fetchOptions,
2164
2196
  });
@@ -2193,7 +2225,7 @@ class Client {
2193
2225
  const response = await this.caller.call(async () => {
2194
2226
  const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/examples?${urlParams.toString()}`, {
2195
2227
  method: "GET",
2196
- headers: this.headers,
2228
+ headers: this._mergedHeaders,
2197
2229
  signal: AbortSignal.timeout(this.timeout_ms),
2198
2230
  ...this.fetchOptions,
2199
2231
  });
@@ -2233,7 +2265,7 @@ class Client {
2233
2265
  const response = await this.caller.call(async () => {
2234
2266
  const res = await this._fetch(endpoint, {
2235
2267
  method: "POST",
2236
- headers: { ...this.headers, "Content-Type": "application/json" },
2268
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2237
2269
  signal: AbortSignal.timeout(this.timeout_ms),
2238
2270
  ...this.fetchOptions,
2239
2271
  body: serializedBody,
@@ -2259,7 +2291,7 @@ class Client {
2259
2291
  const response = await this.caller.call(async () => {
2260
2292
  const res = await this._fetch(endpoint, {
2261
2293
  method: "PATCH",
2262
- headers: { ...this.headers, "Content-Type": "application/json" },
2294
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2263
2295
  signal: AbortSignal.timeout(this.timeout_ms),
2264
2296
  ...this.fetchOptions,
2265
2297
  body,
@@ -2290,7 +2322,7 @@ class Client {
2290
2322
  const response = await this.caller.call(async () => {
2291
2323
  const res = await this._fetch(`${this.apiUrl}${path}?${params}`, {
2292
2324
  method: "GET",
2293
- headers: this.headers,
2325
+ headers: this._mergedHeaders,
2294
2326
  signal: AbortSignal.timeout(this.timeout_ms),
2295
2327
  ...this.fetchOptions,
2296
2328
  });
@@ -2430,7 +2462,7 @@ class Client {
2430
2462
  await this.caller.call(async () => {
2431
2463
  const res = await this._fetch(`${this.apiUrl}/sessions/${projectId_}`, {
2432
2464
  method: "DELETE",
2433
- headers: this.headers,
2465
+ headers: this._mergedHeaders,
2434
2466
  signal: AbortSignal.timeout(this.timeout_ms),
2435
2467
  ...this.fetchOptions,
2436
2468
  });
@@ -2461,7 +2493,7 @@ class Client {
2461
2493
  const response = await this.caller.call(async () => {
2462
2494
  const res = await this._fetch(url, {
2463
2495
  method: "POST",
2464
- headers: this.headers,
2496
+ headers: this._mergedHeaders,
2465
2497
  signal: AbortSignal.timeout(this.timeout_ms),
2466
2498
  ...this.fetchOptions,
2467
2499
  body: formData,
@@ -2491,7 +2523,7 @@ class Client {
2491
2523
  const response = await this.caller.call(async () => {
2492
2524
  const res = await this._fetch(`${this.apiUrl}/datasets`, {
2493
2525
  method: "POST",
2494
- headers: { ...this.headers, "Content-Type": "application/json" },
2526
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2495
2527
  signal: AbortSignal.timeout(this.timeout_ms),
2496
2528
  ...this.fetchOptions,
2497
2529
  body: serializedBody,
@@ -2627,7 +2659,7 @@ class Client {
2627
2659
  const response = await this.caller.call(async () => {
2628
2660
  const res = await this._fetch(`${this.apiUrl}/datasets/${_datasetId}`, {
2629
2661
  method: "PATCH",
2630
- headers: { ...this.headers, "Content-Type": "application/json" },
2662
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2631
2663
  signal: AbortSignal.timeout(this.timeout_ms),
2632
2664
  ...this.fetchOptions,
2633
2665
  body,
@@ -2666,7 +2698,10 @@ class Client {
2666
2698
  await this.caller.call(async () => {
2667
2699
  const res = await this._fetch(`${this.apiUrl}/datasets/${_datasetId}/tags`, {
2668
2700
  method: "PUT",
2669
- headers: { ...this.headers, "Content-Type": "application/json" },
2701
+ headers: {
2702
+ ...this._mergedHeaders,
2703
+ "Content-Type": "application/json",
2704
+ },
2670
2705
  signal: AbortSignal.timeout(this.timeout_ms),
2671
2706
  ...this.fetchOptions,
2672
2707
  body,
@@ -2695,7 +2730,7 @@ class Client {
2695
2730
  await this.caller.call(async () => {
2696
2731
  const res = await this._fetch(this.apiUrl + path, {
2697
2732
  method: "DELETE",
2698
- headers: this.headers,
2733
+ headers: this._mergedHeaders,
2699
2734
  signal: AbortSignal.timeout(this.timeout_ms),
2700
2735
  ...this.fetchOptions,
2701
2736
  });
@@ -2703,90 +2738,6 @@ class Client {
2703
2738
  return res;
2704
2739
  });
2705
2740
  }
2706
- async indexDataset({ datasetId, datasetName, tag, }) {
2707
- let datasetId_ = datasetId;
2708
- if (!datasetId_ && !datasetName) {
2709
- throw new Error("Must provide either datasetName or datasetId");
2710
- }
2711
- else if (datasetId_ && datasetName) {
2712
- throw new Error("Must provide either datasetName or datasetId, not both");
2713
- }
2714
- else if (!datasetId_) {
2715
- const dataset = await this.readDataset({ datasetName });
2716
- datasetId_ = dataset.id;
2717
- }
2718
- (0, _uuid_js_1.assertUuid)(datasetId_);
2719
- const data = {
2720
- tag: tag,
2721
- };
2722
- const body = JSON.stringify(data);
2723
- const response = await this.caller.call(async () => {
2724
- const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId_}/index`, {
2725
- method: "POST",
2726
- headers: { ...this.headers, "Content-Type": "application/json" },
2727
- signal: AbortSignal.timeout(this.timeout_ms),
2728
- ...this.fetchOptions,
2729
- body,
2730
- });
2731
- await (0, error_js_1.raiseForStatus)(res, "index dataset");
2732
- return res;
2733
- });
2734
- await response.json();
2735
- }
2736
- /**
2737
- * Lets you run a similarity search query on a dataset.
2738
- *
2739
- * Requires the dataset to be indexed. Please see the `indexDataset` method to set up indexing.
2740
- *
2741
- * @param inputs The input on which to run the similarity search. Must have the
2742
- * same schema as the dataset.
2743
- *
2744
- * @param datasetId The dataset to search for similar examples.
2745
- *
2746
- * @param limit The maximum number of examples to return. Will return the top `limit` most
2747
- * similar examples in order of most similar to least similar. If no similar
2748
- * examples are found, random examples will be returned.
2749
- *
2750
- * @param filter A filter string to apply to the search. Only examples will be returned that
2751
- * match the filter string. Some examples of filters
2752
- *
2753
- * - eq(metadata.mykey, "value")
2754
- * - and(neq(metadata.my.nested.key, "value"), neq(metadata.mykey, "value"))
2755
- * - or(eq(metadata.mykey, "value"), eq(metadata.mykey, "othervalue"))
2756
- *
2757
- * @returns A list of similar examples.
2758
- *
2759
- *
2760
- * @example
2761
- * dataset_id = "123e4567-e89b-12d3-a456-426614174000"
2762
- * inputs = {"text": "How many people live in Berlin?"}
2763
- * limit = 5
2764
- * examples = await client.similarExamples(inputs, dataset_id, limit)
2765
- */
2766
- async similarExamples(inputs, datasetId, limit, { filter, } = {}) {
2767
- const data = {
2768
- limit: limit,
2769
- inputs: inputs,
2770
- };
2771
- if (filter !== undefined) {
2772
- data["filter"] = filter;
2773
- }
2774
- (0, _uuid_js_1.assertUuid)(datasetId);
2775
- const body = JSON.stringify(data);
2776
- const response = await this.caller.call(async () => {
2777
- const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/search`, {
2778
- headers: { ...this.headers, "Content-Type": "application/json" },
2779
- signal: AbortSignal.timeout(this.timeout_ms),
2780
- ...this.fetchOptions,
2781
- method: "POST",
2782
- body,
2783
- });
2784
- await (0, error_js_1.raiseForStatus)(res, "fetch similar examples");
2785
- return res;
2786
- });
2787
- const result = await response.json();
2788
- return result["examples"];
2789
- }
2790
2741
  async createExample(inputsOrUpdate, outputs, options) {
2791
2742
  if (isExampleCreate(inputsOrUpdate)) {
2792
2743
  if (outputs !== undefined || options !== undefined) {
@@ -2998,7 +2949,7 @@ class Client {
2998
2949
  await this.caller.call(async () => {
2999
2950
  const res = await this._fetch(this.apiUrl + path, {
3000
2951
  method: "DELETE",
3001
- headers: this.headers,
2952
+ headers: this._mergedHeaders,
3002
2953
  signal: AbortSignal.timeout(this.timeout_ms),
3003
2954
  ...this.fetchOptions,
3004
2955
  });
@@ -3021,7 +2972,10 @@ class Client {
3021
2972
  await this.caller.call(async () => {
3022
2973
  const res = await this._fetch(`${this.apiUrl}${path}`, {
3023
2974
  method: "POST",
3024
- headers: { ...this.headers, "Content-Type": "application/json" },
2975
+ headers: {
2976
+ ...this._mergedHeaders,
2977
+ "Content-Type": "application/json",
2978
+ },
3025
2979
  body: JSON.stringify({
3026
2980
  example_ids: exampleIds,
3027
2981
  hard_delete: true,
@@ -3040,7 +2994,7 @@ class Client {
3040
2994
  await this.caller.call(async () => {
3041
2995
  const res = await this._fetch(`${this.apiUrl}/examples?${params.toString()}`, {
3042
2996
  method: "DELETE",
3043
- headers: this.headers,
2997
+ headers: this._mergedHeaders,
3044
2998
  signal: AbortSignal.timeout(this.timeout_ms),
3045
2999
  ...this.fetchOptions,
3046
3000
  });
@@ -3122,7 +3076,7 @@ class Client {
3122
3076
  const response = await this.caller.call(async () => {
3123
3077
  const res = await this._fetch(`${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
3124
3078
  method: "GET",
3125
- headers: { ...this.headers },
3079
+ headers: { ...this._mergedHeaders },
3126
3080
  signal: AbortSignal.timeout(this.timeout_ms),
3127
3081
  ...this.fetchOptions,
3128
3082
  });
@@ -3187,7 +3141,10 @@ class Client {
3187
3141
  await this.caller.call(async () => {
3188
3142
  const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId_}/splits`, {
3189
3143
  method: "PUT",
3190
- headers: { ...this.headers, "Content-Type": "application/json" },
3144
+ headers: {
3145
+ ...this._mergedHeaders,
3146
+ "Content-Type": "application/json",
3147
+ },
3191
3148
  signal: AbortSignal.timeout(this.timeout_ms),
3192
3149
  ...this.fetchOptions,
3193
3150
  body,
@@ -3235,7 +3192,7 @@ class Client {
3235
3192
  await this.caller.call(async () => {
3236
3193
  const res = await this._fetch(url, {
3237
3194
  method: "POST",
3238
- headers: { ...this.headers, "Content-Type": "application/json" },
3195
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3239
3196
  signal: AbortSignal.timeout(this.timeout_ms),
3240
3197
  ...this.fetchOptions,
3241
3198
  body,
@@ -3264,7 +3221,7 @@ class Client {
3264
3221
  await this.caller.call(async () => {
3265
3222
  const res = await this._fetch(`${this.apiUrl}/feedback/${feedbackId}`, {
3266
3223
  method: "PATCH",
3267
- headers: { ...this.headers, "Content-Type": "application/json" },
3224
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3268
3225
  signal: AbortSignal.timeout(this.timeout_ms),
3269
3226
  ...this.fetchOptions,
3270
3227
  body,
@@ -3285,7 +3242,7 @@ class Client {
3285
3242
  await this.caller.call(async () => {
3286
3243
  const res = await this._fetch(this.apiUrl + path, {
3287
3244
  method: "DELETE",
3288
- headers: this.headers,
3245
+ headers: this._mergedHeaders,
3289
3246
  signal: AbortSignal.timeout(this.timeout_ms),
3290
3247
  ...this.fetchOptions,
3291
3248
  });
@@ -3353,7 +3310,7 @@ class Client {
3353
3310
  const response = await this.caller.call(async () => {
3354
3311
  const res = await this._fetch(`${this.apiUrl}/feedback/tokens`, {
3355
3312
  method: "POST",
3356
- headers: { ...this.headers, "Content-Type": "application/json" },
3313
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3357
3314
  signal: AbortSignal.timeout(this.timeout_ms),
3358
3315
  ...this.fetchOptions,
3359
3316
  body: serializedBody,
@@ -3390,7 +3347,7 @@ class Client {
3390
3347
  const response = await this.caller.call(async () => {
3391
3348
  const res = await this._fetch(`${this.apiUrl}/datasets/comparative`, {
3392
3349
  method: "POST",
3393
- headers: { ...this.headers, "Content-Type": "application/json" },
3350
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3394
3351
  signal: AbortSignal.timeout(this.timeout_ms),
3395
3352
  ...this.fetchOptions,
3396
3353
  body: serializedBody,
@@ -3484,7 +3441,7 @@ class Client {
3484
3441
  const response = await this.caller.call(async () => {
3485
3442
  const res = await this._fetch(`${this.apiUrl}/feedback-configs`, {
3486
3443
  method: "POST",
3487
- headers: { ...this.headers, "Content-Type": "application/json" },
3444
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3488
3445
  signal: AbortSignal.timeout(this.timeout_ms),
3489
3446
  ...this.fetchOptions,
3490
3447
  body: JSON.stringify(body),
@@ -3541,7 +3498,7 @@ class Client {
3541
3498
  const response = await this.caller.call(async () => {
3542
3499
  const res = await this._fetch(`${this.apiUrl}/feedback-configs`, {
3543
3500
  method: "PATCH",
3544
- headers: { ...this.headers, "Content-Type": "application/json" },
3501
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3545
3502
  signal: AbortSignal.timeout(this.timeout_ms),
3546
3503
  ...this.fetchOptions,
3547
3504
  body: JSON.stringify(body),
@@ -3560,7 +3517,7 @@ class Client {
3560
3517
  await this.caller.call(async () => {
3561
3518
  const res = await this._fetch(`${this.apiUrl}/feedback-configs?${params}`, {
3562
3519
  method: "DELETE",
3563
- headers: this.headers,
3520
+ headers: this._mergedHeaders,
3564
3521
  signal: AbortSignal.timeout(this.timeout_ms),
3565
3522
  ...this.fetchOptions,
3566
3523
  });
@@ -3623,7 +3580,7 @@ class Client {
3623
3580
  const response = await this.caller.call(async () => {
3624
3581
  const res = await this._fetch(`${this.apiUrl}/annotation-queues`, {
3625
3582
  method: "POST",
3626
- headers: { ...this.headers, "Content-Type": "application/json" },
3583
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3627
3584
  signal: AbortSignal.timeout(this.timeout_ms),
3628
3585
  ...this.fetchOptions,
3629
3586
  body: serializedBody,
@@ -3642,7 +3599,7 @@ class Client {
3642
3599
  const response = await this.caller.call(async () => {
3643
3600
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
3644
3601
  method: "GET",
3645
- headers: this.headers,
3602
+ headers: this._mergedHeaders,
3646
3603
  signal: AbortSignal.timeout(this.timeout_ms),
3647
3604
  ...this.fetchOptions,
3648
3605
  });
@@ -3673,7 +3630,10 @@ class Client {
3673
3630
  await this.caller.call(async () => {
3674
3631
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
3675
3632
  method: "PATCH",
3676
- headers: { ...this.headers, "Content-Type": "application/json" },
3633
+ headers: {
3634
+ ...this._mergedHeaders,
3635
+ "Content-Type": "application/json",
3636
+ },
3677
3637
  signal: AbortSignal.timeout(this.timeout_ms),
3678
3638
  ...this.fetchOptions,
3679
3639
  body,
@@ -3690,7 +3650,7 @@ class Client {
3690
3650
  await this.caller.call(async () => {
3691
3651
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
3692
3652
  method: "DELETE",
3693
- headers: { ...this.headers, Accept: "application/json" },
3653
+ headers: { ...this._mergedHeaders, Accept: "application/json" },
3694
3654
  signal: AbortSignal.timeout(this.timeout_ms),
3695
3655
  ...this.fetchOptions,
3696
3656
  });
@@ -3708,7 +3668,10 @@ class Client {
3708
3668
  await this.caller.call(async () => {
3709
3669
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs`, {
3710
3670
  method: "POST",
3711
- headers: { ...this.headers, "Content-Type": "application/json" },
3671
+ headers: {
3672
+ ...this._mergedHeaders,
3673
+ "Content-Type": "application/json",
3674
+ },
3712
3675
  signal: AbortSignal.timeout(this.timeout_ms),
3713
3676
  ...this.fetchOptions,
3714
3677
  body,
@@ -3729,7 +3692,7 @@ class Client {
3729
3692
  const response = await this.caller.call(async () => {
3730
3693
  const res = await this._fetch(`${this.apiUrl}${baseUrl}/${index}`, {
3731
3694
  method: "GET",
3732
- headers: this.headers,
3695
+ headers: this._mergedHeaders,
3733
3696
  signal: AbortSignal.timeout(this.timeout_ms),
3734
3697
  ...this.fetchOptions,
3735
3698
  });
@@ -3748,7 +3711,7 @@ class Client {
3748
3711
  await this.caller.call(async () => {
3749
3712
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs/${(0, _uuid_js_1.assertUuid)(queueRunId, "queueRunId")}`, {
3750
3713
  method: "DELETE",
3751
- headers: { ...this.headers, Accept: "application/json" },
3714
+ headers: { ...this._mergedHeaders, Accept: "application/json" },
3752
3715
  signal: AbortSignal.timeout(this.timeout_ms),
3753
3716
  ...this.fetchOptions,
3754
3717
  });
@@ -3764,7 +3727,7 @@ class Client {
3764
3727
  const response = await this.caller.call(async () => {
3765
3728
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/size`, {
3766
3729
  method: "GET",
3767
- headers: this.headers,
3730
+ headers: this._mergedHeaders,
3768
3731
  signal: AbortSignal.timeout(this.timeout_ms),
3769
3732
  ...this.fetchOptions,
3770
3733
  });
@@ -3787,7 +3750,7 @@ class Client {
3787
3750
  const response = await this.caller.call(async () => {
3788
3751
  const res = await this._fetch(`${this.apiUrl}/commits/${promptOwnerAndName}/?limit=${1}&offset=${0}`, {
3789
3752
  method: "GET",
3790
- headers: this.headers,
3753
+ headers: this._mergedHeaders,
3791
3754
  signal: AbortSignal.timeout(this.timeout_ms),
3792
3755
  ...this.fetchOptions,
3793
3756
  });
@@ -3806,7 +3769,10 @@ class Client {
3806
3769
  const response = await this.caller.call(async () => {
3807
3770
  const res = await this._fetch(`${this.apiUrl}/likes/${owner}/${promptName}`, {
3808
3771
  method: "POST",
3809
- headers: { ...this.headers, "Content-Type": "application/json" },
3772
+ headers: {
3773
+ ...this._mergedHeaders,
3774
+ "Content-Type": "application/json",
3775
+ },
3810
3776
  signal: AbortSignal.timeout(this.timeout_ms),
3811
3777
  ...this.fetchOptions,
3812
3778
  body,
@@ -3976,7 +3942,7 @@ class Client {
3976
3942
  const response = await this.caller.call(async () => {
3977
3943
  const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
3978
3944
  method: "GET",
3979
- headers: this.headers,
3945
+ headers: this._mergedHeaders,
3980
3946
  signal: AbortSignal.timeout(this.timeout_ms),
3981
3947
  ...this.fetchOptions,
3982
3948
  });
@@ -4044,7 +4010,7 @@ class Client {
4044
4010
  const response = await this.caller.call(async () => {
4045
4011
  const res = await this._fetch(`${this.apiUrl}/repos/`, {
4046
4012
  method: "POST",
4047
- headers: { ...this.headers, "Content-Type": "application/json" },
4013
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
4048
4014
  signal: AbortSignal.timeout(this.timeout_ms),
4049
4015
  ...this.fetchOptions,
4050
4016
  body,
@@ -4095,12 +4061,18 @@ class Client {
4095
4061
  const payload = {
4096
4062
  manifest: JSON.parse(JSON.stringify(object)),
4097
4063
  parent_commit: resolvedParentCommitHash,
4064
+ ...(options?.description !== undefined && {
4065
+ description: options.description,
4066
+ }),
4098
4067
  };
4099
4068
  const body = JSON.stringify(payload);
4100
4069
  const response = await this.caller.call(async () => {
4101
4070
  const res = await this._fetch(`${this.apiUrl}/commits/${owner}/${promptName}`, {
4102
4071
  method: "POST",
4103
- headers: { ...this.headers, "Content-Type": "application/json" },
4072
+ headers: {
4073
+ ...this._mergedHeaders,
4074
+ "Content-Type": "application/json",
4075
+ },
4104
4076
  signal: AbortSignal.timeout(this.timeout_ms),
4105
4077
  ...this.fetchOptions,
4106
4078
  body,
@@ -4183,7 +4155,7 @@ class Client {
4183
4155
  const response = await this.caller.call(async () => {
4184
4156
  const res = await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${datasetIdToUse}/examples`)}`, {
4185
4157
  method: "PATCH",
4186
- headers: this.headers,
4158
+ headers: this._mergedHeaders,
4187
4159
  signal: AbortSignal.timeout(this.timeout_ms),
4188
4160
  ...this.fetchOptions,
4189
4161
  body: formData,
@@ -4266,7 +4238,7 @@ class Client {
4266
4238
  const response = await this.caller.call(async () => {
4267
4239
  const res = await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${datasetId}/examples`)}`, {
4268
4240
  method: "POST",
4269
- headers: this.headers,
4241
+ headers: this._mergedHeaders,
4270
4242
  signal: AbortSignal.timeout(this.timeout_ms),
4271
4243
  ...this.fetchOptions,
4272
4244
  body: formData,
@@ -4304,7 +4276,7 @@ class Client {
4304
4276
  const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
4305
4277
  method: "PATCH",
4306
4278
  headers: {
4307
- ...this.headers,
4279
+ ...this._mergedHeaders,
4308
4280
  "Content-Type": "application/json",
4309
4281
  },
4310
4282
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -4327,7 +4299,7 @@ class Client {
4327
4299
  const response = await this.caller.call(async () => {
4328
4300
  const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
4329
4301
  method: "DELETE",
4330
- headers: this.headers,
4302
+ headers: this._mergedHeaders,
4331
4303
  signal: AbortSignal.timeout(this.timeout_ms),
4332
4304
  ...this.fetchOptions,
4333
4305
  });
@@ -4352,7 +4324,7 @@ class Client {
4352
4324
  const response = await this.caller.call(async () => {
4353
4325
  const res = await this._fetch(`${this.apiUrl}/commits/${owner}/${promptName}/${commitHash}${options?.includeModel ? "?include_model=true" : ""}`, {
4354
4326
  method: "GET",
4355
- headers: this.headers,
4327
+ headers: this._mergedHeaders,
4356
4328
  signal: AbortSignal.timeout(this.timeout_ms),
4357
4329
  ...this.fetchOptions,
4358
4330
  });
@@ -4424,6 +4396,7 @@ class Client {
4424
4396
  // Create a commit with the new manifest
4425
4397
  const url = await this.createCommit(promptIdentifier, options?.object, {
4426
4398
  parentCommitHash: options?.parentCommitHash,
4399
+ description: options?.commitDescription,
4427
4400
  });
4428
4401
  return url;
4429
4402
  }