langsmith 0.7.16 → 0.7.17

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.
@@ -66,7 +66,8 @@ const info_js_1 = require("./resources/info.cjs");
66
66
  const issues_js_1 = require("./resources/issues.cjs");
67
67
  const online_evaluators_js_1 = require("./resources/online-evaluators.cjs");
68
68
  const runs_js_1 = require("./resources/runs.cjs");
69
- const sessions_js_1 = require("./resources/sessions.cjs");
69
+ const threads_js_1 = require("./resources/threads.cjs");
70
+ const traces_js_1 = require("./resources/traces.cjs");
70
71
  const datasets_js_1 = require("./resources/datasets/datasets.cjs");
71
72
  const sandboxes_js_1 = require("./resources/sandboxes/sandboxes.cjs");
72
73
  const headers_js_1 = require("./internal/headers.cjs");
@@ -159,12 +160,6 @@ class Langsmith {
159
160
  writable: true,
160
161
  value: void 0
161
162
  });
162
- Object.defineProperty(this, "sessions", {
163
- enumerable: true,
164
- configurable: true,
165
- writable: true,
166
- value: new API.Sessions(this)
167
- });
168
163
  Object.defineProperty(this, "datasets", {
169
164
  enumerable: true,
170
165
  configurable: true,
@@ -177,6 +172,18 @@ class Langsmith {
177
172
  writable: true,
178
173
  value: new API.Runs(this)
179
174
  });
175
+ Object.defineProperty(this, "threads", {
176
+ enumerable: true,
177
+ configurable: true,
178
+ writable: true,
179
+ value: new API.Threads(this)
180
+ });
181
+ Object.defineProperty(this, "traces", {
182
+ enumerable: true,
183
+ configurable: true,
184
+ writable: true,
185
+ value: new API.Traces(this)
186
+ });
180
187
  Object.defineProperty(this, "onlineEvaluators", {
181
188
  enumerable: true,
182
189
  configurable: true,
@@ -741,9 +748,10 @@ Object.defineProperty(Langsmith, "toFile", {
741
748
  writable: true,
742
749
  value: Uploads.toFile
743
750
  });
744
- Langsmith.Sessions = sessions_js_1.Sessions;
745
751
  Langsmith.Datasets = datasets_js_1.Datasets;
746
752
  Langsmith.Runs = runs_js_1.Runs;
753
+ Langsmith.Threads = threads_js_1.Threads;
754
+ Langsmith.Traces = traces_js_1.Traces;
747
755
  Langsmith.OnlineEvaluators = online_evaluators_js_1.OnlineEvaluators;
748
756
  Langsmith.Info = info_js_1.Info;
749
757
  Langsmith.Issues = issues_js_1.Issues;
@@ -12,7 +12,8 @@ import { Info, InfoListResponse } from './resources/info.js';
12
12
  import { Issue, IssueListParams, Issues, IssuesOffsetPaginationIssues } from './resources/issues.js';
13
13
  import { BulkDeleteEvaluatorFailedItem, BulkDeleteEvaluatorsResponse, CreateOnlineCodeEvaluatorRequest, CreateOnlineEvaluatorRequest, CreateOnlineEvaluatorResponse, CreateOnlineLlmEvaluatorRequest, GetOnlineEvaluatorSpendResponse, OnlineCodeEvaluator, OnlineEvaluator, OnlineEvaluatorBulkDeleteParams, OnlineEvaluatorCreateParams, OnlineEvaluatorDeleteParams, OnlineEvaluatorListParams, OnlineEvaluatorRunRule, OnlineEvaluatorSpendDay, OnlineEvaluatorSpendGroup, OnlineEvaluatorSpendParams, OnlineEvaluatorType, OnlineEvaluatorUpdateParams, OnlineEvaluators, OnlineEvaluatorsOffsetPaginationOnlineEvaluators, OnlineLlmEvaluator, OnlineSpendLimit, UpdateOnlineCodeEvaluatorRequest, UpdateOnlineEvaluatorRequest, UpdateOnlineEvaluatorResponse, UpdateOnlineLlmEvaluatorRequest } from './resources/online-evaluators.js';
14
14
  import { ResponseBodyForRunsGenerateQuery, Run, RunIngest, RunQueryParams, RunQueryV2Params, RunRetrieveParams, RunRetrieveV2Params, RunSchema, RunStatsQueryParams, RunTypeEnum, Runs, RunsFilterDataSourceTypeEnum, RunsItemsCursorPostPagination } from './resources/runs.js';
15
- import { CustomChartsSection, CustomChartsSectionRequest, RunStatsGroupBy, SessionCreateParams, SessionDeleteResponse, SessionListParams, SessionRetrieveParams, SessionSortableColumns, SessionUpdateParams, Sessions, TimedeltaInput, TracerSession, TracerSessionWithoutVirtualFields, TracerSessionsOffsetPaginationTopLevelArray } from './resources/sessions.js';
15
+ import { ThreadListItem, ThreadListItemsItemsCursorPostPagination, ThreadListTracesParams, ThreadQueryParams, ThreadStatsParams, ThreadStatsResponse, ThreadTraceListItem, ThreadTraceListItemsItemsCursorGetPagination, Threads } from './resources/threads.js';
16
+ import { Trace, TraceAggregates, TraceListRunsParams, TraceListRunsResponse, TraceQueryParams, Traces, TracesItemsCursorPostPagination } from './resources/traces.js';
16
17
  import { DataType, Dataset, DatasetTransformation, DatasetVersion, Datasets, FeedbackCreateCoreSchema, Missing, SortByDatasetColumn } from './resources/datasets/datasets.js';
17
18
  import { SandboxListResponse, SandboxResponse, SandboxStatusResponse, Sandboxes, ServiceURLResponse, SnapshotListResponse, SnapshotResponse } from './resources/sandboxes/sandboxes.js';
18
19
  import { type Fetch } from './internal/builtin-types.js';
@@ -187,9 +188,10 @@ export declare class Langsmith {
187
188
  static PermissionDeniedError: typeof Errors.PermissionDeniedError;
188
189
  static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
189
190
  static toFile: typeof Uploads.toFile;
190
- sessions: API.Sessions;
191
191
  datasets: API.Datasets;
192
192
  runs: API.Runs;
193
+ threads: API.Threads;
194
+ traces: API.Traces;
193
195
  onlineEvaluators: API.OnlineEvaluators;
194
196
  info: API.Info;
195
197
  issues: API.Issues;
@@ -215,9 +217,10 @@ export declare namespace Langsmith {
215
217
  export { type ItemsCursorPostPaginationParams as ItemsCursorPostPaginationParams, type ItemsCursorPostPaginationResponse as ItemsCursorPostPaginationResponse, };
216
218
  export import ItemsCursorGetPagination = Pagination.ItemsCursorGetPagination;
217
219
  export { type ItemsCursorGetPaginationParams as ItemsCursorGetPaginationParams, type ItemsCursorGetPaginationResponse as ItemsCursorGetPaginationResponse, };
218
- export { Sessions as Sessions, type CustomChartsSection as CustomChartsSection, type CustomChartsSectionRequest as CustomChartsSectionRequest, type RunStatsGroupBy as RunStatsGroupBy, type SessionSortableColumns as SessionSortableColumns, type TimedeltaInput as TimedeltaInput, type TracerSession as TracerSession, type TracerSessionWithoutVirtualFields as TracerSessionWithoutVirtualFields, type SessionDeleteResponse as SessionDeleteResponse, type TracerSessionsOffsetPaginationTopLevelArray as TracerSessionsOffsetPaginationTopLevelArray, type SessionCreateParams as SessionCreateParams, type SessionRetrieveParams as SessionRetrieveParams, type SessionUpdateParams as SessionUpdateParams, type SessionListParams as SessionListParams, };
219
220
  export { Datasets as Datasets, type DataType as DataType, type Dataset as Dataset, type DatasetTransformation as DatasetTransformation, type DatasetVersion as DatasetVersion, type FeedbackCreateCoreSchema as FeedbackCreateCoreSchema, type Missing as Missing, type SortByDatasetColumn as SortByDatasetColumn, };
220
221
  export { Runs as Runs, type ResponseBodyForRunsGenerateQuery as ResponseBodyForRunsGenerateQuery, type Run as Run, type RunIngest as RunIngest, type RunSchema as RunSchema, type RunStatsQueryParams as RunStatsQueryParams, type RunTypeEnum as RunTypeEnum, type RunsFilterDataSourceTypeEnum as RunsFilterDataSourceTypeEnum, type RunsItemsCursorPostPagination as RunsItemsCursorPostPagination, type RunQueryV2Params as RunQueryV2Params, type RunRetrieveV2Params as RunRetrieveV2Params, type RunRetrieveParams as RunRetrieveParams, type RunQueryParams as RunQueryParams, };
222
+ export { Threads as Threads, type ThreadListItem as ThreadListItem, type ThreadTraceListItem as ThreadTraceListItem, type ThreadStatsResponse as ThreadStatsResponse, type ThreadTraceListItemsItemsCursorGetPagination as ThreadTraceListItemsItemsCursorGetPagination, type ThreadListItemsItemsCursorPostPagination as ThreadListItemsItemsCursorPostPagination, type ThreadListTracesParams as ThreadListTracesParams, type ThreadQueryParams as ThreadQueryParams, type ThreadStatsParams as ThreadStatsParams, };
223
+ export { Traces as Traces, type Trace as Trace, type TraceAggregates as TraceAggregates, type TraceListRunsResponse as TraceListRunsResponse, type TracesItemsCursorPostPagination as TracesItemsCursorPostPagination, type TraceListRunsParams as TraceListRunsParams, type TraceQueryParams as TraceQueryParams, };
221
224
  export { OnlineEvaluators as OnlineEvaluators, type BulkDeleteEvaluatorFailedItem as BulkDeleteEvaluatorFailedItem, type BulkDeleteEvaluatorsResponse as BulkDeleteEvaluatorsResponse, type CreateOnlineCodeEvaluatorRequest as CreateOnlineCodeEvaluatorRequest, type CreateOnlineEvaluatorRequest as CreateOnlineEvaluatorRequest, type CreateOnlineEvaluatorResponse as CreateOnlineEvaluatorResponse, type CreateOnlineLlmEvaluatorRequest as CreateOnlineLlmEvaluatorRequest, type GetOnlineEvaluatorSpendResponse as GetOnlineEvaluatorSpendResponse, type OnlineCodeEvaluator as OnlineCodeEvaluator, type OnlineEvaluator as OnlineEvaluator, type OnlineEvaluatorRunRule as OnlineEvaluatorRunRule, type OnlineEvaluatorSpendDay as OnlineEvaluatorSpendDay, type OnlineEvaluatorSpendGroup as OnlineEvaluatorSpendGroup, type OnlineEvaluatorType as OnlineEvaluatorType, type OnlineLlmEvaluator as OnlineLlmEvaluator, type OnlineSpendLimit as OnlineSpendLimit, type UpdateOnlineCodeEvaluatorRequest as UpdateOnlineCodeEvaluatorRequest, type UpdateOnlineEvaluatorRequest as UpdateOnlineEvaluatorRequest, type UpdateOnlineEvaluatorResponse as UpdateOnlineEvaluatorResponse, type UpdateOnlineLlmEvaluatorRequest as UpdateOnlineLlmEvaluatorRequest, type OnlineEvaluatorsOffsetPaginationOnlineEvaluators as OnlineEvaluatorsOffsetPaginationOnlineEvaluators, type OnlineEvaluatorCreateParams as OnlineEvaluatorCreateParams, type OnlineEvaluatorUpdateParams as OnlineEvaluatorUpdateParams, type OnlineEvaluatorListParams as OnlineEvaluatorListParams, type OnlineEvaluatorDeleteParams as OnlineEvaluatorDeleteParams, type OnlineEvaluatorBulkDeleteParams as OnlineEvaluatorBulkDeleteParams, type OnlineEvaluatorSpendParams as OnlineEvaluatorSpendParams, };
222
225
  export { Info as Info, type InfoListResponse as InfoListResponse };
223
226
  export { Issues as Issues, type Issue as Issue, type IssuesOffsetPaginationIssues as IssuesOffsetPaginationIssues, type IssueListParams as IssueListParams, };
@@ -30,7 +30,8 @@ import { Info } from './resources/info.js';
30
30
  import { Issues } from './resources/issues.js';
31
31
  import { OnlineEvaluators, } from './resources/online-evaluators.js';
32
32
  import { Runs, } from './resources/runs.js';
33
- import { Sessions, } from './resources/sessions.js';
33
+ import { Threads, } from './resources/threads.js';
34
+ import { Traces, } from './resources/traces.js';
34
35
  import { Datasets, } from './resources/datasets/datasets.js';
35
36
  import { Sandboxes, } from './resources/sandboxes/sandboxes.js';
36
37
  import { buildHeaders } from './internal/headers.js';
@@ -123,12 +124,6 @@ export class Langsmith {
123
124
  writable: true,
124
125
  value: void 0
125
126
  });
126
- Object.defineProperty(this, "sessions", {
127
- enumerable: true,
128
- configurable: true,
129
- writable: true,
130
- value: new API.Sessions(this)
131
- });
132
127
  Object.defineProperty(this, "datasets", {
133
128
  enumerable: true,
134
129
  configurable: true,
@@ -141,6 +136,18 @@ export class Langsmith {
141
136
  writable: true,
142
137
  value: new API.Runs(this)
143
138
  });
139
+ Object.defineProperty(this, "threads", {
140
+ enumerable: true,
141
+ configurable: true,
142
+ writable: true,
143
+ value: new API.Threads(this)
144
+ });
145
+ Object.defineProperty(this, "traces", {
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true,
149
+ value: new API.Traces(this)
150
+ });
144
151
  Object.defineProperty(this, "onlineEvaluators", {
145
152
  enumerable: true,
146
153
  configurable: true,
@@ -704,9 +711,10 @@ Object.defineProperty(Langsmith, "toFile", {
704
711
  writable: true,
705
712
  value: Uploads.toFile
706
713
  });
707
- Langsmith.Sessions = Sessions;
708
714
  Langsmith.Datasets = Datasets;
709
715
  Langsmith.Runs = Runs;
716
+ Langsmith.Threads = Threads;
717
+ Langsmith.Traces = Traces;
710
718
  Langsmith.OnlineEvaluators = OnlineEvaluators;
711
719
  Langsmith.Info = Info;
712
720
  Langsmith.Issues = Issues;
@@ -2,7 +2,7 @@
2
2
  // @ts-nocheck
3
3
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.Sessions = exports.Sandboxes = exports.Runs = exports.OnlineEvaluators = exports.Issues = exports.Info = exports.Datasets = void 0;
5
+ exports.Traces = exports.Threads = exports.Sandboxes = exports.Runs = exports.OnlineEvaluators = exports.Issues = exports.Info = exports.Datasets = void 0;
6
6
  var datasets_js_1 = require("./datasets/datasets.cjs");
7
7
  Object.defineProperty(exports, "Datasets", { enumerable: true, get: function () { return datasets_js_1.Datasets; } });
8
8
  var info_js_1 = require("./info.cjs");
@@ -15,5 +15,7 @@ var runs_js_1 = require("./runs.cjs");
15
15
  Object.defineProperty(exports, "Runs", { enumerable: true, get: function () { return runs_js_1.Runs; } });
16
16
  var sandboxes_js_1 = require("./sandboxes/sandboxes.cjs");
17
17
  Object.defineProperty(exports, "Sandboxes", { enumerable: true, get: function () { return sandboxes_js_1.Sandboxes; } });
18
- var sessions_js_1 = require("./sessions.cjs");
19
- Object.defineProperty(exports, "Sessions", { enumerable: true, get: function () { return sessions_js_1.Sessions; } });
18
+ var threads_js_1 = require("./threads.cjs");
19
+ Object.defineProperty(exports, "Threads", { enumerable: true, get: function () { return threads_js_1.Threads; } });
20
+ var traces_js_1 = require("./traces.cjs");
21
+ Object.defineProperty(exports, "Traces", { enumerable: true, get: function () { return traces_js_1.Traces; } });
@@ -4,4 +4,5 @@ export { Issues, type Issue, type IssueListParams, type IssuesOffsetPaginationIs
4
4
  export { OnlineEvaluators, type BulkDeleteEvaluatorFailedItem, type BulkDeleteEvaluatorsResponse, type CreateOnlineCodeEvaluatorRequest, type CreateOnlineEvaluatorRequest, type CreateOnlineEvaluatorResponse, type CreateOnlineLlmEvaluatorRequest, type GetOnlineEvaluatorSpendResponse, type OnlineCodeEvaluator, type OnlineEvaluator, type OnlineEvaluatorRunRule, type OnlineEvaluatorSpendDay, type OnlineEvaluatorSpendGroup, type OnlineEvaluatorType, type OnlineLlmEvaluator, type OnlineSpendLimit, type UpdateOnlineCodeEvaluatorRequest, type UpdateOnlineEvaluatorRequest, type UpdateOnlineEvaluatorResponse, type UpdateOnlineLlmEvaluatorRequest, type OnlineEvaluatorCreateParams, type OnlineEvaluatorUpdateParams, type OnlineEvaluatorListParams, type OnlineEvaluatorDeleteParams, type OnlineEvaluatorBulkDeleteParams, type OnlineEvaluatorSpendParams, type OnlineEvaluatorsOffsetPaginationOnlineEvaluators, } from './online-evaluators.js';
5
5
  export { Runs, type ResponseBodyForRunsGenerateQuery, type Run, type RunIngest, type RunSchema, type RunStatsQueryParams, type RunTypeEnum, type RunsFilterDataSourceTypeEnum, type RunQueryV2Params, type RunRetrieveV2Params, type RunRetrieveParams, type RunQueryParams, type RunsItemsCursorPostPagination, } from './runs.js';
6
6
  export { Sandboxes, type SandboxListResponse, type SandboxResponse, type SandboxStatusResponse, type ServiceURLResponse, type SnapshotListResponse, type SnapshotResponse, } from './sandboxes/sandboxes.js';
7
- export { Sessions, type CustomChartsSection, type CustomChartsSectionRequest, type RunStatsGroupBy, type SessionSortableColumns, type TimedeltaInput, type TracerSession, type TracerSessionWithoutVirtualFields, type SessionDeleteResponse, type SessionCreateParams, type SessionRetrieveParams, type SessionUpdateParams, type SessionListParams, type TracerSessionsOffsetPaginationTopLevelArray, } from './sessions.js';
7
+ export { Threads, type ThreadListItem, type ThreadTraceListItem, type ThreadStatsResponse, type ThreadListTracesParams, type ThreadQueryParams, type ThreadStatsParams, type ThreadTraceListItemsItemsCursorGetPagination, type ThreadListItemsItemsCursorPostPagination, } from './threads.js';
8
+ export { Traces, type Trace, type TraceAggregates, type TraceListRunsResponse, type TraceListRunsParams, type TraceQueryParams, type TracesItemsCursorPostPagination, } from './traces.js';
@@ -6,4 +6,5 @@ export { Issues } from './issues.js';
6
6
  export { OnlineEvaluators, } from './online-evaluators.js';
7
7
  export { Runs, } from './runs.js';
8
8
  export { Sandboxes, } from './sandboxes/sandboxes.js';
9
- export { Sessions, } from './sessions.js';
9
+ export { Threads, } from './threads.js';
10
+ export { Traces, } from './traces.js';
@@ -1,5 +1,4 @@
1
1
  import { APIResource } from '../core/resource.js';
2
- import * as SessionsAPI from './sessions.js';
3
2
  import { APIPromise } from '../core/api-promise.js';
4
3
  import { ItemsCursorPostPagination, type ItemsCursorPostPaginationParams, PagePromise } from '../core/pagination.js';
5
4
  import { RequestOptions } from '../internal/request-options.js';
@@ -548,7 +547,7 @@ export interface RunStatsQueryParams {
548
547
  /**
549
548
  * Group by param for run stats.
550
549
  */
551
- group_by?: SessionsAPI.RunStatsGroupBy | null;
550
+ group_by?: RunStatsQueryParams.GroupBy | null;
552
551
  groups?: Array<string | null> | null;
553
552
  include_details?: boolean;
554
553
  is_root?: boolean | null;
@@ -569,6 +568,16 @@ export interface RunStatsQueryParams {
569
568
  tree_filter?: string | null;
570
569
  use_experimental_search?: boolean;
571
570
  }
571
+ export declare namespace RunStatsQueryParams {
572
+ /**
573
+ * Group by param for run stats.
574
+ */
575
+ interface GroupBy {
576
+ attribute: 'name' | 'run_type' | 'tag' | 'metadata';
577
+ max_groups?: number;
578
+ path?: string | null;
579
+ }
580
+ }
572
581
  /**
573
582
  * Enum for run types.
574
583
  */
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.Threads = void 0;
6
+ const resource_js_1 = require("../core/resource.cjs");
7
+ const pagination_js_1 = require("../core/pagination.cjs");
8
+ const path_js_1 = require("../internal/utils/path.cjs");
9
+ class Threads extends resource_js_1.APIResource {
10
+ /**
11
+ * **Alpha:** The request and response contract may change; Retrieve all traces
12
+ * belonging to a specific thread within a project.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // Automatically fetches more pages as needed.
17
+ * for await (const threadTraceListItem of client.threads.listTraces(
18
+ * 'thread_id',
19
+ * { project_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
20
+ * )) {
21
+ * // ...
22
+ * }
23
+ * ```
24
+ */
25
+ listTraces(threadID, query, options) {
26
+ return this._client.getAPIList((0, path_js_1.path) `/v2/threads/${threadID}/traces`, (pagination_js_1.ItemsCursorGetPagination), { query, ...options });
27
+ }
28
+ /**
29
+ * **Alpha:** The request and response contract may change; Query threads within a
30
+ * project (session), with cursor-based pagination. Returns threads matching the
31
+ * given time range and optional filter.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * // Automatically fetches more pages as needed.
36
+ * for await (const threadListItem of client.threads.query()) {
37
+ * // ...
38
+ * }
39
+ * ```
40
+ */
41
+ query(body, options) {
42
+ return this._client.getAPIList('/v2/threads/query', (pagination_js_1.ItemsCursorPostPagination), {
43
+ body,
44
+ method: 'post',
45
+ ...options,
46
+ });
47
+ }
48
+ /**
49
+ * **Alpha:** The request and response contract may change; Compute aggregate stats
50
+ * for a single thread (turn count, latency percentiles, token/cost sums, and
51
+ * detail breakdowns) within a project.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const response = await client.threads.stats('thread_id', {
56
+ * selects: ['TURNS'],
57
+ * session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
58
+ * });
59
+ * ```
60
+ */
61
+ stats(threadID, query, options) {
62
+ return this._client.get((0, path_js_1.path) `/v2/threads/${threadID}/stats`, { query, ...options });
63
+ }
64
+ }
65
+ exports.Threads = Threads;