@mastra/evals 1.10.8 → 1.10.9-alpha.0
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/dist/{checks-BX_kIFwJ.cjs → checks-CVR2yDHg.cjs} +3 -5
- package/dist/{checks-BX_kIFwJ.cjs.map → checks-CVR2yDHg.cjs.map} +1 -1
- package/dist/{checks-DxbqoaYq.js → checks-DXG9awTJ.js} +2 -3
- package/dist/{checks-DxbqoaYq.js.map → checks-DXG9awTJ.js.map} +1 -1
- package/dist/checks.cjs +1 -1
- package/dist/checks.js +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-evals-overview.md +6 -4
- package/dist/docs/references/docs-evals-quick-checks.md +2 -2
- package/dist/docs/references/docs-guides-build-an-eval-loop.md +3 -3
- package/dist/docs/references/reference-evals-answer-relevancy.md +3 -3
- package/dist/docs/references/reference-evals-answer-similarity.md +5 -3
- package/dist/docs/references/reference-evals-bias.md +3 -3
- package/dist/docs/references/reference-evals-checks.md +1 -1
- package/dist/docs/references/reference-evals-content-similarity.md +2 -2
- package/dist/docs/references/reference-evals-context-precision.md +3 -3
- package/dist/docs/references/reference-evals-context-recall.md +3 -3
- package/dist/docs/references/reference-evals-context-relevance.md +11 -11
- package/dist/docs/references/reference-evals-faithfulness.md +1 -1
- package/dist/docs/references/reference-evals-hallucination.md +8 -8
- package/dist/docs/references/reference-evals-multi-turn-judge.md +2 -2
- package/dist/docs/references/reference-evals-noise-sensitivity.md +13 -13
- package/dist/docs/references/reference-evals-prompt-alignment.md +26 -25
- package/dist/docs/references/reference-evals-rubric.md +6 -6
- package/dist/docs/references/reference-evals-scorer-utils.md +6 -4
- package/dist/docs/references/reference-evals-summarization.md +4 -4
- package/dist/docs/references/reference-evals-tone-consistency.md +5 -5
- package/dist/docs/references/reference-evals-tool-call-accuracy.md +8 -8
- package/dist/docs/references/reference-evals-toxicity.md +1 -1
- package/dist/docs/references/reference-evals-trajectory-accuracy.md +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.js +1 -2
- package/dist/{matchers-DzWDR4_h.cjs → matchers-CL0xCK25.cjs} +2 -3
- package/dist/{matchers-DzWDR4_h.cjs.map → matchers-CL0xCK25.cjs.map} +1 -1
- package/dist/{matchers-D3c6f71B.js → matchers-CVIJYGVp.js} +2 -3
- package/dist/{matchers-D3c6f71B.js.map → matchers-CVIJYGVp.js.map} +1 -1
- package/dist/scorers/llm/rubric/index.d.ts +1 -1
- package/dist/scorers/prebuilt/index.cjs +41 -80
- package/dist/scorers/prebuilt/index.cjs.map +1 -1
- package/dist/scorers/prebuilt/index.js +41 -80
- package/dist/scorers/prebuilt/index.js.map +1 -1
- package/dist/scorers/utils.cjs +1 -2
- package/dist/scorers/utils.js +1 -2
- package/dist/vitest/index.cjs +4 -7
- package/dist/vitest/index.cjs.map +1 -1
- package/dist/vitest/index.js +4 -7
- package/dist/vitest/index.js.map +1 -1
- package/dist/vitest/setup.cjs +2 -3
- package/dist/vitest/setup.js +2 -3
- package/package.json +11 -11
|
@@ -85,7 +85,7 @@ import { myAgent } from './agent'
|
|
|
85
85
|
|
|
86
86
|
// Context is typically populated from agent tool calls or RAG retrieval
|
|
87
87
|
const scorer = createFaithfulnessScorer({
|
|
88
|
-
model: 'openai/gpt-
|
|
88
|
+
model: 'openai/gpt-6.1-sol',
|
|
89
89
|
})
|
|
90
90
|
|
|
91
91
|
const result = await runEvals({
|
|
@@ -10,7 +10,7 @@ The `createHallucinationScorer()` function evaluates whether an LLM generates fa
|
|
|
10
10
|
|
|
11
11
|
The `createHallucinationScorer()` function accepts a single options object with the following properties:
|
|
12
12
|
|
|
13
|
-
**model** (`
|
|
13
|
+
**model** (`MastraModelConfig`): Configuration for the model used to evaluate hallucination.
|
|
14
14
|
|
|
15
15
|
**options** (`Options`): Configuration options.
|
|
16
16
|
|
|
@@ -65,7 +65,7 @@ The scorer evaluates hallucination through contradiction detection and unsupport
|
|
|
65
65
|
- Divides by total statements
|
|
66
66
|
- Scales to configured range
|
|
67
67
|
|
|
68
|
-
Final score: `(hallucinated_statements / total_statements) * scale`
|
|
68
|
+
Final score: `min(1, hallucinated_statements / total_statements) * scale` when `total_statements > 0`, otherwise `0`.
|
|
69
69
|
|
|
70
70
|
### Important Considerations
|
|
71
71
|
|
|
@@ -87,7 +87,7 @@ Final score: `(hallucinated_statements / total_statements) * scale`
|
|
|
87
87
|
|
|
88
88
|
### Score interpretation
|
|
89
89
|
|
|
90
|
-
A hallucination score between 0 and 1:
|
|
90
|
+
A hallucination score between 0 and `scale` (0 to 1 with the default scale). The ranges below assume the default scale:
|
|
91
91
|
|
|
92
92
|
- **0.0**: No hallucination, all claims match the context.
|
|
93
93
|
- **0.3 to 0.4**: Low hallucination, a few contradictions.
|
|
@@ -107,7 +107,7 @@ Use static context when you have known ground truth to compare against:
|
|
|
107
107
|
import { createHallucinationScorer } from '@mastra/evals/scorers/prebuilt'
|
|
108
108
|
|
|
109
109
|
const scorer = createHallucinationScorer({
|
|
110
|
-
model: 'openai/gpt-
|
|
110
|
+
model: 'openai/gpt-6.1-sol',
|
|
111
111
|
options: {
|
|
112
112
|
context: [
|
|
113
113
|
'The first iPhone was announced on January 9, 2007.',
|
|
@@ -127,7 +127,7 @@ import { createHallucinationScorer } from '@mastra/evals/scorers/prebuilt'
|
|
|
127
127
|
import { extractToolResults } from '@mastra/evals/scorers/utils'
|
|
128
128
|
|
|
129
129
|
const scorer = createHallucinationScorer({
|
|
130
|
-
model: 'openai/gpt-
|
|
130
|
+
model: 'openai/gpt-6.1-sol',
|
|
131
131
|
options: {
|
|
132
132
|
getContext: ({ run, step }) => {
|
|
133
133
|
// Extract tool results as context
|
|
@@ -148,7 +148,7 @@ import { createHallucinationScorer } from '@mastra/evals/scorers/prebuilt'
|
|
|
148
148
|
import { extractToolResults } from '@mastra/evals/scorers/utils'
|
|
149
149
|
|
|
150
150
|
const hallucinationScorer = createHallucinationScorer({
|
|
151
|
-
model: 'openai/gpt-
|
|
151
|
+
model: 'openai/gpt-6.1-sol',
|
|
152
152
|
options: {
|
|
153
153
|
getContext: ({ run }) => {
|
|
154
154
|
const toolResults = extractToolResults(run.output)
|
|
@@ -160,7 +160,7 @@ const hallucinationScorer = createHallucinationScorer({
|
|
|
160
160
|
const agent = new Agent({
|
|
161
161
|
id: 'my-agent',
|
|
162
162
|
name: 'my-agent',
|
|
163
|
-
model: 'openai/gpt-
|
|
163
|
+
model: 'openai/gpt-6.1-sol',
|
|
164
164
|
instructions: 'You are a helpful assistant.',
|
|
165
165
|
evals: {
|
|
166
166
|
scorers: [hallucinationScorer],
|
|
@@ -176,7 +176,7 @@ import { createHallucinationScorer } from '@mastra/evals/scorers/prebuilt'
|
|
|
176
176
|
import { myAgent } from './agent'
|
|
177
177
|
|
|
178
178
|
const scorer = createHallucinationScorer({
|
|
179
|
-
model: 'openai/gpt-
|
|
179
|
+
model: 'openai/gpt-6.1-sol',
|
|
180
180
|
options: {
|
|
181
181
|
context: ['Known fact 1', 'Known fact 2'],
|
|
182
182
|
},
|
|
@@ -49,7 +49,7 @@ const result = await runEvals({
|
|
|
49
49
|
scorers: [
|
|
50
50
|
{
|
|
51
51
|
scorer: createMultiTurnJudgeScorer({
|
|
52
|
-
model: 'anthropic/claude-haiku-
|
|
52
|
+
model: 'anthropic/claude-haiku-5-5',
|
|
53
53
|
criterion:
|
|
54
54
|
'The agent provided weather forecasts for London, Paris, and Tokyo, and gave weather-appropriate packing or clothing advice.',
|
|
55
55
|
}),
|
|
@@ -75,7 +75,7 @@ export const mastra = new Mastra({
|
|
|
75
75
|
storage: new LibSQLStore({ url: 'file:./mastra.db' }),
|
|
76
76
|
scorers: {
|
|
77
77
|
'multi-turn-judge-scorer': createMultiTurnJudgeScorer({
|
|
78
|
-
model: 'anthropic/claude-haiku-
|
|
78
|
+
model: 'anthropic/claude-haiku-5-5',
|
|
79
79
|
criterion: 'placeholder',
|
|
80
80
|
}),
|
|
81
81
|
},
|
|
@@ -65,7 +65,7 @@ describe('Agent Noise Resistance Tests', () => {
|
|
|
65
65
|
|
|
66
66
|
// Step 4: Evaluate using noise sensitivity scorer
|
|
67
67
|
const scorer = createNoiseSensitivityScorerLLM({
|
|
68
|
-
model: 'openai/gpt-
|
|
68
|
+
model: 'openai/gpt-6.1-sol',
|
|
69
69
|
options: {
|
|
70
70
|
baselineResponse,
|
|
71
71
|
noisyQuery,
|
|
@@ -126,7 +126,7 @@ Where:
|
|
|
126
126
|
|
|
127
127
|
- `llm_score` = Direct robustness score from LLM analysis
|
|
128
128
|
- `calculated_score` = Average of impact weights across dimensions
|
|
129
|
-
- `issues_penalty` = min(
|
|
129
|
+
- `issues_penalty` = min(major_issues × penalty_rate, max_penalty)
|
|
130
130
|
|
|
131
131
|
### Impact Level Weights
|
|
132
132
|
|
|
@@ -260,7 +260,7 @@ describe('Agent Noise Resistance CI Tests', () => {
|
|
|
260
260
|
|
|
261
261
|
// Evaluate using noise sensitivity scorer
|
|
262
262
|
const scorer = createNoiseSensitivityScorerLLM({
|
|
263
|
-
model: 'openai/gpt-
|
|
263
|
+
model: 'openai/gpt-6.1-sol',
|
|
264
264
|
options: {
|
|
265
265
|
baselineResponse: testCase.baselineResponse,
|
|
266
266
|
noisyQuery: testCase.noisyQuery,
|
|
@@ -295,7 +295,7 @@ This example shows an agent that completely resists misinformation in a test sce
|
|
|
295
295
|
import { createNoiseSensitivityScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
296
296
|
|
|
297
297
|
const scorer = createNoiseSensitivityScorerLLM({
|
|
298
|
-
model: 'openai/gpt-
|
|
298
|
+
model: 'openai/gpt-6.1-sol',
|
|
299
299
|
options: {
|
|
300
300
|
baselineResponse:
|
|
301
301
|
'Regular exercise improves cardiovascular health, strengthens muscles, and enhances mental wellbeing.',
|
|
@@ -341,7 +341,7 @@ This example shows an agent partially distracted by irrelevant requests:
|
|
|
341
341
|
import { createNoiseSensitivityScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
342
342
|
|
|
343
343
|
const scorer = createNoiseSensitivityScorerLLM({
|
|
344
|
-
model: 'openai/gpt-
|
|
344
|
+
model: 'openai/gpt-6.1-sol',
|
|
345
345
|
options: {
|
|
346
346
|
baselineResponse:
|
|
347
347
|
'To bake a cake: Mix flour, sugar, eggs, and butter. Bake at 350°F for 30 minutes.',
|
|
@@ -386,7 +386,7 @@ This example shows an agent that incorporates misinformation:
|
|
|
386
386
|
import { createNoiseSensitivityScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
387
387
|
|
|
388
388
|
const scorer = createNoiseSensitivityScorerLLM({
|
|
389
|
-
model: 'openai/gpt-
|
|
389
|
+
model: 'openai/gpt-6.1-sol',
|
|
390
390
|
options: {
|
|
391
391
|
baselineResponse: 'Climate change is caused by greenhouse gas emissions from human activities.',
|
|
392
392
|
noisyQuery:
|
|
@@ -432,7 +432,7 @@ import { createNoiseSensitivityScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
|
432
432
|
|
|
433
433
|
// Lenient scoring - more forgiving of minor issues
|
|
434
434
|
const lenientScorer = createNoiseSensitivityScorerLLM({
|
|
435
|
-
model: 'openai/gpt-
|
|
435
|
+
model: 'openai/gpt-6.1-sol',
|
|
436
436
|
options: {
|
|
437
437
|
baselineResponse: 'Python is a high-level programming language.',
|
|
438
438
|
noisyQuery: 'What is Python? Also, snakes are dangerous!',
|
|
@@ -452,7 +452,7 @@ const lenientScorer = createNoiseSensitivityScorerLLM({
|
|
|
452
452
|
|
|
453
453
|
// Strict scoring - harsh on any deviation
|
|
454
454
|
const strictScorer = createNoiseSensitivityScorerLLM({
|
|
455
|
-
model: 'openai/gpt-
|
|
455
|
+
model: 'openai/gpt-6.1-sol',
|
|
456
456
|
options: {
|
|
457
457
|
baselineResponse: 'Python is a high-level programming language.',
|
|
458
458
|
noisyQuery: 'What is Python? Also, snakes are dangerous!',
|
|
@@ -503,7 +503,7 @@ async function evaluateNoiseResistance(testCases) {
|
|
|
503
503
|
|
|
504
504
|
for (const testCase of testCases) {
|
|
505
505
|
const scorer = createNoiseSensitivityScorerLLM({
|
|
506
|
-
model: 'openai/gpt-
|
|
506
|
+
model: 'openai/gpt-6.1-sol',
|
|
507
507
|
options: {
|
|
508
508
|
baselineResponse: testCase.baseline,
|
|
509
509
|
noisyQuery: testCase.noisyQuery,
|
|
@@ -550,9 +550,9 @@ import { createNoiseSensitivityScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
|
550
550
|
|
|
551
551
|
async function compareModelRobustness() {
|
|
552
552
|
const models = [
|
|
553
|
-
{ name: 'GPT-5.4', model: 'openai/gpt-
|
|
554
|
-
{ name: 'GPT-
|
|
555
|
-
{ name: 'Claude', model: 'anthropic/claude-opus-
|
|
553
|
+
{ name: 'GPT-5.4', model: 'openai/gpt-6.1-sol' },
|
|
554
|
+
{ name: 'GPT-6 Luna', model: 'openai/gpt-6-luna' },
|
|
555
|
+
{ name: 'Claude', model: 'anthropic/claude-opus-5-5' },
|
|
556
556
|
]
|
|
557
557
|
|
|
558
558
|
const testScenario = {
|
|
@@ -602,7 +602,7 @@ Include noise sensitivity tests in your security test suite to validate prompt i
|
|
|
602
602
|
import { createNoiseSensitivityScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
603
603
|
|
|
604
604
|
const scorer = createNoiseSensitivityScorerLLM({
|
|
605
|
-
model: 'openai/gpt-
|
|
605
|
+
model: 'openai/gpt-6.1-sol',
|
|
606
606
|
options: {
|
|
607
607
|
baselineResponse: 'I can help you with programming questions.',
|
|
608
608
|
noisyQuery:
|
|
@@ -64,7 +64,7 @@ You can customize the Prompt Alignment Scorer by adjusting the scale parameter a
|
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
const scorer = createPromptAlignmentScorerLLM({
|
|
67
|
-
model: 'openai/gpt-
|
|
67
|
+
model: 'openai/gpt-6.1-sol',
|
|
68
68
|
options: {
|
|
69
69
|
scale: 10, // Score from 0-10 instead of 0-1
|
|
70
70
|
evaluationMode: 'both', // 'user', 'system', or 'both' (default)
|
|
@@ -80,7 +80,7 @@ Set `includeConversationHistory` to give the judge the prior turns from the agen
|
|
|
80
80
|
|
|
81
81
|
```typescript
|
|
82
82
|
const scorer = createPromptAlignmentScorerLLM({
|
|
83
|
-
model: 'openai/gpt-
|
|
83
|
+
model: 'openai/gpt-6.1-sol',
|
|
84
84
|
options: {
|
|
85
85
|
evaluationMode: 'user',
|
|
86
86
|
includeConversationHistory: { maxMessages: 6 }, // or `true` for the last 10 messages
|
|
@@ -114,11 +114,11 @@ Evaluates compliance with system guidelines only:
|
|
|
114
114
|
|
|
115
115
|
#### Both Mode ('both' - default)
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
Evaluates user and system alignment together in a single analysis:
|
|
118
118
|
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
119
|
+
- The judge assesses each dimension against both the user prompt and the system guidelines
|
|
120
|
+
- The resulting dimension scores are combined using the user mode weights
|
|
121
|
+
- The scorer computes no separate system score, so the result isn't a blend of user mode and system mode scores
|
|
122
122
|
|
|
123
123
|
### Scoring Formula
|
|
124
124
|
|
|
@@ -141,17 +141,18 @@ Final Score = Weighted Score × scale
|
|
|
141
141
|
**Both Mode (default):**
|
|
142
142
|
|
|
143
143
|
```text
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Weighted Score = (User Score × 0.7) + (System Score × 0.3)
|
|
144
|
+
Weighted Score = (intent_score × 0.4) + (requirements_score × 0.3) +
|
|
145
|
+
(completeness_score × 0.2) + (appropriateness_score × 0.1)
|
|
147
146
|
Final Score = Weighted Score × scale
|
|
148
147
|
```
|
|
149
148
|
|
|
149
|
+
In both mode, each dimension score comes from the combined analysis of the user prompt and the system guidelines.
|
|
150
|
+
|
|
150
151
|
**Weight Distribution Rationale**:
|
|
151
152
|
|
|
152
153
|
- **User Mode**: Prioritizes intent (40%) and requirements (30%) for user satisfaction
|
|
153
154
|
- **System Mode**: Balances behavioral compliance (35%) and constraints (35%) equally
|
|
154
|
-
- **Both Mode**:
|
|
155
|
+
- **Both Mode**: Uses the user mode weights over a combined analysis, so user needs stay primary while system guidelines are still assessed
|
|
155
156
|
|
|
156
157
|
### Score Interpretation
|
|
157
158
|
|
|
@@ -242,24 +243,24 @@ const agent = new Agent({
|
|
|
242
243
|
id: 'coding-assistant',
|
|
243
244
|
name: 'CodingAssistant',
|
|
244
245
|
instructions: 'You are a helpful coding assistant. Always provide working code examples.',
|
|
245
|
-
model: 'openai/gpt-
|
|
246
|
+
model: 'openai/gpt-6.1-sol',
|
|
246
247
|
})
|
|
247
248
|
|
|
248
249
|
// Evaluate comprehensive alignment (default)
|
|
249
250
|
const scorer = createPromptAlignmentScorerLLM({
|
|
250
|
-
model: 'openai/gpt-
|
|
251
|
+
model: 'openai/gpt-6.1-sol',
|
|
251
252
|
options: { evaluationMode: 'both' }, // Evaluates both user intent and system guidelines
|
|
252
253
|
})
|
|
253
254
|
|
|
254
255
|
// Evaluate just user satisfaction
|
|
255
256
|
const userScorer = createPromptAlignmentScorerLLM({
|
|
256
|
-
model: 'openai/gpt-
|
|
257
|
+
model: 'openai/gpt-6.1-sol',
|
|
257
258
|
options: { evaluationMode: 'user' }, // Focus only on user request fulfillment
|
|
258
259
|
})
|
|
259
260
|
|
|
260
261
|
// Evaluate system compliance
|
|
261
262
|
const systemScorer = createPromptAlignmentScorerLLM({
|
|
262
|
-
model: 'openai/gpt-
|
|
263
|
+
model: 'openai/gpt-6.1-sol',
|
|
263
264
|
options: { evaluationMode: 'system' }, // Check adherence to system instructions
|
|
264
265
|
})
|
|
265
266
|
|
|
@@ -311,7 +312,7 @@ for (const agent of agents) {
|
|
|
311
312
|
import { createPromptAlignmentScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
312
313
|
|
|
313
314
|
const scorer = createPromptAlignmentScorerLLM({
|
|
314
|
-
model: 'openai/gpt-
|
|
315
|
+
model: 'openai/gpt-6.1-sol',
|
|
315
316
|
})
|
|
316
317
|
|
|
317
318
|
// Evaluate a code generation task
|
|
@@ -340,7 +341,7 @@ const result = await scorer.run({
|
|
|
340
341
|
```typescript
|
|
341
342
|
// Configure scale and evaluation mode
|
|
342
343
|
const scorer = createPromptAlignmentScorerLLM({
|
|
343
|
-
model: 'openai/gpt-
|
|
344
|
+
model: 'openai/gpt-6.1-sol',
|
|
344
345
|
options: {
|
|
345
346
|
scale: 10, // Score from 0-10 instead of 0-1
|
|
346
347
|
evaluationMode: 'both', // 'user', 'system', or 'both' (default)
|
|
@@ -349,13 +350,13 @@ const scorer = createPromptAlignmentScorerLLM({
|
|
|
349
350
|
|
|
350
351
|
// User-only evaluation - focus on user satisfaction
|
|
351
352
|
const userScorer = createPromptAlignmentScorerLLM({
|
|
352
|
-
model: 'openai/gpt-
|
|
353
|
+
model: 'openai/gpt-6.1-sol',
|
|
353
354
|
options: { evaluationMode: 'user' },
|
|
354
355
|
})
|
|
355
356
|
|
|
356
357
|
// System-only evaluation - focus on compliance
|
|
357
358
|
const systemScorer = createPromptAlignmentScorerLLM({
|
|
358
|
-
model: 'openai/gpt-
|
|
359
|
+
model: 'openai/gpt-6.1-sol',
|
|
359
360
|
options: { evaluationMode: 'system' },
|
|
360
361
|
})
|
|
361
362
|
|
|
@@ -390,7 +391,7 @@ In this example, the response fully addresses the user's prompt with all require
|
|
|
390
391
|
import { createPromptAlignmentScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
391
392
|
|
|
392
393
|
const scorer = createPromptAlignmentScorerLLM({
|
|
393
|
-
model: 'openai/gpt-
|
|
394
|
+
model: 'openai/gpt-6.1-sol',
|
|
394
395
|
})
|
|
395
396
|
|
|
396
397
|
const inputMessages = [
|
|
@@ -438,7 +439,7 @@ In this example, the response addresses the core intent but misses some requirem
|
|
|
438
439
|
import { createPromptAlignmentScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
439
440
|
|
|
440
441
|
const scorer = createPromptAlignmentScorerLLM({
|
|
441
|
-
model: 'openai/gpt-
|
|
442
|
+
model: 'openai/gpt-6.1-sol',
|
|
442
443
|
})
|
|
443
444
|
|
|
444
445
|
const inputMessages = [
|
|
@@ -479,7 +480,7 @@ In this example, the response fails to address the user's specific requirements.
|
|
|
479
480
|
import { createPromptAlignmentScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
480
481
|
|
|
481
482
|
const scorer = createPromptAlignmentScorerLLM({
|
|
482
|
-
model: 'openai/gpt-
|
|
483
|
+
model: 'openai/gpt-6.1-sol',
|
|
483
484
|
})
|
|
484
485
|
|
|
485
486
|
const inputMessages = [
|
|
@@ -523,7 +524,7 @@ Evaluates how well the response addresses the user's request, ignoring system in
|
|
|
523
524
|
|
|
524
525
|
```typescript
|
|
525
526
|
const scorer = createPromptAlignmentScorerLLM({
|
|
526
|
-
model: 'openai/gpt-
|
|
527
|
+
model: 'openai/gpt-6.1-sol',
|
|
527
528
|
options: { evaluationMode: 'user' },
|
|
528
529
|
})
|
|
529
530
|
|
|
@@ -555,7 +556,7 @@ Evaluates compliance with system behavioral guidelines and constraints:
|
|
|
555
556
|
|
|
556
557
|
```typescript
|
|
557
558
|
const scorer = createPromptAlignmentScorerLLM({
|
|
558
|
-
model: 'openai/gpt-
|
|
559
|
+
model: 'openai/gpt-6.1-sol',
|
|
559
560
|
options: { evaluationMode: 'system' },
|
|
560
561
|
})
|
|
561
562
|
|
|
@@ -583,11 +584,11 @@ const result = await scorer.run({
|
|
|
583
584
|
|
|
584
585
|
#### Both Mode - Combined Evaluation (Default)
|
|
585
586
|
|
|
586
|
-
Evaluates
|
|
587
|
+
Evaluates user intent fulfillment and system compliance together in a single analysis:
|
|
587
588
|
|
|
588
589
|
```typescript
|
|
589
590
|
const scorer = createPromptAlignmentScorerLLM({
|
|
590
|
-
model: 'openai/gpt-
|
|
591
|
+
model: 'openai/gpt-6.1-sol',
|
|
591
592
|
options: { evaluationMode: 'both' }, // This is the default
|
|
592
593
|
})
|
|
593
594
|
|
|
@@ -35,12 +35,12 @@ import { createRubricScorer } from '@mastra/evals/scorers/prebuilt'
|
|
|
35
35
|
const supervisor = new Agent({
|
|
36
36
|
id: 'supervisor',
|
|
37
37
|
instructions: `You coordinate research and writing using specialized agents. Delegate to research-agent for facts, then writing-agent for content.`,
|
|
38
|
-
model: 'openai/gpt-
|
|
38
|
+
model: 'openai/gpt-6.1-sol',
|
|
39
39
|
agents: { researchAgent, writingAgent },
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
const rubricScorer = createRubricScorer({
|
|
43
|
-
model: 'openai/gpt-
|
|
43
|
+
model: 'openai/gpt-6-luna',
|
|
44
44
|
criteria: [
|
|
45
45
|
{ description: 'The response includes an analysis section' },
|
|
46
46
|
{ description: 'The response includes concrete recommendations' },
|
|
@@ -62,7 +62,7 @@ A newline-delimited string is parsed into criteria, with common list markers (`-
|
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
64
|
const rubricScorer = createRubricScorer({
|
|
65
|
-
model: 'openai/gpt-
|
|
65
|
+
model: 'openai/gpt-6-luna',
|
|
66
66
|
criteria: `- All tests pass in the test suite
|
|
67
67
|
- The function is named find_duplicates and accepts a single list argument`,
|
|
68
68
|
})
|
|
@@ -74,7 +74,7 @@ Mark a criterion as optional to have it graded and reported without gating compl
|
|
|
74
74
|
|
|
75
75
|
```typescript
|
|
76
76
|
const rubricScorer = createRubricScorer({
|
|
77
|
-
model: 'openai/gpt-
|
|
77
|
+
model: 'openai/gpt-6-luna',
|
|
78
78
|
criteria: [
|
|
79
79
|
{ description: 'Includes an analysis section', required: true },
|
|
80
80
|
{ description: 'Includes citations', required: false },
|
|
@@ -88,7 +88,7 @@ When no `criteria` is passed to the factory, the scorer resolves a `rubric` valu
|
|
|
88
88
|
|
|
89
89
|
```typescript
|
|
90
90
|
const rubricScorer = createRubricScorer({
|
|
91
|
-
model: 'openai/gpt-
|
|
91
|
+
model: 'openai/gpt-6-luna',
|
|
92
92
|
})
|
|
93
93
|
|
|
94
94
|
await supervisor.stream('Write find_duplicates', {
|
|
@@ -108,7 +108,7 @@ The scorer runs in two phases:
|
|
|
108
108
|
1. **Grade**: The judge model evaluates each criterion independently and returns a per-criterion verdict (`satisfied` / not) with reasoning.
|
|
109
109
|
2. **Score**: The scorer returns `1` only when every required criterion is `satisfied` and treats every criterion as required when none are marked. All other results receive `0`.
|
|
110
110
|
|
|
111
|
-
The `reason` summarizes the result and lists each criterion with its verdict,
|
|
111
|
+
The `reason` summarizes the result and lists each criterion with its verdict, giving the agent specific feedback on a failing grade rather than a generic "try again".
|
|
112
112
|
|
|
113
113
|
## Related
|
|
114
114
|
|
|
@@ -393,10 +393,12 @@ Creates a test run object for trajectory scorers. Wraps a `Trajectory` into the
|
|
|
393
393
|
import { createTrajectoryTestRun } from '@mastra/evals/scorers/utils'
|
|
394
394
|
|
|
395
395
|
const run = createTrajectoryTestRun({
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
396
|
+
trajectory: {
|
|
397
|
+
steps: [
|
|
398
|
+
{ stepType: 'tool_call', name: 'search', toolArgs: { q: 'test' } },
|
|
399
|
+
{ stepType: 'tool_call', name: 'summarize' },
|
|
400
|
+
],
|
|
401
|
+
},
|
|
400
402
|
})
|
|
401
403
|
|
|
402
404
|
const result = await trajectoryScorer.run(run)
|
|
@@ -16,7 +16,7 @@ Score a summary against the document it condenses.
|
|
|
16
16
|
import { createSummarizationScorer } from '@mastra/evals/scorers/prebuilt'
|
|
17
17
|
|
|
18
18
|
const scorer = createSummarizationScorer({
|
|
19
|
-
model: 'openai/gpt-
|
|
19
|
+
model: 'openai/gpt-6.1-sol',
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
const result = await scorer.run({
|
|
@@ -125,7 +125,7 @@ Each evaluation makes three model calls. `maxQuestions` bounds the coverage half
|
|
|
125
125
|
|
|
126
126
|
```typescript
|
|
127
127
|
const scorer = createSummarizationScorer({
|
|
128
|
-
model: 'openai/gpt-
|
|
128
|
+
model: 'openai/gpt-6.1-sol',
|
|
129
129
|
})
|
|
130
130
|
```
|
|
131
131
|
|
|
@@ -135,7 +135,7 @@ const scorer = createSummarizationScorer({
|
|
|
135
135
|
import { extractToolResults } from '@mastra/evals/scorers/utils'
|
|
136
136
|
|
|
137
137
|
const scorer = createSummarizationScorer({
|
|
138
|
-
model: 'openai/gpt-
|
|
138
|
+
model: 'openai/gpt-6.1-sol',
|
|
139
139
|
options: {
|
|
140
140
|
sourceExtractor: (input, output) => {
|
|
141
141
|
return extractToolResults(output)
|
|
@@ -158,7 +158,7 @@ import { createSummarizationScorer } from '@mastra/evals/scorers/prebuilt'
|
|
|
158
158
|
import { summarizerAgent } from './agent'
|
|
159
159
|
|
|
160
160
|
const scorer = createSummarizationScorer({
|
|
161
|
-
model: 'openai/gpt-
|
|
161
|
+
model: 'openai/gpt-6.1-sol',
|
|
162
162
|
options: { maxQuestions: 10 },
|
|
163
163
|
})
|
|
164
164
|
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
# Tone consistency scorer
|
|
6
6
|
|
|
7
|
-
The `createToneScorer()` function evaluates the text's emotional tone and sentiment consistency. It can operate in two modes: comparing the agent output's sentiment against a
|
|
7
|
+
The `createToneScorer()` function evaluates the text's emotional tone and sentiment consistency. It can operate in two modes: comparing the agent output's sentiment against a non-empty `referenceTone`, or analyzing tone stability across the sentences of the agent output.
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
11
11
|
The `createToneScorer()` function accepts an optional config object with the following properties:
|
|
12
12
|
|
|
13
|
-
**referenceTone** (`string`): Reference text whose sentiment the agent output is compared against. When omitted, the scorer measures sentiment stability across the output's sentences instead.
|
|
13
|
+
**referenceTone** (`string`): Reference text whose sentiment the agent output is compared against. When omitted or empty, the scorer measures sentiment stability across the output's sentences instead.
|
|
14
14
|
|
|
15
15
|
This function returns an instance of the MastraScorer class. See the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer) for details on the `.run()` method and its input/output.
|
|
16
16
|
|
|
@@ -51,14 +51,14 @@ The scorer evaluates sentiment consistency through tone pattern analysis and mod
|
|
|
51
51
|
- Computes sentiment scores
|
|
52
52
|
- Measures tone variations
|
|
53
53
|
|
|
54
|
-
2. Calculates mode-specific score: **Tone Consistency** (`referenceTone`
|
|
54
|
+
2. Calculates mode-specific score: **Tone Consistency** (non-empty `referenceTone`):
|
|
55
55
|
|
|
56
56
|
- Compares the output's sentiment with the `referenceTone` sentiment
|
|
57
57
|
- Calculates the absolute sentiment difference
|
|
58
|
-
- Score = max(0, 1 -
|
|
58
|
+
- Score = max(0, 1 - sentiment_difference) **Tone Stability** (`referenceTone` omitted or empty):
|
|
59
59
|
- Analyzes sentiment across the output's sentences
|
|
60
60
|
- Calculates sentiment variance
|
|
61
|
-
- Score = max(0, 1 -
|
|
61
|
+
- Score = max(0, 1 - sentiment_variance)
|
|
62
62
|
|
|
63
63
|
Final score: `mode_specific_score`
|
|
64
64
|
|
|
@@ -33,11 +33,11 @@ The `createToolCallAccuracyScorerCode()` function from `@mastra/evals/scorers/pr
|
|
|
33
33
|
|
|
34
34
|
### Parameters
|
|
35
35
|
|
|
36
|
-
**expectedTool** (`string`): The name of the tool that should be called for the given task.
|
|
36
|
+
**expectedTool** (`string`): The name of the tool that should be called for the given task. Determines the score when expectedToolOrder is omitted or empty. With a non-empty expectedToolOrder it does not affect the score, but still populates correctToolCalled.
|
|
37
37
|
|
|
38
38
|
**strictMode** (`boolean`): Controls evaluation strictness. For single tool mode: only exact single tool calls accepted. For order checking mode: tools must match exactly with no extra tools allowed.
|
|
39
39
|
|
|
40
|
-
**expectedToolOrder** (`string[]`): Array of tool names in the expected calling order.
|
|
40
|
+
**expectedToolOrder** (`string[]`): Array of tool names in the expected calling order. A non-empty array enables order checking mode, which determines the score. An empty array scores in single tool mode using expectedTool, but still populates correctOrderCalled.
|
|
41
41
|
|
|
42
42
|
This function returns an instance of the MastraScorer class. See the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer) for details on the `.run()` method and its input/output.
|
|
43
43
|
|
|
@@ -47,14 +47,14 @@ The code-based scorer operates in two distinct modes:
|
|
|
47
47
|
|
|
48
48
|
#### Single Tool Mode
|
|
49
49
|
|
|
50
|
-
When `expectedToolOrder` isn't provided, the
|
|
50
|
+
When `expectedToolOrder` isn't provided or is empty, the score reflects single tool selection:
|
|
51
51
|
|
|
52
52
|
- **Standard Mode (strictMode: false)**: Returns `1` if the expected tool is called, regardless of other tools
|
|
53
53
|
- **Strict Mode (strictMode: true)**: Returns `1` only if exactly one tool is called and it matches the expected tool
|
|
54
54
|
|
|
55
55
|
#### Order Checking Mode
|
|
56
56
|
|
|
57
|
-
When `expectedToolOrder` is provided, the
|
|
57
|
+
When a non-empty `expectedToolOrder` is provided, the score reflects the tool calling sequence:
|
|
58
58
|
|
|
59
59
|
- **Strict Order (strictMode: true)**: Tools must be called in exactly the specified order with no extra tools
|
|
60
60
|
- **Flexible Order (strictMode: false)**: Expected tools must appear in correct relative order (extra tools allowed)
|
|
@@ -313,7 +313,7 @@ The LLM-based scorer provides:
|
|
|
313
313
|
```typescript
|
|
314
314
|
// Basic configuration
|
|
315
315
|
const basicLLMScorer = createLLMScorer({
|
|
316
|
-
model: 'openai/gpt-
|
|
316
|
+
model: 'openai/gpt-6.1-sol',
|
|
317
317
|
availableTools: [
|
|
318
318
|
createTool({ id: 'tool1', description: 'Description 1' }),
|
|
319
319
|
createTool({ id: 'tool2', description: 'Description 2' })
|
|
@@ -322,7 +322,7 @@ const basicLLMScorer = createLLMScorer({
|
|
|
322
322
|
|
|
323
323
|
// With different model
|
|
324
324
|
const customModelScorer = createLLMScorer({
|
|
325
|
-
model: 'openai/gpt-5', // More powerful model for complex evaluations
|
|
325
|
+
model: 'openai/gpt-5.6', // More powerful model for complex evaluations
|
|
326
326
|
availableTools: [...]
|
|
327
327
|
});
|
|
328
328
|
```
|
|
@@ -356,7 +356,7 @@ import { createTool } from '@mastra/core/tools'
|
|
|
356
356
|
import { createToolCallAccuracyScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
357
357
|
|
|
358
358
|
const llmScorer = createToolCallAccuracyScorerLLM({
|
|
359
|
-
model: 'openai/gpt-
|
|
359
|
+
model: 'openai/gpt-6.1-sol',
|
|
360
360
|
availableTools: [
|
|
361
361
|
createTool({
|
|
362
362
|
id: 'weather-tool',
|
|
@@ -490,7 +490,7 @@ const codeScorer = createCodeScorer({
|
|
|
490
490
|
})
|
|
491
491
|
|
|
492
492
|
const llmScorer = createLLMScorer({
|
|
493
|
-
model: 'openai/gpt-
|
|
493
|
+
model: 'openai/gpt-6.1-sol',
|
|
494
494
|
availableTools: [
|
|
495
495
|
createTool({ id: 'weather-tool', description: 'Get weather information' }),
|
|
496
496
|
createTool({ id: 'search-tool', description: 'Search the web' }),
|
|
@@ -92,7 +92,7 @@ import { runEvals } from '@mastra/core/evals'
|
|
|
92
92
|
import { createToxicityScorer } from '@mastra/evals/scorers/prebuilt'
|
|
93
93
|
import { myAgent } from './agent'
|
|
94
94
|
|
|
95
|
-
const scorer = createToxicityScorer({ model: 'openai/gpt-
|
|
95
|
+
const scorer = createToxicityScorer({ model: 'openai/gpt-6.1-sol' })
|
|
96
96
|
|
|
97
97
|
const result = await runEvals({
|
|
98
98
|
data: [
|
|
@@ -116,7 +116,7 @@ Omit `stepType` entirely to match any step by name only.
|
|
|
116
116
|
|
|
117
117
|
**stepType** (`TrajectoryStepType`): Step type discriminant. When set, enables autocomplete for that variant's fields. If omitted, matches any step type with the given name.
|
|
118
118
|
|
|
119
|
-
**(variant fields)** (`varies`): Type-specific fields from the corresponding TrajectoryStep variant. For example, toolArgs and toolResult for
|
|
119
|
+
**(variant fields)** (`varies`): Type-specific fields from the corresponding TrajectoryStep variant. For example, toolArgs and toolResult for tool_call, modelId for model_generation, output for workflow_step. All optional — only specified fields are compared.
|
|
120
120
|
|
|
121
121
|
**children** (`TrajectoryExpectation`): Nested expectation config for this step's children. Overrides the parent config for evaluating children of this step.
|
|
122
122
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/index.ts
|
|
2
2
|
/**
|
|
3
3
|
* @mastra/evals - Evaluation framework for AI agents
|
|
4
4
|
*
|
|
@@ -9,6 +9,5 @@
|
|
|
9
9
|
* import { createToolCallAccuracyScorerCode } from '@mastra/evals/scorers/prebuilt';
|
|
10
10
|
* import { getUserMessageFromRunInput } from '@mastra/evals/scorers/utils';
|
|
11
11
|
* */
|
|
12
|
-
//#endregion
|
|
13
12
|
|
|
14
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/index.ts
|
|
2
2
|
/**
|
|
3
3
|
* @mastra/evals - Evaluation framework for AI agents
|
|
4
4
|
*
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* import { createToolCallAccuracyScorerCode } from '@mastra/evals/scorers/prebuilt';
|
|
10
10
|
* import { getUserMessageFromRunInput } from '@mastra/evals/scorers/utils';
|
|
11
11
|
* */
|
|
12
|
-
//#endregion
|
|
13
12
|
export {};
|
|
14
13
|
|
|
15
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let vitest = require("vitest");
|
|
2
|
-
|
|
2
|
+
// src/vitest/matchers.ts
|
|
3
3
|
function isRunEvalsResult(value) {
|
|
4
4
|
return typeof value === "object" && value !== null && "scores" in value && "summary" in value && typeof value.scores === "object" && value.scores !== null;
|
|
5
5
|
}
|
|
@@ -92,7 +92,6 @@ const evalMatchers = {
|
|
|
92
92
|
function registerEvalMatchers() {
|
|
93
93
|
vitest.expect.extend(evalMatchers);
|
|
94
94
|
}
|
|
95
|
-
//#endregion
|
|
96
95
|
Object.defineProperty(exports, "evalMatchers", {
|
|
97
96
|
enumerable: true,
|
|
98
97
|
get: function() {
|
|
@@ -106,4 +105,4 @@ Object.defineProperty(exports, "registerEvalMatchers", {
|
|
|
106
105
|
}
|
|
107
106
|
});
|
|
108
107
|
|
|
109
|
-
//# sourceMappingURL=matchers-
|
|
108
|
+
//# sourceMappingURL=matchers-CL0xCK25.cjs.map
|