-
Notifications
You must be signed in to change notification settings - Fork 0
/
datasets.ts
395 lines (358 loc) · 13.4 KB
/
datasets.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../resource';
import { isRequestOptions } from '../core';
import * as Core from '../core';
import * as DatasetsAPI from './datasets';
import * as Shared from './shared';
import { DatasetsListObjects } from './shared';
import { type ListObjectsParams } from '../pagination';
export class Datasets extends APIResource {
/**
* Create a new dataset. If there is an existing dataset in the project with the
* same name as the one specified in the request, will return the existing dataset
* unmodified
*/
create(body: DatasetCreateParams, options?: Core.RequestOptions): Core.APIPromise<Shared.Dataset> {
return this._client.post('/v1/dataset', { body, ...options });
}
/**
* Get a dataset object by its id
*/
retrieve(datasetId: string, options?: Core.RequestOptions): Core.APIPromise<Shared.Dataset> {
return this._client.get(`/v1/dataset/${datasetId}`, options);
}
/**
* Partially update a dataset object. Specify the fields to update in the payload.
* Any object-type fields will be deep-merged with existing content. Currently we
* do not support removing fields or setting them to null.
*/
update(
datasetId: string,
body?: DatasetUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.Dataset>;
update(datasetId: string, options?: Core.RequestOptions): Core.APIPromise<Shared.Dataset>;
update(
datasetId: string,
body: DatasetUpdateParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Shared.Dataset> {
if (isRequestOptions(body)) {
return this.update(datasetId, {}, body);
}
return this._client.patch(`/v1/dataset/${datasetId}`, { body, ...options });
}
/**
* List out all datasets. The datasets are sorted by creation date, with the most
* recently-created datasets coming first
*/
list(
query?: DatasetListParams,
options?: Core.RequestOptions,
): Core.PagePromise<DatasetsListObjects, Shared.Dataset>;
list(options?: Core.RequestOptions): Core.PagePromise<DatasetsListObjects, Shared.Dataset>;
list(
query: DatasetListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<DatasetsListObjects, Shared.Dataset> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/v1/dataset', DatasetsListObjects, { query, ...options });
}
/**
* Delete a dataset object by its id
*/
delete(datasetId: string, options?: Core.RequestOptions): Core.APIPromise<Shared.Dataset> {
return this._client.delete(`/v1/dataset/${datasetId}`, options);
}
/**
* Log feedback for a set of dataset events
*/
feedback(
datasetId: string,
body: DatasetFeedbackParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.FeedbackResponseSchema> {
return this._client.post(`/v1/dataset/${datasetId}/feedback`, { body, ...options });
}
/**
* Fetch the events in a dataset. Equivalent to the POST form of the same path, but
* with the parameters in the URL query rather than in the request body
*/
fetch(
datasetId: string,
query?: DatasetFetchParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.FetchDatasetEventsResponse>;
fetch(datasetId: string, options?: Core.RequestOptions): Core.APIPromise<Shared.FetchDatasetEventsResponse>;
fetch(
datasetId: string,
query: DatasetFetchParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Shared.FetchDatasetEventsResponse> {
if (isRequestOptions(query)) {
return this.fetch(datasetId, {}, query);
}
return this._client.get(`/v1/dataset/${datasetId}/fetch`, { query, ...options });
}
/**
* Fetch the events in a dataset. Equivalent to the GET form of the same path, but
* with the parameters in the request body rather than in the URL query
*/
fetchPost(
datasetId: string,
body?: DatasetFetchPostParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.FetchDatasetEventsResponse>;
fetchPost(
datasetId: string,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.FetchDatasetEventsResponse>;
fetchPost(
datasetId: string,
body: DatasetFetchPostParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Shared.FetchDatasetEventsResponse> {
if (isRequestOptions(body)) {
return this.fetchPost(datasetId, {}, body);
}
return this._client.post(`/v1/dataset/${datasetId}/fetch`, { body, ...options });
}
/**
* Insert a set of events into the dataset
*/
insert(
datasetId: string,
body: DatasetInsertParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.InsertEventsResponse> {
return this._client.post(`/v1/dataset/${datasetId}/insert`, { body, ...options });
}
/**
* Summarize dataset
*/
summarize(
datasetId: string,
query?: DatasetSummarizeParams,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.SummarizeDatasetResponse>;
summarize(
datasetId: string,
options?: Core.RequestOptions,
): Core.APIPromise<Shared.SummarizeDatasetResponse>;
summarize(
datasetId: string,
query: DatasetSummarizeParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Shared.SummarizeDatasetResponse> {
if (isRequestOptions(query)) {
return this.summarize(datasetId, {}, query);
}
return this._client.get(`/v1/dataset/${datasetId}/summarize`, { query, ...options });
}
}
export interface DatasetCreateParams {
/**
* Name of the dataset. Within a project, dataset names are unique
*/
name: string;
/**
* Unique identifier for the project that the dataset belongs under
*/
project_id: string;
/**
* Textual description of the dataset
*/
description?: string | null;
}
export interface DatasetUpdateParams {
/**
* Textual description of the dataset
*/
description?: string | null;
/**
* User-controlled metadata about the dataset
*/
metadata?: Record<string, unknown> | null;
/**
* Name of the dataset. Within a project, dataset names are unique
*/
name?: string | null;
}
export interface DatasetListParams extends ListObjectsParams {
/**
* Name of the dataset to search for
*/
dataset_name?: string;
/**
* Filter search results to a particular set of object IDs. To specify a list of
* IDs, include the query param multiple times
*/
ids?: string | Array<string>;
/**
* Filter search results to within a particular organization
*/
org_name?: string;
/**
* Project id
*/
project_id?: string;
/**
* Name of the project to search for
*/
project_name?: string;
}
export interface DatasetFeedbackParams {
/**
* A list of dataset feedback items
*/
feedback: Array<Shared.FeedbackDatasetItem>;
}
export interface DatasetFetchParams {
/**
* limit the number of traces fetched
*
* Fetch queries may be paginated if the total result size is expected to be large
* (e.g. project_logs which accumulate over a long time). Note that fetch queries
* only support pagination in descending time order (from latest to earliest
* `_xact_id`. Furthermore, later pages may return rows which showed up in earlier
* pages, except with an earlier `_xact_id`. This happens because pagination occurs
* over the whole version history of the event log. You will most likely want to
* exclude any such duplicate, outdated rows (by `id`) from your combined result
* set.
*
* The `limit` parameter controls the number of full traces to return. So you may
* end up with more individual rows than the specified limit if you are fetching
* events containing traces.
*/
limit?: number | null;
/**
* DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in
* favor of the explicit 'cursor' returned by object fetch requests. Please prefer
* the 'cursor' argument going forwards.
*
* Together, `max_xact_id` and `max_root_span_id` form a pagination cursor
*
* Since a paginated fetch query returns results in order from latest to earliest,
* the cursor for the next page can be found as the row with the minimum (earliest)
* value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit`
* for an overview of paginating fetch queries.
*/
max_root_span_id?: string;
/**
* DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in
* favor of the explicit 'cursor' returned by object fetch requests. Please prefer
* the 'cursor' argument going forwards.
*
* Together, `max_xact_id` and `max_root_span_id` form a pagination cursor
*
* Since a paginated fetch query returns results in order from latest to earliest,
* the cursor for the next page can be found as the row with the minimum (earliest)
* value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit`
* for an overview of paginating fetch queries.
*/
max_xact_id?: string;
/**
* Retrieve a snapshot of events from a past time
*
* The version id is essentially a filter on the latest event transaction id. You
* can use the `max_xact_id` returned by a past fetch as the version to reproduce
* that exact fetch.
*/
version?: string;
}
export interface DatasetFetchPostParams {
/**
* An opaque string to be used as a cursor for the next page of results, in order
* from latest to earliest.
*
* The string can be obtained directly from the `cursor` property of the previous
* fetch query
*/
cursor?: string | null;
/**
* NOTE: This parameter is deprecated and will be removed in a future revision.
* Consider using the `/btql` endpoint
* (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering.
*
* A list of filters on the events to fetch. Currently, only path-lookup type
* filters are supported.
*/
filters?: Array<Shared.PathLookupFilter> | null;
/**
* limit the number of traces fetched
*
* Fetch queries may be paginated if the total result size is expected to be large
* (e.g. project_logs which accumulate over a long time). Note that fetch queries
* only support pagination in descending time order (from latest to earliest
* `_xact_id`. Furthermore, later pages may return rows which showed up in earlier
* pages, except with an earlier `_xact_id`. This happens because pagination occurs
* over the whole version history of the event log. You will most likely want to
* exclude any such duplicate, outdated rows (by `id`) from your combined result
* set.
*
* The `limit` parameter controls the number of full traces to return. So you may
* end up with more individual rows than the specified limit if you are fetching
* events containing traces.
*/
limit?: number | null;
/**
* DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in
* favor of the explicit 'cursor' returned by object fetch requests. Please prefer
* the 'cursor' argument going forwards.
*
* Together, `max_xact_id` and `max_root_span_id` form a pagination cursor
*
* Since a paginated fetch query returns results in order from latest to earliest,
* the cursor for the next page can be found as the row with the minimum (earliest)
* value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit`
* for an overview of paginating fetch queries.
*/
max_root_span_id?: string | null;
/**
* DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in
* favor of the explicit 'cursor' returned by object fetch requests. Please prefer
* the 'cursor' argument going forwards.
*
* Together, `max_xact_id` and `max_root_span_id` form a pagination cursor
*
* Since a paginated fetch query returns results in order from latest to earliest,
* the cursor for the next page can be found as the row with the minimum (earliest)
* value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit`
* for an overview of paginating fetch queries.
*/
max_xact_id?: string | null;
/**
* Retrieve a snapshot of events from a past time
*
* The version id is essentially a filter on the latest event transaction id. You
* can use the `max_xact_id` returned by a past fetch as the version to reproduce
* that exact fetch.
*/
version?: string | null;
}
export interface DatasetInsertParams {
/**
* A list of dataset events to insert
*/
events: Array<Shared.InsertDatasetEventReplace | Shared.InsertDatasetEventMerge>;
}
export interface DatasetSummarizeParams {
/**
* Whether to summarize the data. If false (or omitted), only the metadata will be
* returned.
*/
summarize_data?: boolean | null;
}
export namespace Datasets {
export import DatasetCreateParams = DatasetsAPI.DatasetCreateParams;
export import DatasetUpdateParams = DatasetsAPI.DatasetUpdateParams;
export import DatasetListParams = DatasetsAPI.DatasetListParams;
export import DatasetFeedbackParams = DatasetsAPI.DatasetFeedbackParams;
export import DatasetFetchParams = DatasetsAPI.DatasetFetchParams;
export import DatasetFetchPostParams = DatasetsAPI.DatasetFetchPostParams;
export import DatasetInsertParams = DatasetsAPI.DatasetInsertParams;
export import DatasetSummarizeParams = DatasetsAPI.DatasetSummarizeParams;
}
export { DatasetsListObjects };