@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
41 lines (26 loc) • 1.14 kB
Markdown
# dataset.addItems()
**Added in:** `@mastra/core@1.4.0`
Adds multiple items to the dataset in a single bulk operation.
## Usage example
```typescript
import { Mastra } from '@mastra/core'
const mastra = new Mastra({
/* storage config */
})
const dataset = await mastra.datasets.get({ id: 'dataset-id' })
const items = await dataset.addItems({
items: [
{ input: { question: 'What is AI?' }, groundTruth: { answer: 'Artificial Intelligence' } },
{ input: { question: 'What is ML?' }, groundTruth: { answer: 'Machine Learning' } },
{ input: { question: 'What is DL?' }, metadata: { category: 'deep-learning' } },
],
})
console.log(`Added ${items.length} items`)
```
## Parameters
**items** (`Array<object>`): Array of items to add. Each item has the same shape as the dataset.addItem() input.
**items.input** (`unknown`): Input data for the item.
**items.groundTruth** (`unknown`): Expected output or ground truth.
**items.metadata** (`Record<string, unknown>`): Arbitrary metadata.
## Returns
**result** (`Promise<DatasetItem[]>`): Array of created dataset items. See dataset.addItem() for the item shape.