mastra-browser-core
Version:
The core foundation of the Mastra framework, providing essential components and interfaces for building AI-powered applications.
1 lines • 2.11 kB
Source Map (JSON)
{"version":3,"sources":["../src/eval/metric.ts","../src/eval/evaluation.ts"],"names":["__name","executeHook"],"mappings":";;;;;;AAKO,IAAe,OAAA,GAAf,MAAe,OAAO,CAAA;AAE7B,CAAA;AAF6BA,wBAAA,CAAA,OAAA,EAAA,QAAA,CAAA;AAAtB,IAAe,MAAf,GAAA;;;ACCP,eAAsB,QAA0B,CAAA;AAAA,EAC9C,SAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CASG,EAAA;AACD,EAAM,MAAA,UAAA,GAAa,KAAS,IAAA,MAAA,CAAO,UAAW,EAAA;AAE9C,EAAA,MAAM,eAAe,MAAM,MAAA,CAAO,QAAQ,KAAM,CAAA,QAAA,IAAY,MAAM,CAAA;AAClE,EAAA,MAAM,WAAc,GAAA;AAAA,IAClB,KAAA,EAAO,MAAM,QAAS,EAAA;AAAA,IACtB,MAAA;AAAA,IACA,MAAQ,EAAA,YAAA;AAAA,IACR,SAAA;AAAA,IACA,UAAA,EAAY,OAAO,WAAY,CAAA,IAAA;AAAA,IAC/B,YAAA;AAAA,IACA,WAAA;AAAA,IACA,KAAO,EAAA,UAAA;AAAA,IACP;AAAA,GACF;AAEA,EAAAC,6BAAA,CAAA,cAAA,sBAA0C,WAAW,CAAA;AAErD,EAAO,OAAA,YAAA;AACT;AArCsBD,wBAAA,CAAA,QAAA,EAAA,UAAA,CAAA","file":"chunk-MZW7EZIY.cjs","sourcesContent":["export interface MetricResult {\n score: number;\n info?: Record<string, any>;\n}\n\nexport abstract class Metric {\n abstract measure(input: string, output: string): Promise<MetricResult>;\n}\n","import type { Agent } from '../agent';\nimport { AvailableHooks, executeHook } from '../hooks';\n\nimport type { Metric } from './metric';\nimport type { TestInfo } from './types';\n\nexport async function evaluate<T extends Agent>({\n agentName,\n input,\n metric,\n output,\n runId,\n globalRunId,\n testInfo,\n instructions,\n}: {\n agentName: string;\n input: Parameters<T['generate']>[0];\n metric: Metric;\n output: string;\n globalRunId: string;\n runId?: string;\n testInfo?: TestInfo;\n instructions: string;\n}) {\n const runIdToUse = runId || crypto.randomUUID();\n\n const metricResult = await metric.measure(input.toString(), output);\n const traceObject = {\n input: input.toString(),\n output: output,\n result: metricResult,\n agentName,\n metricName: metric.constructor.name,\n instructions,\n globalRunId,\n runId: runIdToUse,\n testInfo,\n };\n\n executeHook(AvailableHooks.ON_EVALUATION, traceObject);\n\n return metricResult;\n}\n"]}