@mastra/mcp-docs-server 1.0.0-beta.4 → 1.0.0-beta.6
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/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +29 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +411 -211
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +52 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flance.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Frag.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Freact.md +89 -1
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +92 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +67 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +201 -1
- package/.docs/organized/changelogs/create-mastra.md +201 -1
- package/.docs/organized/changelogs/mastra.md +201 -1
- package/.docs/organized/code-examples/agui.md +1 -0
- package/.docs/organized/code-examples/ai-sdk-v5.md +1 -0
- package/.docs/organized/code-examples/mcp-server-adapters.md +721 -0
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/quick-start.md +1 -1
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/raw/agents/adding-voice.mdx +7 -10
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/guardrails.mdx +26 -23
- package/.docs/raw/agents/networks.mdx +2 -2
- package/.docs/raw/agents/overview.mdx +27 -62
- package/.docs/raw/agents/processors.mdx +279 -0
- package/.docs/raw/agents/using-tools.mdx +4 -5
- package/.docs/raw/course/01-first-agent/05-running-playground.md +5 -5
- package/.docs/raw/course/01-first-agent/09-testing-your-agent.md +3 -3
- package/.docs/raw/course/01-first-agent/13-testing-your-tool.md +3 -3
- package/.docs/raw/course/01-first-agent/17-testing-memory.md +2 -2
- package/.docs/raw/course/04-workflows/07-using-playground.md +1 -1
- package/.docs/raw/deployment/building-mastra.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +20 -27
- package/.docs/raw/deployment/cloud-providers/netlify-deployer.mdx +44 -13
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +19 -17
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +1 -1
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/web-framework.mdx +5 -5
- package/.docs/raw/evals/custom-scorers.mdx +3 -5
- package/.docs/raw/evals/overview.mdx +2 -3
- package/.docs/raw/evals/running-in-ci.mdx +0 -2
- package/.docs/raw/{guides/guide → getting-started}/manual-install.mdx +2 -2
- package/.docs/raw/getting-started/project-structure.mdx +1 -1
- package/.docs/raw/getting-started/start.mdx +72 -0
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/{frameworks/agentic-uis/ai-sdk.mdx → guides/build-your-ui/ai-sdk-ui.mdx} +113 -11
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/astro.mdx +23 -25
- package/.docs/raw/{frameworks/servers → guides/getting-started}/express.mdx +3 -4
- package/.docs/raw/guides/{quickstarts/nextjs.mdx → getting-started/next-js.mdx} +11 -11
- package/.docs/raw/guides/{quickstarts/standalone-server.mdx → getting-started/quickstart.mdx} +7 -7
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/sveltekit.mdx +23 -25
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/vite-react.mdx +7 -7
- package/.docs/raw/guides/guide/ai-recruiter.mdx +2 -3
- package/.docs/raw/guides/guide/chef-michel.mdx +2 -3
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +2 -2
- package/.docs/raw/guides/guide/research-assistant.mdx +7 -8
- package/.docs/raw/guides/guide/stock-agent.mdx +4 -6
- package/.docs/raw/guides/guide/web-search.mdx +12 -10
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/agentnetwork.mdx +4 -4
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +40 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +5 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +51 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +2 -2
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mcp/overview.mdx +3 -5
- package/.docs/raw/memory/memory-processors.mdx +264 -79
- package/.docs/raw/memory/semantic-recall.mdx +7 -7
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-pg.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +2 -4
- package/.docs/raw/memory/threads-and-resources.mdx +3 -3
- package/.docs/raw/memory/working-memory.mdx +14 -7
- package/.docs/raw/{logging.mdx → observability/logging.mdx} +1 -1
- package/.docs/raw/observability/overview.mdx +2 -3
- package/.docs/raw/observability/tracing/bridges/otel.mdx +176 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +17 -0
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +19 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +20 -0
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +12 -0
- package/.docs/raw/observability/tracing/exporters/otel.mdx +25 -5
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +107 -0
- package/.docs/raw/observability/tracing/overview.mdx +74 -8
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +0 -1
- package/.docs/raw/rag/chunking-and-embedding.mdx +16 -17
- package/.docs/raw/rag/overview.mdx +3 -2
- package/.docs/raw/rag/retrieval.mdx +43 -38
- package/.docs/raw/rag/vector-databases.mdx +93 -2
- package/.docs/raw/reference/agents/agent.mdx +7 -10
- package/.docs/raw/reference/agents/generate.mdx +55 -6
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/network.mdx +46 -3
- package/.docs/raw/reference/cli/mastra.mdx +2 -1
- package/.docs/raw/reference/client-js/agents.mdx +3 -3
- package/.docs/raw/reference/client-js/memory.mdx +43 -0
- package/.docs/raw/reference/client-js/workflows.mdx +92 -63
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +1 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +5 -19
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/deployer/netlify.mdx +1 -2
- package/.docs/raw/reference/evals/answer-relevancy.mdx +28 -98
- package/.docs/raw/reference/evals/answer-similarity.mdx +12 -258
- package/.docs/raw/reference/evals/bias.mdx +29 -87
- package/.docs/raw/reference/evals/completeness.mdx +31 -90
- package/.docs/raw/reference/evals/content-similarity.mdx +28 -88
- package/.docs/raw/reference/evals/context-precision.mdx +28 -130
- package/.docs/raw/reference/evals/context-relevance.mdx +11 -11
- package/.docs/raw/reference/evals/faithfulness.mdx +28 -101
- package/.docs/raw/reference/evals/hallucination.mdx +28 -103
- package/.docs/raw/reference/evals/keyword-coverage.mdx +28 -107
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +11 -11
- package/.docs/raw/reference/evals/prompt-alignment.mdx +15 -15
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +27 -100
- package/.docs/raw/reference/evals/tone-consistency.mdx +25 -98
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +7 -7
- package/.docs/raw/reference/evals/toxicity.mdx +29 -92
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/memory/memory-class.mdx +5 -7
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +150 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +4 -0
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +17 -1
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +6 -0
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +132 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +29 -4
- package/.docs/raw/reference/observability/tracing/spans.mdx +0 -4
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
- package/.docs/raw/reference/processors/language-detector.mdx +10 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +12 -5
- package/.docs/raw/reference/processors/pii-detector.mdx +12 -5
- package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +10 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +3 -4
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/rag/embeddings.mdx +5 -5
- package/.docs/raw/reference/rag/rerank.mdx +1 -2
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +0 -1
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/lance.mdx +33 -0
- package/.docs/raw/reference/storage/libsql.mdx +37 -0
- package/.docs/raw/reference/storage/mongodb.mdx +39 -0
- package/.docs/raw/reference/storage/mssql.mdx +37 -0
- package/.docs/raw/reference/storage/postgresql.mdx +37 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +64 -2
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +7 -9
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +83 -24
- package/.docs/raw/reference/templates/overview.mdx +1 -4
- package/.docs/raw/reference/tools/client.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +132 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +5 -5
- package/.docs/raw/reference/tools/mcp-client.mdx +76 -21
- package/.docs/raw/reference/tools/mcp-server.mdx +1 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +14 -15
- package/.docs/raw/reference/vectors/chroma.mdx +81 -1
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/couchbase.mdx +24 -17
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/vectors/lance.mdx +38 -22
- package/.docs/raw/reference/vectors/libsql.mdx +35 -2
- package/.docs/raw/reference/vectors/mongodb.mdx +35 -2
- package/.docs/raw/reference/vectors/opensearch.mdx +37 -16
- package/.docs/raw/reference/vectors/pg.mdx +43 -36
- package/.docs/raw/reference/vectors/pinecone.mdx +48 -1
- package/.docs/raw/reference/vectors/qdrant.mdx +36 -1
- package/.docs/raw/reference/vectors/turbopuffer.mdx +74 -0
- package/.docs/raw/reference/voice/google.mdx +159 -20
- package/.docs/raw/reference/voice/openai-realtime.mdx +2 -2
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +2 -3
- package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
- package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
- package/.docs/raw/reference/voice/voice.close.mdx +1 -1
- package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
- package/.docs/raw/reference/voice/voice.off.mdx +1 -1
- package/.docs/raw/reference/voice/voice.on.mdx +1 -1
- package/.docs/raw/reference/voice/voice.send.mdx +1 -1
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/start.mdx +44 -0
- package/.docs/raw/reference/workflows/run.mdx +13 -5
- package/.docs/raw/reference/workflows/step.mdx +13 -0
- package/.docs/raw/reference/workflows/workflow.mdx +19 -0
- package/.docs/raw/server-db/mastra-client.mdx +1 -2
- package/.docs/raw/server-db/mastra-server.mdx +30 -1
- package/.docs/raw/server-db/request-context.mdx +0 -1
- package/.docs/raw/server-db/storage.mdx +11 -0
- package/.docs/raw/streaming/overview.mdx +26 -15
- package/.docs/raw/streaming/tool-streaming.mdx +48 -5
- package/.docs/raw/streaming/workflow-streaming.mdx +5 -11
- package/.docs/raw/tools-mcp/advanced-usage.mdx +1 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +3 -5
- package/.docs/raw/voice/overview.mdx +21 -41
- package/.docs/raw/voice/speech-to-speech.mdx +4 -4
- package/.docs/raw/voice/speech-to-text.mdx +1 -2
- package/.docs/raw/voice/text-to-speech.mdx +1 -2
- package/.docs/raw/workflows/control-flow.mdx +180 -0
- package/.docs/raw/workflows/error-handling.mdx +1 -0
- package/.docs/raw/workflows/human-in-the-loop.mdx +4 -4
- package/.docs/raw/workflows/overview.mdx +56 -44
- package/.docs/raw/workflows/snapshots.mdx +1 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +85 -16
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +191 -0
- package/CHANGELOG.md +18 -0
- package/dist/{chunk-5NJC7NRO.js → chunk-4CM2BQNP.js} +24 -4
- package/dist/prepare-docs/package-changes.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +7 -7
- package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +0 -90
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +0 -102
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +0 -179
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +0 -379
- package/.docs/raw/getting-started/quickstart.mdx +0 -27
- package/.docs/raw/getting-started/templates.mdx +0 -73
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/assistant-ui.mdx +0 -0
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/copilotkit.mdx +0 -0
|
@@ -105,106 +105,47 @@ A completeness score between 0 and 1:
|
|
|
105
105
|
- **0.1–0.3**: Only partially addresses the query with significant gaps.
|
|
106
106
|
- **0.0**: Fails to address the query or provides irrelevant information.
|
|
107
107
|
|
|
108
|
-
##
|
|
108
|
+
## Example
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
Evaluate agent responses for completeness across different query complexities:
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
```typescript title="src/example-high-completeness.ts" showLineNumbers copy
|
|
115
|
-
import { createCompletenessScorer } from "@mastra/evals/scorers/prebuilt";
|
|
116
|
-
|
|
117
|
-
const scorer = createCompletenessScorer({ model: "openai/gpt-4o-mini" });
|
|
118
|
-
|
|
119
|
-
const query =
|
|
120
|
-
"Explain the process of photosynthesis, including the inputs, outputs, and stages involved.";
|
|
121
|
-
const response =
|
|
122
|
-
"Photosynthesis is the process by which plants convert sunlight into chemical energy. Inputs: Carbon dioxide (CO2) from the air enters through stomata, water (H2O) is absorbed by roots, and sunlight provides energy captured by chlorophyll. The process occurs in two main stages: 1) Light-dependent reactions in the thylakoids convert light energy to ATP and NADPH while splitting water and releasing oxygen. 2) Light-independent reactions (Calvin cycle) in the stroma use ATP, NADPH, and CO2 to produce glucose. Outputs: Glucose (C6H12O6) serves as food for the plant, and oxygen (O2) is released as a byproduct. The overall equation is: 6CO2 + 6H2O + light energy → C6H12O6 + 6O2.";
|
|
123
|
-
|
|
124
|
-
const result = await scorer.run({
|
|
125
|
-
input: [{ role: "user", content: query }],
|
|
126
|
-
output: { text: response },
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
console.log(result);
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
#### High completeness output
|
|
133
|
-
|
|
134
|
-
The output receives a high score because it addresses all requested aspects: inputs, outputs, stages, and provides additional context.
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
{
|
|
138
|
-
score: 1,
|
|
139
|
-
reason: "The score is 1 because the response comprehensively addresses all aspects of the query: it explains what photosynthesis is, lists all inputs (CO2, H2O, sunlight), describes both stages in detail (light-dependent and light-independent reactions), specifies all outputs (glucose and oxygen), and even provides the chemical equation. No significant aspects are missing."
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Partial completeness example
|
|
144
|
-
|
|
145
|
-
In this example, the response addresses some key points but misses important aspects or lacks sufficient detail.
|
|
146
|
-
|
|
147
|
-
```typescript title="src/example-partial-completeness.ts" showLineNumbers copy
|
|
148
|
-
import { createCompletenessScorer } from "@mastra/evals/scorers/prebuilt";
|
|
149
|
-
|
|
150
|
-
const scorer = createCompletenessScorer({ model: "openai/gpt-4o-mini" });
|
|
151
|
-
|
|
152
|
-
const query =
|
|
153
|
-
"What are the benefits and drawbacks of remote work for both employees and employers?";
|
|
154
|
-
const response =
|
|
155
|
-
"Remote work offers several benefits for employees including flexible schedules, no commuting time, and better work-life balance. It also reduces costs for office space and utilities for employers. However, remote work can lead to isolation and communication challenges for employees.";
|
|
156
|
-
|
|
157
|
-
const result = await scorer.run({
|
|
158
|
-
input: [{ role: "user", content: query }],
|
|
159
|
-
output: { text: response },
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
console.log(result);
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
#### Partial completeness output
|
|
166
|
-
|
|
167
|
-
The output receives a moderate score because it covers employee benefits and some drawbacks, but lacks comprehensive coverage of employer drawbacks.
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
{
|
|
171
|
-
score: 0.6,
|
|
172
|
-
reason: "The score is 0.6 because the response covers employee benefits (flexibility, no commuting, work-life balance) and one employer benefit (reduced costs), as well as some employee drawbacks (isolation, communication challenges). However, it fails to address potential drawbacks for employers such as reduced oversight, team cohesion challenges, or productivity monitoring difficulties."
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Low completeness example
|
|
177
|
-
|
|
178
|
-
In this example, the response only partially addresses the query and misses several important aspects.
|
|
179
|
-
|
|
180
|
-
```typescript title="src/example-low-completeness.ts" showLineNumbers copy
|
|
112
|
+
```typescript title="src/example-completeness.ts" showLineNumbers copy
|
|
113
|
+
import { runEvals } from "@mastra/core/evals";
|
|
181
114
|
import { createCompletenessScorer } from "@mastra/evals/scorers/prebuilt";
|
|
115
|
+
import { myAgent } from "./agent";
|
|
182
116
|
|
|
183
|
-
const scorer = createCompletenessScorer(
|
|
184
|
-
|
|
185
|
-
const query =
|
|
186
|
-
"Compare renewable and non-renewable energy sources in terms of cost, environmental impact, and sustainability.";
|
|
187
|
-
const response =
|
|
188
|
-
"Renewable energy sources like solar and wind are becoming cheaper. They're better for the environment than fossil fuels.";
|
|
117
|
+
const scorer = createCompletenessScorer();
|
|
189
118
|
|
|
190
|
-
const result = await
|
|
191
|
-
|
|
192
|
-
|
|
119
|
+
const result = await runEvals({
|
|
120
|
+
data: [
|
|
121
|
+
{
|
|
122
|
+
input:
|
|
123
|
+
"Explain the process of photosynthesis, including the inputs, outputs, and stages involved.",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
input:
|
|
127
|
+
"What are the benefits and drawbacks of remote work for both employees and employers?",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
input:
|
|
131
|
+
"Compare renewable and non-renewable energy sources in terms of cost, environmental impact, and sustainability.",
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
scorers: [scorer],
|
|
135
|
+
target: myAgent,
|
|
136
|
+
onItemComplete: ({ scorerResults }) => {
|
|
137
|
+
console.log({
|
|
138
|
+
score: scorerResults[scorer.id].score,
|
|
139
|
+
});
|
|
140
|
+
},
|
|
193
141
|
});
|
|
194
142
|
|
|
195
|
-
console.log(result);
|
|
143
|
+
console.log(result.scores);
|
|
196
144
|
```
|
|
197
145
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
The output receives a low score because it only briefly mentions cost and environmental impact while completely missing sustainability and lacking detailed comparison.
|
|
146
|
+
For more details on `runEvals`, see the [runEvals reference](/reference/v1/evals/run-evals).
|
|
201
147
|
|
|
202
|
-
|
|
203
|
-
{
|
|
204
|
-
score: 0.2,
|
|
205
|
-
reason: "The score is 0.2 because the response only superficially touches on cost (renewable getting cheaper) and environmental impact (renewable better than fossil fuels) but provides no detailed comparison, fails to address sustainability aspects, doesn't discuss specific non-renewable sources, and lacks depth in all mentioned areas."
|
|
206
|
-
}
|
|
207
|
-
```
|
|
148
|
+
To add this scorer to an agent, see the [Scorers overview](/docs/v1/evals/overview#adding-scorers-to-agents) guide.
|
|
208
149
|
|
|
209
150
|
## Related
|
|
210
151
|
|
|
@@ -78,106 +78,46 @@ The scorer evaluates textual similarity through character-level matching and con
|
|
|
78
78
|
|
|
79
79
|
Final score: `similarity_value * scale`
|
|
80
80
|
|
|
81
|
-
##
|
|
81
|
+
## Example
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
Evaluate textual similarity between expected and actual agent outputs:
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
```typescript title="src/example-high-similarity.ts" showLineNumbers copy
|
|
85
|
+
```typescript title="src/example-content-similarity.ts" showLineNumbers copy
|
|
86
|
+
import { runEvals } from "@mastra/core/evals";
|
|
88
87
|
import { createContentSimilarityScorer } from "@mastra/evals/scorers/prebuilt";
|
|
88
|
+
import { myAgent } from "./agent";
|
|
89
89
|
|
|
90
90
|
const scorer = createContentSimilarityScorer();
|
|
91
91
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
const result = await runEvals({
|
|
93
|
+
data: [
|
|
94
|
+
{
|
|
95
|
+
input: "Summarize the benefits of TypeScript",
|
|
96
|
+
groundTruth:
|
|
97
|
+
"TypeScript provides static typing, better tooling support, and improved code maintainability.",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
input: "What is machine learning?",
|
|
101
|
+
groundTruth:
|
|
102
|
+
"Machine learning is a subset of AI that enables systems to learn from data without explicit programming.",
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
scorers: [scorer],
|
|
106
|
+
target: myAgent,
|
|
107
|
+
onItemComplete: ({ scorerResults }) => {
|
|
108
|
+
console.log({
|
|
109
|
+
score: scorerResults[scorer.id].score,
|
|
110
|
+
groundTruth: scorerResults[scorer.id].groundTruth,
|
|
111
|
+
});
|
|
112
112
|
},
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Moderate similarity example
|
|
117
|
-
|
|
118
|
-
In this example, the response shares some conceptual overlap with the query but diverges in structure and wording. Key elements remain present, but the phrasing introduces moderate variation.
|
|
119
|
-
|
|
120
|
-
```typescript title="src/example-moderate-similarity.ts" showLineNumbers copy
|
|
121
|
-
import { createContentSimilarityScorer } from "@mastra/evals/scorers/prebuilt";
|
|
122
|
-
|
|
123
|
-
const scorer = createContentSimilarityScorer();
|
|
124
|
-
|
|
125
|
-
const query = "A brown fox quickly leaps across a sleeping dog.";
|
|
126
|
-
const response = "The quick brown fox jumps over the lazy dog.";
|
|
127
|
-
|
|
128
|
-
const result = await scorer.run({
|
|
129
|
-
input: [{ role: "user", content: query }],
|
|
130
|
-
output: { text: response },
|
|
131
113
|
});
|
|
132
114
|
|
|
133
|
-
console.log(result);
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
#### Moderate similarity output
|
|
137
|
-
|
|
138
|
-
The output receives a mid-range score because the response captures the general idea of the query, though it differs enough in wording to reduce overall similarity.
|
|
139
|
-
|
|
140
|
-
```typescript
|
|
141
|
-
{
|
|
142
|
-
score: 0.40540540540540543,
|
|
143
|
-
analyzeStepResult: {
|
|
144
|
-
similarity: 0.40540540540540543
|
|
145
|
-
}
|
|
146
|
-
}
|
|
115
|
+
console.log(result.scores);
|
|
147
116
|
```
|
|
148
117
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
In this example, the response and query are unrelated in meaning, despite having a similar grammatical structure. There is little to no shared content overlap.
|
|
152
|
-
|
|
153
|
-
```typescript title="src/example-low-similarity.ts" showLineNumbers copy
|
|
154
|
-
import { createContentSimilarityScorer } from "@mastra/evals/scorers/prebuilt";
|
|
155
|
-
|
|
156
|
-
const scorer = createContentSimilarityScorer();
|
|
118
|
+
For more details on `runEvals`, see the [runEvals reference](/reference/v1/evals/run-evals).
|
|
157
119
|
|
|
158
|
-
|
|
159
|
-
const response = "The quick brown fox jumps over the lazy dog.";
|
|
160
|
-
|
|
161
|
-
const result = await scorer.run({
|
|
162
|
-
input: [{ role: "user", content: query }],
|
|
163
|
-
output: { text: response },
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
console.log(result);
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
#### Low similarity output
|
|
170
|
-
|
|
171
|
-
The output receives a low score because the response does not align with the content or intent of the query.
|
|
172
|
-
|
|
173
|
-
```typescript
|
|
174
|
-
{
|
|
175
|
-
score: 0.25806451612903225,
|
|
176
|
-
analyzeStepResult: {
|
|
177
|
-
similarity: 0.25806451612903225
|
|
178
|
-
},
|
|
179
|
-
}
|
|
180
|
-
```
|
|
120
|
+
To add this scorer to an agent, see the [Scorers overview](/docs/v1/evals/overview#adding-scorers-to-agents) guide.
|
|
181
121
|
|
|
182
122
|
### Score interpretation
|
|
183
123
|
|
|
@@ -152,7 +152,7 @@ MAP = (1.0 + 0.67) / 2 = 0.835 ≈ **0.83**
|
|
|
152
152
|
|
|
153
153
|
```typescript
|
|
154
154
|
const scorer = createContextPrecisionScorer({
|
|
155
|
-
model: "openai/gpt-
|
|
155
|
+
model: "openai/gpt-5.1",
|
|
156
156
|
options: {
|
|
157
157
|
contextExtractor: (input, output) => {
|
|
158
158
|
// Extract context dynamically based on the query
|
|
@@ -171,7 +171,7 @@ const scorer = createContextPrecisionScorer({
|
|
|
171
171
|
|
|
172
172
|
```typescript
|
|
173
173
|
const scorer = createContextPrecisionScorer({
|
|
174
|
-
model: "openai/gpt-
|
|
174
|
+
model: "openai/gpt-5.1",
|
|
175
175
|
options: {
|
|
176
176
|
context: [
|
|
177
177
|
// Simulate retrieved documents from vector database
|
|
@@ -186,152 +186,50 @@ const scorer = createContextPrecisionScorer({
|
|
|
186
186
|
});
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
##
|
|
189
|
+
## Example
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
Evaluate RAG system context retrieval precision for different queries:
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
import {
|
|
193
|
+
```typescript title="src/example-context-precision.ts" showLineNumbers copy
|
|
194
|
+
import { runEvals } from "@mastra/core/evals";
|
|
195
|
+
import { createContextPrecisionScorer } from "@mastra/evals/scorers/prebuilt";
|
|
196
|
+
import { myAgent } from "./agent";
|
|
197
197
|
|
|
198
198
|
const scorer = createContextPrecisionScorer({
|
|
199
|
-
model: "openai/gpt-4o
|
|
199
|
+
model: "openai/gpt-4o",
|
|
200
200
|
options: {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
],
|
|
206
|
-
scale: 1,
|
|
201
|
+
contextExtractor: (input, output) => {
|
|
202
|
+
// Extract context from agent's retrieved documents
|
|
203
|
+
return output.metadata?.retrievedContext || [];
|
|
204
|
+
},
|
|
207
205
|
},
|
|
208
206
|
});
|
|
209
207
|
|
|
210
|
-
const result = await
|
|
211
|
-
|
|
212
|
-
inputMessages: [
|
|
213
|
-
{
|
|
214
|
-
id: "1",
|
|
215
|
-
role: "user",
|
|
216
|
-
content: "How does photosynthesis work in plants?",
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
},
|
|
220
|
-
output: [
|
|
208
|
+
const result = await runEvals({
|
|
209
|
+
data: [
|
|
221
210
|
{
|
|
222
|
-
|
|
223
|
-
role: "assistant",
|
|
224
|
-
content:
|
|
225
|
-
"Photosynthesis is the process where plants convert sunlight, CO2, and water into glucose and oxygen using chloroplasts.",
|
|
211
|
+
input: "How does photosynthesis work in plants?",
|
|
226
212
|
},
|
|
227
|
-
],
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
console.log(result);
|
|
231
|
-
// Output:
|
|
232
|
-
// {
|
|
233
|
-
// score: 1.0,
|
|
234
|
-
// reason: "The score is 1.0 because all context pieces are highly relevant to explaining photosynthesis and are optimally ordered to support the expected output."
|
|
235
|
-
// }
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Mixed precision example
|
|
239
|
-
|
|
240
|
-
This example shows moderate precision with both relevant and irrelevant context:
|
|
241
|
-
|
|
242
|
-
```typescript
|
|
243
|
-
import { createContextPrecisionScorer } from "@mastra/evals";
|
|
244
|
-
|
|
245
|
-
const scorer = createContextPrecisionScorer({
|
|
246
|
-
model: "openai/gpt-4o-mini",
|
|
247
|
-
options: {
|
|
248
|
-
context: [
|
|
249
|
-
"Regular exercise improves cardiovascular health by strengthening the heart muscle.",
|
|
250
|
-
"A balanced diet should include fruits, vegetables, and whole grains.",
|
|
251
|
-
"Physical activity releases endorphins which improve mood and reduce stress.",
|
|
252
|
-
"The average person should drink 8 glasses of water per day.",
|
|
253
|
-
"Exercise also helps maintain healthy body weight and muscle mass.",
|
|
254
|
-
],
|
|
255
|
-
scale: 1,
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
const result = await scorer.run({
|
|
260
|
-
input: {
|
|
261
|
-
inputMessages: [
|
|
262
|
-
{
|
|
263
|
-
id: "1",
|
|
264
|
-
role: "user",
|
|
265
|
-
content: "What are the mental and physical benefits of exercise?",
|
|
266
|
-
},
|
|
267
|
-
],
|
|
268
|
-
},
|
|
269
|
-
output: [
|
|
270
213
|
{
|
|
271
|
-
|
|
272
|
-
role: "assistant",
|
|
273
|
-
content:
|
|
274
|
-
"Exercise provides cardiovascular benefits, improves mood through endorphin release, and helps maintain healthy body composition.",
|
|
214
|
+
input: "What are the mental and physical benefits of exercise?",
|
|
275
215
|
},
|
|
276
216
|
],
|
|
217
|
+
scorers: [scorer],
|
|
218
|
+
target: myAgent,
|
|
219
|
+
onItemComplete: ({ scorerResults }) => {
|
|
220
|
+
console.log({
|
|
221
|
+
score: scorerResults[scorer.id].score,
|
|
222
|
+
reason: scorerResults[scorer.id].reason,
|
|
223
|
+
});
|
|
224
|
+
},
|
|
277
225
|
});
|
|
278
226
|
|
|
279
|
-
console.log(result);
|
|
280
|
-
// Output:
|
|
281
|
-
// {
|
|
282
|
-
// score: 0.72,
|
|
283
|
-
// reason: "The score is 0.72 because contexts 1, 3, and 5 are relevant to exercise benefits, but irrelevant contexts about diet and hydration reduce the precision score."
|
|
284
|
-
// }
|
|
227
|
+
console.log(result.scores);
|
|
285
228
|
```
|
|
286
229
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
This example shows poor context precision with mostly irrelevant context:
|
|
290
|
-
|
|
291
|
-
```typescript
|
|
292
|
-
import { createContextPrecisionScorer } from "@mastra/evals";
|
|
293
|
-
|
|
294
|
-
const scorer = createContextPrecisionScorer({
|
|
295
|
-
model: "openai/gpt-4o-mini",
|
|
296
|
-
options: {
|
|
297
|
-
context: [
|
|
298
|
-
"The weather forecast shows sunny skies this weekend.",
|
|
299
|
-
"Coffee is one of the world's most popular beverages.",
|
|
300
|
-
"Machine learning requires large amounts of training data.",
|
|
301
|
-
"Cats typically sleep 12-16 hours per day.",
|
|
302
|
-
"The capital of France is Paris.",
|
|
303
|
-
],
|
|
304
|
-
scale: 1,
|
|
305
|
-
},
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
const result = await scorer.run({
|
|
309
|
-
input: {
|
|
310
|
-
inputMessages: [
|
|
311
|
-
{
|
|
312
|
-
id: "1",
|
|
313
|
-
role: "user",
|
|
314
|
-
content: "How does photosynthesis work?",
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
|
-
},
|
|
318
|
-
output: [
|
|
319
|
-
{
|
|
320
|
-
id: "2",
|
|
321
|
-
role: "assistant",
|
|
322
|
-
content:
|
|
323
|
-
"Photosynthesis is the process by which plants convert sunlight into energy using chlorophyll.",
|
|
324
|
-
},
|
|
325
|
-
],
|
|
326
|
-
});
|
|
230
|
+
For more details on `runEvals`, see the [runEvals reference](/reference/v1/evals/run-evals).
|
|
327
231
|
|
|
328
|
-
|
|
329
|
-
// Output:
|
|
330
|
-
// {
|
|
331
|
-
// score: 0.0,
|
|
332
|
-
// reason: "The score is 0.0 because none of the retrieved context pieces are relevant to explaining photosynthesis."
|
|
333
|
-
// }
|
|
334
|
-
```
|
|
232
|
+
To add this scorer to an agent, see the [Scorers overview](/docs/v1/evals/overview#adding-scorers-to-agents) guide.
|
|
335
233
|
|
|
336
234
|
## Comparison with Context Relevance
|
|
337
235
|
|
|
@@ -198,7 +198,7 @@ import { createContextRelevanceScorerLLM } from "@mastra/evals";
|
|
|
198
198
|
|
|
199
199
|
// Stricter penalty configuration
|
|
200
200
|
const strictScorer = createContextRelevanceScorerLLM({
|
|
201
|
-
model: "openai/gpt-
|
|
201
|
+
model: "openai/gpt-5.1",
|
|
202
202
|
options: {
|
|
203
203
|
context: [
|
|
204
204
|
"Einstein won the Nobel Prize for photoelectric effect",
|
|
@@ -216,7 +216,7 @@ const strictScorer = createContextRelevanceScorerLLM({
|
|
|
216
216
|
|
|
217
217
|
// Lenient penalty configuration
|
|
218
218
|
const lenientScorer = createContextRelevanceScorerLLM({
|
|
219
|
-
model: "openai/gpt-
|
|
219
|
+
model: "openai/gpt-5.1",
|
|
220
220
|
options: {
|
|
221
221
|
context: [
|
|
222
222
|
"Einstein won the Nobel Prize for photoelectric effect",
|
|
@@ -263,7 +263,7 @@ console.log("Lenient penalties:", lenientResult.score); // Higher score, less pe
|
|
|
263
263
|
|
|
264
264
|
```typescript
|
|
265
265
|
const scorer = createContextRelevanceScorerLLM({
|
|
266
|
-
model: "openai/gpt-
|
|
266
|
+
model: "openai/gpt-5.1",
|
|
267
267
|
options: {
|
|
268
268
|
contextExtractor: (input, output) => {
|
|
269
269
|
// Extract context based on the query
|
|
@@ -287,7 +287,7 @@ const scorer = createContextRelevanceScorerLLM({
|
|
|
287
287
|
|
|
288
288
|
```typescript
|
|
289
289
|
const scorer = createContextRelevanceScorerLLM({
|
|
290
|
-
model: "openai/gpt-
|
|
290
|
+
model: "openai/gpt-5.1",
|
|
291
291
|
options: {
|
|
292
292
|
context: ["Relevant information...", "Supporting details..."],
|
|
293
293
|
scale: 100, // Scale scores from 0-100 instead of 0-1
|
|
@@ -301,7 +301,7 @@ const scorer = createContextRelevanceScorerLLM({
|
|
|
301
301
|
|
|
302
302
|
```typescript
|
|
303
303
|
const scorer = createContextRelevanceScorerLLM({
|
|
304
|
-
model: "openai/gpt-
|
|
304
|
+
model: "openai/gpt-5.1",
|
|
305
305
|
options: {
|
|
306
306
|
contextExtractor: (input, output) => {
|
|
307
307
|
const query = input?.inputMessages?.[0]?.content || "";
|
|
@@ -328,7 +328,7 @@ This example shows excellent context relevance where all context directly suppor
|
|
|
328
328
|
import { createContextRelevanceScorerLLM } from "@mastra/evals";
|
|
329
329
|
|
|
330
330
|
const scorer = createContextRelevanceScorerLLM({
|
|
331
|
-
model: "openai/gpt-
|
|
331
|
+
model: "openai/gpt-5.1",
|
|
332
332
|
options: {
|
|
333
333
|
context: [
|
|
334
334
|
"Einstein won the Nobel Prize for his discovery of the photoelectric effect in 1921.",
|
|
@@ -375,7 +375,7 @@ This example shows moderate relevance with some context being irrelevant or unus
|
|
|
375
375
|
import { createContextRelevanceScorerLLM } from "@mastra/evals";
|
|
376
376
|
|
|
377
377
|
const scorer = createContextRelevanceScorerLLM({
|
|
378
|
-
model: "openai/gpt-
|
|
378
|
+
model: "openai/gpt-5.1",
|
|
379
379
|
options: {
|
|
380
380
|
context: [
|
|
381
381
|
"Solar eclipses occur when the Moon blocks the Sun.",
|
|
@@ -417,7 +417,7 @@ console.log(result);
|
|
|
417
417
|
|
|
418
418
|
// With custom penalty configuration
|
|
419
419
|
const customScorer = createContextRelevanceScorerLLM({
|
|
420
|
-
model: "openai/gpt-
|
|
420
|
+
model: "openai/gpt-5.1",
|
|
421
421
|
options: {
|
|
422
422
|
context: [
|
|
423
423
|
"Solar eclipses occur when the Moon blocks the Sun.",
|
|
@@ -466,7 +466,7 @@ This example shows poor context relevance with mostly irrelevant information:
|
|
|
466
466
|
import { createContextRelevanceScorerLLM } from "@mastra/evals";
|
|
467
467
|
|
|
468
468
|
const scorer = createContextRelevanceScorerLLM({
|
|
469
|
-
model: "openai/gpt-
|
|
469
|
+
model: "openai/gpt-5.1",
|
|
470
470
|
options: {
|
|
471
471
|
context: [
|
|
472
472
|
"The Great Barrier Reef is located in Australia.",
|
|
@@ -514,7 +514,7 @@ Extract context dynamically based on the run input:
|
|
|
514
514
|
import { createContextRelevanceScorerLLM } from "@mastra/evals";
|
|
515
515
|
|
|
516
516
|
const scorer = createContextRelevanceScorerLLM({
|
|
517
|
-
model: "openai/gpt-
|
|
517
|
+
model: "openai/gpt-5.1",
|
|
518
518
|
options: {
|
|
519
519
|
contextExtractor: (input, output) => {
|
|
520
520
|
// Extract query from input
|
|
@@ -557,7 +557,7 @@ Integrate with RAG pipelines to evaluate retrieved context:
|
|
|
557
557
|
import { createContextRelevanceScorerLLM } from "@mastra/evals";
|
|
558
558
|
|
|
559
559
|
const scorer = createContextRelevanceScorerLLM({
|
|
560
|
-
model: "openai/gpt-
|
|
560
|
+
model: "openai/gpt-5.1",
|
|
561
561
|
options: {
|
|
562
562
|
contextExtractor: (input, output) => {
|
|
563
563
|
// Extract from RAG retrieval results
|