langsmith 0.8.0 → 0.8.2
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/_openapi_client/client.d.ts +2 -2
- package/dist/_openapi_client/resources/index.d.ts +1 -1
- package/dist/_openapi_client/resources/online-evaluators.d.ts +5 -0
- package/dist/_openapi_client/resources/runs.d.ts +4 -0
- package/dist/_openapi_client/resources/sandboxes/boxes.cjs +1 -2
- package/dist/_openapi_client/resources/sandboxes/boxes.d.ts +99 -6
- package/dist/_openapi_client/resources/sandboxes/boxes.js +1 -2
- package/dist/_openapi_client/resources/sandboxes/sandboxes.d.ts +98 -4
- package/dist/_openapi_client/resources/threads.cjs +9 -6
- package/dist/_openapi_client/resources/threads.d.ts +200 -189
- package/dist/_openapi_client/resources/threads.js +9 -6
- package/dist/client.cjs +63 -8
- package/dist/client.d.ts +19 -3
- package/dist/client.js +63 -8
- package/dist/index.cjs +16 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/schemas.d.ts +15 -0
- package/dist/utils/constants.cjs +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ export declare class Threads extends APIResource {
|
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
12
|
* // Automatically fetches more pages as needed.
|
|
13
|
-
* for await (const
|
|
13
|
+
* for await (const threadTrace of client.threads.listTraces(
|
|
14
14
|
* 'thread_id',
|
|
15
15
|
* { project_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
|
|
16
16
|
* )) {
|
|
@@ -18,7 +18,7 @@ export declare class Threads extends APIResource {
|
|
|
18
18
|
* }
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
listTraces(threadID: string, query: ThreadListTracesParams, options?: RequestOptions): PagePromise<
|
|
21
|
+
listTraces(threadID: string, query: ThreadListTracesParams, options?: RequestOptions): PagePromise<ThreadTracesItemsCursorGetPagination, ThreadTrace>;
|
|
22
22
|
/**
|
|
23
23
|
* **Alpha:** The request and response contract may change; Query threads within a
|
|
24
24
|
* project (session), with cursor-based pagination. Returns threads matching the
|
|
@@ -27,12 +27,12 @@ export declare class Threads extends APIResource {
|
|
|
27
27
|
* @example
|
|
28
28
|
* ```ts
|
|
29
29
|
* // Automatically fetches more pages as needed.
|
|
30
|
-
* for await (const
|
|
30
|
+
* for await (const thread of client.threads.query()) {
|
|
31
31
|
* // ...
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
query(body: ThreadQueryParams, options?: RequestOptions): PagePromise<
|
|
35
|
+
query(body: ThreadQueryParams, options?: RequestOptions): PagePromise<ThreadsItemsCursorPostPagination, Thread>;
|
|
36
36
|
/**
|
|
37
37
|
* **Alpha:** The request and response contract may change; Compute aggregate stats
|
|
38
38
|
* for a single thread (turn count, latency percentiles, token/cost sums, and
|
|
@@ -40,17 +40,20 @@ export declare class Threads extends APIResource {
|
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
|
-
* const
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* const threadStats = await client.threads.stats(
|
|
44
|
+
* 'thread_id',
|
|
45
|
+
* {
|
|
46
|
+
* selects: ['TURNS'],
|
|
47
|
+
* session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
|
|
48
|
+
* },
|
|
49
|
+
* );
|
|
47
50
|
* ```
|
|
48
51
|
*/
|
|
49
|
-
stats(threadID: string, query: ThreadStatsParams, options?: RequestOptions): APIPromise<
|
|
52
|
+
stats(threadID: string, query: ThreadStatsParams, options?: RequestOptions): APIPromise<ThreadStats>;
|
|
50
53
|
}
|
|
51
|
-
export type
|
|
52
|
-
export type
|
|
53
|
-
export interface
|
|
54
|
+
export type ThreadTracesItemsCursorGetPagination = ItemsCursorGetPagination<ThreadTrace>;
|
|
55
|
+
export type ThreadsItemsCursorPostPagination = ItemsCursorPostPagination<Thread>;
|
|
56
|
+
export interface Thread {
|
|
54
57
|
/**
|
|
55
58
|
* `count` is how many root traces (conversation turns) fall in this thread for the
|
|
56
59
|
* query time range.
|
|
@@ -61,7 +64,7 @@ export interface ThreadListItem {
|
|
|
61
64
|
* by feedback key; shape matches `feedback_stats` on a single run.
|
|
62
65
|
*/
|
|
63
66
|
feedback_stats?: {
|
|
64
|
-
[key: string]:
|
|
67
|
+
[key: string]: Thread.FeedbackStats;
|
|
65
68
|
};
|
|
66
69
|
/**
|
|
67
70
|
* `first_inputs` is a truncated preview of inputs from the earliest trace in the
|
|
@@ -156,7 +159,7 @@ export interface ThreadListItem {
|
|
|
156
159
|
*/
|
|
157
160
|
trace_id?: string;
|
|
158
161
|
}
|
|
159
|
-
export declare namespace
|
|
162
|
+
export declare namespace Thread {
|
|
160
163
|
interface FeedbackStats {
|
|
161
164
|
/**
|
|
162
165
|
* `avg` is the arithmetic mean of numeric feedback scores for this key on the run,
|
|
@@ -222,172 +225,7 @@ export declare namespace ThreadListItem {
|
|
|
222
225
|
};
|
|
223
226
|
}
|
|
224
227
|
}
|
|
225
|
-
export interface
|
|
226
|
-
/**
|
|
227
|
-
* `completion_cost` is the estimated USD cost for the completion. Omitted unless
|
|
228
|
-
* included in `selects`.
|
|
229
|
-
*/
|
|
230
|
-
completion_cost?: number;
|
|
231
|
-
/**
|
|
232
|
-
* `completion_cost_details` is the USD cost breakdown for completion-side
|
|
233
|
-
* categories; per-category values are under `raw`. Omitted unless included in
|
|
234
|
-
* `selects`.
|
|
235
|
-
*/
|
|
236
|
-
completion_cost_details?: ThreadTraceListItem.CompletionCostDetails;
|
|
237
|
-
/**
|
|
238
|
-
* `completion_token_details` is the completion-side token breakdown by category;
|
|
239
|
-
* per-category counts are under `raw`. Omitted unless included in `selects`.
|
|
240
|
-
*/
|
|
241
|
-
completion_token_details?: ThreadTraceListItem.CompletionTokenDetails;
|
|
242
|
-
/**
|
|
243
|
-
* `completion_tokens` is the completion-side token count. Omitted unless included
|
|
244
|
-
* in `selects`.
|
|
245
|
-
*/
|
|
246
|
-
completion_tokens?: number;
|
|
247
|
-
/**
|
|
248
|
-
* `end_time` is when the root run ended (RFC3339 date-time). JSON null if the run
|
|
249
|
-
* is still in progress. Omitted unless included in `selects`.
|
|
250
|
-
*/
|
|
251
|
-
end_time?: string;
|
|
252
|
-
/**
|
|
253
|
-
* `error_preview` is a short error summary when the run failed. Omitted unless
|
|
254
|
-
* included in `selects`.
|
|
255
|
-
*/
|
|
256
|
-
error_preview?: string;
|
|
257
|
-
/**
|
|
258
|
-
* `first_token_time` is when the first output token was produced (RFC3339
|
|
259
|
-
* date-time), for streamed runs when that metadata exists. Omitted unless included
|
|
260
|
-
* in `selects`.
|
|
261
|
-
*/
|
|
262
|
-
first_token_time?: string;
|
|
263
|
-
/**
|
|
264
|
-
* `inputs_preview` is a truncated text preview of inputs. Omitted unless included
|
|
265
|
-
* in `selects`.
|
|
266
|
-
*/
|
|
267
|
-
inputs_preview?: string;
|
|
268
|
-
/**
|
|
269
|
-
* `latency` is wall-clock duration from start to end in seconds. Omitted unless
|
|
270
|
-
* included in `selects`.
|
|
271
|
-
*/
|
|
272
|
-
latency?: number;
|
|
273
|
-
/**
|
|
274
|
-
* `name` is a human-readable label for the root run (for example the model name,
|
|
275
|
-
* function name, or step name chosen when the run was traced). Omitted unless
|
|
276
|
-
* included in `selects`.
|
|
277
|
-
*/
|
|
278
|
-
name?: string;
|
|
279
|
-
/**
|
|
280
|
-
* `op` is a numeric code identifying the root run's `run_type` (for example LLM
|
|
281
|
-
* vs. tool vs. chain). Encoded as a number for compatibility with legacy clients;
|
|
282
|
-
* prefer the string `run_type` on `RunResponse` when available. Omitted unless
|
|
283
|
-
* included in `selects`.
|
|
284
|
-
*/
|
|
285
|
-
op?: number;
|
|
286
|
-
/**
|
|
287
|
-
* `outputs_preview` is a truncated text preview of outputs. Omitted unless
|
|
288
|
-
* included in `selects`.
|
|
289
|
-
*/
|
|
290
|
-
outputs_preview?: string;
|
|
291
|
-
/**
|
|
292
|
-
* `prompt_cost` is the estimated USD cost for the prompt. Omitted unless included
|
|
293
|
-
* in `selects`.
|
|
294
|
-
*/
|
|
295
|
-
prompt_cost?: number;
|
|
296
|
-
/**
|
|
297
|
-
* `prompt_cost_details` is the USD cost breakdown for prompt-side categories;
|
|
298
|
-
* per-category values are under `raw`. Omitted unless included in `selects`.
|
|
299
|
-
*/
|
|
300
|
-
prompt_cost_details?: ThreadTraceListItem.PromptCostDetails;
|
|
301
|
-
/**
|
|
302
|
-
* `prompt_token_details` is the prompt-side token breakdown by category;
|
|
303
|
-
* per-category counts are under nested `raw`. Omitted unless included in
|
|
304
|
-
* `selects`.
|
|
305
|
-
*/
|
|
306
|
-
prompt_token_details?: ThreadTraceListItem.PromptTokenDetails;
|
|
307
|
-
/**
|
|
308
|
-
* `prompt_tokens` is the prompt-side token count. Omitted unless included in
|
|
309
|
-
* `selects`.
|
|
310
|
-
*/
|
|
311
|
-
prompt_tokens?: number;
|
|
312
|
-
/**
|
|
313
|
-
* `start_time` is when the trace started (RFC3339 date-time). Omitted unless
|
|
314
|
-
* included in `selects`.
|
|
315
|
-
*/
|
|
316
|
-
start_time?: string;
|
|
317
|
-
/**
|
|
318
|
-
* `thread_id` is the conversation thread UUID that contains this trace. Matches
|
|
319
|
-
* the `thread_id` path parameter of the request. Omitted unless included in
|
|
320
|
-
* `selects`.
|
|
321
|
-
*/
|
|
322
|
-
thread_id?: string;
|
|
323
|
-
/**
|
|
324
|
-
* `total_cost` is the estimated total USD cost for the root run. Omitted unless
|
|
325
|
-
* included in `selects`.
|
|
326
|
-
*/
|
|
327
|
-
total_cost?: number;
|
|
328
|
-
/**
|
|
329
|
-
* `total_tokens` is the total token count (prompt plus completion). Omitted unless
|
|
330
|
-
* included in `selects`.
|
|
331
|
-
*/
|
|
332
|
-
total_tokens?: number;
|
|
333
|
-
/**
|
|
334
|
-
* `trace_id` is the UUID of this trace (the root run). Always present.
|
|
335
|
-
*/
|
|
336
|
-
trace_id?: string;
|
|
337
|
-
}
|
|
338
|
-
export declare namespace ThreadTraceListItem {
|
|
339
|
-
/**
|
|
340
|
-
* `completion_cost_details` is the USD cost breakdown for completion-side
|
|
341
|
-
* categories; per-category values are under `raw`. Omitted unless included in
|
|
342
|
-
* `selects`.
|
|
343
|
-
*/
|
|
344
|
-
interface CompletionCostDetails {
|
|
345
|
-
/**
|
|
346
|
-
* `raw` maps each category name to its estimated USD cost.
|
|
347
|
-
*/
|
|
348
|
-
raw?: {
|
|
349
|
-
[key: string]: number;
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* `completion_token_details` is the completion-side token breakdown by category;
|
|
354
|
-
* per-category counts are under `raw`. Omitted unless included in `selects`.
|
|
355
|
-
*/
|
|
356
|
-
interface CompletionTokenDetails {
|
|
357
|
-
/**
|
|
358
|
-
* `raw` maps each category name to its completion-token count.
|
|
359
|
-
*/
|
|
360
|
-
raw?: {
|
|
361
|
-
[key: string]: number;
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* `prompt_cost_details` is the USD cost breakdown for prompt-side categories;
|
|
366
|
-
* per-category values are under `raw`. Omitted unless included in `selects`.
|
|
367
|
-
*/
|
|
368
|
-
interface PromptCostDetails {
|
|
369
|
-
/**
|
|
370
|
-
* `raw` maps each category name to its estimated USD cost.
|
|
371
|
-
*/
|
|
372
|
-
raw?: {
|
|
373
|
-
[key: string]: number;
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* `prompt_token_details` is the prompt-side token breakdown by category;
|
|
378
|
-
* per-category counts are under nested `raw`. Omitted unless included in
|
|
379
|
-
* `selects`.
|
|
380
|
-
*/
|
|
381
|
-
interface PromptTokenDetails {
|
|
382
|
-
/**
|
|
383
|
-
* `raw` maps each category name to its prompt-token count.
|
|
384
|
-
*/
|
|
385
|
-
raw?: {
|
|
386
|
-
[key: string]: number;
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
export interface ThreadStatsResponse {
|
|
228
|
+
export interface ThreadStats {
|
|
391
229
|
/**
|
|
392
230
|
* `completion_cost` is the sum of per-trace completion costs across the thread, in
|
|
393
231
|
* USD. Populated when `COMPLETION_COST` is selected.
|
|
@@ -397,13 +235,13 @@ export interface ThreadStatsResponse {
|
|
|
397
235
|
* `completion_cost_details` is the per-sub-category sum of completion cost details
|
|
398
236
|
* across the thread. Populated when `COMPLETION_COST_DETAILS` is selected.
|
|
399
237
|
*/
|
|
400
|
-
completion_cost_details?:
|
|
238
|
+
completion_cost_details?: ThreadStats.CompletionCostDetails;
|
|
401
239
|
/**
|
|
402
240
|
* `completion_token_details` is the per-sub-category sum of completion token
|
|
403
241
|
* details across the thread. Populated when `COMPLETION_TOKEN_DETAILS` is
|
|
404
242
|
* selected.
|
|
405
243
|
*/
|
|
406
|
-
completion_token_details?:
|
|
244
|
+
completion_token_details?: ThreadStats.CompletionTokenDetails;
|
|
407
245
|
/**
|
|
408
246
|
* `completion_tokens` is the sum of per-trace completion token counts across the
|
|
409
247
|
* thread. Populated when `COMPLETION_TOKENS` is selected.
|
|
@@ -414,7 +252,7 @@ export interface ThreadStatsResponse {
|
|
|
414
252
|
* by feedback key. Populated when `FEEDBACK_STATS` is selected.
|
|
415
253
|
*/
|
|
416
254
|
feedback_stats?: {
|
|
417
|
-
[key: string]:
|
|
255
|
+
[key: string]: ThreadStats.FeedbackStats;
|
|
418
256
|
};
|
|
419
257
|
/**
|
|
420
258
|
* `first_start_time` is the earliest trace start time in the thread (RFC3339).
|
|
@@ -450,12 +288,12 @@ export interface ThreadStatsResponse {
|
|
|
450
288
|
* `prompt_cost_details` is the per-sub-category sum of prompt cost details across
|
|
451
289
|
* the thread. Populated when `PROMPT_COST_DETAILS` is selected.
|
|
452
290
|
*/
|
|
453
|
-
prompt_cost_details?:
|
|
291
|
+
prompt_cost_details?: ThreadStats.PromptCostDetails;
|
|
454
292
|
/**
|
|
455
293
|
* `prompt_token_details` is the per-sub-category sum of prompt token details
|
|
456
294
|
* across the thread. Populated when `PROMPT_TOKEN_DETAILS` is selected.
|
|
457
295
|
*/
|
|
458
|
-
prompt_token_details?:
|
|
296
|
+
prompt_token_details?: ThreadStats.PromptTokenDetails;
|
|
459
297
|
/**
|
|
460
298
|
* `prompt_tokens` is the sum of per-trace prompt token counts across the thread.
|
|
461
299
|
* Populated when `PROMPT_TOKENS` is selected.
|
|
@@ -477,7 +315,7 @@ export interface ThreadStatsResponse {
|
|
|
477
315
|
*/
|
|
478
316
|
turns?: number;
|
|
479
317
|
}
|
|
480
|
-
export declare namespace
|
|
318
|
+
export declare namespace ThreadStats {
|
|
481
319
|
/**
|
|
482
320
|
* `completion_cost_details` is the per-sub-category sum of completion cost details
|
|
483
321
|
* across the thread. Populated when `COMPLETION_COST_DETAILS` is selected.
|
|
@@ -592,6 +430,171 @@ export declare namespace ThreadStatsResponse {
|
|
|
592
430
|
};
|
|
593
431
|
}
|
|
594
432
|
}
|
|
433
|
+
export interface ThreadTrace {
|
|
434
|
+
/**
|
|
435
|
+
* `completion_cost` is the estimated USD cost for the completion. Omitted unless
|
|
436
|
+
* included in `selects`.
|
|
437
|
+
*/
|
|
438
|
+
completion_cost?: number;
|
|
439
|
+
/**
|
|
440
|
+
* `completion_cost_details` is the USD cost breakdown for completion-side
|
|
441
|
+
* categories; per-category values are under `raw`. Omitted unless included in
|
|
442
|
+
* `selects`.
|
|
443
|
+
*/
|
|
444
|
+
completion_cost_details?: ThreadTrace.CompletionCostDetails;
|
|
445
|
+
/**
|
|
446
|
+
* `completion_token_details` is the completion-side token breakdown by category;
|
|
447
|
+
* per-category counts are under `raw`. Omitted unless included in `selects`.
|
|
448
|
+
*/
|
|
449
|
+
completion_token_details?: ThreadTrace.CompletionTokenDetails;
|
|
450
|
+
/**
|
|
451
|
+
* `completion_tokens` is the completion-side token count. Omitted unless included
|
|
452
|
+
* in `selects`.
|
|
453
|
+
*/
|
|
454
|
+
completion_tokens?: number;
|
|
455
|
+
/**
|
|
456
|
+
* `end_time` is when the root run ended (RFC3339 date-time). JSON null if the run
|
|
457
|
+
* is still in progress. Omitted unless included in `selects`.
|
|
458
|
+
*/
|
|
459
|
+
end_time?: string;
|
|
460
|
+
/**
|
|
461
|
+
* `error_preview` is a short error summary when the run failed. Omitted unless
|
|
462
|
+
* included in `selects`.
|
|
463
|
+
*/
|
|
464
|
+
error_preview?: string;
|
|
465
|
+
/**
|
|
466
|
+
* `first_token_time` is when the first output token was produced (RFC3339
|
|
467
|
+
* date-time), for streamed runs when that metadata exists. Omitted unless included
|
|
468
|
+
* in `selects`.
|
|
469
|
+
*/
|
|
470
|
+
first_token_time?: string;
|
|
471
|
+
/**
|
|
472
|
+
* `inputs_preview` is a truncated text preview of inputs. Omitted unless included
|
|
473
|
+
* in `selects`.
|
|
474
|
+
*/
|
|
475
|
+
inputs_preview?: string;
|
|
476
|
+
/**
|
|
477
|
+
* `latency` is wall-clock duration from start to end in seconds. Omitted unless
|
|
478
|
+
* included in `selects`.
|
|
479
|
+
*/
|
|
480
|
+
latency?: number;
|
|
481
|
+
/**
|
|
482
|
+
* `name` is a human-readable label for the root run (for example the model name,
|
|
483
|
+
* function name, or step name chosen when the run was traced). Omitted unless
|
|
484
|
+
* included in `selects`.
|
|
485
|
+
*/
|
|
486
|
+
name?: string;
|
|
487
|
+
/**
|
|
488
|
+
* `op` is a numeric code identifying the root run's `run_type` (for example LLM
|
|
489
|
+
* vs. tool vs. chain). Encoded as a number for compatibility with legacy clients;
|
|
490
|
+
* prefer the string `run_type` on `RunResponse` when available. Omitted unless
|
|
491
|
+
* included in `selects`.
|
|
492
|
+
*/
|
|
493
|
+
op?: number;
|
|
494
|
+
/**
|
|
495
|
+
* `outputs_preview` is a truncated text preview of outputs. Omitted unless
|
|
496
|
+
* included in `selects`.
|
|
497
|
+
*/
|
|
498
|
+
outputs_preview?: string;
|
|
499
|
+
/**
|
|
500
|
+
* `prompt_cost` is the estimated USD cost for the prompt. Omitted unless included
|
|
501
|
+
* in `selects`.
|
|
502
|
+
*/
|
|
503
|
+
prompt_cost?: number;
|
|
504
|
+
/**
|
|
505
|
+
* `prompt_cost_details` is the USD cost breakdown for prompt-side categories;
|
|
506
|
+
* per-category values are under `raw`. Omitted unless included in `selects`.
|
|
507
|
+
*/
|
|
508
|
+
prompt_cost_details?: ThreadTrace.PromptCostDetails;
|
|
509
|
+
/**
|
|
510
|
+
* `prompt_token_details` is the prompt-side token breakdown by category;
|
|
511
|
+
* per-category counts are under nested `raw`. Omitted unless included in
|
|
512
|
+
* `selects`.
|
|
513
|
+
*/
|
|
514
|
+
prompt_token_details?: ThreadTrace.PromptTokenDetails;
|
|
515
|
+
/**
|
|
516
|
+
* `prompt_tokens` is the prompt-side token count. Omitted unless included in
|
|
517
|
+
* `selects`.
|
|
518
|
+
*/
|
|
519
|
+
prompt_tokens?: number;
|
|
520
|
+
/**
|
|
521
|
+
* `start_time` is when the trace started (RFC3339 date-time). Omitted unless
|
|
522
|
+
* included in `selects`.
|
|
523
|
+
*/
|
|
524
|
+
start_time?: string;
|
|
525
|
+
/**
|
|
526
|
+
* `thread_id` is the conversation thread UUID that contains this trace. Matches
|
|
527
|
+
* the `thread_id` path parameter of the request. Omitted unless included in
|
|
528
|
+
* `selects`.
|
|
529
|
+
*/
|
|
530
|
+
thread_id?: string;
|
|
531
|
+
/**
|
|
532
|
+
* `total_cost` is the estimated total USD cost for the root run. Omitted unless
|
|
533
|
+
* included in `selects`.
|
|
534
|
+
*/
|
|
535
|
+
total_cost?: number;
|
|
536
|
+
/**
|
|
537
|
+
* `total_tokens` is the total token count (prompt plus completion). Omitted unless
|
|
538
|
+
* included in `selects`.
|
|
539
|
+
*/
|
|
540
|
+
total_tokens?: number;
|
|
541
|
+
/**
|
|
542
|
+
* `trace_id` is the UUID of this trace (the root run). Always present.
|
|
543
|
+
*/
|
|
544
|
+
trace_id?: string;
|
|
545
|
+
}
|
|
546
|
+
export declare namespace ThreadTrace {
|
|
547
|
+
/**
|
|
548
|
+
* `completion_cost_details` is the USD cost breakdown for completion-side
|
|
549
|
+
* categories; per-category values are under `raw`. Omitted unless included in
|
|
550
|
+
* `selects`.
|
|
551
|
+
*/
|
|
552
|
+
interface CompletionCostDetails {
|
|
553
|
+
/**
|
|
554
|
+
* `raw` maps each category name to its estimated USD cost.
|
|
555
|
+
*/
|
|
556
|
+
raw?: {
|
|
557
|
+
[key: string]: number;
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* `completion_token_details` is the completion-side token breakdown by category;
|
|
562
|
+
* per-category counts are under `raw`. Omitted unless included in `selects`.
|
|
563
|
+
*/
|
|
564
|
+
interface CompletionTokenDetails {
|
|
565
|
+
/**
|
|
566
|
+
* `raw` maps each category name to its completion-token count.
|
|
567
|
+
*/
|
|
568
|
+
raw?: {
|
|
569
|
+
[key: string]: number;
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* `prompt_cost_details` is the USD cost breakdown for prompt-side categories;
|
|
574
|
+
* per-category values are under `raw`. Omitted unless included in `selects`.
|
|
575
|
+
*/
|
|
576
|
+
interface PromptCostDetails {
|
|
577
|
+
/**
|
|
578
|
+
* `raw` maps each category name to its estimated USD cost.
|
|
579
|
+
*/
|
|
580
|
+
raw?: {
|
|
581
|
+
[key: string]: number;
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* `prompt_token_details` is the prompt-side token breakdown by category;
|
|
586
|
+
* per-category counts are under nested `raw`. Omitted unless included in
|
|
587
|
+
* `selects`.
|
|
588
|
+
*/
|
|
589
|
+
interface PromptTokenDetails {
|
|
590
|
+
/**
|
|
591
|
+
* `raw` maps each category name to its prompt-token count.
|
|
592
|
+
*/
|
|
593
|
+
raw?: {
|
|
594
|
+
[key: string]: number;
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
}
|
|
595
598
|
export interface ThreadListTracesParams extends ItemsCursorGetPaginationParams {
|
|
596
599
|
/**
|
|
597
600
|
* `project_id` is the tracing project UUID (required).
|
|
@@ -624,12 +627,12 @@ export interface ThreadQueryParams extends ItemsCursorPostPaginationParams {
|
|
|
624
627
|
filter?: string;
|
|
625
628
|
/**
|
|
626
629
|
* `max_start_time` is the exclusive upper bound on thread activity (RFC3339
|
|
627
|
-
* date-time).
|
|
630
|
+
* date-time). Defaults to now (UTC) when omitted.
|
|
628
631
|
*/
|
|
629
632
|
max_start_time?: string;
|
|
630
633
|
/**
|
|
631
634
|
* `min_start_time` is the inclusive lower bound on thread activity (RFC3339
|
|
632
|
-
* date-time).
|
|
635
|
+
* date-time). Defaults to 1 day before now (UTC) when omitted.
|
|
633
636
|
*/
|
|
634
637
|
min_start_time?: string;
|
|
635
638
|
/**
|
|
@@ -648,7 +651,15 @@ export interface ThreadStatsParams {
|
|
|
648
651
|
* `session_id` is the tracing project (session) UUID (required).
|
|
649
652
|
*/
|
|
650
653
|
session_id: string;
|
|
654
|
+
/**
|
|
655
|
+
* `filter` narrows which of the thread's traces are aggregated, using a LangSmith
|
|
656
|
+
* filter expression. For example: lt(start_time, "2025-01-01T00:00:00Z") or
|
|
657
|
+
* eq(trace_id, "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328"). See
|
|
658
|
+
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
|
|
659
|
+
* for syntax.
|
|
660
|
+
*/
|
|
661
|
+
filter?: string;
|
|
651
662
|
}
|
|
652
663
|
export declare namespace Threads {
|
|
653
|
-
export { type
|
|
664
|
+
export { type Thread as Thread, type ThreadStats as ThreadStats, type ThreadTrace as ThreadTrace, type ThreadTracesItemsCursorGetPagination as ThreadTracesItemsCursorGetPagination, type ThreadsItemsCursorPostPagination as ThreadsItemsCursorPostPagination, type ThreadListTracesParams as ThreadListTracesParams, type ThreadQueryParams as ThreadQueryParams, type ThreadStatsParams as ThreadStatsParams, };
|
|
654
665
|
}
|
|
@@ -11,7 +11,7 @@ export class Threads extends APIResource {
|
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
13
|
* // Automatically fetches more pages as needed.
|
|
14
|
-
* for await (const
|
|
14
|
+
* for await (const threadTrace of client.threads.listTraces(
|
|
15
15
|
* 'thread_id',
|
|
16
16
|
* { project_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
|
|
17
17
|
* )) {
|
|
@@ -30,7 +30,7 @@ export class Threads extends APIResource {
|
|
|
30
30
|
* @example
|
|
31
31
|
* ```ts
|
|
32
32
|
* // Automatically fetches more pages as needed.
|
|
33
|
-
* for await (const
|
|
33
|
+
* for await (const thread of client.threads.query()) {
|
|
34
34
|
* // ...
|
|
35
35
|
* }
|
|
36
36
|
* ```
|
|
@@ -49,10 +49,13 @@ export class Threads extends APIResource {
|
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
51
|
* ```ts
|
|
52
|
-
* const
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* const threadStats = await client.threads.stats(
|
|
53
|
+
* 'thread_id',
|
|
54
|
+
* {
|
|
55
|
+
* selects: ['TURNS'],
|
|
56
|
+
* session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
|
|
57
|
+
* },
|
|
58
|
+
* );
|
|
56
59
|
* ```
|
|
57
60
|
*/
|
|
58
61
|
stats(threadID, query, options) {
|
package/dist/client.cjs
CHANGED
|
@@ -238,6 +238,7 @@ class AutoBatchQueue {
|
|
|
238
238
|
otelContext: item.otelContext,
|
|
239
239
|
apiKey: item.apiKey,
|
|
240
240
|
apiUrl: item.apiUrl,
|
|
241
|
+
workspaceId: item.workspaceId,
|
|
241
242
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
242
243
|
itemPromiseResolve: itemPromiseResolve,
|
|
243
244
|
itemPromise,
|
|
@@ -278,6 +279,7 @@ class AutoBatchQueue {
|
|
|
278
279
|
otelContext: it.otelContext,
|
|
279
280
|
apiKey: it.apiKey,
|
|
280
281
|
apiUrl: it.apiUrl,
|
|
282
|
+
workspaceId: it.workspaceId,
|
|
281
283
|
size: it.size,
|
|
282
284
|
})),
|
|
283
285
|
() => popped.forEach((it) => it.itemPromiseResolve()),
|
|
@@ -1256,8 +1258,13 @@ class Client {
|
|
|
1256
1258
|
const batchesByDestination = batch.reduce((acc, item) => {
|
|
1257
1259
|
const apiUrl = item.apiUrl ?? this.apiUrl;
|
|
1258
1260
|
const apiKey = item.apiKey ?? this.apiKey;
|
|
1259
|
-
const
|
|
1260
|
-
const
|
|
1261
|
+
const workspaceId = item.workspaceId ?? this.workspaceId;
|
|
1262
|
+
const isDefault = item.apiKey === this.apiKey &&
|
|
1263
|
+
item.apiUrl === this.apiUrl &&
|
|
1264
|
+
item.workspaceId === this.workspaceId;
|
|
1265
|
+
const batchKey = isDefault
|
|
1266
|
+
? "default"
|
|
1267
|
+
: `${apiUrl}|${apiKey}|${workspaceId ?? ""}`;
|
|
1261
1268
|
if (!acc[batchKey]) {
|
|
1262
1269
|
acc[batchKey] = [];
|
|
1263
1270
|
}
|
|
@@ -1266,9 +1273,13 @@ class Client {
|
|
|
1266
1273
|
}, {});
|
|
1267
1274
|
const batchPromises = [];
|
|
1268
1275
|
for (const [batchKey, batch] of Object.entries(batchesByDestination)) {
|
|
1276
|
+
const isDefault = batchKey === "default";
|
|
1277
|
+
const parts = isDefault ? [] : batchKey.split("|");
|
|
1278
|
+
const workspaceIdPart = parts[2];
|
|
1269
1279
|
const batchPromise = this._processBatch(batch, {
|
|
1270
|
-
apiUrl:
|
|
1271
|
-
apiKey:
|
|
1280
|
+
apiUrl: isDefault ? undefined : parts[0],
|
|
1281
|
+
apiKey: isDefault ? undefined : parts[1],
|
|
1282
|
+
workspaceId: isDefault || !workspaceIdPart ? undefined : workspaceIdPart,
|
|
1272
1283
|
});
|
|
1273
1284
|
batchPromises.push(batchPromise);
|
|
1274
1285
|
}
|
|
@@ -1548,6 +1559,7 @@ class Client {
|
|
|
1548
1559
|
otelContext,
|
|
1549
1560
|
apiKey: options?.apiKey,
|
|
1550
1561
|
apiUrl: options?.apiUrl,
|
|
1562
|
+
workspaceId: options?.workspaceId,
|
|
1551
1563
|
}).catch(console.error);
|
|
1552
1564
|
return;
|
|
1553
1565
|
}
|
|
@@ -1642,6 +1654,9 @@ class Client {
|
|
|
1642
1654
|
if (options?.apiKey !== undefined) {
|
|
1643
1655
|
headers["x-api-key"] = options.apiKey;
|
|
1644
1656
|
}
|
|
1657
|
+
if (options?.workspaceId !== undefined) {
|
|
1658
|
+
headers["x-tenant-id"] = options.workspaceId;
|
|
1659
|
+
}
|
|
1645
1660
|
await this.batchIngestCaller.callWithOptions({ sizeBytes: options?.sizeBytes }, async () => {
|
|
1646
1661
|
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/batch`, {
|
|
1647
1662
|
method: "POST",
|
|
@@ -1865,6 +1880,9 @@ class Client {
|
|
|
1865
1880
|
if (options?.apiKey !== undefined) {
|
|
1866
1881
|
headers["x-api-key"] = options.apiKey;
|
|
1867
1882
|
}
|
|
1883
|
+
if (options?.workspaceId !== undefined) {
|
|
1884
|
+
headers["x-tenant-id"] = options.workspaceId;
|
|
1885
|
+
}
|
|
1868
1886
|
let transformedBody = body;
|
|
1869
1887
|
if (options?.useGzip &&
|
|
1870
1888
|
typeof body === "object" &&
|
|
@@ -1967,6 +1985,7 @@ class Client {
|
|
|
1967
1985
|
otelContext,
|
|
1968
1986
|
apiKey: options?.apiKey,
|
|
1969
1987
|
apiUrl: options?.apiUrl,
|
|
1988
|
+
workspaceId: options?.workspaceId,
|
|
1970
1989
|
}).catch(console.error);
|
|
1971
1990
|
return;
|
|
1972
1991
|
}
|
|
@@ -1977,6 +1996,7 @@ class Client {
|
|
|
1977
1996
|
otelContext,
|
|
1978
1997
|
apiKey: options?.apiKey,
|
|
1979
1998
|
apiUrl: options?.apiUrl,
|
|
1999
|
+
workspaceId: options?.workspaceId,
|
|
1980
2000
|
}).catch(console.error);
|
|
1981
2001
|
}
|
|
1982
2002
|
return;
|
|
@@ -4085,13 +4105,48 @@ class Client {
|
|
|
4085
4105
|
}
|
|
4086
4106
|
/**
|
|
4087
4107
|
* Add runs to an annotation queue with the specified queue ID.
|
|
4108
|
+
*
|
|
4109
|
+
* The second argument is either:
|
|
4110
|
+
* - `RunKey[]` (preferred): each entry carries the run's full lookup key, so
|
|
4111
|
+
* it can be located directly without a scan. Required for workspaces served
|
|
4112
|
+
* by SmithDB; routes to `POST /runs/by-key`.
|
|
4113
|
+
* - `string[]`: a plain list of run IDs. This path will be deprecated in a
|
|
4114
|
+
* future release; prefer the key form. Routes to `POST /runs`.
|
|
4115
|
+
*
|
|
4116
|
+
* If every element is a string (or the list is empty) it is treated as run
|
|
4117
|
+
* IDs; otherwise the list is treated as `RunKey` objects.
|
|
4118
|
+
*
|
|
4088
4119
|
* @param queueId - The ID of the annotation queue
|
|
4089
|
-
* @param
|
|
4120
|
+
* @param runs - Either a list of run IDs (deprecated) or a list of run keys.
|
|
4090
4121
|
*/
|
|
4091
|
-
async addRunsToAnnotationQueue(queueId,
|
|
4092
|
-
const
|
|
4122
|
+
async addRunsToAnnotationQueue(queueId, runs) {
|
|
4123
|
+
const base = `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}/runs`;
|
|
4124
|
+
// All strings (including empty) -> legacy /runs; otherwise treat as run keys.
|
|
4125
|
+
const allStrings = runs.every((r) => typeof r === "string");
|
|
4126
|
+
let url;
|
|
4127
|
+
let body;
|
|
4128
|
+
if (!allStrings) {
|
|
4129
|
+
url = `${base}/by-key`;
|
|
4130
|
+
body = JSON.stringify(runs.map((run, i) => {
|
|
4131
|
+
const serialized = {
|
|
4132
|
+
run_id: (0, _uuid_js_1.assertUuid)(run.runId, `runs[${i}].runId`).toString(),
|
|
4133
|
+
session_id: (0, _uuid_js_1.assertUuid)(run.sessionId, `runs[${i}].sessionId`).toString(),
|
|
4134
|
+
start_time: typeof run.startTime === "string"
|
|
4135
|
+
? run.startTime
|
|
4136
|
+
: new Date(run.startTime).toISOString(),
|
|
4137
|
+
};
|
|
4138
|
+
if (run.sourceProposedExampleId != null) {
|
|
4139
|
+
serialized.source_proposed_example_id = (0, _uuid_js_1.assertUuid)(run.sourceProposedExampleId, `runs[${i}].sourceProposedExampleId`).toString();
|
|
4140
|
+
}
|
|
4141
|
+
return serialized;
|
|
4142
|
+
}));
|
|
4143
|
+
}
|
|
4144
|
+
else {
|
|
4145
|
+
url = base;
|
|
4146
|
+
body = JSON.stringify(runs.map((id, i) => (0, _uuid_js_1.assertUuid)(id, `runs[${i}]`).toString()));
|
|
4147
|
+
}
|
|
4093
4148
|
await this.caller.call(async () => {
|
|
4094
|
-
const res = await this._fetch(
|
|
4149
|
+
const res = await this._fetch(url, {
|
|
4095
4150
|
method: "POST",
|
|
4096
4151
|
headers: {
|
|
4097
4152
|
...this._mergedHeaders,
|