UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

53 lines (31 loc) 1.34 kB
# dataset.addItem() **Added in:** `@mastra/core@1.4.0` Adds a single item to the dataset. Each item has an input, optional ground truth, and optional metadata. ## Usage example ```typescript import { Mastra } from '@mastra/core' const mastra = new Mastra({ /* storage config */ }) const dataset = await mastra.datasets.get({ id: 'dataset-id' }) const item = await dataset.addItem({ input: { question: 'What is TypeScript?' }, groundTruth: { answer: 'A typed superset of JavaScript' }, metadata: { source: 'manual' }, }) console.log(item.id) ``` ## Parameters **input** (`unknown`): Input data for the item. **groundTruth** (`unknown`): Expected output or ground truth for scoring. **metadata** (`Record<string, unknown>`): Arbitrary metadata for the item. ## Returns **result** (`Promise<DatasetItem>`): The created dataset item. **result.id** (`string`): Unique identifier of the item. **result.datasetId** (`string`): ID of the parent dataset. **result.datasetVersion** (`number`): Dataset version when the item was created. **result.input** (`unknown`): Input data. **result.groundTruth** (`unknown`): Ground truth data. **result.metadata** (`Record<string, unknown>`): Item metadata. **result.createdAt** (`Date`): When the item was created. **result.updatedAt** (`Date`): When the item was last updated.