Dataset

type Dataset = {
  id: string;
  createdAt: string;
  name?: Maybe<string>;
  description?: Maybe<string>;
  metadata: Record<string, any>;
  items?: Maybe<DatasetItem[]>;
  type?: Maybe<DatasetType>
}
id
string

The unique identifier of the dataset. This is an immutable field generated when the dataset is created.

createdAt
string

The date and time when the dataset was created, expressed in ISO 8601 format.

metadata
Record<string, any>

A dictionary containing additional data associated with the dataset. This can include user-defined key-value pairs that provide more context or details about the dataset.

name
Maybe<string>

An optional name for the dataset. This can be used to give a descriptive, human-readable title to the dataset for easier identification.

description
Maybe<string>

An optional description field that can provide more detailed information about the dataset, such as its purpose, contents, or specific characteristics.

items
Maybe<DatasetItem[]>

An optional list of items contained within the dataset. Each item in the list is a dictionary representing a specific data entry in the dataset.

type
Maybe<DatasetType>

An optional type of dataset. Defaults to “key_value”, other option is “generation”.

Create a dataset

const dataset = await literalAiClient.api.createDataset({
    name: "Foo", 
    description: "A dataset to store samples.", 
    metadata: { isDemo: true },
});

Params

dataset
DatasetInput

A partial representation of a dataset.

dataset.name
Maybe<string>

An optional name for the dataset. This can be used to give a descriptive, human-readable title to the dataset for easier identification.

dataset.description
Maybe<string>

An optional description field that can provide more detailed information about the dataset, such as its purpose, contents, or specific characteristics.

dataset.metadata
Maybe<Record<string, any>>

A dictionary containing additional data associated with the dataset. This can include user-defined key-value pairs that provide more context or details about the dataset.

Response

dataset
Dataset

Return a Dataset

Update a dataset

const dataset = await literalAiClient.api.updateDataset("dataset_id", {
  name: "Baz",
});

Params

id
string

The unique identifier of the dataset. This is an immutable field generated when the dataset is created.

dataset
DatasetInput

A partial representation of a dataset.

dataset.name
Maybe<string>

An optional name for the dataset. This can be used to give a descriptive, human-readable title to the dataset for easier identification.

dataset.description
Maybe<string>

An optional description field that can provide more detailed information about the dataset, such as its purpose, contents, or specific characteristics.

dataset.metadata
Maybe<Record<string, any>>

A dictionary containing additional data associated with the dataset. This can include user-defined key-value pairs that provide more context or details about the dataset.

Response

dataset
Dataset

Return a Dataset

Get a dataset

const dataset = await literalAiClient.api.getDataset("dataset_id")

Params

id
string

The unique identifier of the dataset. This is an immutable field generated when the dataset is created.

Response

dataset
Dataset

Return a Dataset

Delete a dataset

await literalAiClient.api.deleteDataset("dataset_id")

Params

id
string

The unique identifier of the dataset. This is an immutable field generated when the dataset is created.

Response

dataset
Dataset

Return a Dataset

DatasetItem

type DatasetItem = {
  id: string;
  createdAt: string;
  datasetId: string;
  metadata: Record<string, any>;
  input: Record<string, any>;
  expectedOutput?: Maybe<Record<string, any>>;
  intermediarySteps: Record<string, any>[];
  stepId?: Maybe<string>;
}
id
string

The unique identifier of the dataset item. Each item within a dataset has its own unique ID.

createdAt
string

The date and time when the dataset item was created, expressed in ISO 8601 format.

datasetId
string

The identifier of the dataset to which this item belongs. Links the item to its parent dataset.

metadata
Record<string, any>

A dictionary containing additional data associated with this dataset item. This can include specific details relevant to the item.

input
Record<string, any>

The input data for this dataset item. Typically contains the parameters or information that forms the LLM request.

expectedOutput
Maybe<Record<string, any>>

The optional output data for this dataset item. Represents the result or outcome associated with the item’s input.

intermediarySteps
Record<string, any>[]

An optional list of intermediary steps involved in the output. This can include any processing steps or intermediate results. They are automatically generated when using “steps” to build a dataset.

stepId
Record<string, any>[]

The optional reference ID to a specific step.

Create a dataset item

const datasetItem = await literalAiClient.api.createDatasetItem("dataset_id", {
  input: { content: "What is Literal AI?" },
  expectedOutput: { content: "Literal AI is an observability solution." },
});

# Or directly through a Dataset
const datasetItem = await dataset.createDatasetItem("dataset_id", {
  input: { content: "What is Literal AI?" },
  expectedOutput: { content: "Literal AI is an observability solution." },
});

Params

datasetId
string

The identifier of the dataset to which this item belongs.

datasetItem
DatasetItemInput

A partial representation of a dataset item.

datasetItem.input
Record<string, any>

The input data for this dataset item. Typically contains the parameters or information that forms the LLM request.

datasetItem.expectedOutput
Maybe<Record<string, any>>

The optional output data for this dataset item. Represents the result or outcome associated with the item’s input.

datasetItem.metadata
Maybe<Record<string, any>>

A dictionary containing additional data associated with this dataset item. This can include specific details relevant to the item.

Response

datasetItem
DatasetItem

Return a DatasetItem

Add a step to a dataset

const datasetItem = await literalAiClient.api.addStepToDataset("dataset_id", "step_id");

# Or directly through a Dataset
const datasetItem = await dataset.addStep("step_id");

Params

datasetId
string

The identifier of the dataset to which this item belongs.

stepId
string

The identifier of the step created beforehand.

metadata
Maybe<Record<string, any>>

A dictionary containing additional data associated with this dataset item. This can include specific details relevant to the item.

Response

datasetItem
DatasetItem

Return a DatasetItem

Add a generation to a dataset

const datasetItem = await literalAiClient.api.addGeneationToDataset("dataset_id", "generation_id");

# Or directly through a Dataset
const datasetItem = await dataset.addGeneration("generation_id");

Params

datasetId
string

The identifier of the dataset to which this item belongs.

generationId
string

The identifier of the generation created beforehand.

metadata
Maybe<Record<string, any>>

A dictionary containing additional data associated with this dataset item. This can include specific details relevant to the item.

Response

datasetItem
DatasetItem

Return a DatasetItem

Get a dataset item

const datasetItem = await literalAiClient.api.getDatasetItem("dataset_item_id");

Params

id
string

The unique identifier of the dataset item. Each item within a dataset has its own unique ID.

Response

datasetItem
DatasetItem

Return a DatasetItem

Delete a dataset item

await literalAiClient.api.deleteDatasetItem("dataset_item_id");

# Or directly through a Dataset
await dataset.deleteDatasetItem("dataset_item_id");

Params

id
string

The unique identifier of the dataset item. Each item within a dataset has its own unique ID.

Response

datasetItem
DatasetItem

Return a DatasetItem