본문으로 건너뛰기

데이터 세트 클래스

추가된 항목: @mastra/core@1.4.0

Dataset 클래스는 단일 데이터 세트에서 항목 CRUD, 버전 관리, 실험 관리를 수행하는 메서드를 제공합니다. mastra.datasets.get() 또는 mastra.datasets.create()를 통해 가져올 수 있습니다.

사용 예
사용 예에 대한 직접 링크

항목 추가 및 실험 실행
항목 추가 및 실험 실행에 대한 직접 링크

src/mastra/datasets/usage.ts
import { Mastra } from '@mastra/core'

const mastra = new Mastra({/* storage config */})

const dataset = await mastra.datasets.create({
name: 'QA pairs',
})

// Add items
await dataset.addItems({
items: [
{ input: { question: 'What is AI?' }, groundTruth: { answer: 'Artificial Intelligence' } },
{ input: { question: 'What is ML?' }, groundTruth: { answer: 'Machine Learning' } },
],
})

// Run an experiment
const summary = await dataset.startExperiment({
targetType: 'agent',
targetId: 'my-agent',
scorers: ['accuracy'],
})

console.log(`${summary.succeededCount}/${summary.totalItems} succeeded`)

버전 및 기록 관리
버전 및 기록 관리에 대한 직접 링크

src/mastra/datasets/versioning.ts
import { Mastra } from '@mastra/core'

const mastra = new Mastra({/* storage config */})

const dataset = await mastra.datasets.get({ id: 'dataset-id' })

// List versions
const { versions } = await dataset.listVersions()

// List items at a specific version
const items = await dataset.listItems({ version: 2 })

// Get item change history
const history = await dataset.getItemHistory({ itemId: 'item-id' })

입장
입장에 대한 직접 링크

Dataset직접 인스턴스화되지 않습니다. 다음을 통해 구입하세요.DatasetsManager:

const dataset = await mastra.datasets.get({ id: 'dataset-id' })
// or
const dataset = await mastra.datasets.create({ name: 'My dataset' })

속성
속성에 대한 직접 링크

전체 데이터 세트 레코드(이름, 설명, 스키마, 버전, 타임스탬프)를 보려면 다음을 호출하세요.dataset.getDetails().

id:

string
데이터 세트의 고유 식별자입니다. 읽기 전용입니다.