@mastra/core
Version:
80 lines • 2.63 kB
TypeScript
import type { TraceRecord, MastraStorage } from '../../storage/index.js';
import type { MastraScorer } from '../base.js';
import type { ScoreRowData } from '../types.js';
export type ScoreTraceTarget = {
traceId: string;
spanId?: string;
} | {
trace: TraceRecord;
spanId?: string;
};
export type ScoreTraceBatchTarget = {
traceId: string;
spanId?: string;
datasetItemId?: string;
};
export type ScoreTraceBatchResult = {
ok: true;
index: number;
traceId: string;
spanId: string;
datasetItemId?: string;
score: ScoreRowData;
} | {
ok: false;
index: number;
traceId: string;
spanId?: string;
datasetItemId?: string;
error: Error;
};
/**
* Resolve a trace/span target, run the scorer, and persist the resulting score.
*/
export declare function scoreTrace({ storage, scorer, target, batchId, datasetId, datasetItemId, }: {
storage: MastraStorage;
scorer: MastraScorer;
target: ScoreTraceTarget;
/** Optional batch handle stamped on the persisted score so all scores from one
* batch scoring call share a `batchId` (each keeps its own per-execution `runId`). */
batchId?: string;
/** Optional dataset provenance stamped on the persisted score so baseline scores
* can join back to the curated dataset item that produced them. Top-level handles,
* independent of how the trace is resolved. */
datasetId?: string;
datasetItemId?: string;
}): Promise<ScoreRowData>;
export declare function scoreTraceBatch({ storage, scorer, targets, batchId, datasetId, concurrency, }: {
storage: MastraStorage;
scorer: MastraScorer;
targets: ScoreTraceBatchTarget[];
batchId?: string;
datasetId?: string;
concurrency?: number;
}): Promise<{
batchId?: string;
datasetId?: string;
scoredCount: number;
failedCount: number;
results: ScoreTraceBatchResult[];
}>;
export declare const scoreTracesWorkflow: import("../../workflows/evented").EventedWorkflow<import("../../workflows/evented").EventedEngineType, import("../../workflows").Step<"__process-trace-scoring", unknown, {
targets: {
traceId: string;
spanId?: string | undefined;
}[];
scorerId: string;
}, any, unknown, unknown, import("../../workflows").DefaultEngineType, unknown>[], "__batch-scoring-traces", unknown, {
targets: {
traceId: string;
spanId?: string | undefined;
}[];
scorerId: string;
}, any, {
targets: {
traceId: string;
spanId?: string | undefined;
}[];
scorerId: string;
}>;
//# sourceMappingURL=scoreTracesWorkflow.d.ts.map