dataset.updateItem()
Added in: @mastra/core@1.4.0
Updates an existing item in the dataset. Only the provided fields are updated. Updating an item creates a new version.
Usage exampleUsage example的直接链接
import { Mastra } from '@mastra/core'
const mastra = new Mastra({/* storage config */})
const dataset = await mastra.datasets.get({ id: 'dataset-id' })
const updated = await dataset.updateItem({
itemId: 'item-id',
input: { question: 'What is TypeScript?' },
groundTruth: { answer: 'A typed superset of JavaScript' },
scorerIds: null,
metadata: { reviewed: true },
})
ParametersParameters的直接链接
itemId:
string
ID of the item to update.
input?:
unknown
Updated input data.
groundTruth?:
unknown
Updated ground truth.
expectedTrajectory?:
unknown
Updated expected trajectory for trajectory scorers.
toolMocks?:
DatasetItemToolMock[]
Updated static tool mocks used during experiments. Each mock has
toolName, args, output, and an optional matchArgs ('strict' | 'ignore').unmockedToolPolicy?:
'allow' | 'deny'
Overrides how the experiment handles tool calls that are not declared in
toolMocks.requestContext?:
Record<string, unknown>
Updated request context applied when the item runs.
scorerIds?:
string[] | null
Scorer IDs that override dataset-attached scorers for this item. Use
[] to run no scorers, null to remove the override and restore dataset inheritance, or omit the field to preserve the current value.metadata?:
Record<string, unknown>
Updated metadata.
source?:
{ type: 'csv' | 'json' | 'trace' | 'llm' | 'experiment-result' | 'candidate-screener'; referenceId?: string }
Updated provenance of the item.
ReturnsReturns的直接链接
result:
Promise<DatasetItem>
The updated dataset item. See dataset.addItem() for the item shape.