langsmith 0.0.50 → 0.0.52

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 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, limit, offset, query, filter, }) {
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
- if (projectId_) {
333
- queryParams.append("session", projectId_);
334
- }
335
- if (parentRunId) {
336
- queryParams.append("parent_run", parentRunId);
337
- }
338
- if (referenceExampleId) {
339
- queryParams.append("reference_example", referenceExampleId);
340
- }
341
- if (startTime) {
342
- queryParams.append("start_time", startTime.toISOString());
343
- }
344
- if (executionOrder) {
345
- queryParams.append("execution_order", executionOrder.toString());
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, limit, offset, query, filter, }: ListRunsParams): AsyncIterable<Run>;
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, limit, offset, query, filter, }) {
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
- if (projectId_) {
307
- queryParams.append("session", projectId_);
308
- }
309
- if (parentRunId) {
310
- queryParams.append("parent_run", parentRunId);
311
- }
312
- if (referenceExampleId) {
313
- queryParams.append("reference_example", referenceExampleId);
314
- }
315
- if (startTime) {
316
- queryParams.append("start_time", startTime.toISOString());
317
- }
318
- if (executionOrder) {
319
- queryParams.append("execution_order", executionOrder.toString());
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
  }
package/dist/schemas.d.ts CHANGED
@@ -2,6 +2,8 @@ export interface TracerSession {
2
2
  tenant_id: string;
3
3
  id: string;
4
4
  start_time: number;
5
+ end_time?: number;
6
+ description?: string;
5
7
  name?: string;
6
8
  }
7
9
  export interface TracerSessionResult extends TracerSession {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "files": [
6
6
  "dist/",