@mastra/evals 0.1.0-alpha.44 → 0.1.0-alpha.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @mastra/evals
2
2
 
3
+ ## 0.1.0-alpha.46
4
+
5
+ ### Patch Changes
6
+
7
+ - 5fdc87c: Update evals storage in attachListeners
8
+ - b97ca96: Tracing into default storage
9
+ - 72d1990: Updated evals table schema
10
+ - Updated dependencies [5fdc87c]
11
+ - Updated dependencies [b97ca96]
12
+ - Updated dependencies [72d1990]
13
+ - Updated dependencies [cf6d825]
14
+ - Updated dependencies [10870bc]
15
+ - @mastra/core@0.2.0-alpha.104
16
+
17
+ ## 0.1.0-alpha.45
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [4534e77]
22
+ - @mastra/core@0.2.0-alpha.103
23
+
3
24
  ## 0.1.0-alpha.44
4
25
 
5
26
  ### Patch Changes
package/README.md CHANGED
@@ -158,6 +158,8 @@ await attachListeners();
158
158
 
159
159
  // Store evals in Mastra Storage (if storage is enabled)
160
160
  await attachListeners(mastra);
161
+ // Note: When using in-memory storage, evaluations are isolated to the test process.
162
+ // When using file storage, evaluations are persisted and can be queried later.
161
163
  ```
162
164
 
163
165
  ## Environment Variables
@@ -470,7 +470,7 @@ export declare function generateReasonPrompt_alias_9({ originalText, summary, al
470
470
  export declare const getCurrentTestInfo: () => Promise<{
471
471
  testName: string | undefined;
472
472
  testPath: string | undefined;
473
- } | null>;
473
+ } | undefined>;
474
474
 
475
475
  export declare function getReasonPrompt({ score, toxics }: {
476
476
  score: number;
package/dist/index.js CHANGED
@@ -50,19 +50,27 @@ var getCurrentTestInfo = async () => {
50
50
  }
51
51
  } catch {
52
52
  }
53
- return null;
53
+ return undefined;
54
54
  };
55
55
  async function attachListeners(mastra) {
56
+ if (mastra?.storage) {
57
+ await mastra.storage.init();
58
+ }
56
59
  registerHook(AvailableHooks.ON_EVALUATION, async (traceObject) => {
57
- if (mastra?.memory?.storage) {
58
- await mastra.memory.storage.insert({
60
+ if (mastra?.storage) {
61
+ await mastra.storage.insert({
59
62
  tableName: MastraStorage.TABLE_EVALS,
60
63
  record: {
61
- result: JSON.stringify(traceObject.result),
62
- meta: JSON.stringify(traceObject.meta),
63
64
  input: traceObject.input,
64
65
  output: traceObject.output,
65
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
66
+ result: JSON.stringify(traceObject.result),
67
+ agent_name: traceObject.agentName,
68
+ metric_name: traceObject.metricName,
69
+ instructions: traceObject.instructions,
70
+ test_info: traceObject.testInfo ? JSON.stringify(traceObject.testInfo) : null,
71
+ global_run_id: traceObject.globalRunId,
72
+ run_id: traceObject.runId,
73
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
66
74
  }
67
75
  });
68
76
  }
@@ -1237,7 +1237,7 @@ var ToxicityJudge = class extends MastraAgentJudge {
1237
1237
  verdicts: z.array(
1238
1238
  z.object({
1239
1239
  verdict: z.string(),
1240
- reason: z.string()
1240
+ reason: z.string().optional()
1241
1241
  })
1242
1242
  )
1243
1243
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/evals",
3
- "version": "0.1.0-alpha.44",
3
+ "version": "0.1.0-alpha.46",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "sentiment": "^5.0.2",
38
38
  "string-similarity": "^4.0.4",
39
39
  "zod": "^3.24.1",
40
- "@mastra/core": "^0.2.0-alpha.102"
40
+ "@mastra/core": "^0.2.0-alpha.104"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "ai": "^4.0.0"
@@ -5,16 +5,25 @@ import { MastraStorage } from '@mastra/core/storage';
5
5
  import { GLOBAL_RUN_ID_ENV_KEY } from './constants';
6
6
 
7
7
  export async function attachListeners(mastra?: Mastra) {
8
+ if (mastra?.storage) {
9
+ await mastra.storage.init();
10
+ }
11
+
8
12
  registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
9
- if (mastra?.memory?.storage) {
10
- await mastra.memory.storage.insert({
13
+ if (mastra?.storage) {
14
+ await mastra.storage.insert({
11
15
  tableName: MastraStorage.TABLE_EVALS,
12
16
  record: {
13
- result: JSON.stringify(traceObject.result),
14
- meta: JSON.stringify(traceObject.meta),
15
17
  input: traceObject.input,
16
18
  output: traceObject.output,
17
- createdAt: new Date().toISOString(),
19
+ result: JSON.stringify(traceObject.result),
20
+ agent_name: traceObject.agentName,
21
+ metric_name: traceObject.metricName,
22
+ instructions: traceObject.instructions,
23
+ test_info: traceObject.testInfo ? JSON.stringify(traceObject.testInfo) : null,
24
+ global_run_id: traceObject.globalRunId,
25
+ run_id: traceObject.runId,
26
+ created_at: new Date().toISOString(),
18
27
  },
19
28
  });
20
29
  }
package/src/evaluation.ts CHANGED
@@ -53,5 +53,5 @@ export const getCurrentTestInfo = async () => {
53
53
  }
54
54
  } catch {}
55
55
 
56
- return null;
56
+ return undefined;
57
57
  };
@@ -17,7 +17,7 @@ export class ToxicityJudge extends MastraAgentJudge {
17
17
  verdicts: z.array(
18
18
  z.object({
19
19
  verdict: z.string(),
20
- reason: z.string(),
20
+ reason: z.string().optional(),
21
21
  }),
22
22
  ),
23
23
  }),