langsmith 0.5.16 → 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 (94) hide show
  1. package/dist/client.cjs +112 -143
  2. package/dist/client.d.ts +19 -40
  3. package/dist/client.js +112 -143
  4. package/dist/experimental/anthropic/index.cjs +4 -1
  5. package/dist/experimental/anthropic/index.js +4 -1
  6. package/dist/experimental/vercel/index.cjs +1 -0
  7. package/dist/experimental/vercel/index.js +1 -0
  8. package/dist/experimental/vercel/middleware.cjs +2 -0
  9. package/dist/experimental/vercel/middleware.js +2 -0
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/schemas.d.ts +1 -3
  14. package/dist/utils/chalk/source/index.cjs +187 -0
  15. package/dist/utils/chalk/source/index.d.ts +19 -0
  16. package/dist/utils/chalk/source/index.js +173 -0
  17. package/dist/utils/chalk/source/utilities.cjs +35 -0
  18. package/dist/utils/chalk/source/utilities.d.ts +2 -0
  19. package/dist/utils/chalk/source/utilities.js +31 -0
  20. package/dist/utils/chalk/source/vendor/ansi-styles/index.cjs +193 -0
  21. package/dist/utils/chalk/source/vendor/ansi-styles/index.d.ts +58 -0
  22. package/dist/utils/chalk/source/vendor/ansi-styles/index.js +190 -0
  23. package/dist/utils/chalk/source/vendor/supports-color/browser.cjs +31 -0
  24. package/dist/utils/chalk/source/vendor/supports-color/browser.d.ts +15 -0
  25. package/dist/utils/chalk/source/vendor/supports-color/browser.js +29 -0
  26. package/dist/utils/chalk/source/vendor/supports-color/index.cjs +155 -0
  27. package/dist/utils/chalk/source/vendor/supports-color/index.d.ts +21 -0
  28. package/dist/utils/chalk/source/vendor/supports-color/index.js +149 -0
  29. package/dist/utils/console-table-printer/index.cjs +11 -0
  30. package/dist/utils/console-table-printer/index.d.ts +4 -0
  31. package/dist/utils/console-table-printer/index.js +3 -0
  32. package/dist/utils/console-table-printer/src/console-table-printer.cjs +42 -0
  33. package/dist/utils/console-table-printer/src/console-table-printer.d.ts +14 -0
  34. package/dist/utils/console-table-printer/src/console-table-printer.js +36 -0
  35. package/dist/utils/console-table-printer/src/internalTable/input-converter.cjs +25 -0
  36. package/dist/utils/console-table-printer/src/internalTable/input-converter.d.ts +6 -0
  37. package/dist/utils/console-table-printer/src/internalTable/input-converter.js +20 -0
  38. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.cjs +142 -0
  39. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.d.ts +6 -0
  40. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.js +133 -0
  41. package/dist/utils/console-table-printer/src/internalTable/internal-table.cjs +186 -0
  42. package/dist/utils/console-table-printer/src/internalTable/internal-table.d.ts +31 -0
  43. package/dist/utils/console-table-printer/src/internalTable/internal-table.js +184 -0
  44. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.cjs +53 -0
  45. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.d.ts +3 -0
  46. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.js +48 -0
  47. package/dist/utils/console-table-printer/src/models/common.cjs +2 -0
  48. package/dist/utils/console-table-printer/src/models/common.d.ts +14 -0
  49. package/dist/utils/console-table-printer/src/models/common.js +1 -0
  50. package/dist/utils/console-table-printer/src/models/external-table.cjs +2 -0
  51. package/dist/utils/console-table-printer/src/models/external-table.d.ts +99 -0
  52. package/dist/utils/console-table-printer/src/models/external-table.js +1 -0
  53. package/dist/utils/console-table-printer/src/models/internal-table.cjs +2 -0
  54. package/dist/utils/console-table-printer/src/models/internal-table.d.ts +24 -0
  55. package/dist/utils/console-table-printer/src/models/internal-table.js +1 -0
  56. package/dist/utils/console-table-printer/src/utils/colored-console-line.cjs +43 -0
  57. package/dist/utils/console-table-printer/src/utils/colored-console-line.d.ts +12 -0
  58. package/dist/utils/console-table-printer/src/utils/colored-console-line.js +39 -0
  59. package/dist/utils/console-table-printer/src/utils/console-utils.cjs +23 -0
  60. package/dist/utils/console-table-printer/src/utils/console-utils.d.ts +3 -0
  61. package/dist/utils/console-table-printer/src/utils/console-utils.js +18 -0
  62. package/dist/utils/console-table-printer/src/utils/string-utils.cjs +68 -0
  63. package/dist/utils/console-table-printer/src/utils/string-utils.d.ts +4 -0
  64. package/dist/utils/console-table-printer/src/utils/string-utils.js +62 -0
  65. package/dist/utils/console-table-printer/src/utils/table-constants.cjs +55 -0
  66. package/dist/utils/console-table-printer/src/utils/table-constants.d.ts +11 -0
  67. package/dist/utils/console-table-printer/src/utils/table-constants.js +52 -0
  68. package/dist/utils/console-table-printer/src/utils/table-helpers.cjs +101 -0
  69. package/dist/utils/console-table-printer/src/utils/table-helpers.d.ts +29 -0
  70. package/dist/utils/console-table-printer/src/utils/table-helpers.js +88 -0
  71. package/dist/utils/jestlike/reporter.cjs +23 -23
  72. package/dist/utils/jestlike/reporter.js +2 -2
  73. package/dist/utils/prompts.cjs +0 -10
  74. package/dist/utils/prompts.d.ts +0 -1
  75. package/dist/utils/prompts.js +0 -9
  76. package/dist/utils/simple-wcswidth/index.cjs +10 -0
  77. package/dist/utils/simple-wcswidth/index.d.ts +3 -0
  78. package/dist/utils/simple-wcswidth/index.js +3 -0
  79. package/dist/utils/simple-wcswidth/src/binary-search.cjs +24 -0
  80. package/dist/utils/simple-wcswidth/src/binary-search.d.ts +3 -0
  81. package/dist/utils/simple-wcswidth/src/binary-search.js +22 -0
  82. package/dist/utils/simple-wcswidth/src/models.cjs +2 -0
  83. package/dist/utils/simple-wcswidth/src/models.d.ts +4 -0
  84. package/dist/utils/simple-wcswidth/src/models.js +1 -0
  85. package/dist/utils/simple-wcswidth/src/non-spacing-chars.cjs +149 -0
  86. package/dist/utils/simple-wcswidth/src/non-spacing-chars.d.ts +3 -0
  87. package/dist/utils/simple-wcswidth/src/non-spacing-chars.js +147 -0
  88. package/dist/utils/simple-wcswidth/src/wcswidth.cjs +20 -0
  89. package/dist/utils/simple-wcswidth/src/wcswidth.d.ts +2 -0
  90. package/dist/utils/simple-wcswidth/src/wcswidth.js +15 -0
  91. package/dist/utils/simple-wcswidth/src/wcwidth.cjs +67 -0
  92. package/dist/utils/simple-wcswidth/src/wcwidth.d.ts +2 -0
  93. package/dist/utils/simple-wcswidth/src/wcwidth.js +62 -0
  94. package/package.json +5 -7
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");
@@ -616,10 +624,13 @@ class Client {
616
624
  return this.webUrl;
617
625
  }
