langsmith 0.0.46 → 0.0.48
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/cli/nginx.conf +1 -1
- package/dist/client.cjs +29 -0
- package/dist/client.js +29 -0
- package/package.json +1 -1
package/dist/cli/nginx.conf
CHANGED
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,
|
|
@@ -500,6 +515,7 @@ class Client {
|
|
|
500
515
|
throw new Error("Must provide either projectName or projectId, not both");
|
|
501
516
|
}
|
|
502
517
|
else if (projectId !== undefined) {
|
|
518
|
+
assertUuid(projectId);
|
|
503
519
|
path += `/${projectId}`;
|
|
504
520
|
}
|
|
505
521
|
else if (projectName !== undefined) {
|
|
@@ -575,6 +591,7 @@ class Client {
|
|
|
575
591
|
else {
|
|
576
592
|
projectId_ = projectId;
|
|
577
593
|
}
|
|
594
|
+
assertUuid(projectId_);
|
|
578
595
|
const response = await this.caller.call(fetch, `${this.apiUrl}/sessions/${projectId_}`, {
|
|
579
596
|
method: "DELETE",
|
|
580
597
|
headers: this.headers,
|
|
@@ -649,6 +666,7 @@ class Client {
|
|
|
649
666
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
650
667
|
}
|
|
651
668
|
else if (datasetId !== undefined) {
|
|
669
|
+
assertUuid(datasetId);
|
|
652
670
|
path += `/${datasetId}`;
|
|
653
671
|
}
|
|
654
672
|
else if (datasetName !== undefined) {
|
|
@@ -721,6 +739,7 @@ class Client {
|
|
|
721
739
|
datasetId_ = dataset.id;
|
|
722
740
|
}
|
|
723
741
|
if (datasetId_ !== undefined) {
|
|
742
|
+
assertUuid(datasetId_);
|
|
724
743
|
path += `/${datasetId_}`;
|
|
725
744
|
}
|
|
726
745
|
else {
|
|
@@ -784,6 +803,7 @@ class Client {
|
|
|
784
803
|
return this.createExample({ input: finalInput }, { output: finalOutput }, options);
|
|
785
804
|
}
|
|
786
805
|
async readExample(exampleId) {
|
|
806
|
+
assertUuid(exampleId);
|
|
787
807
|
const path = `/examples/${exampleId}`;
|
|
788
808
|
return await this._get(path);
|
|
789
809
|
}
|
|
@@ -813,6 +833,7 @@ class Client {
|
|
|
813
833
|
}
|
|
814
834
|
}
|
|
815
835
|
async deleteExample(exampleId) {
|
|
836
|
+
assertUuid(exampleId);
|
|
816
837
|
const path = `/examples/${exampleId}`;
|
|
817
838
|
const response = await this.caller.call(fetch, this.apiUrl + path, {
|
|
818
839
|
method: "DELETE",
|
|
@@ -825,6 +846,7 @@ class Client {
|
|
|
825
846
|
await response.json();
|
|
826
847
|
}
|
|
827
848
|
async updateExample(exampleId, update) {
|
|
849
|
+
assertUuid(exampleId);
|
|
828
850
|
const response = await this.caller.call(fetch, `${this.apiUrl}/examples/${exampleId}`, {
|
|
829
851
|
method: "PATCH",
|
|
830
852
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -877,6 +899,10 @@ class Client {
|
|
|
877
899
|
!feedback_source.metadata["__run"]) {
|
|
878
900
|
feedback_source.metadata["__run"] = { run_id: sourceRunId };
|
|
879
901
|
}
|
|
902
|
+
if (feedback_source?.metadata !== undefined &&
|
|
903
|
+
feedback_source.metadata["__run"]?.run_id !== undefined) {
|
|
904
|
+
assertUuid(feedback_source.metadata["__run"].run_id);
|
|
905
|
+
}
|
|
880
906
|
const feedback = {
|
|
881
907
|
id: feedbackId ?? uuid.v4(),
|
|
882
908
|
run_id: runId,
|
|
@@ -911,6 +937,7 @@ class Client {
|
|
|
911
937
|
if (comment !== undefined && comment !== null) {
|
|
912
938
|
feedbackUpdate["comment"] = comment;
|
|
913
939
|
}
|
|
940
|
+
assertUuid(feedbackId);
|
|
914
941
|
const response = await this.caller.call(fetch, `${this.apiUrl}/feedback/${feedbackId}`, {
|
|
915
942
|
method: "PATCH",
|
|
916
943
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -920,11 +947,13 @@ class Client {
|
|
|
920
947
|
await raiseForStatus(response, "update feedback");
|
|
921
948
|
}
|
|
922
949
|
async readFeedback(feedbackId) {
|
|
950
|
+
assertUuid(feedbackId);
|
|
923
951
|
const path = `/feedback/${feedbackId}`;
|
|
924
952
|
const response = await this._get(path);
|
|
925
953
|
return response;
|
|
926
954
|
}
|
|
927
955
|
async deleteFeedback(feedbackId) {
|
|
956
|
+
assertUuid(feedbackId);
|
|
928
957
|
const path = `/feedback/${feedbackId}`;
|
|
929
958
|
const response = await this.caller.call(fetch, this.apiUrl + path, {
|
|
930
959
|
method: "DELETE",
|
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,
|
|
@@ -474,6 +489,7 @@ export class Client {
|
|
|
474
489
|
throw new Error("Must provide either projectName or projectId, not both");
|
|
475
490
|
}
|
|
476
491
|
else if (projectId !== undefined) {
|
|
492
|
+
assertUuid(projectId);
|
|
477
493
|
path += `/${projectId}`;
|
|
478
494
|
}
|
|
479
495
|
else if (projectName !== undefined) {
|
|
@@ -549,6 +565,7 @@ export class Client {
|
|
|
549
565
|
else {
|
|
550
566
|
projectId_ = projectId;
|
|
551
567
|
}
|
|
568
|
+
assertUuid(projectId_);
|
|
552
569
|
const response = await this.caller.call(fetch, `${this.apiUrl}/sessions/${projectId_}`, {
|
|
553
570
|
method: "DELETE",
|
|
554
571
|
headers: this.headers,
|
|
@@ -623,6 +640,7 @@ export class Client {
|
|
|
623
640
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
624
641
|
}
|
|
625
642
|
else if (datasetId !== undefined) {
|
|
643
|
+
assertUuid(datasetId);
|
|
626
644
|
path += `/${datasetId}`;
|
|
627
645
|
}
|
|
628
646
|
else if (datasetName !== undefined) {
|
|
@@ -695,6 +713,7 @@ export class Client {
|
|
|
695
713
|
datasetId_ = dataset.id;
|
|
696
714
|
}
|
|
697
715
|
if (datasetId_ !== undefined) {
|
|
716
|
+
assertUuid(datasetId_);
|
|
698
717
|
path += `/${datasetId_}`;
|
|
699
718
|
}
|
|
700
719
|
else {
|
|
@@ -758,6 +777,7 @@ export class Client {
|
|
|
758
777
|
return this.createExample({ input: finalInput }, { output: finalOutput }, options);
|
|
759
778
|
}
|
|
760
779
|
async readExample(exampleId) {
|
|
780
|
+
assertUuid(exampleId);
|
|
761
781
|
const path = `/examples/${exampleId}`;
|
|
762
782
|
return await this._get(path);
|
|
763
783
|
}
|
|
@@ -787,6 +807,7 @@ export class Client {
|
|
|
787
807
|
}
|
|
788
808
|
}
|
|
789
809
|
async deleteExample(exampleId) {
|
|
810
|
+
assertUuid(exampleId);
|
|
790
811
|
const path = `/examples/${exampleId}`;
|
|
791
812
|
const response = await this.caller.call(fetch, this.apiUrl + path, {
|
|
792
813
|
method: "DELETE",
|
|
@@ -799,6 +820,7 @@ export class Client {
|
|
|
799
820
|
await response.json();
|
|
800
821
|
}
|
|
801
822
|
async updateExample(exampleId, update) {
|
|
823
|
+
assertUuid(exampleId);
|
|
802
824
|
const response = await this.caller.call(fetch, `${this.apiUrl}/examples/${exampleId}`, {
|
|
803
825
|
method: "PATCH",
|
|
804
826
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -851,6 +873,10 @@ export class Client {
|
|
|
851
873
|
!feedback_source.metadata["__run"]) {
|
|
852
874
|
feedback_source.metadata["__run"] = { run_id: sourceRunId };
|
|
853
875
|
}
|
|
876
|
+
if (feedback_source?.metadata !== undefined &&
|
|
877
|
+
feedback_source.metadata["__run"]?.run_id !== undefined) {
|
|
878
|
+
assertUuid(feedback_source.metadata["__run"].run_id);
|
|
879
|
+
}
|
|
854
880
|
const feedback = {
|
|
855
881
|
id: feedbackId ?? uuid.v4(),
|
|
856
882
|
run_id: runId,
|
|
@@ -885,6 +911,7 @@ export class Client {
|
|
|
885
911
|
if (comment !== undefined && comment !== null) {
|
|
886
912
|
feedbackUpdate["comment"] = comment;
|
|
887
913
|
}
|
|
914
|
+
assertUuid(feedbackId);
|
|
888
915
|
const response = await this.caller.call(fetch, `${this.apiUrl}/feedback/${feedbackId}`, {
|
|
889
916
|
method: "PATCH",
|
|
890
917
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -894,11 +921,13 @@ export class Client {
|
|
|
894
921
|
await raiseForStatus(response, "update feedback");
|
|
895
922
|
}
|
|
896
923
|
async readFeedback(feedbackId) {
|
|
924
|
+
assertUuid(feedbackId);
|
|
897
925
|
const path = `/feedback/${feedbackId}`;
|
|
898
926
|
const response = await this._get(path);
|
|
899
927
|
return response;
|
|
900
928
|
}
|
|
901
929
|
async deleteFeedback(feedbackId) {
|
|
930
|
+
assertUuid(feedbackId);
|
|
902
931
|
const path = `/feedback/${feedbackId}`;
|
|
903
932
|
const response = await this.caller.call(fetch, this.apiUrl + path, {
|
|
904
933
|
method: "DELETE",
|