langsmith 0.0.47 → 0.0.49
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 +61 -5
- package/dist/client.d.ts +12 -3
- package/dist/client.js +61 -5
- package/dist/schemas.d.ts +1 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -70,6 +70,11 @@ function hideOutputs(outputs) {
|
|
|
70
70
|
}
|
|
71
71
|
return outputs;
|
|
72
72
|
}
|
|
73
|
+
function assertUuid(str) {
|
|
74
|
+
if (!uuid.validate(str)) {
|
|
75
|
+
throw new Error(`Invalid UUID: ${str}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
73
78
|
class Client {
|
|
74
79
|
constructor(config = {}) {
|
|
75
80
|
Object.defineProperty(this, "apiKey", {
|
|
@@ -229,6 +234,7 @@ class Client {
|
|
|
229
234
|
await raiseForStatus(response, "create run");
|
|
230
235
|
}
|
|
231
236
|
async updateRun(runId, run) {
|
|
237
|
+
assertUuid(runId);
|
|
232
238
|
if (run.inputs) {
|
|
233
239
|
run.inputs = hideInputs(run.inputs);
|
|
234
240
|
}
|
|
@@ -245,6 +251,7 @@ class Client {
|
|
|
245
251
|
await raiseForStatus(response, "update run");
|
|
246
252
|
}
|
|
247
253
|
async readRun(runId, { loadChildRuns } = { loadChildRuns: false }) {
|
|
254
|
+
assertUuid(runId);
|
|
248
255
|
let run = await this._get(`/runs/${runId}`);
|
|
249
256
|
if (loadChildRuns && run.child_run_ids) {
|
|
250
257
|
run = await this._loadChildRuns(run);
|
|
@@ -365,6 +372,7 @@ class Client {
|
|
|
365
372
|
run_id: runId,
|
|
366
373
|
share_token: shareId || uuid.v4(),
|
|
367
374
|
};
|
|
375
|
+
assertUuid(runId);
|
|
368
376
|
const response = await this.caller.call(fetch, `${this.apiUrl}/runs/${runId}/share`, {
|
|
369
377
|
method: "PUT",
|
|
370
378
|
headers: this.headers,
|
|
@@ -378,6 +386,7 @@ class Client {
|
|
|
378
386
|
return `${this.getHostUrl()}/public/${result["share_token"]}/r`;
|
|
379
387
|
}
|
|
380
388
|
async unshareRun(runId) {
|
|
389
|
+
assertUuid(runId);
|
|
381
390
|
const response = await this.caller.call(fetch, `${this.apiUrl}/runs/${runId}/share`, {
|
|
382
391
|
method: "DELETE",
|
|
383
392
|
headers: this.headers,
|
|
@@ -386,6 +395,7 @@ class Client {
|
|
|
386
395
|
await raiseForStatus(response, "unshare run");
|
|
387
396
|
}
|
|
388
397
|
async readRunSharedLink(runId) {
|
|
398
|
+
assertUuid(runId);
|
|
389
399
|
const response = await this.caller.call(fetch, `${this.apiUrl}/runs/${runId}/share`, {
|
|
390
400
|
method: "GET",
|
|
391
401
|
headers: this.headers,
|
|
@@ -406,6 +416,7 @@ class Client {
|
|
|
406
416
|
queryParams.append("id", runId);
|
|
407
417
|
}
|
|
408
418
|
}
|
|
419
|
+
assertUuid(shareToken);
|
|
409
420
|
const response = await this.caller.call(fetch, `${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
|
|
410
421
|
method: "GET",
|
|
411
422
|
headers: this.headers,
|
|
@@ -422,6 +433,7 @@ class Client {
|
|
|
422
433
|
const dataset = await this.readDataset({ datasetName });
|
|
423
434
|
datasetId = dataset.id;
|
|
424
435
|
}
|
|
436
|
+
assertUuid(datasetId);
|
|
425
437
|
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
426
438
|
method: "GET",
|
|
427
439
|
headers: this.headers,
|
|
@@ -442,6 +454,7 @@ class Client {
|
|
|
442
454
|
const data = {
|
|
443
455
|
dataset_id: datasetId,
|
|
444
456
|
};
|
|
457
|
+
assertUuid(datasetId);
|
|
445
458
|
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
446
459
|
method: "PUT",
|
|
447
460
|
headers: this.headers,
|
|
@@ -453,6 +466,7 @@ class Client {
|
|
|
453
466
|
return shareSchema;
|
|
454
467
|
}
|
|
455
468
|
async unshareDataset(datasetId) {
|
|
469
|
+
assertUuid(datasetId);
|
|
456
470
|
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
457
471
|
method: "DELETE",
|
|
458
472
|
headers: this.headers,
|
|
@@ -461,6 +475,7 @@ class Client {
|
|
|
461
475
|
await raiseForStatus(response, "unshare dataset");
|
|
462
476
|
}
|
|
463
477
|
async readSharedDataset(shareToken) {
|
|
478
|
+
assertUuid(shareToken);
|
|
464
479
|
const response = await this.caller.call(fetch, `${this.apiUrl}/public/${shareToken}/datasets`, {
|
|
465
480
|
method: "GET",
|
|
466
481
|
headers: this.headers,
|
|
@@ -469,16 +484,19 @@ class Client {
|
|
|
469
484
|
const dataset = await response.json();
|
|
470
485
|
return dataset;
|
|
471
486
|
}
|
|
472
|
-
async createProject({ projectName,
|
|
487
|
+
async createProject({ projectName, description = null, metadata = null, upsert = false, projectExtra = null, referenceDatasetId = null, }) {
|
|
473
488
|
const upsert_ = upsert ? `?upsert=true` : "";
|
|
474
489
|
const endpoint = `${this.apiUrl}/sessions${upsert_}`;
|
|
490
|
+
const extra = projectExtra || {};
|
|
491
|
+
if (metadata) {
|
|
492
|
+
extra["metadata"] = metadata;
|
|
493
|
+
}
|
|
475
494
|
const body = {
|
|
476
495
|
name: projectName,
|
|
496
|
+
extra,
|
|
497
|
+
description,
|
|
477
498
|
};
|
|
478
|
-
if (
|
|
479
|
-
body["extra"] = projectExtra;
|
|
480
|
-
}
|
|
481
|
-
if (referenceDatasetId !== undefined) {
|
|
499
|
+
if (referenceDatasetId !== null) {
|
|
482
500
|
body["reference_dataset_id"] = referenceDatasetId;
|
|
483
501
|
}
|
|
484
502
|
const response = await this.caller.call(fetch, endpoint, {
|
|
@@ -493,6 +511,30 @@ class Client {
|
|
|
493
511
|
}
|
|
494
512
|
return result;
|
|
495
513
|
}
|
|
514
|
+
async updateProject(projectId, { name = null, description = null, metadata = null, projectExtra = null, endTime = null, }) {
|
|
515
|
+
const endpoint = `${this.apiUrl}/sessions/${projectId}`;
|
|
516
|
+
let extra = projectExtra;
|
|
517
|
+
if (metadata) {
|
|
518
|
+
extra = { ...(extra || {}), metadata };
|
|
519
|
+
}
|
|
520
|
+
const body = {
|
|
521
|
+
name,
|
|
522
|
+
extra,
|
|
523
|
+
description,
|
|
524
|
+
end_time: endTime ? new Date(endTime).toISOString() : null,
|
|
525
|
+
};
|
|
526
|
+
const response = await this.caller.call(fetch, endpoint, {
|
|
527
|
+
method: "PATCH",
|
|
528
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
529
|
+
body: JSON.stringify(body),
|
|
530
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
531
|
+
});
|
|
532
|
+
const result = await response.json();
|
|
533
|
+
if (!response.ok) {
|
|
534
|
+
throw new Error(`Failed to update project ${projectId}: ${response.status} ${response.statusText}`);
|
|
535
|
+
}
|
|
536
|
+
return result;
|
|
537
|
+
}
|
|
496
538
|
async readProject({ projectId, projectName, }) {
|
|
497
539
|
let path = "/sessions";
|
|
498
540
|
const params = new URLSearchParams();
|
|
@@ -500,6 +542,7 @@ class Client {
|
|
|
500
542
|
throw new Error("Must provide either projectName or projectId, not both");
|
|
501
543
|
}
|
|
502
544
|
else if (projectId !== undefined) {
|
|
545
|
+
assertUuid(projectId);
|
|
503
546
|
path += `/${projectId}`;
|
|
504
547
|
}
|
|
505
548
|
else if (projectName !== undefined) {
|
|
@@ -575,6 +618,7 @@ class Client {
|
|
|
575
618
|
else {
|
|
576
619
|
projectId_ = projectId;
|
|
577
620
|
}
|
|
621
|
+
assertUuid(projectId_);
|
|
578
622
|
const response = await this.caller.call(fetch, `${this.apiUrl}/sessions/${projectId_}`, {
|
|
579
623
|
method: "DELETE",
|
|
580
624
|
headers: this.headers,
|
|
@@ -649,6 +693,7 @@ class Client {
|
|
|
649
693
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
650
694
|
}
|
|
651
695
|
else if (datasetId !== undefined) {
|
|
696
|
+
assertUuid(datasetId);
|
|
652
697
|
path += `/${datasetId}`;
|
|
653
698
|
}
|
|
654
699
|
else if (datasetName !== undefined) {
|
|
@@ -721,6 +766,7 @@ class Client {
|
|
|
721
766
|
datasetId_ = dataset.id;
|
|
722
767
|
}
|
|
723
768
|
if (datasetId_ !== undefined) {
|
|
769
|
+
assertUuid(datasetId_);
|
|
724
770
|
path += `/${datasetId_}`;
|
|
725
771
|
}
|
|
726
772
|
else {
|
|
@@ -784,6 +830,7 @@ class Client {
|
|
|
784
830
|
return this.createExample({ input: finalInput }, { output: finalOutput }, options);
|
|
785
831
|
}
|
|
786
832
|
async readExample(exampleId) {
|
|
833
|
+
assertUuid(exampleId);
|
|
787
834
|
const path = `/examples/${exampleId}`;
|
|
788
835
|
return await this._get(path);
|
|
789
836
|
}
|
|
@@ -813,6 +860,7 @@ class Client {
|
|
|
813
860
|
}
|
|
814
861
|
}
|
|
815
862
|
async deleteExample(exampleId) {
|
|
863
|
+
assertUuid(exampleId);
|
|
816
864
|
const path = `/examples/${exampleId}`;
|
|
817
865
|
const response = await this.caller.call(fetch, this.apiUrl + path, {
|
|
818
866
|
method: "DELETE",
|
|
@@ -825,6 +873,7 @@ class Client {
|
|
|
825
873
|
await response.json();
|
|
826
874
|
}
|
|
827
875
|
async updateExample(exampleId, update) {
|
|
876
|
+
assertUuid(exampleId);
|
|
828
877
|
const response = await this.caller.call(fetch, `${this.apiUrl}/examples/${exampleId}`, {
|
|
829
878
|
method: "PATCH",
|
|
830
879
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -877,6 +926,10 @@ class Client {
|
|
|
877
926
|
!feedback_source.metadata["__run"]) {
|
|
878
927
|
feedback_source.metadata["__run"] = { run_id: sourceRunId };
|
|
879
928
|
}
|
|
929
|
+
if (feedback_source?.metadata !== undefined &&
|
|
930
|
+
feedback_source.metadata["__run"]?.run_id !== undefined) {
|
|
931
|
+
assertUuid(feedback_source.metadata["__run"].run_id);
|
|
932
|
+
}
|
|
880
933
|
const feedback = {
|
|
881
934
|
id: feedbackId ?? uuid.v4(),
|
|
882
935
|
run_id: runId,
|
|
@@ -911,6 +964,7 @@ class Client {
|
|
|
911
964
|
if (comment !== undefined && comment !== null) {
|
|
912
965
|
feedbackUpdate["comment"] = comment;
|
|
913
966
|
}
|
|
967
|
+
assertUuid(feedbackId);
|
|
914
968
|
const response = await this.caller.call(fetch, `${this.apiUrl}/feedback/${feedbackId}`, {
|
|
915
969
|
method: "PATCH",
|
|
916
970
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -920,11 +974,13 @@ class Client {
|
|
|
920
974
|
await raiseForStatus(response, "update feedback");
|
|
921
975
|
}
|
|
922
976
|
async readFeedback(feedbackId) {
|
|
977
|
+
assertUuid(feedbackId);
|
|
923
978
|
const path = `/feedback/${feedbackId}`;
|
|
924
979
|
const response = await this._get(path);
|
|
925
980
|
return response;
|
|
926
981
|
}
|
|
927
982
|
async deleteFeedback(feedbackId) {
|
|
983
|
+
assertUuid(feedbackId);
|
|
928
984
|
const path = `/feedback/${feedbackId}`;
|
|
929
985
|
const response = await this.caller.call(fetch, this.apiUrl + path, {
|
|
930
986
|
method: "DELETE",
|
package/dist/client.d.ts
CHANGED
|
@@ -103,11 +103,20 @@ export declare class Client {
|
|
|
103
103
|
shareDataset(datasetId?: string, datasetName?: string): Promise<DatasetShareSchema>;
|
|
104
104
|
unshareDataset(datasetId: string): Promise<void>;
|
|
105
105
|
readSharedDataset(shareToken: string): Promise<Dataset>;
|
|
106
|
-
createProject({ projectName,
|
|
106
|
+
createProject({ projectName, description, metadata, upsert, projectExtra, referenceDatasetId, }: {
|
|
107
107
|
projectName: string;
|
|
108
|
-
|
|
108
|
+
description?: string | null;
|
|
109
|
+
metadata?: Record<string, any> | null;
|
|
109
110
|
upsert?: boolean;
|
|
110
|
-
|
|
111
|
+
projectExtra?: Record<string, any> | null;
|
|
112
|
+
referenceDatasetId?: string | null;
|
|
113
|
+
}): Promise<TracerSession>;
|
|
114
|
+
updateProject(projectId: string, { name, description, metadata, projectExtra, endTime, }: {
|
|
115
|
+
name?: string | null;
|
|
116
|
+
description?: string | null;
|
|
117
|
+
metadata?: Record<string, any> | null;
|
|
118
|
+
projectExtra?: Record<string, any> | null;
|
|
119
|
+
endTime?: string | null;
|
|
111
120
|
}): Promise<TracerSession>;
|
|
112
121
|
readProject({ projectId, projectName, }: {
|
|
113
122
|
projectId?: string;
|
package/dist/client.js
CHANGED
|
@@ -44,6 +44,11 @@ function hideOutputs(outputs) {
|
|
|
44
44
|
}
|
|
45
45
|
return outputs;
|
|
46
46
|
}
|
|
47
|
+
function assertUuid(str) {
|
|
48
|
+
if (!uuid.validate(str)) {
|
|
49
|
+
throw new Error(`Invalid UUID: ${str}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
47
52
|
export class Client {
|
|
48
53
|
constructor(config = {}) {
|
|
49
54
|
Object.defineProperty(this, "apiKey", {
|
|
@@ -203,6 +208,7 @@ export class Client {
|
|
|
203
208
|
await raiseForStatus(response, "create run");
|
|
204
209
|
}
|
|
205
210
|
async updateRun(runId, run) {
|
|
211
|
+
assertUuid(runId);
|
|
206
212
|
if (run.inputs) {
|
|
207
213
|
run.inputs = hideInputs(run.inputs);
|
|
208
214
|
}
|
|
@@ -219,6 +225,7 @@ export class Client {
|
|
|
219
225
|
await raiseForStatus(response, "update run");
|
|
220
226
|
}
|
|
221
227
|
async readRun(runId, { loadChildRuns } = { loadChildRuns: false }) {
|
|
228
|
+
assertUuid(runId);
|
|
222
229
|
let run = await this._get(`/runs/${runId}`);
|
|
223
230
|
if (loadChildRuns && run.child_run_ids) {
|
|
224
231
|
run = await this._loadChildRuns(run);
|
|
@@ -339,6 +346,7 @@ export class Client {
|
|
|
339
346
|
run_id: runId,
|
|
340
347
|
share_token: shareId || uuid.v4(),
|
|
341
348
|
};
|
|
349
|
+
assertUuid(runId);
|
|
342
350
|
const response = await this.caller.call(fetch, `${this.apiUrl}/runs/${runId}/share`, {
|
|
343
351
|
method: "PUT",
|
|
344
352
|
headers: this.headers,
|
|
@@ -352,6 +360,7 @@ export class Client {
|
|
|
352
360
|
return `${this.getHostUrl()}/public/${result["share_token"]}/r`;
|
|
353
361
|
}
|
|
354
362
|
async unshareRun(runId) {
|
|
363
|
+
assertUuid(runId);
|
|
355
364
|
const response = await this.caller.call(fetch, `${this.apiUrl}/runs/${runId}/share`, {
|
|
356
365
|
method: "DELETE",
|
|
357
366
|
headers: this.headers,
|
|
@@ -360,6 +369,7 @@ export class Client {
|
|
|
360
369
|
await raiseForStatus(response, "unshare run");
|
|
361
370
|
}
|
|
362
371
|
async readRunSharedLink(runId) {
|
|
372
|
+
assertUuid(runId);
|
|
363
373
|
const response = await this.caller.call(fetch, `${this.apiUrl}/runs/${runId}/share`, {
|
|
364
374
|
method: "GET",
|
|
365
375
|
headers: this.headers,
|
|
@@ -380,6 +390,7 @@ export class Client {
|
|
|
380
390
|
queryParams.append("id", runId);
|
|
381
391
|
}
|
|
382
392
|
}
|
|
393
|
+
assertUuid(shareToken);
|
|
383
394
|
const response = await this.caller.call(fetch, `${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
|
|
384
395
|
method: "GET",
|
|
385
396
|
headers: this.headers,
|
|
@@ -396,6 +407,7 @@ export class Client {
|
|
|
396
407
|
const dataset = await this.readDataset({ datasetName });
|
|
397
408
|
datasetId = dataset.id;
|
|
398
409
|
}
|
|
410
|
+
assertUuid(datasetId);
|
|
399
411
|
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
400
412
|
method: "GET",
|
|
401
413
|
headers: this.headers,
|
|
@@ -416,6 +428,7 @@ export class Client {
|
|
|
416
428
|
const data = {
|
|
417
429
|
dataset_id: datasetId,
|
|
418
430
|
};
|
|
431
|
+
assertUuid(datasetId);
|
|
419
432
|
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
420
433
|
method: "PUT",
|
|
421
434
|
headers: this.headers,
|
|
@@ -427,6 +440,7 @@ export class Client {
|
|
|
427
440
|
return shareSchema;
|
|
428
441
|
}
|
|
429
442
|
async unshareDataset(datasetId) {
|
|
443
|
+
assertUuid(datasetId);
|
|
430
444
|
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
|
|
431
445
|
method: "DELETE",
|
|
432
446
|
headers: this.headers,
|
|
@@ -435,6 +449,7 @@ export class Client {
|
|
|
435
449
|
await raiseForStatus(response, "unshare dataset");
|
|
436
450
|
}
|
|
437
451
|
async readSharedDataset(shareToken) {
|
|
452
|
+
assertUuid(shareToken);
|
|
438
453
|
const response = await this.caller.call(fetch, `${this.apiUrl}/public/${shareToken}/datasets`, {
|
|
439
454
|
method: "GET",
|
|
440
455
|
headers: this.headers,
|
|
@@ -443,16 +458,19 @@ export class Client {
|
|
|
443
458
|
const dataset = await response.json();
|
|
444
459
|
return dataset;
|
|
445
460
|
}
|
|
446
|
-
async createProject({ projectName,
|
|
461
|
+
async createProject({ projectName, description = null, metadata = null, upsert = false, projectExtra = null, referenceDatasetId = null, }) {
|
|
447
462
|
const upsert_ = upsert ? `?upsert=true` : "";
|
|
448
463
|
const endpoint = `${this.apiUrl}/sessions${upsert_}`;
|
|
464
|
+
const extra = projectExtra || {};
|
|
465
|
+
if (metadata) {
|
|
466
|
+
extra["metadata"] = metadata;
|
|
467
|
+
}
|
|
449
468
|
const body = {
|
|
450
469
|
name: projectName,
|
|
470
|
+
extra,
|
|
471
|
+
description,
|
|
451
472
|
};
|
|
452
|
-
if (
|
|
453
|
-
body["extra"] = projectExtra;
|
|
454
|
-
}
|
|
455
|
-
if (referenceDatasetId !== undefined) {
|
|
473
|
+
if (referenceDatasetId !== null) {
|
|
456
474
|
body["reference_dataset_id"] = referenceDatasetId;
|
|
457
475
|
}
|
|
458
476
|
const response = await this.caller.call(fetch, endpoint, {
|
|
@@ -467,6 +485,30 @@ export class Client {
|
|
|
467
485
|
}
|
|
468
486
|
return result;
|
|
469
487
|
}
|
|
488
|
+
async updateProject(projectId, { name = null, description = null, metadata = null, projectExtra = null, endTime = null, }) {
|
|
489
|
+
const endpoint = `${this.apiUrl}/sessions/${projectId}`;
|
|
490
|
+
let extra = projectExtra;
|
|
491
|
+
if (metadata) {
|
|
492
|
+
extra = { ...(extra || {}), metadata };
|
|
493
|
+
}
|
|
494
|
+
const body = {
|
|
495
|
+
name,
|
|
496
|
+
extra,
|
|
497
|
+
description,
|
|
498
|
+
end_time: endTime ? new Date(endTime).toISOString() : null,
|
|
499
|
+
};
|
|
500
|
+
const response = await this.caller.call(fetch, endpoint, {
|
|
501
|
+
method: "PATCH",
|
|
502
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
503
|
+
body: JSON.stringify(body),
|
|
504
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
505
|
+
});
|
|
506
|
+
const result = await response.json();
|
|
507
|
+
if (!response.ok) {
|
|
508
|
+
throw new Error(`Failed to update project ${projectId}: ${response.status} ${response.statusText}`);
|
|
509
|
+
}
|
|
510
|
+
return result;
|
|
511
|
+
}
|
|
470
512
|
async readProject({ projectId, projectName, }) {
|
|
471
513
|
let path = "/sessions";
|
|
472
514
|
const params = new URLSearchParams();
|
|
@@ -474,6 +516,7 @@ export class Client {
|
|
|
474
516
|
throw new Error("Must provide either projectName or projectId, not both");
|
|
475
517
|
}
|
|
476
518
|
else if (projectId !== undefined) {
|
|
519
|
+
assertUuid(projectId);
|
|
477
520
|
path += `/${projectId}`;
|
|
478
521
|
}
|
|
479
522
|
else if (projectName !== undefined) {
|
|
@@ -549,6 +592,7 @@ export class Client {
|
|
|
549
592
|
else {
|
|
550
593
|
projectId_ = projectId;
|
|
551
594
|
}
|
|
595
|
+
assertUuid(projectId_);
|
|
552
596
|
const response = await this.caller.call(fetch, `${this.apiUrl}/sessions/${projectId_}`, {
|
|
553
597
|
method: "DELETE",
|
|
554
598
|
headers: this.headers,
|
|
@@ -623,6 +667,7 @@ export class Client {
|
|
|
623
667
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
624
668
|
}
|
|
625
669
|
else if (datasetId !== undefined) {
|
|
670
|
+
assertUuid(datasetId);
|
|
626
671
|
path += `/${datasetId}`;
|
|
627
672
|
}
|
|
628
673
|
else if (datasetName !== undefined) {
|
|
@@ -695,6 +740,7 @@ export class Client {
|
|
|
695
740
|
datasetId_ = dataset.id;
|
|
696
741
|
}
|
|
697
742
|
if (datasetId_ !== undefined) {
|
|
743
|
+
assertUuid(datasetId_);
|
|
698
744
|
path += `/${datasetId_}`;
|
|
699
745
|
}
|
|
700
746
|
else {
|
|
@@ -758,6 +804,7 @@ export class Client {
|
|
|
758
804
|
return this.createExample({ input: finalInput }, { output: finalOutput }, options);
|
|
759
805
|
}
|
|
760
806
|
async readExample(exampleId) {
|
|
807
|
+
assertUuid(exampleId);
|
|
761
808
|
const path = `/examples/${exampleId}`;
|
|
762
809
|
return await this._get(path);
|
|
763
810
|
}
|
|
@@ -787,6 +834,7 @@ export class Client {
|
|
|
787
834
|
}
|
|
788
835
|
}
|
|
789
836
|
async deleteExample(exampleId) {
|
|
837
|
+
assertUuid(exampleId);
|
|
790
838
|
const path = `/examples/${exampleId}`;
|
|
791
839
|
const response = await this.caller.call(fetch, this.apiUrl + path, {
|
|
792
840
|
method: "DELETE",
|
|
@@ -799,6 +847,7 @@ export class Client {
|
|
|
799
847
|
await response.json();
|
|
800
848
|
}
|
|
801
849
|
async updateExample(exampleId, update) {
|
|
850
|
+
assertUuid(exampleId);
|
|
802
851
|
const response = await this.caller.call(fetch, `${this.apiUrl}/examples/${exampleId}`, {
|
|
803
852
|
method: "PATCH",
|
|
804
853
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -851,6 +900,10 @@ export class Client {
|
|
|
851
900
|
!feedback_source.metadata["__run"]) {
|
|
852
901
|
feedback_source.metadata["__run"] = { run_id: sourceRunId };
|
|
853
902
|
}
|
|
903
|
+
if (feedback_source?.metadata !== undefined &&
|
|
904
|
+
feedback_source.metadata["__run"]?.run_id !== undefined) {
|
|
905
|
+
assertUuid(feedback_source.metadata["__run"].run_id);
|
|
906
|
+
}
|
|
854
907
|
const feedback = {
|
|
855
908
|
id: feedbackId ?? uuid.v4(),
|
|
856
909
|
run_id: runId,
|
|
@@ -885,6 +938,7 @@ export class Client {
|
|
|
885
938
|
if (comment !== undefined && comment !== null) {
|
|
886
939
|
feedbackUpdate["comment"] = comment;
|
|
887
940
|
}
|
|
941
|
+
assertUuid(feedbackId);
|
|
888
942
|
const response = await this.caller.call(fetch, `${this.apiUrl}/feedback/${feedbackId}`, {
|
|
889
943
|
method: "PATCH",
|
|
890
944
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -894,11 +948,13 @@ export class Client {
|
|
|
894
948
|
await raiseForStatus(response, "update feedback");
|
|
895
949
|
}
|
|
896
950
|
async readFeedback(feedbackId) {
|
|
951
|
+
assertUuid(feedbackId);
|
|
897
952
|
const path = `/feedback/${feedbackId}`;
|
|
898
953
|
const response = await this._get(path);
|
|
899
954
|
return response;
|
|
900
955
|
}
|
|
901
956
|
async deleteFeedback(feedbackId) {
|
|
957
|
+
assertUuid(feedbackId);
|
|
902
958
|
const path = `/feedback/${feedbackId}`;
|
|
903
959
|
const response = await this.caller.call(fetch, this.apiUrl + path, {
|
|
904
960
|
method: "DELETE",
|
package/dist/schemas.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface Run extends BaseRun {
|
|
|
70
70
|
/** A unique identifier for the run, mandatory when loaded from DB. */
|
|
71
71
|
id: string;
|
|
72
72
|
/** Defines the sequence in which the run was executed. */
|
|
73
|
-
execution_order
|
|
73
|
+
execution_order?: number;
|
|
74
74
|
/** The ID of the project that owns this run. */
|
|
75
75
|
session_id?: string;
|
|
76
76
|
/** IDs of any child runs spawned by this run. */
|