langsmith 0.0.41 → 0.0.43
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 +41 -1
- package/dist/client.d.ts +9 -1
- package/dist/client.js +41 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -156,7 +156,7 @@ class Client {
|
|
|
156
156
|
}
|
|
157
157
|
return headers;
|
|
158
158
|
}
|
|
159
|
-
async
|
|
159
|
+
async _getResponse(path, queryParams) {
|
|
160
160
|
const paramsString = queryParams?.toString() ?? "";
|
|
161
161
|
const url = `${this.apiUrl}${path}?${paramsString}`;
|
|
162
162
|
const response = await this.caller.call(fetch, url, {
|
|
@@ -167,6 +167,10 @@ class Client {
|
|
|
167
167
|
if (!response.ok) {
|
|
168
168
|
throw new Error(`Failed to fetch ${path}: ${response.status} ${response.statusText}`);
|
|
169
169
|
}
|
|
170
|
+
return response;
|
|
171
|
+
}
|
|
172
|
+
async _get(path, queryParams) {
|
|
173
|
+
const response = await this._getResponse(path, queryParams);
|
|
170
174
|
return response.json();
|
|
171
175
|
}
|
|
172
176
|
async *_getPaginated(path, queryParams = new URLSearchParams()) {
|
|
@@ -393,6 +397,23 @@ class Client {
|
|
|
393
397
|
}
|
|
394
398
|
return `${this.getHostUrl()}/public/${result["share_token"]}/r`;
|
|
395
399
|
}
|
|
400
|
+
async listSharedRuns(shareToken, { runIds, } = {}) {
|
|
401
|
+
const queryParams = new URLSearchParams({
|
|
402
|
+
share_token: shareToken,
|
|
403
|
+
});
|
|
404
|
+
if (runIds !== undefined) {
|
|
405
|
+
for (const runId of runIds) {
|
|
406
|
+
queryParams.append("id", runId);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const response = await this.caller.call(fetch, `${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
|
|
410
|
+
method: "GET",
|
|
411
|
+
headers: this.headers,
|
|
412
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
413
|
+
});
|
|
414
|
+
const runs = await response.json();
|
|
415
|
+
return runs;
|
|
416
|
+
}
|
|
396
417
|
async createProject({ projectName, projectExtra, upsert, referenceDatasetId, }) {
|
|
397
418
|
const upsert_ = upsert ? `?upsert=true` : "";
|
|
398
419
|
const endpoint = `${this.apiUrl}/sessions${upsert_}`;
|
|
@@ -594,6 +615,25 @@ class Client {
|
|
|
594
615
|
}
|
|
595
616
|
return result;
|
|
596
617
|
}
|
|
618
|
+
async readDatasetOpenaiFinetuning({ datasetId, datasetName, }) {
|
|
619
|
+
const path = "/datasets";
|
|
620
|
+
if (datasetId !== undefined) {
|
|
621
|
+
// do nothing
|
|
622
|
+
}
|
|
623
|
+
else if (datasetName !== undefined) {
|
|
624
|
+
datasetId = (await this.readDataset({ datasetName })).id;
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
throw new Error("Must provide datasetName or datasetId");
|
|
628
|
+
}
|
|
629
|
+
const response = await this._getResponse(`${path}/${datasetId}/openai_ft`);
|
|
630
|
+
const datasetText = await response.text();
|
|
631
|
+
const dataset = datasetText
|
|
632
|
+
.trim()
|
|
633
|
+
.split("\n")
|
|
634
|
+
.map((line) => JSON.parse(line));
|
|
635
|
+
return dataset;
|
|
636
|
+
}
|
|
597
637
|
async *listDatasets({ limit = 100, offset = 0, datasetIds, datasetName, datasetNameContains, } = {}) {
|
|
598
638
|
const path = "/datasets";
|
|
599
639
|
const params = new URLSearchParams({
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncCallerParams } from "./utils/async_caller.js";
|
|
2
|
-
import { Dataset, Example, ExampleUpdate, Feedback, KVMap, Run, RunCreate, RunUpdate, ScoreType, TracerSession, TracerSessionResult, ValueType
|
|
2
|
+
import { DataType, Dataset, Example, ExampleUpdate, Feedback, KVMap, LangChainBaseMessage, Run, RunCreate, RunUpdate, ScoreType, TracerSession, TracerSessionResult, ValueType } from "./schemas.js";
|
|
3
3
|
import { RunEvaluator } from "./evaluation/evaluator.js";
|
|
4
4
|
interface ClientConfig {
|
|
5
5
|
apiUrl?: string;
|
|
@@ -76,6 +76,7 @@ export declare class Client {
|
|
|
76
76
|
private validateApiKeyIfHosted;
|
|
77
77
|
private getHostUrl;
|
|
78
78
|
private get headers();
|
|
79
|
+
private _getResponse;
|
|
79
80
|
private _get;
|
|
80
81
|
private _getPaginated;
|
|
81
82
|
createRun(run: CreateRunParams): Promise<void>;
|
|
@@ -95,6 +96,9 @@ export declare class Client {
|
|
|
95
96
|
}): Promise<string>;
|
|
96
97
|
unshareRun(runId: string): Promise<void>;
|
|
97
98
|
readRunSharedLink(runId: string): Promise<string | undefined>;
|
|
99
|
+
listSharedRuns(shareToken: string, { runIds, }?: {
|
|
100
|
+
runIds?: string[];
|
|
101
|
+
}): Promise<Run[]>;
|
|
98
102
|
createProject({ projectName, projectExtra, upsert, referenceDatasetId, }: {
|
|
99
103
|
projectName: string;
|
|
100
104
|
projectExtra?: object;
|
|
@@ -127,6 +131,10 @@ export declare class Client {
|
|
|
127
131
|
datasetId?: string;
|
|
128
132
|
datasetName?: string;
|
|
129
133
|
}): Promise<Dataset>;
|
|
134
|
+
readDatasetOpenaiFinetuning({ datasetId, datasetName, }: {
|
|
135
|
+
datasetId?: string;
|
|
136
|
+
datasetName?: string;
|
|
137
|
+
}): Promise<any[]>;
|
|
130
138
|
listDatasets({ limit, offset, datasetIds, datasetName, datasetNameContains, }?: {
|
|
131
139
|
limit?: number;
|
|
132
140
|
offset?: number;
|
package/dist/client.js
CHANGED
|
@@ -130,7 +130,7 @@ export class Client {
|
|
|
130
130
|
}
|
|
131
131
|
return headers;
|
|
132
132
|
}
|
|
133
|
-
async
|
|
133
|
+
async _getResponse(path, queryParams) {
|
|
134
134
|
const paramsString = queryParams?.toString() ?? "";
|
|
135
135
|
const url = `${this.apiUrl}${path}?${paramsString}`;
|
|
136
136
|
const response = await this.caller.call(fetch, url, {
|
|
@@ -141,6 +141,10 @@ export class Client {
|
|
|
141
141
|
if (!response.ok) {
|
|
142
142
|
throw new Error(`Failed to fetch ${path}: ${response.status} ${response.statusText}`);
|
|
143
143
|
}
|
|
144
|
+
return response;
|
|
145
|
+
}
|
|
146
|
+
async _get(path, queryParams) {
|
|
147
|
+
const response = await this._getResponse(path, queryParams);
|
|
144
148
|
return response.json();
|
|
145
149
|
}
|
|
146
150
|
async *_getPaginated(path, queryParams = new URLSearchParams()) {
|
|
@@ -367,6 +371,23 @@ export class Client {
|
|
|
367
371
|
}
|
|
368
372
|
return `${this.getHostUrl()}/public/${result["share_token"]}/r`;
|
|
369
373
|
}
|
|
374
|
+
async listSharedRuns(shareToken, { runIds, } = {}) {
|
|
375
|
+
const queryParams = new URLSearchParams({
|
|
376
|
+
share_token: shareToken,
|
|
377
|
+
});
|
|
378
|
+
if (runIds !== undefined) {
|
|
379
|
+
for (const runId of runIds) {
|
|
380
|
+
queryParams.append("id", runId);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const response = await this.caller.call(fetch, `${this.apiUrl}/public/${shareToken}/runs${queryParams}`, {
|
|
384
|
+
method: "GET",
|
|
385
|
+
headers: this.headers,
|
|
386
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
387
|
+
});
|
|
388
|
+
const runs = await response.json();
|
|
389
|
+
return runs;
|
|
390
|
+
}
|
|
370
391
|
async createProject({ projectName, projectExtra, upsert, referenceDatasetId, }) {
|
|
371
392
|
const upsert_ = upsert ? `?upsert=true` : "";
|
|
372
393
|
const endpoint = `${this.apiUrl}/sessions${upsert_}`;
|
|
@@ -568,6 +589,25 @@ export class Client {
|
|
|
568
589
|
}
|
|
569
590
|
return result;
|
|
570
591
|
}
|
|
592
|
+
async readDatasetOpenaiFinetuning({ datasetId, datasetName, }) {
|
|
593
|
+
const path = "/datasets";
|
|
594
|
+
if (datasetId !== undefined) {
|
|
595
|
+
// do nothing
|
|
596
|
+
}
|
|
597
|
+
else if (datasetName !== undefined) {
|
|
598
|
+
datasetId = (await this.readDataset({ datasetName })).id;
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
throw new Error("Must provide datasetName or datasetId");
|
|
602
|
+
}
|
|
603
|
+
const response = await this._getResponse(`${path}/${datasetId}/openai_ft`);
|
|
604
|
+
const datasetText = await response.text();
|
|
605
|
+
const dataset = datasetText
|
|
606
|
+
.trim()
|
|
607
|
+
.split("\n")
|
|
608
|
+
.map((line) => JSON.parse(line));
|
|
609
|
+
return dataset;
|
|
610
|
+
}
|
|
571
611
|
async *listDatasets({ limit = 100, offset = 0, datasetIds, datasetName, datasetNameContains, } = {}) {
|
|
572
612
|
const path = "/datasets";
|
|
573
613
|
const params = new URLSearchParams({
|