langsmith 0.8.1 → 0.8.3
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 +5 -0
- package/dist/_openapi_client/resources/sandboxes/boxes.cjs +1 -2
- package/dist/_openapi_client/resources/sandboxes/boxes.d.ts +107 -6
- package/dist/_openapi_client/resources/sandboxes/boxes.js +1 -2
- package/dist/_openapi_client/resources/sandboxes/sandboxes.d.ts +99 -4
- package/dist/_openapi_client/resources/threads.cjs +9 -6
- package/dist/_openapi_client/resources/threads.d.ts +216 -190
- 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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -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 +4 -2
|
@@ -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,186 @@ 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` is the full root run error message when the run failed. Omitted unless
|
|
462
|
+
* included in `selects`.
|
|
463
|
+
*/
|
|
464
|
+
error?: string;
|
|
465
|
+
/**
|
|
466
|
+
* `error_preview` is a short error summary when the run failed. Omitted unless
|
|
467
|
+
* included in `selects`.
|
|
468
|
+
*/
|
|
469
|
+
error_preview?: string;
|
|
470
|
+
/**
|
|
471
|
+
* `first_token_time` is when the first output token was produced (RFC3339
|
|
472
|
+
* date-time), for streamed runs when that metadata exists. Omitted unless included
|
|
473
|
+
* in `selects`.
|
|
474
|
+
*/
|
|
475
|
+
first_token_time?: string;
|
|
476
|
+
/**
|
|
477
|
+
* `inputs` is the full root run input payload. Omitted unless included in
|
|
478
|
+
* `selects`.
|
|
479
|
+
*/
|
|
480
|
+
inputs?: unknown;
|
|
481
|
+
/**
|
|
482
|
+
* `inputs_preview` is a truncated text preview of inputs. Omitted unless included
|
|
483
|
+
* in `selects`.
|
|
484
|
+
*/
|
|
485
|
+
inputs_preview?: string;
|
|
486
|
+
/**
|
|
487
|
+
* `latency` is wall-clock duration from start to end in seconds. Omitted unless
|
|
488
|
+
* included in `selects`.
|
|
489
|
+
*/
|
|
490
|
+
latency?: number;
|
|
491
|
+
/**
|
|
492
|
+
* `name` is a human-readable label for the root run (for example the model name,
|
|
493
|
+
* function name, or step name chosen when the run was traced). Omitted unless
|
|
494
|
+
* included in `selects`.
|
|
495
|
+
*/
|
|
496
|
+
name?: string;
|
|
497
|
+
/**
|
|
498
|
+
* `op` is a numeric code identifying the root run's `run_type` (for example LLM
|
|
499
|
+
* vs. tool vs. chain). Encoded as a number for compatibility with legacy clients;
|
|
500
|
+
* prefer the string `run_type` on `RunResponse` when available. Omitted unless
|
|
501
|
+
* included in `selects`.
|
|
502
|
+
*/
|
|
503
|
+
op?: number;
|
|
504
|
+
/**
|
|
505
|
+
* `outputs` is the full root run output payload. Omitted unless included in
|
|
506
|
+
* `selects`.
|
|
507
|
+
*/
|
|
508
|
+
outputs?: unknown;
|
|
509
|
+
/**
|
|
510
|
+
* `outputs_preview` is a truncated text preview of outputs. Omitted unless
|
|
511
|
+
* included in `selects`.
|
|
512
|
+
*/
|
|
513
|
+
outputs_preview?: string;
|
|
514
|
+
/**
|
|
515
|
+
* `prompt_cost` is the estimated USD cost for the prompt. Omitted unless included
|
|
516
|
+
* in `selects`.
|
|
517
|
+
*/
|
|
518
|
+
prompt_cost?: number;
|
|
519
|
+
/**
|
|
520
|
+
* `prompt_cost_details` is the USD cost breakdown for prompt-side categories;
|
|
521
|
+
* per-category values are under `raw`. Omitted unless included in `selects`.
|
|
522
|
+
*/
|
|
523
|
+
prompt_cost_details?: ThreadTrace.PromptCostDetails;
|
|
524
|
+
/**
|
|
525
|
+
* `prompt_token_details` is the prompt-side token breakdown by category;
|
|
526
|
+
* per-category counts are under nested `raw`. Omitted unless included in
|
|
527
|
+
* `selects`.
|
|
528
|
+
*/
|
|
529
|
+
prompt_token_details?: ThreadTrace.PromptTokenDetails;
|
|
530
|
+
/**
|
|
531
|
+
* `prompt_tokens` is the prompt-side token count. Omitted unless included in
|
|
532
|
+
* `selects`.
|
|
533
|
+
*/
|
|
534
|
+
prompt_tokens?: number;
|
|
535
|
+
/**
|
|
536
|
+
* `start_time` is when the trace started (RFC3339 date-time). Omitted unless
|
|
537
|
+
* included in `selects`.
|
|
538
|
+
*/
|
|
539
|
+
start_time?: string;
|
|
540
|
+
/**
|
|
541
|
+
* `thread_id` is the conversation thread UUID that contains this trace. Matches
|
|
542
|
+
* the `thread_id` path parameter of the request. Omitted unless included in
|
|
543
|
+
* `selects`.
|
|
544
|
+
*/
|
|
545
|
+
thread_id?: string;
|
|
546
|
+
/**
|
|
547
|
+
* `total_cost` is the estimated total USD cost for the root run. Omitted unless
|
|
548
|
+
* included in `selects`.
|
|
549
|
+
*/
|
|
550
|
+
total_cost?: number;
|
|
551
|
+
/**
|
|
552
|
+
* `total_tokens` is the total token count (prompt plus completion). Omitted unless
|
|
553
|
+
* included in `selects`.
|
|
554
|
+
*/
|
|
555
|
+
total_tokens?: number;
|
|
556
|
+
/**
|
|
557
|
+
* `trace_id` is the UUID of this trace (the root run). Always present.
|
|
558
|
+
*/
|
|
559
|
+
trace_id?: string;
|
|
560
|
+
}
|
|
561
|
+
export declare namespace ThreadTrace {
|
|
562
|
+
/**
|
|
563
|
+
* `completion_cost_details` is the USD cost breakdown for completion-side
|
|
564
|
+
* categories; per-category values are under `raw`. Omitted unless included in
|
|
565
|
+
* `selects`.
|
|
566
|
+
*/
|
|
567
|
+
interface CompletionCostDetails {
|
|
568
|
+
/**
|
|
569
|
+
* `raw` maps each category name to its estimated USD cost.
|
|
570
|
+
*/
|
|
571
|
+
raw?: {
|
|
572
|
+
[key: string]: number;
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* `completion_token_details` is the completion-side token breakdown by category;
|
|
577
|
+
* per-category counts are under `raw`. Omitted unless included in `selects`.
|
|
578
|
+
*/
|
|
579
|
+
interface CompletionTokenDetails {
|
|
580
|
+
/**
|
|
581
|
+
* `raw` maps each category name to its completion-token count.
|
|
582
|
+
*/
|
|
583
|
+
raw?: {
|
|
584
|
+
[key: string]: number;
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* `prompt_cost_details` is the USD cost breakdown for prompt-side categories;
|
|
589
|
+
* per-category values are under `raw`. Omitted unless included in `selects`.
|
|
590
|
+
*/
|
|
591
|
+
interface PromptCostDetails {
|
|
592
|
+
/**
|
|
593
|
+
* `raw` maps each category name to its estimated USD cost.
|
|
594
|
+
*/
|
|
595
|
+
raw?: {
|
|
596
|
+
[key: string]: number;
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* `prompt_token_details` is the prompt-side token breakdown by category;
|
|
601
|
+
* per-category counts are under nested `raw`. Omitted unless included in
|
|
602
|
+
* `selects`.
|
|
603
|
+
*/
|
|
604
|
+
interface PromptTokenDetails {
|
|
605
|
+
/**
|
|
606
|
+
* `raw` maps each category name to its prompt-token count.
|
|
607
|
+
*/
|
|
608
|
+
raw?: {
|
|
609
|
+
[key: string]: number;
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
}
|
|
595
613
|
export interface ThreadListTracesParams extends ItemsCursorGetPaginationParams {
|
|
596
614
|
/**
|
|
597
615
|
* `project_id` is the tracing project UUID (required).
|
|
@@ -611,7 +629,7 @@ export interface ThreadListTracesParams extends ItemsCursorGetPaginationParams {
|
|
|
611
629
|
* Properties not listed are omitted from each trace object; `trace_id` is always
|
|
612
630
|
* returned.
|
|
613
631
|
*/
|
|
614
|
-
selects?: Array<'THREAD_ID' | 'TRACE_ID' | 'OP' | 'PROMPT_TOKENS' | 'COMPLETION_TOKENS' | 'TOTAL_TOKENS' | 'START_TIME' | 'END_TIME' | 'LATENCY' | 'FIRST_TOKEN_TIME' | 'INPUTS_PREVIEW' | 'OUTPUTS_PREVIEW' | 'PROMPT_COST' | 'COMPLETION_COST' | 'TOTAL_COST' | 'PROMPT_TOKEN_DETAILS' | 'COMPLETION_TOKEN_DETAILS' | 'PROMPT_COST_DETAILS' | 'COMPLETION_COST_DETAILS' | 'NAME' | 'ERROR_PREVIEW'>;
|
|
632
|
+
selects?: Array<'THREAD_ID' | 'TRACE_ID' | 'OP' | 'PROMPT_TOKENS' | 'COMPLETION_TOKENS' | 'TOTAL_TOKENS' | 'START_TIME' | 'END_TIME' | 'LATENCY' | 'FIRST_TOKEN_TIME' | 'INPUTS_PREVIEW' | 'OUTPUTS_PREVIEW' | 'INPUTS' | 'OUTPUTS' | 'ERROR' | 'PROMPT_COST' | 'COMPLETION_COST' | 'TOTAL_COST' | 'PROMPT_TOKEN_DETAILS' | 'COMPLETION_TOKEN_DETAILS' | 'PROMPT_COST_DETAILS' | 'COMPLETION_COST_DETAILS' | 'NAME' | 'ERROR_PREVIEW'>;
|
|
615
633
|
}
|
|
616
634
|
export interface ThreadQueryParams extends ItemsCursorPostPaginationParams {
|
|
617
635
|
/**
|
|
@@ -624,12 +642,12 @@ export interface ThreadQueryParams extends ItemsCursorPostPaginationParams {
|
|
|
624
642
|
filter?: string;
|
|
625
643
|
/**
|
|
626
644
|
* `max_start_time` is the exclusive upper bound on thread activity (RFC3339
|
|
627
|
-
* date-time).
|
|
645
|
+
* date-time). Defaults to now (UTC) when omitted.
|
|
628
646
|
*/
|
|
629
647
|
max_start_time?: string;
|
|
630
648
|
/**
|
|
631
649
|
* `min_start_time` is the inclusive lower bound on thread activity (RFC3339
|
|
632
|
-
* date-time).
|
|
650
|
+
* date-time). Defaults to 1 day before now (UTC) when omitted.
|
|
633
651
|
*/
|
|
634
652
|
min_start_time?: string;
|
|
635
653
|
/**
|
|
@@ -648,7 +666,15 @@ export interface ThreadStatsParams {
|
|
|
648
666
|
* `session_id` is the tracing project (session) UUID (required).
|
|
649
667
|
*/
|
|
650
668
|
session_id: string;
|
|
669
|
+
/**
|
|
670
|
+
* `filter` narrows which of the thread's traces are aggregated, using a LangSmith
|
|
671
|
+
* filter expression. For example: lt(start_time, "2025-01-01T00:00:00Z") or
|
|
672
|
+
* eq(trace_id, "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328"). See
|
|
673
|
+
* https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
|
|
674
|
+
* for syntax.
|
|
675
|
+
*/
|
|
676
|
+
filter?: string;
|
|
651
677
|
}
|
|
652
678
|
export declare namespace Threads {
|
|
653
|
-
export { type
|
|
679
|
+
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
680
|
}
|
|
@@ -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) {
|