langsmith 0.0.50 → 0.0.51
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 +42 -41
- package/dist/client.d.ts +2 -2
- package/dist/client.js +42 -41
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -208,6 +208,33 @@ class Client {
|
|
|
208
208
|
offset += items.length;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
+
async *_getCursorPaginatedList(path, body = null, requestMethod = "POST", dataKey = "runs") {
|
|
212
|
+
let bodyParams = body ? { ...body } : {};
|
|
213
|
+
while (true) {
|
|
214
|
+
const response = await this.caller.call(fetch, `${this.apiUrl}${path}`, {
|
|
215
|
+
method: requestMethod,
|
|
216
|
+
headers: this.headers,
|
|
217
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
218
|
+
body: JSON.stringify(bodyParams),
|
|
219
|
+
});
|
|
220
|
+
const responseBody = await response.json();
|
|
221
|
+
if (!responseBody) {
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
if (!responseBody[dataKey]) {
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
yield responseBody[dataKey];
|
|
228
|
+
const cursors = responseBody.cursors;
|
|
229
|
+
if (!cursors) {
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
if (!cursors.next) {
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
bodyParams.cursor = cursors.next;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
211
238
|
async createRun(run) {
|
|
212
239
|
const headers = { ...this.headers, "Content-Type": "application/json" };
|
|
213
240
|
const extra = run.extra ?? {};
|
|
@@ -320,8 +347,7 @@ class Client {
|
|
|
320
347
|
}
|
|
321
348
|
return run;
|
|
322
349
|
}
|
|
323
|
-
async *listRuns({ projectId, projectName, parentRunId, referenceExampleId, startTime, executionOrder, runType, error, id,
|
|
324
|
-
const queryParams = new URLSearchParams();
|
|
350
|
+
async *listRuns({ projectId, projectName, parentRunId, referenceExampleId, startTime, executionOrder, runType, error, id, query, filter, limit, }) {
|
|
325
351
|
let projectId_ = projectId;
|
|
326
352
|
if (projectName) {
|
|
327
353
|
if (projectId) {
|
|
@@ -329,45 +355,20 @@ class Client {
|
|
|
329
355
|
}
|
|
330
356
|
projectId_ = (await this.readProject({ projectName })).id;
|
|
331
357
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
if (runType) {
|
|
348
|
-
queryParams.append("run_type", runType);
|
|
349
|
-
}
|
|
350
|
-
if (error !== undefined) {
|
|
351
|
-
queryParams.append("error", error.toString());
|
|
352
|
-
}
|
|
353
|
-
if (id !== undefined) {
|
|
354
|
-
for (const id_ of id) {
|
|
355
|
-
queryParams.append("id", id_);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
if (limit !== undefined) {
|
|
359
|
-
queryParams.append("limit", limit.toString());
|
|
360
|
-
}
|
|
361
|
-
if (offset !== undefined) {
|
|
362
|
-
queryParams.append("offset", offset.toString());
|
|
363
|
-
}
|
|
364
|
-
if (query !== undefined) {
|
|
365
|
-
queryParams.append("query", query);
|
|
366
|
-
}
|
|
367
|
-
if (filter !== undefined) {
|
|
368
|
-
queryParams.append("filter", filter);
|
|
369
|
-
}
|
|
370
|
-
for await (const runs of this._getPaginated("/runs", queryParams)) {
|
|
358
|
+
const body = {
|
|
359
|
+
session: projectId_ ? [projectId_] : null,
|
|
360
|
+
run_type: runType,
|
|
361
|
+
reference_example: referenceExampleId,
|
|
362
|
+
query,
|
|
363
|
+
filter,
|
|
364
|
+
execution_order: executionOrder,
|
|
365
|
+
parent_run: parentRunId ? [parentRunId] : null,
|
|
366
|
+
start_time: startTime ? startTime.toISOString() : null,
|
|
367
|
+
error,
|
|
368
|
+
id,
|
|
369
|
+
limit,
|
|
370
|
+
};
|
|
371
|
+
for await (const runs of this._getCursorPaginatedList("/runs", body)) {
|
|
371
372
|
yield* runs;
|
|
372
373
|
}
|
|
373
374
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ interface ListRunsParams {
|
|
|
19
19
|
error?: boolean;
|
|
20
20
|
id?: string[];
|
|
21
21
|
limit?: number;
|
|
22
|
-
offset?: number;
|
|
23
22
|
query?: string;
|
|
24
23
|
filter?: string;
|
|
25
24
|
}
|
|
@@ -79,6 +78,7 @@ export declare class Client {
|
|
|
79
78
|
private _getResponse;
|
|
80
79
|
private _get;
|
|
81
80
|
private _getPaginated;
|
|
81
|
+
private _getCursorPaginatedList;
|
|
82
82
|
createRun(run: CreateRunParams): Promise<void>;
|
|
83
83
|
updateRun(runId: string, run: RunUpdate): Promise<void>;
|
|
84
84
|
readRun(runId: string, { loadChildRuns }?: {
|
|
@@ -90,7 +90,7 @@ export declare class Client {
|
|
|
90
90
|
projectOpts?: projectOptions;
|
|
91
91
|
}): Promise<string>;
|
|
92
92
|
private _loadChildRuns;
|
|
93
|
-
listRuns({ projectId, projectName, parentRunId, referenceExampleId, startTime, executionOrder, runType, error, id,
|
|
93
|
+
listRuns({ projectId, projectName, parentRunId, referenceExampleId, startTime, executionOrder, runType, error, id, query, filter, limit, }: ListRunsParams): AsyncIterable<Run>;
|
|
94
94
|
shareRun(runId: string, { shareId }?: {
|
|
95
95
|
shareId?: string;
|
|
96
96
|
}): Promise<string>;
|
package/dist/client.js
CHANGED
|
@@ -182,6 +182,33 @@ export class Client {
|
|
|
182
182
|
offset += items.length;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
+
async *_getCursorPaginatedList(path, body = null, requestMethod = "POST", dataKey = "runs") {
|
|
186
|
+
let bodyParams = body ? { ...body } : {};
|
|
187
|
+
while (true) {
|
|
188
|
+
const response = await this.caller.call(fetch, `${this.apiUrl}${path}`, {
|
|
189
|
+
method: requestMethod,
|
|
190
|
+
headers: this.headers,
|
|
191
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
192
|
+
body: JSON.stringify(bodyParams),
|
|
193
|
+
});
|
|
194
|
+
const responseBody = await response.json();
|
|
195
|
+
if (!responseBody) {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
if (!responseBody[dataKey]) {
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
yield responseBody[dataKey];
|
|
202
|
+
const cursors = responseBody.cursors;
|
|
203
|
+
if (!cursors) {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
if (!cursors.next) {
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
bodyParams.cursor = cursors.next;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
185
212
|
async createRun(run) {
|
|
186
213
|
const headers = { ...this.headers, "Content-Type": "application/json" };
|
|
187
214
|
const extra = run.extra ?? {};
|
|
@@ -294,8 +321,7 @@ export class Client {
|
|
|
294
321
|
}
|
|
295
322
|
return run;
|
|
296
323
|
}
|
|
297
|
-
async *listRuns({ projectId, projectName, parentRunId, referenceExampleId, startTime, executionOrder, runType, error, id,
|
|
298
|
-
const queryParams = new URLSearchParams();
|
|
324
|
+
async *listRuns({ projectId, projectName, parentRunId, referenceExampleId, startTime, executionOrder, runType, error, id, query, filter, limit, }) {
|
|
299
325
|
let projectId_ = projectId;
|
|
300
326
|
if (projectName) {
|
|
301
327
|
if (projectId) {
|
|
@@ -303,45 +329,20 @@ export class Client {
|
|
|
303
329
|
}
|
|
304
330
|
projectId_ = (await this.readProject({ projectName })).id;
|
|
305
331
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
if (runType) {
|
|
322
|
-
queryParams.append("run_type", runType);
|
|
323
|
-
}
|
|
324
|
-
if (error !== undefined) {
|
|
325
|
-
queryParams.append("error", error.toString());
|
|
326
|
-
}
|
|
327
|
-
if (id !== undefined) {
|
|
328
|
-
for (const id_ of id) {
|
|
329
|
-
queryParams.append("id", id_);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
if (limit !== undefined) {
|
|
333
|
-
queryParams.append("limit", limit.toString());
|
|
334
|
-
}
|
|
335
|
-
if (offset !== undefined) {
|
|
336
|
-
queryParams.append("offset", offset.toString());
|
|
337
|
-
}
|
|
338
|
-
if (query !== undefined) {
|
|
339
|
-
queryParams.append("query", query);
|
|
340
|
-
}
|
|
341
|
-
if (filter !== undefined) {
|
|
342
|
-
queryParams.append("filter", filter);
|
|
343
|
-
}
|
|
344
|
-
for await (const runs of this._getPaginated("/runs", queryParams)) {
|
|
332
|
+
const body = {
|
|
333
|
+
session: projectId_ ? [projectId_] : null,
|
|
334
|
+
run_type: runType,
|
|
335
|
+
reference_example: referenceExampleId,
|
|
336
|
+
query,
|
|
337
|
+
filter,
|
|
338
|
+
execution_order: executionOrder,
|
|
339
|
+
parent_run: parentRunId ? [parentRunId] : null,
|
|
340
|
+
start_time: startTime ? startTime.toISOString() : null,
|
|
341
|
+
error,
|
|
342
|
+
id,
|
|
343
|
+
limit,
|
|
344
|
+
};
|
|
345
|
+
for await (const runs of this._getCursorPaginatedList("/runs", body)) {
|
|
345
346
|
yield* runs;
|
|
346
347
|
}
|
|
347
348
|
}
|