618
626
  }
619
- get headers() {
627
+ get _mergedHeaders() {
628
+ // Start with custom headers so they don't override required headers
620
629
  const headers = {
621
630
  "User-Agent": `langsmith-js/${index_js_1.__version__}`,
631
+ ...this._customHeaders,
622
632
  };
633
+ // Required headers that should not be overridden
623
634
  if (this.apiKey) {
624
635
  headers["x-api-key"] = `${this.apiKey}`;
625
636
  }
@@ -628,6 +639,17 @@ class Client {
628
639
  }
629
640
  return headers;
630
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
+ }
631
653
  _getPlatformEndpointPath(path) {
632
654
  // Check if apiUrl already ends with /v1 or /v1/ to avoid double /v1/v1/ paths
633
655
  const needsV1Prefix = this.apiUrl.slice(-3) !== "/v1" && this.apiUrl.slice(-4) !== "/v1/";
@@ -673,7 +695,7 @@ class Client {
673
695
  const response = await this.caller.call(async () => {
674
696
  const res = await this._fetch(url, {
675
697
  method: "GET",
676
- headers: this.headers,
698
+ headers: this._mergedHeaders,
677
699
  signal: AbortSignal.timeout(this.timeout_ms),
678
700
  ...this.fetchOptions,
679
701
  });
@@ -696,7 +718,7 @@ class Client {
696
718
  const response = await this.caller.call(async () => {
697
719
  const res = await this._fetch(url, {
698
720
  method: "GET",
699
- headers: this.headers,
721
+ headers: this._mergedHeaders,
700
722
  signal: AbortSignal.timeout(this.timeout_ms),
701
723
  ...this.fetchOptions,
702
724
  });
@@ -723,7 +745,10 @@ class Client {
723
745
  const response = await this.caller.call(async () => {
724
746
  const res = await this._fetch(`${this.apiUrl}${path}`, {
725
747
  method: requestMethod,
726
- headers: { ...this.headers, "Content-Type": "application/json" },
748
+ headers: {
749
+ ...this._mergedHeaders,
750
+ "Content-Type": "application/json",
751
+ },
727
752
  signal: AbortSignal.timeout(this.timeout_ms),
728
753
  ...this.fetchOptions,
729
754
  body,
@@ -1100,7 +1125,7 @@ class Client {
1100
1125
  return;
1101
1126
  }
1102
1127
  const headers = {
1103
- ...this.headers,
1128
+ ...this._mergedHeaders,
1104
1129
  "Content-Type": "application/json",
1105
1130
  };
1106
1131
  const session_name = run.project_name;
@@ -1207,7 +1232,7 @@ class Client {
1207
1232
  }
1208
1233
  async _postBatchIngestRuns(body, options) {
1209
1234
  const headers = {
1210
- ...this.headers,
1235
+ ...this._mergedHeaders,
1211
1236
  "Content-Type": "application/json",
1212
1237
  Accept: "application/json",
1213
1238
  };
@@ -1431,7 +1456,7 @@ class Client {
1431
1456
  return this.batchIngestCaller.callWithOptions({ sizeBytes: options?.sizeBytes }, async () => {
1432
1457
  const body = await bodyFactory();
1433
1458
  const headers = {
1434
- ...this.headers,
1459
+ ...this._mergedHeaders,
1435
1460
  "Content-Type": `multipart/form-data; boundary=${boundary}`,
1436
1461
  };
1437
1462
  if (options?.apiKey !== undefined) {
@@ -1542,7 +1567,7 @@ class Client {
1542
1567
  return;
1543
1568
  }
1544
1569
  const headers = {
1545
- ...this.headers,
1570
+ ...this._mergedHeaders,
1546
1571
  "Content-Type": "application/json",
1547
1572
  };
1548
1573
  if (options?.apiKey !== undefined) {
@@ -1828,7 +1853,10 @@ class Client {
1828
1853
  const response = await this.caller.call(async () => {
1829
1854
  const res = await this._fetch(url, {
1830
1855
  method: "POST",
1831
- headers: { ...this.headers, "Content-Type": "application/json" },
1856
+ headers: {
1857
+ ...this._mergedHeaders,
1858
+ "Content-Type": "application/json",
1859
+ },
1832
1860
  signal: AbortSignal.timeout(this.timeout_ms),
1833
1861
  ...this.fetchOptions,
1834
1862
  body,
@@ -2004,7 +2032,7 @@ class Client {
2004
2032
  const response = await this.caller.call(async () => {
2005
2033
  const res = await this._fetch(`${this.apiUrl}/runs/stats`, {
2006
2034
  method: "POST",
2007
- headers: { ...this.headers, "Content-Type": "application/json" },
2035
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2008
2036
  signal: AbortSignal.timeout(this.timeout_ms),
2009
2037
  ...this.fetchOptions,
2010
2038
  body,
@@ -2025,7 +2053,7 @@ class Client {
2025
2053
  const response = await this.caller.call(async () => {
2026
2054
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
2027
2055
  method: "PUT",
2028
- headers: this.headers,
2056
+ headers: this._mergedHeaders,
2029
2057
  signal: AbortSignal.timeout(this.timeout_ms),
2030
2058
  ...this.fetchOptions,
2031
2059
  body,
@@ -2044,7 +2072,7 @@ class Client {
2044
2072
  await this.caller.call(async () => {
2045
2073
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
2046
2074
  method: "DELETE",
2047
- headers: this.headers,
2075
+ headers: this._mergedHeaders,
2048
2076
  signal: AbortSignal.timeout(this.timeout_ms),
2049
2077
  ...this.fetchOptions,
2050
2078
  });
@@ -2057,7 +2085,7 @@ class Client {
2057
2085
  const response = await this.caller.call(async () => {
2058
2086
  const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
2059
2087
  method: "GET",
2060
- headers: this.headers,
2088
+ headers: this._mergedHeaders,
2061
2089
  signal: AbortSignal.timeout(this.timeout_ms),
2062
2090
  ...this.fetchOptions,
2063
2091
  });
@@ -2083,7 +2111,7 @@ class Client {
2083
2111
  const response = await this.caller.call(async () => {
2084
2112
  const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
2085
2113
  method: "GET",
2086
- headers: this.headers,
2114
+ headers: this._mergedHeaders,
2087
2115
  signal: AbortSignal.timeout(this.timeout_ms),
2088
2116
  ...this.fetchOptions,
2089
2117
  });
@@ -2105,7 +2133,7 @@ class Client {
2105
2133
  const response = await this.caller.call(async () => {
2106
2134
  const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
2107
2135
  method: "GET",
2108
- headers: this.headers,
2136
+ headers: this._mergedHeaders,
2109
2137
  signal: AbortSignal.timeout(this.timeout_ms),
2110
2138
  ...this.fetchOptions,
2111
2139
  });
@@ -2132,7 +2160,7 @@ class Client {
2132
2160
  const response = await this.caller.call(async () => {
2133
2161
  const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
2134
2162
  method: "PUT",
2135
- headers: this.headers,
2163
+ headers: this._mergedHeaders,
2136
2164
  signal: AbortSignal.timeout(this.timeout_ms),
2137
2165
  ...this.fetchOptions,
2138
2166
  body,
@@ -2149,7 +2177,7 @@ class Client {
2149
2177
  await this.caller.call(async () => {
2150
2178
  const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
2151
2179
  method: "DELETE",
2152
- headers: this.headers,
2180
+ headers: this._mergedHeaders,
2153
2181
  signal: AbortSignal.timeout(this.timeout_ms),
2154
2182
  ...this.fetchOptions,
2155
2183
  });
@@ -2162,7 +2190,7 @@ class Client {
2162
2190
  const response = await this.caller.call(async () => {
2163
2191
  const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/datasets`, {
2164
2192
  method: "GET",
2165
- headers: this.headers,
2193
+ headers: this._mergedHeaders,
2166
2194
  signal: AbortSignal.timeout(this.timeout_ms),
2167
2195
  ...this.fetchOptions,
2168
2196
  });
@@ -2197,7 +2225,7 @@ class Client {
2197
2225
  const response = await this.caller.call(async () => {
2198
2226
  const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/examples?${urlParams.toString()}`, {
2199
2227
  method: "GET",
2200
- headers: this.headers,
2228
+ headers: this._mergedHeaders,
2201
2229
  signal: AbortSignal.timeout(this.timeout_ms),
2202
2230
  ...this.fetchOptions,
2203
2231
  });
@@ -2237,7 +2265,7 @@ class Client {
2237
2265
  const response = await this.caller.call(async () => {
2238
2266
  const res = await this._fetch(endpoint, {
2239
2267
  method: "POST",
2240
- headers: { ...this.headers, "Content-Type": "application/json" },
2268
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2241
2269
  signal: AbortSignal.timeout(this.timeout_ms),
2242
2270
  ...this.fetchOptions,
2243
2271
  body: serializedBody,
@@ -2263,7 +2291,7 @@ class Client {
2263
2291
  const response = await this.caller.call(async () => {
2264
2292
  const res = await this._fetch(endpoint, {
2265
2293
  method: "PATCH",
2266
- headers: { ...this.headers, "Content-Type": "application/json" },
2294
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2267
2295
  signal: AbortSignal.timeout(this.timeout_ms),
2268
2296
  ...this.fetchOptions,
2269
2297
  body,
@@ -2294,7 +2322,7 @@ class Client {
2294
2322
  const response = await this.caller.call(async () => {
2295
2323
  const res = await this._fetch(`${this.apiUrl}${path}?${params}`, {
2296
2324
  method: "GET",
2297
- headers: this.headers,
2325
+ headers: this._mergedHeaders,
2298
2326
  signal: AbortSignal.timeout(this.timeout_ms),
2299
2327
  ...this.fetchOptions,
2300
2328
  });
@@ -2434,7 +2462,7 @@ class Client {
2434
2462
  await this.caller.call(async () => {
2435
2463
  const res = await this._fetch(`${this.apiUrl}/sessions/${projectId_}`, {
2436
2464
  method: "DELETE",
2437
- headers: this.headers,
2465
+ headers: this._mergedHeaders,
2438
2466
  signal: AbortSignal.timeout(this.timeout_ms),
2439
2467
  ...this.fetchOptions,
2440
2468
  });
@@ -2465,7 +2493,7 @@ class Client {
2465
2493
  const response = await this.caller.call(async () => {
2466
2494
  const res = await this._fetch(url, {
2467
2495
  method: "POST",
2468
- headers: this.headers,
2496
+ headers: this._mergedHeaders,
2469
2497
  signal: AbortSignal.timeout(this.timeout_ms),
2470
2498
  ...this.fetchOptions,
2471
2499
  body: formData,
@@ -2495,7 +2523,7 @@ class Client {
2495
2523
  const response = await this.caller.call(async () => {
2496
2524
  const res = await this._fetch(`${this.apiUrl}/datasets`, {
2497
2525
  method: "POST",
2498
- headers: { ...this.headers, "Content-Type": "application/json" },
2526
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2499
2527
  signal: AbortSignal.timeout(this.timeout_ms),
2500
2528
  ...this.fetchOptions,
2501
2529
  body: serializedBody,
@@ -2631,7 +2659,7 @@ class Client {
2631
2659
  const response = await this.caller.call(async () => {
2632
2660
  const res = await this._fetch(`${this.apiUrl}/datasets/${_datasetId}`, {
2633
2661
  method: "PATCH",
2634
- headers: { ...this.headers, "Content-Type": "application/json" },
2662
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
2635
2663
  signal: AbortSignal.timeout(this.timeout_ms),
2636
2664
  ...this.fetchOptions,
2637
2665
  body,
@@ -2670,7 +2698,10 @@ class Client {
2670
2698
  await this.caller.call(async () => {
2671
2699
  const res = await this._fetch(`${this.apiUrl}/datasets/${_datasetId}/tags`, {
2672
2700
  method: "PUT",
2673
- headers: { ...this.headers, "Content-Type": "application/json" },
2701
+ headers: {
2702
+ ...this._mergedHeaders,
2703
+ "Content-Type": "application/json",
2704
+ },
2674
2705
  signal: AbortSignal.timeout(this.timeout_ms),
2675
2706
  ...this.fetchOptions,
2676
2707
  body,
@@ -2699,7 +2730,7 @@ class Client {
2699
2730
  await this.caller.call(async () => {
2700
2731
  const res = await this._fetch(this.apiUrl + path, {
2701
2732
  method: "DELETE",
2702
- headers: this.headers,
2733
+ headers: this._mergedHeaders,
2703
2734
  signal: AbortSignal.timeout(this.timeout_ms),
2704
2735
  ...this.fetchOptions,
2705
2736
  });
@@ -2707,90 +2738,6 @@ class Client {
2707
2738
  return res;
2708
2739
  });
2709
2740
  }
2710
- async indexDataset({ datasetId, datasetName, tag, }) {
2711
- let datasetId_ = datasetId;
2712
- if (!datasetId_ && !datasetName) {
2713
- throw new Error("Must provide either datasetName or datasetId");
2714
- }
2715
- else if (datasetId_ && datasetName) {
2716
- throw new Error("Must provide either datasetName or datasetId, not both");
2717
- }
2718
- else if (!datasetId_) {
2719
- const dataset = await this.readDataset({ datasetName });
2720
- datasetId_ = dataset.id;
2721
- }
2722
- (0, _uuid_js_1.assertUuid)(datasetId_);
2723
- const data = {
2724
- tag: tag,
2725
- };
2726
- const body = JSON.stringify(data);
2727
- const response = await this.caller.call(async () => {
2728
- const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId_}/index`, {
2729
- method: "POST",
2730
- headers: { ...this.headers, "Content-Type": "application/json" },
2731
- signal: AbortSignal.timeout(this.timeout_ms),
2732
- ...this.fetchOptions,
2733
- body,
2734
- });
2735
- await (0, error_js_1.raiseForStatus)(res, "index dataset");
2736
- return res;
2737
- });
2738
- await response.json();
2739
- }
2740
- /**
2741
- * Lets you run a similarity search query on a dataset.
2742
- *
2743
- * Requires the dataset to be indexed. Please see the `indexDataset` method to set up indexing.
2744
- *
2745
- * @param inputs The input on which to run the similarity search. Must have the
2746
- * same schema as the dataset.
2747
- *
2748
- * @param datasetId The dataset to search for similar examples.
2749
- *
2750
- * @param limit The maximum number of examples to return. Will return the top `limit` most
2751
- * similar examples in order of most similar to least similar. If no similar
2752
- * examples are found, random examples will be returned.
2753
- *
2754
- * @param filter A filter string to apply to the search. Only examples will be returned that
2755
- * match the filter string. Some examples of filters
2756
- *
2757
- * - eq(metadata.mykey, "value")
2758
- * - and(neq(metadata.my.nested.key, "value"), neq(metadata.mykey, "value"))
2759
- * - or(eq(metadata.mykey, "value"), eq(metadata.mykey, "othervalue"))
2760
- *
2761
- * @returns A list of similar examples.
2762
- *
2763
- *
2764
- * @example
2765
- * dataset_id = "123e4567-e89b-12d3-a456-426614174000"
2766
- * inputs = {"text": "How many people live in Berlin?"}
2767
- * limit = 5
2768
- * examples = await client.similarExamples(inputs, dataset_id, limit)
2769
- */
2770
- async similarExamples(inputs, datasetId, limit, { filter, } = {}) {
2771
- const data = {
2772
- limit: limit,
2773
- inputs: inputs,
2774
- };
2775
- if (filter !== undefined) {
2776
- data["filter"] = filter;
2777
- }
2778
- (0, _uuid_js_1.assertUuid)(datasetId);
2779
- const body = JSON.stringify(data);
2780
- const response = await this.caller.call(async () => {
2781
- const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/search`, {
2782
- headers: { ...this.headers, "Content-Type": "application/json" },
2783
- signal: AbortSignal.timeout(this.timeout_ms),
2784
- ...this.fetchOptions,
2785
- method: "POST",
2786
- body,
2787
- });
2788
- await (0, error_js_1.raiseForStatus)(res, "fetch similar examples");
2789
- return res;
2790
- });
2791
- const result = await response.json();
2792
- return result["examples"];
2793
- }
2794
2741
  async createExample(inputsOrUpdate, outputs, options) {
2795
2742
  if (isExampleCreate(inputsOrUpdate)) {
2796
2743
  if (outputs !== undefined || options !== undefined) {
@@ -3002,7 +2949,7 @@ class Client {
3002
2949
  await this.caller.call(async () => {
3003
2950
  const res = await this._fetch(this.apiUrl + path, {
3004
2951
  method: "DELETE",
3005
- headers: this.headers,
2952
+ headers: this._mergedHeaders,
3006
2953
  signal: AbortSignal.timeout(this.timeout_ms),
3007
2954
  ...this.fetchOptions,
3008
2955
  });
@@ -3025,7 +2972,10 @@ class Client {
3025
2972
  await this.caller.call(async () => {
3026
2973
  const res = await this._fetch(`${this.apiUrl}${path}`, {
3027
2974
  method: "POST",
3028
- headers: { ...this.headers, "Content-Type": "application/json" },
2975
+ headers: {
2976
+ ...this._mergedHeaders,
2977
+ "Content-Type": "application/json",
2978
+ },
3029
2979
  body: JSON.stringify({
3030
2980
  example_ids: exampleIds,
3031
2981
  hard_delete: true,
@@ -3044,7 +2994,7 @@ class Client {
3044
2994
  await this.caller.call(async () => {
3045
2995
  const res = await this._fetch(`${this.apiUrl}/examples?${params.toString()}`, {
3046
2996
  method: "DELETE",
3047
- headers: this.headers,
2997
+ headers: this._mergedHeaders,
3048
2998
  signal: AbortSignal.timeout(this.timeout_ms),
3049
2999
  ...this.fetchOptions,
3050
3000
  });
@@ -3126,7 +3076,7 @@ class Client {
3126
3076
  const response = await this.caller.call(async () => {
3127
3077
  const res = await this._fetch(`${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
3128
3078
  method: "GET",
3129
- headers: { ...this.headers },
3079
+ headers: { ...this._mergedHeaders },
3130
3080
  signal: AbortSignal.timeout(this.timeout_ms),
3131
3081
  ...this.fetchOptions,
3132
3082
  });
@@ -3191,7 +3141,10 @@ class Client {
3191
3141
  await this.caller.call(async () => {
3192
3142
  const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId_}/splits`, {
3193
3143
  method: "PUT",
3194
- headers: { ...this.headers, "Content-Type": "application/json" },
3144
+ headers: {
3145
+ ...this._mergedHeaders,
3146
+ "Content-Type": "application/json",
3147
+ },
3195
3148
  signal: AbortSignal.timeout(this.timeout_ms),
3196
3149
  ...this.fetchOptions,
3197
3150
  body,
@@ -3239,7 +3192,7 @@ class Client {
3239
3192
  await this.caller.call(async () => {
3240
3193
  const res = await this._fetch(url, {
3241
3194
  method: "POST",
3242
- headers: { ...this.headers, "Content-Type": "application/json" },
3195
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3243
3196
  signal: AbortSignal.timeout(this.timeout_ms),
3244
3197
  ...this.fetchOptions,
3245
3198
  body,
@@ -3268,7 +3221,7 @@ class Client {
3268
3221
  await this.caller.call(async () => {
3269
3222
  const res = await this._fetch(`${this.apiUrl}/feedback/${feedbackId}`, {
3270
3223
  method: "PATCH",
3271
- headers: { ...this.headers, "Content-Type": "application/json" },
3224
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3272
3225
  signal: AbortSignal.timeout(this.timeout_ms),
3273
3226
  ...this.fetchOptions,
3274
3227
  body,
@@ -3289,7 +3242,7 @@ class Client {
3289
3242
  await this.caller.call(async () => {
3290
3243
  const res = await this._fetch(this.apiUrl + path, {
3291
3244
  method: "DELETE",
3292
- headers: this.headers,
3245
+ headers: this._mergedHeaders,
3293
3246
  signal: AbortSignal.timeout(this.timeout_ms),
3294
3247
  ...this.fetchOptions,
3295
3248
  });
@@ -3357,7 +3310,7 @@ class Client {
3357
3310
  const response = await this.caller.call(async () => {
3358
3311
  const res = await this._fetch(`${this.apiUrl}/feedback/tokens`, {
3359
3312
  method: "POST",
3360
- headers: { ...this.headers, "Content-Type": "application/json" },
3313
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3361
3314
  signal: AbortSignal.timeout(this.timeout_ms),
3362
3315
  ...this.fetchOptions,
3363
3316
  body: serializedBody,
@@ -3394,7 +3347,7 @@ class Client {
3394
3347
  const response = await this.caller.call(async () => {
3395
3348
  const res = await this._fetch(`${this.apiUrl}/datasets/comparative`, {
3396
3349
  method: "POST",
3397
- headers: { ...this.headers, "Content-Type": "application/json" },
3350
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3398
3351
  signal: AbortSignal.timeout(this.timeout_ms),
3399
3352
  ...this.fetchOptions,
3400
3353
  body: serializedBody,
@@ -3488,7 +3441,7 @@ class Client {
3488
3441
  const response = await this.caller.call(async () => {
3489
3442
  const res = await this._fetch(`${this.apiUrl}/feedback-configs`, {
3490
3443
  method: "POST",
3491
- headers: { ...this.headers, "Content-Type": "application/json" },
3444
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3492
3445
  signal: AbortSignal.timeout(this.timeout_ms),
3493
3446
  ...this.fetchOptions,
3494
3447
  body: JSON.stringify(body),
@@ -3545,7 +3498,7 @@ class Client {
3545
3498
  const response = await this.caller.call(async () => {
3546
3499
  const res = await this._fetch(`${this.apiUrl}/feedback-configs`, {
3547
3500
  method: "PATCH",
3548
- headers: { ...this.headers, "Content-Type": "application/json" },
3501
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3549
3502
  signal: AbortSignal.timeout(this.timeout_ms),
3550
3503
  ...this.fetchOptions,
3551
3504
  body: JSON.stringify(body),
@@ -3564,7 +3517,7 @@ class Client {
3564
3517
  await this.caller.call(async () => {
3565
3518
  const res = await this._fetch(`${this.apiUrl}/feedback-configs?${params}`, {
3566
3519
  method: "DELETE",
3567
- headers: this.headers,
3520
+ headers: this._mergedHeaders,
3568
3521
  signal: AbortSignal.timeout(this.timeout_ms),
3569
3522
  ...this.fetchOptions,
3570
3523
  });
@@ -3627,7 +3580,7 @@ class Client {
3627
3580
  const response = await this.caller.call(async () => {
3628
3581
  const res = await this._fetch(`${this.apiUrl}/annotation-queues`, {
3629
3582
  method: "POST",
3630
- headers: { ...this.headers, "Content-Type": "application/json" },
3583
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
3631
3584
  signal: AbortSignal.timeout(this.timeout_ms),
3632
3585
  ...this.fetchOptions,
3633
3586
  body: serializedBody,
@@ -3646,7 +3599,7 @@ class Client {
3646
3599
  const response = await this.caller.call(async () => {
3647
3600
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
3648
3601
  method: "GET",
3649
- headers: this.headers,
3602
+ headers: this._mergedHeaders,
3650
3603
  signal: AbortSignal.timeout(this.timeout_ms),
3651
3604
  ...this.fetchOptions,
3652
3605
  });
@@ -3677,7 +3630,10 @@ class Client {
3677
3630
  await this.caller.call(async () => {
3678
3631
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
3679
3632
  method: "PATCH",
3680
- headers: { ...this.headers, "Content-Type": "application/json" },
3633
+ headers: {
3634
+ ...this._mergedHeaders,
3635
+ "Content-Type": "application/json",
3636
+ },
3681
3637
  signal: AbortSignal.timeout(this.timeout_ms),
3682
3638
  ...this.fetchOptions,
3683
3639
  body,
@@ -3694,7 +3650,7 @@ class Client {
3694
3650
  await this.caller.call(async () => {
3695
3651
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
3696
3652
  method: "DELETE",
3697
- headers: { ...this.headers, Accept: "application/json" },
3653
+ headers: { ...this._mergedHeaders, Accept: "application/json" },
3698
3654
  signal: AbortSignal.timeout(this.timeout_ms),
3699
3655
  ...this.fetchOptions,
3700
3656
  });
@@ -3712,7 +3668,10 @@ class Client {
3712
3668
  await this.caller.call(async () => {
3713
3669
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs`, {
3714
3670
  method: "POST",
3715
- headers: { ...this.headers, "Content-Type": "application/json" },
3671
+ headers: {
3672
+ ...this._mergedHeaders,
3673
+ "Content-Type": "application/json",
3674
+ },
3716
3675
  signal: AbortSignal.timeout(this.timeout_ms),
3717
3676
  ...this.fetchOptions,
3718
3677
  body,
@@ -3733,7 +3692,7 @@ class Client {
3733
3692
  const response = await this.caller.call(async () => {
3734
3693
  const res = await this._fetch(`${this.apiUrl}${baseUrl}/${index}`, {
3735
3694
  method: "GET",
3736
- headers: this.headers,
3695
+ headers: this._mergedHeaders,
3737
3696
  signal: AbortSignal.timeout(this.timeout_ms),
3738
3697
  ...this.fetchOptions,
3739
3698
  });
@@ -3752,7 +3711,7 @@ class Client {
3752
3711
  await this.caller.call(async () => {
3753
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")}`, {
3754
3713
  method: "DELETE",
3755
- headers: { ...this.headers, Accept: "application/json" },
3714
+ headers: { ...this._mergedHeaders, Accept: "application/json" },
3756
3715
  signal: AbortSignal.timeout(this.timeout_ms),
3757
3716
  ...this.fetchOptions,
3758
3717
  });
@@ -3768,7 +3727,7 @@ class Client {
3768
3727
  const response = await this.caller.call(async () => {
3769
3728
  const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/size`, {
3770
3729
  method: "GET",
3771
- headers: this.headers,
3730
+ headers: this._mergedHeaders,
3772
3731
  signal: AbortSignal.timeout(this.timeout_ms),
3773
3732
  ...this.fetchOptions,
3774
3733
  });
@@ -3791,7 +3750,7 @@ class Client {
3791
3750
  const response = await this.caller.call(async () => {
3792
3751
  const res = await this._fetch(`${this.apiUrl}/commits/${promptOwnerAndName}/?limit=${1}&offset=${0}`, {
3793
3752
  method: "GET",
3794
- headers: this.headers,
3753
+ headers: this._mergedHeaders,
3795
3754
  signal: AbortSignal.timeout(this.timeout_ms),
3796
3755
  ...this.fetchOptions,
3797
3756
  });
@@ -3810,7 +3769,10 @@ class Client {
3810
3769
  const response = await this.caller.call(async () => {
3811
3770
  const res = await this._fetch(`${this.apiUrl}/likes/${owner}/${promptName}`, {
3812
3771
  method: "POST",
3813
- headers: { ...this.headers, "Content-Type": "application/json" },
3772
+ headers: {
3773
+ ...this._mergedHeaders,
3774
+ "Content-Type": "application/json",
3775
+ },
3814
3776
  signal: AbortSignal.timeout(this.timeout_ms),
3815
3777
  ...this.fetchOptions,
3816
3778
  body,
@@ -3980,7 +3942,7 @@ class Client {
3980
3942
  const response = await this.caller.call(async () => {
3981
3943
  const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
3982
3944
  method: "GET",
3983
- headers: this.headers,
3945
+ headers: this._mergedHeaders,
3984
3946
  signal: AbortSignal.timeout(this.timeout_ms),
3985
3947
  ...this.fetchOptions,
3986
3948
  });
@@ -4048,7 +4010,7 @@ class Client {
4048
4010
  const response = await this.caller.call(async () => {
4049
4011
  const res = await this._fetch(`${this.apiUrl}/repos/`, {
4050
4012
  method: "POST",
4051
- headers: { ...this.headers, "Content-Type": "application/json" },
4013
+ headers: { ...this._mergedHeaders, "Content-Type": "application/json" },
4052
4014
  signal: AbortSignal.timeout(this.timeout_ms),
4053
4015
  ...this.fetchOptions,
4054
4016
  body,
@@ -4099,12 +4061,18 @@ class Client {
4099
4061
  const payload = {
4100
4062
  manifest: JSON.parse(JSON.stringify(object)),
4101
4063
  parent_commit: resolvedParentCommitHash,
4064
+ ...(options?.description !== undefined && {
4065
+ description: options.description,
4066
+ }),
4102
4067
  };
4103
4068
  const body = JSON.stringify(payload);
4104
4069
  const response = await this.caller.call(async () => {
4105
4070
  const res = await this._fetch(`${this.apiUrl}/commits/${owner}/${promptName}`, {
4106
4071
  method: "POST",
4107
- headers: { ...this.headers, "Content-Type": "application/json" },
4072
+ headers: {
4073
+ ...this._mergedHeaders,
4074
+ "Content-Type": "application/json",
4075
+ },
4108
4076
  signal: AbortSignal.timeout(this.timeout_ms),
4109
4077
  ...this.fetchOptions,
4110
4078
  body,
@@ -4187,7 +4155,7 @@ class Client {
4187
4155
  const response = await this.caller.call(async () => {
4188
4156
  const res = await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${datasetIdToUse}/examples`)}`, {
4189
4157
  method: "PATCH",
4190
- headers: this.headers,
4158
+ headers: this._mergedHeaders,
4191
4159
  signal: AbortSignal.timeout(this.timeout_ms),
4192
4160
  ...this.fetchOptions,
4193
4161
  body: formData,
@@ -4270,7 +4238,7 @@ class Client {
4270
4238
  const response = await this.caller.call(async () => {
4271
4239
  const res = await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${datasetId}/examples`)}`, {
4272
4240
  method: "POST",
4273
- headers: this.headers,
4241
+ headers: this._mergedHeaders,
4274
4242
  signal: AbortSignal.timeout(this.timeout_ms),
4275
4243
  ...this.fetchOptions,
4276
4244
  body: formData,
@@ -4308,7 +4276,7 @@ class Client {
4308
4276
  const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
4309
4277
  method: "PATCH",
4310
4278
  headers: {
4311
- ...this.headers,
4279
+ ...this._mergedHeaders,
4312
4280
  "Content-Type": "application/json",
4313
4281
  },
4314
4282
  signal: AbortSignal.timeout(this.timeout_ms),
@@ -4331,7 +4299,7 @@ class Client {
4331
4299
  const response = await this.caller.call(async () => {
4332
4300
  const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
4333
4301
  method: "DELETE",
4334
- headers: this.headers,
4302
+ headers: this._mergedHeaders,
4335
4303
  signal: AbortSignal.timeout(this.timeout_ms),
4336
4304
  ...this.fetchOptions,
4337
4305
  });
@@ -4356,7 +4324,7 @@ class Client {
4356
4324
  const response = await this.caller.call(async () => {
4357
4325
  const res = await this._fetch(`${this.apiUrl}/commits/${owner}/${promptName}/${commitHash}${options?.includeModel ? "?include_model=true" : ""}`, {
4358
4326
  method: "GET",
4359
- headers: this.headers,
4327
+ headers: this._mergedHeaders,
4360
4328
  signal: AbortSignal.timeout(this.timeout_ms),
4361
4329
  ...this.fetchOptions,
4362
4330
  });
@@ -4428,6 +4396,7 @@ class Client {
4428
4396
  // Create a commit with the new manifest
4429
4397
  const url = await this.createCommit(promptIdentifier, options?.object, {
4430
4398
  parentCommitHash: options?.parentCommitHash,
4399
+ description: options?.commitDescription,
4431
4400
  });
4432
4401
  return url;
4433
4402
  }