@mastra/evals 1.10.8 → 1.10.9
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-completeness.md +5 -1
- package/dist/docs/references/reference-evals-content-similarity.md +2 -2
- package/dist/docs/references/reference-evals-context-precision.md +6 -4
- 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 +6 -6
- 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 +42 -81
- package/dist/scorers/prebuilt/index.cjs.map +1 -1
- package/dist/scorers/prebuilt/index.js +42 -81
- 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 +14 -14
|
@@ -123,7 +123,7 @@ import { createContextRelevanceScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
|
123
123
|
|
|
124
124
|
// Stricter penalty configuration
|
|
125
125
|
const strictScorer = createContextRelevanceScorerLLM({
|
|
126
|
-
model: 'openai/gpt-
|
|
126
|
+
model: 'openai/gpt-6.1-sol',
|
|
127
127
|
options: {
|
|
128
128
|
context: [
|
|
129
129
|
'Einstein won the Nobel Prize for photoelectric effect',
|
|
@@ -141,7 +141,7 @@ const strictScorer = createContextRelevanceScorerLLM({
|
|
|
141
141
|
|
|
142
142
|
// Lenient penalty configuration
|
|
143
143
|
const lenientScorer = createContextRelevanceScorerLLM({
|
|
144
|
-
model: 'openai/gpt-
|
|
144
|
+
model: 'openai/gpt-6.1-sol',
|
|
145
145
|
options: {
|
|
146
146
|
context: [
|
|
147
147
|
'Einstein won the Nobel Prize for photoelectric effect',
|
|
@@ -187,7 +187,7 @@ console.log('Lenient penalties:', lenientResult.score) // Higher score, less pen
|
|
|
187
187
|
|
|
188
188
|
```typescript
|
|
189
189
|
const scorer = createContextRelevanceScorerLLM({
|
|
190
|
-
model: 'openai/gpt-
|
|
190
|
+
model: 'openai/gpt-6.1-sol',
|
|
191
191
|
options: {
|
|
192
192
|
contextExtractor: (input, output) => {
|
|
193
193
|
// Extract context based on the query
|
|
@@ -211,7 +211,7 @@ const scorer = createContextRelevanceScorerLLM({
|
|
|
211
211
|
|
|
212
212
|
```typescript
|
|
213
213
|
const scorer = createContextRelevanceScorerLLM({
|
|
214
|
-
model: 'openai/gpt-
|
|
214
|
+
model: 'openai/gpt-6.1-sol',
|
|
215
215
|
options: {
|
|
216
216
|
context: ['Relevant information...', 'Supporting details...'],
|
|
217
217
|
scale: 100, // Scale scores from 0-100 instead of 0-1
|
|
@@ -225,7 +225,7 @@ const scorer = createContextRelevanceScorerLLM({
|
|
|
225
225
|
|
|
226
226
|
```typescript
|
|
227
227
|
const scorer = createContextRelevanceScorerLLM({
|
|
228
|
-
model: 'openai/gpt-
|
|
228
|
+
model: 'openai/gpt-6.1-sol',
|
|
229
229
|
options: {
|
|
230
230
|
contextExtractor: (input, output) => {
|
|
231
231
|
const query = input?.inputMessages?.[0]?.content || ''
|
|
@@ -252,7 +252,7 @@ This example shows excellent context relevance where all context directly suppor
|
|
|
252
252
|
import { createContextRelevanceScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
253
253
|
|
|
254
254
|
const scorer = createContextRelevanceScorerLLM({
|
|
255
|
-
model: 'openai/gpt-
|
|
255
|
+
model: 'openai/gpt-6.1-sol',
|
|
256
256
|
options: {
|
|
257
257
|
context: [
|
|
258
258
|
'Einstein won the Nobel Prize for his discovery of the photoelectric effect in 1921.',
|
|
@@ -299,7 +299,7 @@ This example shows moderate relevance with some context being irrelevant or unus
|
|
|
299
299
|
import { createContextRelevanceScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
300
300
|
|
|
301
301
|
const scorer = createContextRelevanceScorerLLM({
|
|
302
|
-
model: 'openai/gpt-
|
|
302
|
+
model: 'openai/gpt-6.1-sol',
|
|
303
303
|
options: {
|
|
304
304
|
context: [
|
|
305
305
|
'Solar eclipses occur when the Moon blocks the Sun.',
|
|
@@ -341,7 +341,7 @@ console.log(result)
|
|
|
341
341
|
|
|
342
342
|
// With custom penalty configuration
|
|
343
343
|
const customScorer = createContextRelevanceScorerLLM({
|
|
344
|
-
model: 'openai/gpt-
|
|
344
|
+
model: 'openai/gpt-6.1-sol',
|
|
345
345
|
options: {
|
|
346
346
|
context: [
|
|
347
347
|
'Solar eclipses occur when the Moon blocks the Sun.',
|
|
@@ -388,7 +388,7 @@ This example shows poor context relevance with mostly irrelevant information:
|
|
|
388
388
|
import { createContextRelevanceScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
389
389
|
|
|
390
390
|
const scorer = createContextRelevanceScorerLLM({
|
|
391
|
-
model: 'openai/gpt-
|
|
391
|
+
model: 'openai/gpt-6.1-sol',
|
|
392
392
|
options: {
|
|
393
393
|
context: [
|
|
394
394
|
'The Great Barrier Reef is located in Australia.',
|
|
@@ -436,7 +436,7 @@ Extract context at runtime based on the run input:
|
|
|
436
436
|
import { createContextRelevanceScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
437
437
|
|
|
438
438
|
const scorer = createContextRelevanceScorerLLM({
|
|
439
|
-
model: 'openai/gpt-
|
|
439
|
+
model: 'openai/gpt-6.1-sol',
|
|
440
440
|
options: {
|
|
441
441
|
contextExtractor: (input, output) => {
|
|
442
442
|
// Extract query from input
|
|
@@ -479,7 +479,7 @@ Integrate with RAG pipelines to evaluate retrieved context:
|
|
|
479
479
|
import { createContextRelevanceScorerLLM } from '@mastra/evals/scorers/prebuilt'
|
|
480
480
|
|
|
481
481
|
const scorer = createContextRelevanceScorerLLM({
|
|
482
|
-
model: 'openai/gpt-
|
|
482
|
+
model: 'openai/gpt-6.1-sol',
|
|
483
483
|
options: {
|
|
484
484
|
contextExtractor: (input, output) => {
|
|
485
485
|
// Extract from RAG retrieval results
|
|
@@ -16,7 +16,7 @@ The `createFaithfulnessScorer()` function accepts a single options object with t
|
|
|
16
16
|
|
|
17
17
|
**options.context** (`string[]`): Array of context chunks against which the output's claims will be verified. When omitted, the scorer uses the results of tool calls in the run output.
|
|
18
18
|
|
|
19
|
-
**options.scale** (`number`): The maximum score value. The final score will be normalized to this scale.
|
|
19
|
+
**options.scale** (`number`): The maximum score value. The final score will be normalized to this scale. A value of 0 falls back to 1 (the implementation uses scale || 1).
|
|
20
20
|
|
|
21
21
|
This function returns an instance of the MastraScorer class. The `.run()` method accepts the same input as other scorers (see the [MastraScorer reference](https://mastra.ai/reference/evals/mastra-scorer)), but the return value includes LLM-specific fields as documented below.
|
|
22
22
|
|
|
@@ -32,7 +32,7 @@ This function returns an instance of the MastraScorer class. The `.run()` method
|
|
|
32
32
|
|
|
33
33
|
**analyzePrompt** (`string`): The prompt sent to the LLM for the analyze step (optional).
|
|
34
34
|
|
|
35
|
-
**score** (`number`): A score between 0 and the
|
|
35
|
+
**score** (`number`): A score between 0 and the effective scale, representing the proportion of claims that are supported by the context. The effective scale is scale || 1, so an unset or 0 scale means 1.
|
|
36
36
|
|
|
37
37
|
**reason** (`string`): A detailed explanation of the score, including which claims were supported, contradicted, or marked as unsure.
|
|
38
38
|
|
|
@@ -60,13 +60,13 @@ The scorer evaluates faithfulness through claim verification against provided co
|
|
|
60
60
|
|
|
61
61
|
- Counts supported claims
|
|
62
62
|
- Divides by total claims
|
|
63
|
-
- Scales to
|
|
63
|
+
- Scales to the effective range
|
|
64
64
|
|
|
65
|
-
Final score: `(supported_claims / total_claims) * scale`
|
|
65
|
+
Final score: `(supported_claims / total_claims) * effective_scale`, where `effective_scale` is `scale || 1`
|
|
66
66
|
|
|
67
67
|
### Score interpretation
|
|
68
68
|
|
|
69
|
-
A faithfulness score between 0 and the
|
|
69
|
+
A faithfulness score between 0 and the effective scale (default 1). With the default scale:
|
|
70
70
|
|
|
71
71
|
- **1.0**: All claims are accurate and directly supported by the context.
|
|
72
72
|
- **0.7 to 0.9**: Most claims are correct, with minor additions or omissions.
|
|
@@ -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
|
|