Reference/SDK/Typescript/Classes

Class: Dataset<IsLegacyDataset>

A dataset is a collection of records, such as model inputs and expected outputs, which represent data you can use to evaluate and fine-tune models. You can log production data to datasets, curate them with interesting examples, edit/delete records, and run evaluations against them.

You should not create Dataset objects directly. Instead, use the braintrust.initDataset() method.

Type parameters

NameType
IsLegacyDatasetextends boolean = typeof DEFAULT_IS_LEGACY_DATASET

Hierarchy

Accessors

id

get id(): Promise<string>

Returns

Promise<string>

Overrides

ObjectFetcher.id


name

get name(): Promise<string>

Returns

Promise<string>


project

get project(): Promise<ObjectMetadata>

Returns

Promise<ObjectMetadata>

Constructors

constructor

new Dataset<IsLegacyDataset>(state, lazyMetadata, pinnedVersion?, legacy?): Dataset<IsLegacyDataset>

Type parameters

NameType
IsLegacyDatasetextends boolean = false

Parameters

NameType
stateBraintrustState
lazyMetadataLazyValue<ProjectDatasetMetadata>
pinnedVersion?string
legacy?IsLegacyDataset

Returns

Dataset<IsLegacyDataset>

Overrides

ObjectFetcher&lt;DatasetRecord&lt;IsLegacyDataset&gt;&gt;.constructor

Methods

[asyncIterator]

[asyncIterator](): AsyncIterator<WithTransactionId<DatasetRecord<IsLegacyDataset>>, any, undefined>

Returns

AsyncIterator<WithTransactionId<DatasetRecord<IsLegacyDataset>>, any, undefined>

Inherited from

ObjectFetcher.[asyncIterator]


clearCache

clearCache(): void

Returns

void

Inherited from

ObjectFetcher.clearCache


close

close(): Promise<string>

This function is deprecated. You can simply remove it from your code.

Returns

Promise<string>


delete

delete(id): string

Parameters

NameType
idstring

Returns

string


fetch

fetch(): AsyncGenerator<WithTransactionId<DatasetRecord<IsLegacyDataset>>, any, unknown>

Returns

AsyncGenerator<WithTransactionId<DatasetRecord<IsLegacyDataset>>, any, unknown>

Inherited from

ObjectFetcher.fetch


fetchedData

fetchedData(): Promise<WithTransactionId<DatasetRecord<IsLegacyDataset>>[]>

Returns

Promise<WithTransactionId<DatasetRecord<IsLegacyDataset>>[]>

Inherited from

ObjectFetcher.fetchedData


flush

flush(): Promise<void>

Flush any pending rows to the server.

Returns

Promise<void>


getState

getState(): Promise<BraintrustState>

Returns

Promise<BraintrustState>

Overrides

ObjectFetcher.getState


insert

insert(event): string

Insert a single record to the dataset. The record will be batched and uploaded behind the scenes. If you pass in an id, and a record with that id already exists, it will be overwritten (upsert).

Parameters

NameTypeDescription
eventObjectThe event to log.
event.expected?unknownThe output of your application, including post-processing (an arbitrary, JSON serializable object).
event.id?string(Optional) a unique identifier for the event. If you don't provide one, Braintrust will generate one for you.
event.input?unknownThe argument that uniquely define an input case (an arbitrary, JSON serializable object).
event.metadata?Record<string, unknown>(Optional) a dictionary with additional data about the test example, model outputs, or just about anything else that's relevant, that you can use to help find and analyze examples later. For example, you could log the prompt, example's id, or anything else that would be useful to slice/dice later. The values in metadata can be any JSON-serializable type, but its keys must be strings.
event.output?unknown-
event.tags?string[](Optional) a list of strings that you can use to filter and group records later.

Returns

string

The id of the logged record.


summarize

summarize(options?): Promise<DatasetSummary>

Summarize the dataset, including high level metrics about its size and other metadata.

Parameters

NameType
optionsObject
options.summarizeData?boolean

Returns

Promise<DatasetSummary>

DatasetSummary

A summary of the dataset.


version

version(): Promise<undefined | string>

Returns

Promise<undefined | string>

Inherited from

ObjectFetcher.version