langsmith 0.3.62 → 0.3.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +626 -421
- package/dist/client.d.ts +6 -0
- package/dist/client.js +627 -422
- package/dist/evaluation/evaluate_comparative.cjs +1 -0
- package/dist/evaluation/evaluate_comparative.d.ts +1 -0
- package/dist/evaluation/evaluate_comparative.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/langchain.cjs +4 -0
- package/dist/langchain.d.ts +1 -0
- package/dist/langchain.js +4 -0
- package/dist/run_trees.cjs +2 -2
- package/dist/run_trees.js +2 -2
- package/dist/singletons/fetch.cjs +5 -1
- package/dist/singletons/fetch.d.ts +1 -0
- package/dist/singletons/fetch.js +3 -0
- package/dist/traceable.cjs +4 -1
- package/dist/traceable.js +4 -1
- package/dist/utils/async_caller.cjs +15 -35
- package/dist/utils/async_caller.d.ts +0 -2
- package/dist/utils/async_caller.js +15 -35
- package/dist/utils/env.cjs +5 -1
- package/dist/utils/env.js +5 -1
- package/dist/utils/error.cjs +4 -4
- package/dist/utils/error.d.ts +1 -1
- package/dist/utils/error.js +4 -4
- package/dist/wrappers/openai.cjs +11 -6
- package/dist/wrappers/openai.d.ts +1 -1
- package/dist/wrappers/openai.js +11 -6
- package/package.json +2 -2
package/dist/client.cjs
CHANGED
|
@@ -202,10 +202,13 @@ class AutoBatchQueue {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
exports.AutoBatchQueue = AutoBatchQueue;
|
|
205
|
-
exports.DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES =
|
|
205
|
+
exports.DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES = 24 * 1024 * 1024;
|
|
206
206
|
const SERVER_INFO_REQUEST_TIMEOUT_MS = 10000;
|
|
207
207
|
const DEFAULT_API_URL = "https://api.smith.langchain.com";
|
|
208
208
|
class Client {
|
|
209
|
+
get _fetch() {
|
|
210
|
+
return this.fetchImplementation || (0, fetch_js_1._getFetchImplementation)(this.debug);
|
|
211
|
+
}
|
|
209
212
|
constructor(config = {}) {
|
|
210
213
|
Object.defineProperty(this, "apiKey", {
|
|
211
214
|
enumerable: true,
|
|
@@ -352,6 +355,12 @@ class Client {
|
|
|
352
355
|
writable: true,
|
|
353
356
|
value: void 0
|
|
354
357
|
});
|
|
358
|
+
Object.defineProperty(this, "fetchImplementation", {
|
|
359
|
+
enumerable: true,
|
|
360
|
+
configurable: true,
|
|
361
|
+
writable: true,
|
|
362
|
+
value: void 0
|
|
363
|
+
});
|
|
355
364
|
Object.defineProperty(this, "multipartStreamingDisabled", {
|
|
356
365
|
enumerable: true,
|
|
357
366
|
configurable: true,
|
|
@@ -378,6 +387,7 @@ class Client {
|
|
|
378
387
|
this.timeout_ms = config.timeout_ms ?? 90_000;
|
|
379
388
|
this.caller = new async_caller_js_1.AsyncCaller({
|
|
380
389
|
...(config.callerOptions ?? {}),
|
|
390
|
+
maxRetries: 4,
|
|
381
391
|
debug: config.debug ?? this.debug,
|
|
382
392
|
});
|
|
383
393
|
this.traceBatchConcurrency =
|
|
@@ -386,6 +396,7 @@ class Client {
|
|
|
386
396
|
throw new Error("Trace batch concurrency must be positive.");
|
|
387
397
|
}
|
|
388
398
|
this.debug = config.debug ?? this.debug;
|
|
399
|
+
this.fetchImplementation = config.fetchImplementation;
|
|
389
400
|
this.batchIngestCaller = new async_caller_js_1.AsyncCaller({
|
|
390
401
|
maxRetries: 2,
|
|
391
402
|
maxConcurrency: this.traceBatchConcurrency,
|
|
@@ -505,13 +516,16 @@ class Client {
|
|
|
505
516
|
async _getResponse(path, queryParams) {
|
|
506
517
|
const paramsString = queryParams?.toString() ?? "";
|
|
507
518
|
const url = `${this.apiUrl}${path}?${paramsString}`;
|
|
508
|
-
const response = await this.caller.call(
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
519
|
+
const response = await this.caller.call(async () => {
|
|
520
|
+
const res = await this._fetch(url, {
|
|
521
|
+
method: "GET",
|
|
522
|
+
headers: this.headers,
|
|
523
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
524
|
+
...this.fetchOptions,
|
|
525
|
+
});
|
|
526
|
+
await (0, error_js_1.raiseForStatus)(res, `Failed to fetch ${path}`);
|
|
527
|
+
return res;
|
|
513
528
|
});
|
|
514
|
-
await (0, error_js_1.raiseForStatus)(response, `Failed to fetch ${path}`);
|
|
515
529
|
return response;
|
|
516
530
|
}
|
|
517
531
|
async _get(path, queryParams) {
|
|
@@ -525,13 +539,16 @@ class Client {
|
|
|
525
539
|
queryParams.set("offset", String(offset));
|
|
526
540
|
queryParams.set("limit", String(limit));
|
|
527
541
|
const url = `${this.apiUrl}${path}?${queryParams}`;
|
|
528
|
-
const response = await this.caller.call(
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
542
|
+
const response = await this.caller.call(async () => {
|
|
543
|
+
const res = await this._fetch(url, {
|
|
544
|
+
method: "GET",
|
|
545
|
+
headers: this.headers,
|
|
546
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
547
|
+
...this.fetchOptions,
|
|
548
|
+
});
|
|
549
|
+
await (0, error_js_1.raiseForStatus)(res, `Failed to fetch ${path}`);
|
|
550
|
+
return res;
|
|
533
551
|
});
|
|
534
|
-
await (0, error_js_1.raiseForStatus)(response, `Failed to fetch ${path}`);
|
|
535
552
|
const items = transform
|
|
536
553
|
? transform(await response.json())
|
|
537
554
|
: await response.json();
|
|
@@ -548,12 +565,17 @@ class Client {
|
|
|
548
565
|
async *_getCursorPaginatedList(path, body = null, requestMethod = "POST", dataKey = "runs") {
|
|
549
566
|
const bodyParams = body ? { ...body } : {};
|
|
550
567
|
while (true) {
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
568
|
+
const body = JSON.stringify(bodyParams);
|
|
569
|
+
const response = await this.caller.call(async () => {
|
|
570
|
+
const res = await this._fetch(`${this.apiUrl}${path}`, {
|
|
571
|
+
method: requestMethod,
|
|
572
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
573
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
574
|
+
...this.fetchOptions,
|
|
575
|
+
body,
|
|
576
|
+
});
|
|
577
|
+
await (0, error_js_1.raiseForStatus)(res, `Failed to fetch ${path}`);
|
|
578
|
+
return res;
|
|
557
579
|
});
|
|
558
580
|
const responseBody = await response.json();
|
|
559
581
|
if (!responseBody) {
|
|
@@ -747,7 +769,7 @@ class Client {
|
|
|
747
769
|
}
|
|
748
770
|
async _getServerInfo() {
|
|
749
771
|
const response = await this.caller.call(async () => {
|
|
750
|
-
const res = await
|
|
772
|
+
const res = await this._fetch(`${this.apiUrl}/info`, {
|
|
751
773
|
method: "GET",
|
|
752
774
|
headers: { Accept: "application/json" },
|
|
753
775
|
signal: AbortSignal.timeout(SERVER_INFO_REQUEST_TIMEOUT_MS),
|
|
@@ -772,7 +794,7 @@ class Client {
|
|
|
772
794
|
this._serverInfo = await this._getServerInfo();
|
|
773
795
|
}
|
|
774
796
|
catch (e) {
|
|
775
|
-
console.warn(`[
|
|
797
|
+
console.warn(`[LANGSMITH]: Failed to fetch info on supported operations. Falling back to batch operations and default limits. Info: ${e.status ?? "Unspecified status code"} ${e.message}`);
|
|
776
798
|
}
|
|
777
799
|
}
|
|
778
800
|
return this._serverInfo ?? {};
|
|
@@ -841,14 +863,18 @@ class Client {
|
|
|
841
863
|
if (options?.apiKey !== undefined) {
|
|
842
864
|
headers["x-api-key"] = options.apiKey;
|
|
843
865
|
}
|
|
844
|
-
const
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
866
|
+
const body = (0, index_js_2.serialize)(mergedRunCreateParam, `Creating run with id: ${mergedRunCreateParam.id}`);
|
|
867
|
+
await this.caller.call(async () => {
|
|
868
|
+
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs`, {
|
|
869
|
+
method: "POST",
|
|
870
|
+
headers,
|
|
871
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
872
|
+
...this.fetchOptions,
|
|
873
|
+
body,
|
|
874
|
+
});
|
|
875
|
+
await (0, error_js_1.raiseForStatus)(res, "create run", true);
|
|
876
|
+
return res;
|
|
850
877
|
});
|
|
851
|
-
await (0, error_js_1.raiseForStatus)(response, "create run", true);
|
|
852
878
|
}
|
|
853
879
|
/**
|
|
854
880
|
* Batch ingest/upsert multiple runs in the Langsmith system.
|
|
@@ -921,14 +947,17 @@ class Client {
|
|
|
921
947
|
if (options?.apiKey !== undefined) {
|
|
922
948
|
headers["x-api-key"] = options.apiKey;
|
|
923
949
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
950
|
+
await this.batchIngestCaller.call(async () => {
|
|
951
|
+
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/batch`, {
|
|
952
|
+
method: "POST",
|
|
953
|
+
headers,
|
|
954
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
955
|
+
...this.fetchOptions,
|
|
956
|
+
body,
|
|
957
|
+
});
|
|
958
|
+
await (0, error_js_1.raiseForStatus)(res, "batch create run", true);
|
|
959
|
+
return res;
|
|
930
960
|
});
|
|
931
|
-
await (0, error_js_1.raiseForStatus)(response, "batch create run", true);
|
|
932
961
|
}
|
|
933
962
|
/**
|
|
934
963
|
* Batch ingest/upsert multiple runs in the Langsmith system.
|
|
@@ -1132,40 +1161,47 @@ class Client {
|
|
|
1132
1161
|
const isNodeFetch = (0, fetch_js_1._globalFetchImplementationIsNodeFetch)();
|
|
1133
1162
|
const buildBuffered = () => this._createNodeFetchBody(parts, boundary);
|
|
1134
1163
|
const buildStream = () => this._createMultipartStream(parts, boundary);
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1164
|
+
const sendWithRetry = async (bodyFactory) => {
|
|
1165
|
+
return this.batchIngestCaller.call(async () => {
|
|
1166
|
+
const body = await bodyFactory();
|
|
1167
|
+
const headers = {
|
|
1168
|
+
...this.headers,
|
|
1169
|
+
"Content-Type": `multipart/form-data; boundary=${boundary}`,
|
|
1170
|
+
};
|
|
1171
|
+
if (options?.apiKey !== undefined) {
|
|
1172
|
+
headers["x-api-key"] = options.apiKey;
|
|
1173
|
+
}
|
|
1174
|
+
let transformedBody = body;
|
|
1175
|
+
if (options?.useGzip &&
|
|
1176
|
+
typeof body === "object" &&
|
|
1177
|
+
"pipeThrough" in body) {
|
|
1178
|
+
transformedBody = body.pipeThrough(new CompressionStream("gzip"));
|
|
1179
|
+
headers["Content-Encoding"] = "gzip";
|
|
1180
|
+
}
|
|
1181
|
+
const response = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/multipart`, {
|
|
1182
|
+
method: "POST",
|
|
1183
|
+
headers,
|
|
1184
|
+
body: transformedBody,
|
|
1185
|
+
duplex: "half",
|
|
1186
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1187
|
+
...this.fetchOptions,
|
|
1188
|
+
});
|
|
1189
|
+
await (0, error_js_1.raiseForStatus)(response, `Failed to send multipart request`, true);
|
|
1190
|
+
return response;
|
|
1157
1191
|
});
|
|
1158
1192
|
};
|
|
1159
1193
|
try {
|
|
1160
1194
|
let res;
|
|
1161
1195
|
let streamedAttempt = false;
|
|
1162
|
-
// attempt stream only if not disabled and not using node-fetch
|
|
1163
|
-
if (!isNodeFetch &&
|
|
1196
|
+
// attempt stream only if not disabled and not using node-fetch or Bun
|
|
1197
|
+
if (!isNodeFetch &&
|
|
1198
|
+
!this.multipartStreamingDisabled &&
|
|
1199
|
+
(0, env_js_1.getEnv)() !== "bun") {
|
|
1164
1200
|
streamedAttempt = true;
|
|
1165
|
-
res = await
|
|
1201
|
+
res = await sendWithRetry(buildStream);
|
|
1166
1202
|
}
|
|
1167
1203
|
else {
|
|
1168
|
-
res = await
|
|
1204
|
+
res = await sendWithRetry(buildBuffered);
|
|
1169
1205
|
}
|
|
1170
1206
|
// if stream fails, fallback to buffered body
|
|
1171
1207
|
if ((!this.multipartStreamingDisabled || streamedAttempt) &&
|
|
@@ -1177,10 +1213,8 @@ class Client {
|
|
|
1177
1213
|
// Disable streaming for future requests
|
|
1178
1214
|
this.multipartStreamingDisabled = true;
|
|
1179
1215
|
// retry with fully-buffered body
|
|
1180
|
-
res = await
|
|
1216
|
+
res = await sendWithRetry(buildBuffered);
|
|
1181
1217
|
}
|
|
1182
|
-
// raise if still failing
|
|
1183
|
-
await (0, error_js_1.raiseForStatus)(res, "ingest multipart runs", true);
|
|
1184
1218
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1185
1219
|
}
|
|
1186
1220
|
catch (e) {
|
|
@@ -1237,14 +1271,18 @@ class Client {
|
|
|
1237
1271
|
if (options?.apiKey !== undefined) {
|
|
1238
1272
|
headers["x-api-key"] = options.apiKey;
|
|
1239
1273
|
}
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1274
|
+
const body = (0, index_js_2.serialize)(run, `Serializing payload to update run with id: ${runId}`);
|
|
1275
|
+
await this.caller.call(async () => {
|
|
1276
|
+
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/${runId}`, {
|
|
1277
|
+
method: "PATCH",
|
|
1278
|
+
headers,
|
|
1279
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1280
|
+
...this.fetchOptions,
|
|
1281
|
+
body,
|
|
1282
|
+
});
|
|
1283
|
+
await (0, error_js_1.raiseForStatus)(res, "update run", true);
|
|
1284
|
+
return res;
|
|
1246
1285
|
});
|
|
1247
|
-
await (0, error_js_1.raiseForStatus)(response, "update run", true);
|
|
1248
1286
|
}
|
|
1249
1287
|
async readRun(runId, { loadChildRuns } = { loadChildRuns: false }) {
|
|
1250
1288
|
(0, _uuid_js_1.assertUuid)(runId);
|
|
@@ -1502,14 +1540,18 @@ class Client {
|
|
|
1502
1540
|
};
|
|
1503
1541
|
// Remove undefined values from the payload
|
|
1504
1542
|
const filteredPayload = Object.fromEntries(Object.entries(currentBody).filter(([_, value]) => value !== undefined));
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1543
|
+
const body = JSON.stringify(filteredPayload);
|
|
1544
|
+
const response = await this.caller.call(async () => {
|
|
1545
|
+
const res = await this._fetch(url, {
|
|
1546
|
+
method: "POST",
|
|
1547
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1548
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1549
|
+
...this.fetchOptions,
|
|
1550
|
+
body,
|
|
1551
|
+
});
|
|
1552
|
+
await (0, error_js_1.raiseForStatus)(res, `Failed to fetch ${path}`);
|
|
1553
|
+
return res;
|
|
1511
1554
|
});
|
|
1512
|
-
await (0, error_js_1.raiseForStatus)(response, `Failed to fetch ${path}`);
|
|
1513
1555
|
const items = await response.json();
|
|
1514
1556
|
const { groups, total } = items;
|
|
1515
1557
|
if (groups.length === 0) {
|
|
@@ -1551,12 +1593,17 @@ class Client {
|
|
|
1551
1593
|
};
|
|
1552
1594
|
// Remove undefined values from the payload
|
|
1553
1595
|
const filteredPayload = Object.fromEntries(Object.entries(payload).filter(([_, value]) => value !== undefined));
|
|
1554
|
-
const
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1596
|
+
const body = JSON.stringify(filteredPayload);
|
|
1597
|
+
const response = await this.caller.call(async () => {
|
|
1598
|
+
const res = await this._fetch(`${this.apiUrl}/runs/stats`, {
|
|
1599
|
+
method: "POST",
|
|
1600
|
+
headers: this.headers,
|
|
1601
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1602
|
+
...this.fetchOptions,
|
|
1603
|
+
body,
|
|
1604
|
+
});
|
|
1605
|
+
await (0, error_js_1.raiseForStatus)(res, "get run stats");
|
|
1606
|
+
return res;
|
|
1560
1607
|
});
|
|
1561
1608
|
const result = await response.json();
|
|
1562
1609
|
return result;
|
|
@@ -1567,12 +1614,17 @@ class Client {
|
|
|
1567
1614
|
share_token: shareId || uuid.v4(),
|
|
1568
1615
|
};
|
|
1569
1616
|
(0, _uuid_js_1.assertUuid)(runId);
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1617
|
+
const body = JSON.stringify(data);
|
|
1618
|
+
const response = await this.caller.call(async () => {
|
|
1619
|
+
const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
|
|
1620
|
+
method: "PUT",
|
|
1621
|
+
headers: this.headers,
|
|
1622
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1623
|
+
...this.fetchOptions,
|
|
1624
|
+
body,
|
|
1625
|
+
});
|
|
1626
|
+
await (0, error_js_1.raiseForStatus)(res, "share run");
|
|
1627
|
+
return res;
|
|
1576
1628
|
});
|
|
1577
1629
|
const result = await response.json();
|
|
1578
1630
|
if (result === null || !("share_token" in result)) {
|
|
@@ -1582,21 +1634,28 @@ class Client {
|
|
|
1582
1634
|
}
|
|
1583
1635
|
async unshareRun(runId) {
|
|
1584
1636
|
(0, _uuid_js_1.assertUuid)(runId);
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1637
|
+
await this.caller.call(async () => {
|
|
1638
|
+
const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
|
|
1639
|
+
method: "DELETE",
|
|
1640
|
+
headers: this.headers,
|
|
1641
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1642
|
+
...this.fetchOptions,
|
|
1643
|
+
});
|
|
1644
|
+
await (0, error_js_1.raiseForStatus)(res, "unshare run", true);
|
|
1645
|
+
return res;
|
|
1590
1646
|
});
|
|
1591
|
-
await (0, error_js_1.raiseForStatus)(response, "unshare run", true);
|
|
1592
1647
|
}
|
|
1593
1648
|
async readRunSharedLink(runId) {
|
|
1594
1649
|
(0, _uuid_js_1.assertUuid)(runId);
|
|
1595
|
-
const response = await this.caller.call(
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1650
|
+
const response = await this.caller.call(async () => {
|
|
1651
|
+
const res = await this._fetch(`${this.apiUrl}/runs/${runId}/share`, {
|
|
1652
|
+
method: "GET",
|
|
1653
|
+
headers: this.headers,
|
|
1654
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1655
|
+
...this.fetchOptions,
|
|
1656
|
+
});
|
|
1657
|
+
await (0, error_js_1.raiseForStatus)(res, "read run shared link");
|
|
1658
|
+
return res;
|
|
1600
1659
|
});
|
|
1601
1660
|
const result = await response.json();
|
|
1602
1661
|
if (result === null || !("share_token" in result)) {
|
|
@@ -1614,11 +1673,15 @@ class Client {
|
|
|
1614
1673
|
}
|
|
1615
1674
|
}
|
|
1616
1675
|
(0, _uuid_js_1.assertUuid)(shareToken);
|
|
1617
|
-
const response = await this.caller.call(
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1676
|
+
const response = await this.caller.call(async () => {
|
|
1677
|
+
const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
|
|
1678
|
+
method: "GET",
|
|
1679
|
+
headers: this.headers,
|
|
1680
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1681
|
+
...this.fetchOptions,
|
|
1682
|
+
});
|
|
1683
|
+
await (0, error_js_1.raiseForStatus)(res, "list shared runs");
|
|
1684
|
+
return res;
|
|
1622
1685
|
});
|
|
1623
1686
|
const runs = await response.json();
|
|
1624
1687
|
return runs;
|
|
@@ -1632,11 +1695,15 @@ class Client {
|
|
|
1632
1695
|
datasetId = dataset.id;
|
|
1633
1696
|
}
|
|
1634
1697
|
(0, _uuid_js_1.assertUuid)(datasetId);
|
|
1635
|
-
const response = await this.caller.call(
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1698
|
+
const response = await this.caller.call(async () => {
|
|
1699
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
1700
|
+
method: "GET",
|
|
1701
|
+
headers: this.headers,
|
|
1702
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1703
|
+
...this.fetchOptions,
|
|
1704
|
+
});
|
|
1705
|
+
await (0, error_js_1.raiseForStatus)(res, "read dataset shared schema");
|
|
1706
|
+
return res;
|
|
1640
1707
|
});
|
|
1641
1708
|
const shareSchema = await response.json();
|
|
1642
1709
|
shareSchema.url = `${this.getHostUrl()}/public/${shareSchema.share_token}/d`;
|
|
@@ -1654,12 +1721,17 @@ class Client {
|
|
|
1654
1721
|
dataset_id: datasetId,
|
|
1655
1722
|
};
|
|
1656
1723
|
(0, _uuid_js_1.assertUuid)(datasetId);
|
|
1657
|
-
const
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1724
|
+
const body = JSON.stringify(data);
|
|
1725
|
+
const response = await this.caller.call(async () => {
|
|
1726
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
1727
|
+
method: "PUT",
|
|
1728
|
+
headers: this.headers,
|
|
1729
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1730
|
+
...this.fetchOptions,
|
|
1731
|
+
body,
|
|
1732
|
+
});
|
|
1733
|
+
await (0, error_js_1.raiseForStatus)(res, "share dataset");
|
|
1734
|
+
return res;
|
|
1663
1735
|
});
|
|
1664
1736
|
const shareSchema = await response.json();
|
|
1665
1737
|
shareSchema.url = `${this.getHostUrl()}/public/${shareSchema.share_token}/d`;
|
|
@@ -1667,21 +1739,28 @@ class Client {
|
|
|
1667
1739
|
}
|
|
1668
1740
|
async unshareDataset(datasetId) {
|
|
1669
1741
|
(0, _uuid_js_1.assertUuid)(datasetId);
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1742
|
+
await this.caller.call(async () => {
|
|
1743
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
1744
|
+
method: "DELETE",
|
|
1745
|
+
headers: this.headers,
|
|
1746
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1747
|
+
...this.fetchOptions,
|
|
1748
|
+
});
|
|
1749
|
+
await (0, error_js_1.raiseForStatus)(res, "unshare dataset", true);
|
|
1750
|
+
return res;
|
|
1675
1751
|
});
|
|
1676
|
-
await (0, error_js_1.raiseForStatus)(response, "unshare dataset", true);
|
|
1677
1752
|
}
|
|
1678
1753
|
async readSharedDataset(shareToken) {
|
|
1679
1754
|
(0, _uuid_js_1.assertUuid)(shareToken);
|
|
1680
|
-
const response = await this.caller.call(
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1755
|
+
const response = await this.caller.call(async () => {
|
|
1756
|
+
const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/datasets`, {
|
|
1757
|
+
method: "GET",
|
|
1758
|
+
headers: this.headers,
|
|
1759
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1760
|
+
...this.fetchOptions,
|
|
1761
|
+
});
|
|
1762
|
+
await (0, error_js_1.raiseForStatus)(res, "read shared dataset");
|
|
1763
|
+
return res;
|
|
1685
1764
|
});
|
|
1686
1765
|
const dataset = await response.json();
|
|
1687
1766
|
return dataset;
|
|
@@ -1708,11 +1787,15 @@ class Client {
|
|
|
1708
1787
|
urlParams.append(key, value);
|
|
1709
1788
|
}
|
|
1710
1789
|
});
|
|
1711
|
-
const response = await this.caller.call(
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1790
|
+
const response = await this.caller.call(async () => {
|
|
1791
|
+
const res = await this._fetch(`${this.apiUrl}/public/${shareToken}/examples?${urlParams.toString()}`, {
|
|
1792
|
+
method: "GET",
|
|
1793
|
+
headers: this.headers,
|
|
1794
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1795
|
+
...this.fetchOptions,
|
|
1796
|
+
});
|
|
1797
|
+
await (0, error_js_1.raiseForStatus)(res, "list shared examples");
|
|
1798
|
+
return res;
|
|
1716
1799
|
});
|
|
1717
1800
|
const result = await response.json();
|
|
1718
1801
|
if (!response.ok) {
|
|
@@ -1743,14 +1826,18 @@ class Client {
|
|
|
1743
1826
|
if (referenceDatasetId !== null) {
|
|
1744
1827
|
body["reference_dataset_id"] = referenceDatasetId;
|
|
1745
1828
|
}
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1829
|
+
const serializedBody = JSON.stringify(body);
|
|
1830
|
+
const response = await this.caller.call(async () => {
|
|
1831
|
+
const res = await this._fetch(endpoint, {
|
|
1832
|
+
method: "POST",
|
|
1833
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1834
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1835
|
+
...this.fetchOptions,
|
|
1836
|
+
body: serializedBody,
|
|
1837
|
+
});
|
|
1838
|
+
await (0, error_js_1.raiseForStatus)(res, "create project");
|
|
1839
|
+
return res;
|
|
1752
1840
|
});
|
|
1753
|
-
await (0, error_js_1.raiseForStatus)(response, "create project");
|
|
1754
1841
|
const result = await response.json();
|
|
1755
1842
|
return result;
|
|
1756
1843
|
}
|
|
@@ -1760,20 +1847,23 @@ class Client {
|
|
|
1760
1847
|
if (metadata) {
|
|
1761
1848
|
extra = { ...(extra || {}), metadata };
|
|
1762
1849
|
}
|
|
1763
|
-
const body = {
|
|
1850
|
+
const body = JSON.stringify({
|
|
1764
1851
|
name,
|
|
1765
1852
|
extra,
|
|
1766
1853
|
description,
|
|
1767
1854
|
end_time: endTime ? new Date(endTime).toISOString() : null,
|
|
1768
|
-
};
|
|
1769
|
-
const response = await this.caller.call(
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1855
|
+
});
|
|
1856
|
+
const response = await this.caller.call(async () => {
|
|
1857
|
+
const res = await this._fetch(endpoint, {
|
|
1858
|
+
method: "PATCH",
|
|
1859
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1860
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1861
|
+
...this.fetchOptions,
|
|
1862
|
+
body,
|
|
1863
|
+
});
|
|
1864
|
+
await (0, error_js_1.raiseForStatus)(res, "update project");
|
|
1865
|
+
return res;
|
|
1866
|
+
});
|
|
1777
1867
|
const result = await response.json();
|
|
1778
1868
|
return result;
|
|
1779
1869
|
}
|
|
@@ -1794,11 +1884,15 @@ class Client {
|
|
|
1794
1884
|
else {
|
|
1795
1885
|
throw new Error("Must provide projectName or projectId");
|
|
1796
1886
|
}
|
|
1797
|
-
const response = await this.caller.call(
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1887
|
+
const response = await this.caller.call(async () => {
|
|
1888
|
+
const res = await this._fetch(`${this.apiUrl}${path}?${params}`, {
|
|
1889
|
+
method: "GET",
|
|
1890
|
+
headers: this.headers,
|
|
1891
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1892
|
+
...this.fetchOptions,
|
|
1893
|
+
});
|
|
1894
|
+
await (0, error_js_1.raiseForStatus)(res, "has project");
|
|
1895
|
+
return res;
|
|
1802
1896
|
});
|
|
1803
1897
|
// consume the response body to release the connection
|
|
1804
1898
|
// https://undici.nodejs.org/#/?id=garbage-collection
|
|
@@ -1924,13 +2018,16 @@ class Client {
|
|
|
1924
2018
|
projectId_ = projectId;
|
|
1925
2019
|
}
|
|
1926
2020
|
(0, _uuid_js_1.assertUuid)(projectId_);
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2021
|
+
await this.caller.call(async () => {
|
|
2022
|
+
const res = await this._fetch(`${this.apiUrl}/sessions/${projectId_}`, {
|
|
2023
|
+
method: "DELETE",
|
|
2024
|
+
headers: this.headers,
|
|
2025
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2026
|
+
...this.fetchOptions,
|
|
2027
|
+
});
|
|
2028
|
+
await (0, error_js_1.raiseForStatus)(res, `delete session ${projectId_} (${projectName})`, true);
|
|
2029
|
+
return res;
|
|
1932
2030
|
});
|
|
1933
|
-
await (0, error_js_1.raiseForStatus)(response, `delete session ${projectId_} (${projectName})`, true);
|
|
1934
2031
|
}
|
|
1935
2032
|
async uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, dataType, name, }) {
|
|
1936
2033
|
const url = `${this.apiUrl}/datasets/upload`;
|
|
@@ -1951,14 +2048,17 @@ class Client {
|
|
|
1951
2048
|
if (name) {
|
|
1952
2049
|
formData.append("name", name);
|
|
1953
2050
|
}
|
|
1954
|
-
const response = await this.caller.call(
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
2051
|
+
const response = await this.caller.call(async () => {
|
|
2052
|
+
const res = await this._fetch(url, {
|
|
2053
|
+
method: "POST",
|
|
2054
|
+
headers: this.headers,
|
|
2055
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2056
|
+
...this.fetchOptions,
|
|
2057
|
+
body: formData,
|
|
2058
|
+
});
|
|
2059
|
+
await (0, error_js_1.raiseForStatus)(res, "upload CSV");
|
|
2060
|
+
return res;
|
|
1960
2061
|
});
|
|
1961
|
-
await (0, error_js_1.raiseForStatus)(response, "upload CSV");
|
|
1962
2062
|
const result = await response.json();
|
|
1963
2063
|
return result;
|
|
1964
2064
|
}
|
|
@@ -1977,14 +2077,18 @@ class Client {
|
|
|
1977
2077
|
if (outputsSchema) {
|
|
1978
2078
|
body.outputs_schema_definition = outputsSchema;
|
|
1979
2079
|
}
|
|
1980
|
-
const
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
2080
|
+
const serializedBody = JSON.stringify(body);
|
|
2081
|
+
const response = await this.caller.call(async () => {
|
|
2082
|
+
const res = await this._fetch(`${this.apiUrl}/datasets`, {
|
|
2083
|
+
method: "POST",
|
|
2084
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2085
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2086
|
+
...this.fetchOptions,
|
|
2087
|
+
body: serializedBody,
|
|
2088
|
+
});
|
|
2089
|
+
await (0, error_js_1.raiseForStatus)(res, "create dataset");
|
|
2090
|
+
return res;
|
|
1986
2091
|
});
|
|
1987
|
-
await (0, error_js_1.raiseForStatus)(response, "create dataset");
|
|
1988
2092
|
const result = await response.json();
|
|
1989
2093
|
return result;
|
|
1990
2094
|
}
|
|
@@ -2109,14 +2213,18 @@ class Client {
|
|
|
2109
2213
|
}
|
|
2110
2214
|
const _datasetId = datasetId ?? (await this.readDataset({ datasetName })).id;
|
|
2111
2215
|
(0, _uuid_js_1.assertUuid)(_datasetId);
|
|
2112
|
-
const
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2216
|
+
const body = JSON.stringify(update);
|
|
2217
|
+
const response = await this.caller.call(async () => {
|
|
2218
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${_datasetId}`, {
|
|
2219
|
+
method: "PATCH",
|
|
2220
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2221
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2222
|
+
...this.fetchOptions,
|
|
2223
|
+
body,
|
|
2224
|
+
});
|
|
2225
|
+
await (0, error_js_1.raiseForStatus)(res, "update dataset");
|
|
2226
|
+
return res;
|
|
2227
|
+
});
|
|
2120
2228
|
return (await response.json());
|
|
2121
2229
|
}
|
|
2122
2230
|
/**
|
|
@@ -2141,17 +2249,21 @@ class Client {
|
|
|
2141
2249
|
}
|
|
2142
2250
|
const _datasetId = datasetId ?? (await this.readDataset({ datasetName })).id;
|
|
2143
2251
|
(0, _uuid_js_1.assertUuid)(_datasetId);
|
|
2144
|
-
const
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2252
|
+
const body = JSON.stringify({
|
|
2253
|
+
as_of: typeof asOf === "string" ? asOf : asOf.toISOString(),
|
|
2254
|
+
tag,
|
|
2255
|
+
});
|
|
2256
|
+
await this.caller.call(async () => {
|
|
2257
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${_datasetId}/tags`, {
|
|
2258
|
+
method: "PUT",
|
|
2259
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2260
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2261
|
+
...this.fetchOptions,
|
|
2262
|
+
body,
|
|
2263
|
+
});
|
|
2264
|
+
await (0, error_js_1.raiseForStatus)(res, "update dataset tags", true);
|
|
2265
|
+
return res;
|
|
2153
2266
|
});
|
|
2154
|
-
await (0, error_js_1.raiseForStatus)(response, "update dataset tags");
|
|
2155
2267
|
}
|
|
2156
2268
|
async deleteDataset({ datasetId, datasetName, }) {
|
|
2157
2269
|
let path = "/datasets";
|
|
@@ -2170,14 +2282,16 @@ class Client {
|
|
|
2170
2282
|
else {
|
|
2171
2283
|
throw new Error("Must provide datasetName or datasetId");
|
|
2172
2284
|
}
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2285
|
+
await this.caller.call(async () => {
|
|
2286
|
+
const res = await this._fetch(this.apiUrl + path, {
|
|
2287
|
+
method: "DELETE",
|
|
2288
|
+
headers: this.headers,
|
|
2289
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2290
|
+
...this.fetchOptions,
|
|
2291
|
+
});
|
|
2292
|
+
await (0, error_js_1.raiseForStatus)(res, `delete ${path}`, true);
|
|
2293
|
+
return res;
|
|
2178
2294
|
});
|
|
2179
|
-
await (0, error_js_1.raiseForStatus)(response, `delete ${path}`);
|
|
2180
|
-
await response.json();
|
|
2181
2295
|
}
|
|
2182
2296
|
async indexDataset({ datasetId, datasetName, tag, }) {
|
|
2183
2297
|
let datasetId_ = datasetId;
|
|
@@ -2195,14 +2309,18 @@ class Client {
|
|
|
2195
2309
|
const data = {
|
|
2196
2310
|
tag: tag,
|
|
2197
2311
|
};
|
|
2198
|
-
const
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2312
|
+
const body = JSON.stringify(data);
|
|
2313
|
+
const response = await this.caller.call(async () => {
|
|
2314
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId_}/index`, {
|
|
2315
|
+
method: "POST",
|
|
2316
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2317
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2318
|
+
...this.fetchOptions,
|
|
2319
|
+
body,
|
|
2320
|
+
});
|
|
2321
|
+
await (0, error_js_1.raiseForStatus)(res, "index dataset");
|
|
2322
|
+
return res;
|
|
2323
|
+
});
|
|
2206
2324
|
await response.json();
|
|
2207
2325
|
}
|
|
2208
2326
|
/**
|
|
@@ -2244,14 +2362,18 @@ class Client {
|
|
|
2244
2362
|
data["filter"] = filter;
|
|
2245
2363
|
}
|
|
2246
2364
|
(0, _uuid_js_1.assertUuid)(datasetId);
|
|
2247
|
-
const
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2365
|
+
const body = JSON.stringify(data);
|
|
2366
|
+
const response = await this.caller.call(async () => {
|
|
2367
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId}/search`, {
|
|
2368
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2369
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2370
|
+
...this.fetchOptions,
|
|
2371
|
+
method: "POST",
|
|
2372
|
+
body,
|
|
2373
|
+
});
|
|
2374
|
+
await (0, error_js_1.raiseForStatus)(res, "fetch similar examples");
|
|
2375
|
+
return res;
|
|
2376
|
+
});
|
|
2255
2377
|
const result = await response.json();
|
|
2256
2378
|
return result["examples"];
|
|
2257
2379
|
}
|
|
@@ -2463,14 +2585,16 @@ class Client {
|
|
|
2463
2585
|
async deleteExample(exampleId) {
|
|
2464
2586
|
(0, _uuid_js_1.assertUuid)(exampleId);
|
|
2465
2587
|
const path = `/examples/${exampleId}`;
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2588
|
+
await this.caller.call(async () => {
|
|
2589
|
+
const res = await this._fetch(this.apiUrl + path, {
|
|
2590
|
+
method: "DELETE",
|
|
2591
|
+
headers: this.headers,
|
|
2592
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2593
|
+
...this.fetchOptions,
|
|
2594
|
+
});
|
|
2595
|
+
await (0, error_js_1.raiseForStatus)(res, `delete ${path}`, true);
|
|
2596
|
+
return res;
|
|
2471
2597
|
});
|
|
2472
|
-
await (0, error_js_1.raiseForStatus)(response, `delete ${path}`);
|
|
2473
|
-
await response.json();
|
|
2474
2598
|
}
|
|
2475
2599
|
async updateExample(exampleIdOrUpdate, update) {
|
|
2476
2600
|
let exampleId;
|
|
@@ -2542,13 +2666,16 @@ class Client {
|
|
|
2542
2666
|
if (tag !== undefined) {
|
|
2543
2667
|
params.append("tag", tag);
|
|
2544
2668
|
}
|
|
2545
|
-
const response = await this.caller.call(
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2669
|
+
const response = await this.caller.call(async () => {
|
|
2670
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
|
|
2671
|
+
method: "GET",
|
|
2672
|
+
headers: { ...this.headers },
|
|
2673
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2674
|
+
...this.fetchOptions,
|
|
2675
|
+
});
|
|
2676
|
+
await (0, error_js_1.raiseForStatus)(res, "read dataset version");
|
|
2677
|
+
return res;
|
|
2550
2678
|
});
|
|
2551
|
-
await (0, error_js_1.raiseForStatus)(response, "read dataset version");
|
|
2552
2679
|
return await response.json();
|
|
2553
2680
|
}
|
|
2554
2681
|
async listDatasetSplits({ datasetId, datasetName, asOf, }) {
|
|
@@ -2603,14 +2730,18 @@ class Client {
|
|
|
2603
2730
|
}),
|
|
2604
2731
|
remove,
|
|
2605
2732
|
};
|
|
2606
|
-
const
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2733
|
+
const body = JSON.stringify(data);
|
|
2734
|
+
await this.caller.call(async () => {
|
|
2735
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/${datasetId_}/splits`, {
|
|
2736
|
+
method: "PUT",
|
|
2737
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2738
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2739
|
+
...this.fetchOptions,
|
|
2740
|
+
body,
|
|
2741
|
+
});
|
|
2742
|
+
await (0, error_js_1.raiseForStatus)(res, "update dataset splits", true);
|
|
2743
|
+
return res;
|
|
2612
2744
|
});
|
|
2613
|
-
await (0, error_js_1.raiseForStatus)(response, "update dataset splits", true);
|
|
2614
2745
|
}
|
|
2615
2746
|
/**
|
|
2616
2747
|
* @deprecated This method is deprecated and will be removed in future LangSmith versions, use `evaluate` from `langsmith/evaluation` instead.
|
|
@@ -2668,15 +2799,19 @@ class Client {
|
|
|
2668
2799
|
feedbackConfig,
|
|
2669
2800
|
session_id: projectId,
|
|
2670
2801
|
};
|
|
2802
|
+
const body = JSON.stringify(feedback);
|
|
2671
2803
|
const url = `${this.apiUrl}/feedback`;
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2804
|
+
await this.caller.call(async () => {
|
|
2805
|
+
const res = await this._fetch(url, {
|
|
2806
|
+
method: "POST",
|
|
2807
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2808
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2809
|
+
...this.fetchOptions,
|
|
2810
|
+
body,
|
|
2811
|
+
});
|
|
2812
|
+
await (0, error_js_1.raiseForStatus)(res, "create feedback", true);
|
|
2813
|
+
return res;
|
|
2814
|
+
});
|
|
2680
2815
|
return feedback;
|
|
2681
2816
|
}
|
|
2682
2817
|
async updateFeedback(feedbackId, { score, value, correction, comment, }) {
|
|
@@ -2694,14 +2829,18 @@ class Client {
|
|
|
2694
2829
|
feedbackUpdate["comment"] = comment;
|
|
2695
2830
|
}
|
|
2696
2831
|
(0, _uuid_js_1.assertUuid)(feedbackId);
|
|
2697
|
-
const
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2832
|
+
const body = JSON.stringify(feedbackUpdate);
|
|
2833
|
+
await this.caller.call(async () => {
|
|
2834
|
+
const res = await this._fetch(`${this.apiUrl}/feedback/${feedbackId}`, {
|
|
2835
|
+
method: "PATCH",
|
|
2836
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2837
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2838
|
+
...this.fetchOptions,
|
|
2839
|
+
body,
|
|
2840
|
+
});
|
|
2841
|
+
await (0, error_js_1.raiseForStatus)(res, "update feedback", true);
|
|
2842
|
+
return res;
|
|
2703
2843
|
});
|
|
2704
|
-
await (0, error_js_1.raiseForStatus)(response, "update feedback", true);
|
|
2705
2844
|
}
|
|
2706
2845
|
async readFeedback(feedbackId) {
|
|
2707
2846
|
(0, _uuid_js_1.assertUuid)(feedbackId);
|
|
@@ -2712,14 +2851,16 @@ class Client {
|
|
|
2712
2851
|
async deleteFeedback(feedbackId) {
|
|
2713
2852
|
(0, _uuid_js_1.assertUuid)(feedbackId);
|
|
2714
2853
|
const path = `/feedback/${feedbackId}`;
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2854
|
+
await this.caller.call(async () => {
|
|
2855
|
+
const res = await this._fetch(this.apiUrl + path, {
|
|
2856
|
+
method: "DELETE",
|
|
2857
|
+
headers: this.headers,
|
|
2858
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2859
|
+
...this.fetchOptions,
|
|
2860
|
+
});
|
|
2861
|
+
await (0, error_js_1.raiseForStatus)(res, `delete ${path}`, true);
|
|
2862
|
+
return res;
|
|
2720
2863
|
});
|
|
2721
|
-
await (0, error_js_1.raiseForStatus)(response, `delete ${path}`);
|
|
2722
|
-
await response.json();
|
|
2723
2864
|
}
|
|
2724
2865
|
async *listFeedback({ runIds, feedbackKeys, feedbackSourceTypes, } = {}) {
|
|
2725
2866
|
const queryParams = new URLSearchParams();
|
|
@@ -2774,15 +2915,19 @@ class Client {
|
|
|
2774
2915
|
hours: 3,
|
|
2775
2916
|
};
|
|
2776
2917
|
}
|
|
2777
|
-
const
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2918
|
+
const serializedBody = JSON.stringify(body);
|
|
2919
|
+
const response = await this.caller.call(async () => {
|
|
2920
|
+
const res = await this._fetch(`${this.apiUrl}/feedback/tokens`, {
|
|
2921
|
+
method: "POST",
|
|
2922
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2923
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2924
|
+
...this.fetchOptions,
|
|
2925
|
+
body: serializedBody,
|
|
2926
|
+
});
|
|
2927
|
+
await (0, error_js_1.raiseForStatus)(res, "create presigned feedback token");
|
|
2928
|
+
return res;
|
|
2783
2929
|
});
|
|
2784
|
-
|
|
2785
|
-
return result;
|
|
2930
|
+
return await response.json();
|
|
2786
2931
|
}
|
|
2787
2932
|
async createComparativeExperiment({ name, experimentIds, referenceDatasetId, createdAt, description, metadata, id, }) {
|
|
2788
2933
|
if (experimentIds.length === 0) {
|
|
@@ -2807,14 +2952,19 @@ class Client {
|
|
|
2807
2952
|
};
|
|
2808
2953
|
if (metadata)
|
|
2809
2954
|
body.extra["metadata"] = metadata;
|
|
2810
|
-
const
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2955
|
+
const serializedBody = JSON.stringify(body);
|
|
2956
|
+
const response = await this.caller.call(async () => {
|
|
2957
|
+
const res = await this._fetch(`${this.apiUrl}/datasets/comparative`, {
|
|
2958
|
+
method: "POST",
|
|
2959
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
2960
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
2961
|
+
...this.fetchOptions,
|
|
2962
|
+
body: serializedBody,
|
|
2963
|
+
});
|
|
2964
|
+
await (0, error_js_1.raiseForStatus)(res, "create comparative experiment");
|
|
2965
|
+
return res;
|
|
2816
2966
|
});
|
|
2817
|
-
return
|
|
2967
|
+
return response.json();
|
|
2818
2968
|
}
|
|
2819
2969
|
/**
|
|
2820
2970
|
* Retrieves a list of presigned feedback tokens for a given run ID.
|
|
@@ -2923,16 +3073,19 @@ class Client {
|
|
|
2923
3073
|
id: queueId || uuid.v4(),
|
|
2924
3074
|
rubric_instructions: rubricInstructions,
|
|
2925
3075
|
};
|
|
2926
|
-
const
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3076
|
+
const serializedBody = JSON.stringify(Object.fromEntries(Object.entries(body).filter(([_, v]) => v !== undefined)));
|
|
3077
|
+
const response = await this.caller.call(async () => {
|
|
3078
|
+
const res = await this._fetch(`${this.apiUrl}/annotation-queues`, {
|
|
3079
|
+
method: "POST",
|
|
3080
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
3081
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3082
|
+
...this.fetchOptions,
|
|
3083
|
+
body: serializedBody,
|
|
3084
|
+
});
|
|
3085
|
+
await (0, error_js_1.raiseForStatus)(res, "create annotation queue");
|
|
3086
|
+
return res;
|
|
2932
3087
|
});
|
|
2933
|
-
|
|
2934
|
-
const data = await response.json();
|
|
2935
|
-
return data;
|
|
3088
|
+
return response.json();
|
|
2936
3089
|
}
|
|
2937
3090
|
/**
|
|
2938
3091
|
* Read an annotation queue with the specified queue ID.
|
|
@@ -2940,15 +3093,17 @@ class Client {
|
|
|
2940
3093
|
* @returns The AnnotationQueueWithDetails object
|
|
2941
3094
|
*/
|
|
2942
3095
|
async readAnnotationQueue(queueId) {
|
|
2943
|
-
const response = await this.caller.call(
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
3096
|
+
const response = await this.caller.call(async () => {
|
|
3097
|
+
const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
|
|
3098
|
+
method: "GET",
|
|
3099
|
+
headers: this.headers,
|
|
3100
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3101
|
+
...this.fetchOptions,
|
|
3102
|
+
});
|
|
3103
|
+
await (0, error_js_1.raiseForStatus)(res, "read annotation queue");
|
|
3104
|
+
return res;
|
|
2948
3105
|
});
|
|
2949
|
-
|
|
2950
|
-
const data = await response.json();
|
|
2951
|
-
return data;
|
|
3106
|
+
return response.json();
|
|
2952
3107
|
}
|
|
2953
3108
|
/**
|
|
2954
3109
|
* Update an annotation queue with the specified queue ID.
|
|
@@ -2959,31 +3114,38 @@ class Client {
|
|
|
2959
3114
|
*/
|
|
2960
3115
|
async updateAnnotationQueue(queueId, options) {
|
|
2961
3116
|
const { name, description, rubricInstructions } = options;
|
|
2962
|
-
const
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
3117
|
+
const body = JSON.stringify({
|
|
3118
|
+
name,
|
|
3119
|
+
description,
|
|
3120
|
+
rubric_instructions: rubricInstructions,
|
|
3121
|
+
});
|
|
3122
|
+
await this.caller.call(async () => {
|
|
3123
|
+
const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
|
|
3124
|
+
method: "PATCH",
|
|
3125
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
3126
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3127
|
+
...this.fetchOptions,
|
|
3128
|
+
body,
|
|
3129
|
+
});
|
|
3130
|
+
await (0, error_js_1.raiseForStatus)(res, "update annotation queue", true);
|
|
3131
|
+
return res;
|
|
2972
3132
|
});
|
|
2973
|
-
await (0, error_js_1.raiseForStatus)(response, "update annotation queue");
|
|
2974
3133
|
}
|
|
2975
3134
|
/**
|
|
2976
3135
|
* Delete an annotation queue with the specified queue ID.
|
|
2977
3136
|
* @param queueId - The ID of the annotation queue to delete
|
|
2978
3137
|
*/
|
|
2979
3138
|
async deleteAnnotationQueue(queueId) {
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
3139
|
+
await this.caller.call(async () => {
|
|
3140
|
+
const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
|
|
3141
|
+
method: "DELETE",
|
|
3142
|
+
headers: { ...this.headers, Accept: "application/json" },
|
|
3143
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3144
|
+
...this.fetchOptions,
|
|
3145
|
+
});
|
|
3146
|
+
await (0, error_js_1.raiseForStatus)(res, "delete annotation queue", true);
|
|
3147
|
+
return res;
|
|
2985
3148
|
});
|
|
2986
|
-
await (0, error_js_1.raiseForStatus)(response, "delete annotation queue");
|
|
2987
3149
|
}
|
|
2988
3150
|
/**
|
|
2989
3151
|
* Add runs to an annotation queue with the specified queue ID.
|
|
@@ -2991,14 +3153,18 @@ class Client {
|
|
|
2991
3153
|
* @param runIds - The IDs of the runs to be added to the annotation queue
|
|
2992
3154
|
*/
|
|
2993
3155
|
async addRunsToAnnotationQueue(queueId, runIds) {
|
|
2994
|
-
const
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3156
|
+
const body = JSON.stringify(runIds.map((id, i) => (0, _uuid_js_1.assertUuid)(id, `runIds[${i}]`).toString()));
|
|
3157
|
+
await this.caller.call(async () => {
|
|
3158
|
+
const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs`, {
|
|
3159
|
+
method: "POST",
|
|
3160
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
3161
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3162
|
+
...this.fetchOptions,
|
|
3163
|
+
body,
|
|
3164
|
+
});
|
|
3165
|
+
await (0, error_js_1.raiseForStatus)(res, "add runs to annotation queue", true);
|
|
3166
|
+
return res;
|
|
3000
3167
|
});
|
|
3001
|
-
await (0, error_js_1.raiseForStatus)(response, "add runs to annotation queue");
|
|
3002
3168
|
}
|
|
3003
3169
|
/**
|
|
3004
3170
|
* Get a run from an annotation queue at the specified index.
|
|
@@ -3009,14 +3175,17 @@ class Client {
|
|
|
3009
3175
|
*/
|
|
3010
3176
|
async getRunFromAnnotationQueue(queueId, index) {
|
|
3011
3177
|
const baseUrl = `/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/run`;
|
|
3012
|
-
const response = await this.caller.call(
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3178
|
+
const response = await this.caller.call(async () => {
|
|
3179
|
+
const res = await this._fetch(`${this.apiUrl}${baseUrl}/${index}`, {
|
|
3180
|
+
method: "GET",
|
|
3181
|
+
headers: this.headers,
|
|
3182
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3183
|
+
...this.fetchOptions,
|
|
3184
|
+
});
|
|
3185
|
+
await (0, error_js_1.raiseForStatus)(res, "get run from annotation queue");
|
|
3186
|
+
return res;
|
|
3017
3187
|
});
|
|
3018
|
-
|
|
3019
|
-
return await response.json();
|
|
3188
|
+
return response.json();
|
|
3020
3189
|
}
|
|
3021
3190
|
/**
|
|
3022
3191
|
* Delete a run from an an annotation queue.
|
|
@@ -3024,27 +3193,33 @@ class Client {
|
|
|
3024
3193
|
* @param queueRunId - The ID of the run to delete from the annotation queue
|
|
3025
3194
|
*/
|
|
3026
3195
|
async deleteRunFromAnnotationQueue(queueId, queueRunId) {
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3196
|
+
await this.caller.call(async () => {
|
|
3197
|
+
const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs/${(0, _uuid_js_1.assertUuid)(queueRunId, "queueRunId")}`, {
|
|
3198
|
+
method: "DELETE",
|
|
3199
|
+
headers: { ...this.headers, Accept: "application/json" },
|
|
3200
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3201
|
+
...this.fetchOptions,
|
|
3202
|
+
});
|
|
3203
|
+
await (0, error_js_1.raiseForStatus)(res, "delete run from annotation queue", true);
|
|
3204
|
+
return res;
|
|
3032
3205
|
});
|
|
3033
|
-
await (0, error_js_1.raiseForStatus)(response, "delete run from annotation queue");
|
|
3034
3206
|
}
|
|
3035
3207
|
/**
|
|
3036
3208
|
* Get the size of an annotation queue.
|
|
3037
3209
|
* @param queueId - The ID of the annotation queue
|
|
3038
3210
|
*/
|
|
3039
3211
|
async getSizeFromAnnotationQueue(queueId) {
|
|
3040
|
-
const response = await this.caller.call(
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3212
|
+
const response = await this.caller.call(async () => {
|
|
3213
|
+
const res = await this._fetch(`${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/size`, {
|
|
3214
|
+
method: "GET",
|
|
3215
|
+
headers: this.headers,
|
|
3216
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3217
|
+
...this.fetchOptions,
|
|
3218
|
+
});
|
|
3219
|
+
await (0, error_js_1.raiseForStatus)(res, "get size from annotation queue");
|
|
3220
|
+
return res;
|
|
3045
3221
|
});
|
|
3046
|
-
|
|
3047
|
-
return await response.json();
|
|
3222
|
+
return response.json();
|
|
3048
3223
|
}
|
|
3049
3224
|
async _currentTenantIsOwner(owner) {
|
|
3050
3225
|
const settings = await this._getSettings();
|
|
@@ -3057,22 +3232,17 @@ class Client {
|
|
|
3057
3232
|
Requested tenant: ${owner}`);
|
|
3058
3233
|
}
|
|
3059
3234
|
async _getLatestCommitHash(promptOwnerAndName) {
|
|
3060
|
-
const
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
const error = new Error(`Error ${res.status}: ${res.statusText}\n${detail}`);
|
|
3072
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3073
|
-
error.statusCode = res.status;
|
|
3074
|
-
throw error;
|
|
3075
|
-
}
|
|
3235
|
+
const response = await this.caller.call(async () => {
|
|
3236
|
+
const res = await this._fetch(`${this.apiUrl}/commits/${promptOwnerAndName}/?limit=${1}&offset=${0}`, {
|
|
3237
|
+
method: "GET",
|
|
3238
|
+
headers: this.headers,
|
|
3239
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3240
|
+
...this.fetchOptions,
|
|
3241
|
+
});
|
|
3242
|
+
await (0, error_js_1.raiseForStatus)(res, "get latest commit hash");
|
|
3243
|
+
return res;
|
|
3244
|
+
});
|
|
3245
|
+
const json = await response.json();
|
|
3076
3246
|
if (json.commits.length === 0) {
|
|
3077
3247
|
return undefined;
|
|
3078
3248
|
}
|
|
@@ -3080,15 +3250,19 @@ class Client {
|
|
|
3080
3250
|
}
|
|
3081
3251
|
async _likeOrUnlikePrompt(promptIdentifier, like) {
|
|
3082
3252
|
const [owner, promptName, _] = (0, prompts_js_1.parsePromptIdentifier)(promptIdentifier);
|
|
3083
|
-
const
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3253
|
+
const body = JSON.stringify({ like: like });
|
|
3254
|
+
const response = await this.caller.call(async () => {
|
|
3255
|
+
const res = await this._fetch(`${this.apiUrl}/likes/${owner}/${promptName}`, {
|
|
3256
|
+
method: "POST",
|
|
3257
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
3258
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3259
|
+
...this.fetchOptions,
|
|
3260
|
+
body,
|
|
3261
|
+
});
|
|
3262
|
+
await (0, error_js_1.raiseForStatus)(res, `${like ? "like" : "unlike"} prompt`);
|
|
3263
|
+
return res;
|
|
3264
|
+
});
|
|
3265
|
+
return response.json();
|
|
3092
3266
|
}
|
|
3093
3267
|
async _getPromptUrl(promptIdentifier) {
|
|
3094
3268
|
const [owner, promptName, commitHash] = (0, prompts_js_1.parsePromptIdentifier)(promptIdentifier);
|
|
@@ -3142,18 +3316,21 @@ class Client {
|
|
|
3142
3316
|
}
|
|
3143
3317
|
async getPrompt(promptIdentifier) {
|
|
3144
3318
|
const [owner, promptName, _] = (0, prompts_js_1.parsePromptIdentifier)(promptIdentifier);
|
|
3145
|
-
const response = await this.caller.call(
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3319
|
+
const response = await this.caller.call(async () => {
|
|
3320
|
+
const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
|
|
3321
|
+
method: "GET",
|
|
3322
|
+
headers: this.headers,
|
|
3323
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3324
|
+
...this.fetchOptions,
|
|
3325
|
+
});
|
|
3326
|
+
if (res?.status === 404) {
|
|
3327
|
+
return null;
|
|
3328
|
+
}
|
|
3329
|
+
await (0, error_js_1.raiseForStatus)(res, "get prompt");
|
|
3330
|
+
return res;
|
|
3150
3331
|
});
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
}
|
|
3154
|
-
await (0, error_js_1.raiseForStatus)(response, "get prompt");
|
|
3155
|
-
const result = await response.json();
|
|
3156
|
-
if (result.repo) {
|
|
3332
|
+
const result = await response?.json();
|
|
3333
|
+
if (result?.repo) {
|
|
3157
3334
|
return result.repo;
|
|
3158
3335
|
}
|
|
3159
3336
|
else {
|
|
@@ -3179,14 +3356,18 @@ class Client {
|
|
|
3179
3356
|
...(options?.tags && { tags: options.tags }),
|
|
3180
3357
|
is_public: !!options?.isPublic,
|
|
3181
3358
|
};
|
|
3182
|
-
const
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3359
|
+
const body = JSON.stringify(data);
|
|
3360
|
+
const response = await this.caller.call(async () => {
|
|
3361
|
+
const res = await this._fetch(`${this.apiUrl}/repos/`, {
|
|
3362
|
+
method: "POST",
|
|
3363
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
3364
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3365
|
+
...this.fetchOptions,
|
|
3366
|
+
body,
|
|
3367
|
+
});
|
|
3368
|
+
await (0, error_js_1.raiseForStatus)(res, "create prompt");
|
|
3369
|
+
return res;
|
|
3370
|
+
});
|
|
3190
3371
|
const { repo } = await response.json();
|
|
3191
3372
|
return repo;
|
|
3192
3373
|
}
|
|
@@ -3202,14 +3383,18 @@ class Client {
|
|
|
3202
3383
|
manifest: JSON.parse(JSON.stringify(object)),
|
|
3203
3384
|
parent_commit: resolvedParentCommitHash,
|
|
3204
3385
|
};
|
|
3205
|
-
const
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3386
|
+
const body = JSON.stringify(payload);
|
|
3387
|
+
const response = await this.caller.call(async () => {
|
|
3388
|
+
const res = await this._fetch(`${this.apiUrl}/commits/${owner}/${promptName}`, {
|
|
3389
|
+
method: "POST",
|
|
3390
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
3391
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3392
|
+
...this.fetchOptions,
|
|
3393
|
+
body,
|
|
3394
|
+
});
|
|
3395
|
+
await (0, error_js_1.raiseForStatus)(res, "create commit");
|
|
3396
|
+
return res;
|
|
3397
|
+
});
|
|
3213
3398
|
const result = await response.json();
|
|
3214
3399
|
return this._getPromptUrl(`${owner}/${promptName}${result.commit_hash ? `:${result.commit_hash}` : ""}`);
|
|
3215
3400
|
}
|
|
@@ -3282,13 +3467,18 @@ class Client {
|
|
|
3282
3467
|
}
|
|
3283
3468
|
}
|
|
3284
3469
|
const datasetIdToUse = datasetId ?? updates[0]?.dataset_id;
|
|
3285
|
-
const response = await this.caller.call(
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3470
|
+
const response = await this.caller.call(async () => {
|
|
3471
|
+
const res = await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${datasetIdToUse}/examples`)}`, {
|
|
3472
|
+
method: "PATCH",
|
|
3473
|
+
headers: this.headers,
|
|
3474
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3475
|
+
...this.fetchOptions,
|
|
3476
|
+
body: formData,
|
|
3477
|
+
});
|
|
3478
|
+
await (0, error_js_1.raiseForStatus)(res, "update examples");
|
|
3479
|
+
return res;
|
|
3289
3480
|
});
|
|
3290
|
-
|
|
3291
|
-
return result;
|
|
3481
|
+
return response.json();
|
|
3292
3482
|
}
|
|
3293
3483
|
/**
|
|
3294
3484
|
* Upload examples with attachments using multipart form data.
|
|
@@ -3360,14 +3550,18 @@ class Client {
|
|
|
3360
3550
|
}
|
|
3361
3551
|
}
|
|
3362
3552
|
}
|
|
3363
|
-
const response = await this.caller.call(
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3553
|
+
const response = await this.caller.call(async () => {
|
|
3554
|
+
const res = await this._fetch(`${this.apiUrl}${this._getPlatformEndpointPath(`datasets/${datasetId}/examples`)}`, {
|
|
3555
|
+
method: "POST",
|
|
3556
|
+
headers: this.headers,
|
|
3557
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3558
|
+
...this.fetchOptions,
|
|
3559
|
+
body: formData,
|
|
3560
|
+
});
|
|
3561
|
+
await (0, error_js_1.raiseForStatus)(res, "upload examples");
|
|
3562
|
+
return res;
|
|
3367
3563
|
});
|
|
3368
|
-
|
|
3369
|
-
const result = await response.json();
|
|
3370
|
-
return result;
|
|
3564
|
+
return response.json();
|
|
3371
3565
|
}
|
|
3372
3566
|
async updatePrompt(promptIdentifier, options) {
|
|
3373
3567
|
if (!(await this.promptExists(promptIdentifier))) {
|
|
@@ -3392,17 +3586,21 @@ class Client {
|
|
|
3392
3586
|
if (Object.keys(payload).length === 0) {
|
|
3393
3587
|
throw new Error("No valid update options provided");
|
|
3394
3588
|
}
|
|
3395
|
-
const
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3589
|
+
const body = JSON.stringify(payload);
|
|
3590
|
+
const response = await this.caller.call(async () => {
|
|
3591
|
+
const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
|
|
3592
|
+
method: "PATCH",
|
|
3593
|
+
headers: {
|
|
3594
|
+
...this.headers,
|
|
3595
|
+
"Content-Type": "application/json",
|
|
3596
|
+
},
|
|
3597
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3598
|
+
...this.fetchOptions,
|
|
3599
|
+
body,
|
|
3600
|
+
});
|
|
3601
|
+
await (0, error_js_1.raiseForStatus)(res, "update prompt");
|
|
3602
|
+
return res;
|
|
3404
3603
|
});
|
|
3405
|
-
await (0, error_js_1.raiseForStatus)(response, "update prompt");
|
|
3406
3604
|
return response.json();
|
|
3407
3605
|
}
|
|
3408
3606
|
async deletePrompt(promptIdentifier) {
|
|
@@ -3413,23 +3611,30 @@ class Client {
|
|
|
3413
3611
|
if (!(await this._currentTenantIsOwner(owner))) {
|
|
3414
3612
|
throw await this._ownerConflictError("delete a prompt", owner);
|
|
3415
3613
|
}
|
|
3416
|
-
const response = await this.caller.call(
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3614
|
+
const response = await this.caller.call(async () => {
|
|
3615
|
+
const res = await this._fetch(`${this.apiUrl}/repos/${owner}/${promptName}`, {
|
|
3616
|
+
method: "DELETE",
|
|
3617
|
+
headers: this.headers,
|
|
3618
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3619
|
+
...this.fetchOptions,
|
|
3620
|
+
});
|
|
3621
|
+
await (0, error_js_1.raiseForStatus)(res, "delete prompt");
|
|
3622
|
+
return res;
|
|
3421
3623
|
});
|
|
3422
|
-
return
|
|
3624
|
+
return response.json();
|
|
3423
3625
|
}
|
|
3424
3626
|
async pullPromptCommit(promptIdentifier, options) {
|
|
3425
3627
|
const [owner, promptName, commitHash] = (0, prompts_js_1.parsePromptIdentifier)(promptIdentifier);
|
|
3426
|
-
const response = await this.caller.call(
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3628
|
+
const response = await this.caller.call(async () => {
|
|
3629
|
+
const res = await this._fetch(`${this.apiUrl}/commits/${owner}/${promptName}/${commitHash}${options?.includeModel ? "?include_model=true" : ""}`, {
|
|
3630
|
+
method: "GET",
|
|
3631
|
+
headers: this.headers,
|
|
3632
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
3633
|
+
...this.fetchOptions,
|
|
3634
|
+
});
|
|
3635
|
+
await (0, error_js_1.raiseForStatus)(res, "pull prompt commit");
|
|
3636
|
+
return res;
|
|
3431
3637
|
});
|
|
3432
|
-
await (0, error_js_1.raiseForStatus)(response, "pull prompt commit");
|
|
3433
3638
|
const result = await response.json();
|
|
3434
3639
|
return {
|
|
3435
3640
|
owner,
|