@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
51 lines (36 loc) • 1.27 kB
Markdown
# DatasetsManager.create()
**Added in:** `@mastra/core@1.4.0`
Creates a new dataset. Use Standard JSON Schema (Zod, Valibot, ArkType, etc.) for defining schemas.
## Usage example
```typescript
import { Mastra } from '@mastra/core'
import { z } from 'zod'
const mastra = new Mastra({
/* storage config */
})
// Create with metadata
const dataset = await mastra.datasets.create({
name: 'QA evaluation set',
description: 'Question-answer pairs for testing',
metadata: { team: 'ml' },
})
// Create with Zod schema (library that supports Standard JSON Schema)
const typedDataset = await mastra.datasets.create({
name: 'Typed QA set',
inputSchema: z.object({
question: z.string(),
context: z.string().optional(),
}),
groundTruthSchema: z.object({
answer: z.string(),
}),
})
```
## Parameters
**name** (`string`): Display name for the dataset.
**description** (`string`): Description of the dataset.
**inputSchema** (`StandardJSONSchemaV1`): Standard JSON Schema for item inputs.
**groundTruthSchema** (`StandardJSONSchemaV1`): Standard JSON Schema for item ground truths.
**metadata** (`Record<string, unknown>`): Arbitrary metadata.
## Returns
**result** (`Promise<Dataset>`): A Dataset instance for the newly created dataset.