@mastra/mcp-docs-server 0.13.39 → 1.0.0-beta.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/.docs/organized/changelogs/%40internal%2Fai-sdk-v4.md +1 -0
- package/.docs/organized/changelogs/%40internal%2Fchangeset-cli.md +0 -10
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +0 -10
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +36 -36
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +0 -10
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +40 -40
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fauth.md +4 -14
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +223 -223
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +190 -190
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +214 -214
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +74 -74
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +209 -209
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +191 -191
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Ffastembed.md +5 -13
- package/.docs/organized/changelogs/%40mastra%2Flance.md +182 -182
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +65 -65
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +228 -228
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +199 -199
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +206 -206
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +197 -197
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +217 -217
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Frag.md +61 -61
- package/.docs/organized/changelogs/%40mastra%2Freact.md +70 -70
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -17
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -30
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +206 -206
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +190 -190
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +56 -56
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +20 -20
- package/.docs/organized/changelogs/create-mastra.md +33 -33
- package/.docs/organized/changelogs/mastra.md +86 -86
- package/.docs/organized/code-examples/a2a.md +4 -2
- package/.docs/organized/code-examples/agui.md +12 -9
- package/.docs/organized/code-examples/ai-sdk-useChat.md +12 -18
- package/.docs/organized/code-examples/ai-sdk-v5.md +4 -2
- package/.docs/organized/code-examples/bird-checker-with-express.md +5 -4
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +4 -3
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +4 -3
- package/.docs/organized/code-examples/client-side-tools.md +1 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
- package/.docs/organized/code-examples/experimental-auth-weather-agent.md +8 -177
- package/.docs/organized/code-examples/fireworks-r1.md +2 -2
- package/.docs/organized/code-examples/heads-up-game.md +10 -7
- package/.docs/organized/code-examples/mcp-configuration.md +5 -3
- package/.docs/organized/code-examples/mcp-registry-registry.md +3 -2
- package/.docs/organized/code-examples/memory-per-resource-example.md +4 -2
- package/.docs/organized/code-examples/memory-todo-agent.md +1 -0
- package/.docs/organized/code-examples/memory-with-context.md +2 -1
- package/.docs/organized/code-examples/memory-with-libsql.md +4 -2
- package/.docs/organized/code-examples/memory-with-mongodb.md +4 -2
- package/.docs/organized/code-examples/memory-with-pg.md +4 -2
- package/.docs/organized/code-examples/memory-with-processors.md +13 -8
- package/.docs/organized/code-examples/memory-with-upstash.md +5 -3
- package/.docs/organized/code-examples/openapi-spec-writer.md +32 -41
- package/.docs/organized/code-examples/quick-start.md +5 -32
- package/.docs/organized/code-examples/stock-price-tool.md +6 -5
- package/.docs/organized/code-examples/weather-agent.md +21 -16
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +3 -2
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +9 -12
- package/.docs/organized/code-examples/workflow-with-memory.md +16 -15
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +2 -2
- package/.docs/organized/code-examples/workflow-with-suspend-resume.md +3 -2
- package/.docs/raw/agents/adding-voice.mdx +27 -22
- package/.docs/raw/agents/agent-memory.mdx +23 -15
- package/.docs/raw/agents/guardrails.mdx +33 -12
- package/.docs/raw/agents/networks.mdx +8 -4
- package/.docs/raw/agents/overview.mdx +21 -15
- package/.docs/raw/agents/using-tools.mdx +11 -8
- package/.docs/raw/auth/auth0.mdx +8 -8
- package/.docs/raw/auth/clerk.mdx +6 -6
- package/.docs/raw/auth/firebase.mdx +8 -8
- package/.docs/raw/auth/index.mdx +6 -6
- package/.docs/raw/auth/jwt.mdx +6 -6
- package/.docs/raw/auth/supabase.mdx +7 -7
- package/.docs/raw/auth/workos.mdx +8 -8
- package/.docs/raw/community/contributing-templates.mdx +3 -3
- package/.docs/raw/community/discord.mdx +1 -1
- package/.docs/raw/course/01-first-agent/08-exporting-your-agent.md +2 -1
- package/.docs/raw/course/01-first-agent/16-adding-memory-to-agent.md +2 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/04-creating-basic-memory-agent.md +1 -0
- package/.docs/raw/course/03-agent-memory/10-storage-configuration.md +2 -3
- package/.docs/raw/course/03-agent-memory/13-vector-store-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/16-configuring-semantic-recall.md +2 -0
- package/.docs/raw/course/03-agent-memory/18-advanced-configuration-semantic-recall.md +1 -0
- package/.docs/raw/course/03-agent-memory/21-configuring-working-memory.md +2 -0
- package/.docs/raw/course/03-agent-memory/22-custom-working-memory-templates.md +1 -0
- package/.docs/raw/course/03-agent-memory/25-combining-memory-features.md +1 -0
- package/.docs/raw/course/03-agent-memory/27-creating-learning-assistant.md +1 -0
- package/.docs/raw/course/04-workflows/08-running-workflows-programmatically.md +2 -2
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +5 -5
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +7 -5
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +3 -3
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +4 -4
- package/.docs/raw/deployment/cloud-providers/index.mdx +11 -8
- package/.docs/raw/deployment/monorepo.mdx +2 -2
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/server-deployment.mdx +2 -10
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +4 -4
- package/.docs/raw/deployment/serverless-platforms/index.mdx +10 -7
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +4 -4
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +4 -4
- package/.docs/raw/deployment/web-framework.mdx +8 -8
- package/.docs/raw/{scorers → evals}/custom-scorers.mdx +6 -6
- package/.docs/raw/evals/off-the-shelf-scorers.mdx +50 -0
- package/.docs/raw/{scorers → evals}/overview.mdx +8 -8
- package/.docs/raw/evals/running-in-ci.mdx +113 -0
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +22 -21
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +8 -8
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +3 -0
- package/.docs/raw/frameworks/servers/express.mdx +10 -9
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +6 -6
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +3 -3
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +4 -4
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +2 -2
- package/.docs/raw/getting-started/installation.mdx +13 -12
- package/.docs/raw/getting-started/mcp-docs-server.mdx +1 -1
- package/.docs/raw/getting-started/project-structure.mdx +4 -4
- package/.docs/raw/getting-started/studio.mdx +8 -8
- package/.docs/raw/getting-started/templates.mdx +1 -1
- package/.docs/raw/guides/guide/ai-recruiter.mdx +264 -0
- package/.docs/raw/guides/guide/chef-michel.mdx +271 -0
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +450 -0
- package/.docs/raw/guides/guide/research-assistant.mdx +389 -0
- package/.docs/raw/guides/guide/stock-agent.mdx +185 -0
- package/.docs/raw/guides/guide/web-search.mdx +291 -0
- package/.docs/raw/guides/index.mdx +43 -0
- package/.docs/raw/guides/migrations/agentnetwork.mdx +114 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/_template.mdx +50 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +265 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/cli.mdx +48 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/client.mdx +153 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/evals.mdx +230 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mastra.mdx +171 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/mcp.mdx +114 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/memory.mdx +241 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/overview.mdx +83 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/processors.mdx +62 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/storage.mdx +270 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +115 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tracing.mdx +280 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/vectors.mdx +23 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/voice.mdx +39 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +178 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +367 -0
- package/.docs/raw/index.mdx +9 -9
- package/.docs/raw/{observability/logging.mdx → logging.mdx} +4 -4
- package/.docs/raw/mastra-cloud/dashboard.mdx +2 -2
- package/.docs/raw/mastra-cloud/observability.mdx +6 -6
- package/.docs/raw/mastra-cloud/overview.mdx +2 -2
- package/.docs/raw/mastra-cloud/setting-up.mdx +4 -4
- package/.docs/raw/memory/conversation-history.mdx +1 -0
- package/.docs/raw/memory/memory-processors.mdx +4 -3
- package/.docs/raw/memory/overview.mdx +9 -5
- package/.docs/raw/memory/semantic-recall.mdx +12 -7
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +10 -5
- package/.docs/raw/memory/storage/memory-with-pg.mdx +9 -4
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +9 -4
- package/.docs/raw/memory/threads-and-resources.mdx +11 -13
- package/.docs/raw/memory/working-memory.mdx +30 -14
- package/.docs/raw/observability/overview.mdx +13 -30
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/arize.mdx +10 -18
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +7 -16
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/cloud.mdx +11 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/default.mdx +16 -20
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +7 -16
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +7 -16
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/otel.mdx +9 -18
- package/.docs/raw/observability/{ai-tracing → tracing}/overview.mdx +107 -142
- package/.docs/raw/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +14 -13
- package/.docs/raw/rag/chunking-and-embedding.mdx +5 -5
- package/.docs/raw/rag/overview.mdx +3 -13
- package/.docs/raw/rag/retrieval.mdx +24 -12
- package/.docs/raw/rag/vector-databases.mdx +7 -1
- package/.docs/raw/reference/agents/agent.mdx +33 -28
- package/.docs/raw/reference/agents/generate.mdx +10 -10
- package/.docs/raw/reference/agents/generateLegacy.mdx +8 -8
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +21 -15
- package/.docs/raw/reference/agents/getDefaultOptions.mdx +69 -0
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +22 -16
- package/.docs/raw/reference/agents/getDescription.mdx +1 -1
- package/.docs/raw/reference/agents/getInstructions.mdx +8 -8
- package/.docs/raw/reference/agents/getLLM.mdx +9 -9
- package/.docs/raw/reference/agents/getMemory.mdx +9 -9
- package/.docs/raw/reference/agents/getModel.mdx +10 -10
- package/.docs/raw/reference/agents/getVoice.mdx +8 -8
- package/.docs/raw/reference/agents/listAgents.mdx +9 -9
- package/.docs/raw/reference/agents/listScorers.mdx +7 -7
- package/.docs/raw/reference/agents/listTools.mdx +7 -7
- package/.docs/raw/reference/agents/listWorkflows.mdx +7 -7
- package/.docs/raw/reference/agents/network.mdx +11 -10
- package/.docs/raw/reference/auth/auth0.mdx +4 -4
- package/.docs/raw/reference/auth/clerk.mdx +4 -4
- package/.docs/raw/reference/auth/firebase.mdx +6 -6
- package/.docs/raw/reference/auth/jwt.mdx +4 -4
- package/.docs/raw/reference/auth/supabase.mdx +4 -4
- package/.docs/raw/reference/auth/workos.mdx +4 -4
- package/.docs/raw/reference/cli/mastra.mdx +7 -7
- package/.docs/raw/reference/client-js/agents.mdx +6 -2
- package/.docs/raw/reference/client-js/mastra-client.mdx +7 -7
- package/.docs/raw/reference/client-js/memory.mdx +24 -16
- package/.docs/raw/reference/client-js/observability.mdx +11 -11
- package/.docs/raw/reference/client-js/workflows.mdx +6 -34
- package/.docs/raw/reference/core/getAgent.mdx +1 -1
- package/.docs/raw/reference/core/getAgentById.mdx +1 -1
- package/.docs/raw/reference/core/getDeployer.mdx +2 -2
- package/.docs/raw/reference/core/getLogger.mdx +2 -2
- package/.docs/raw/reference/core/getMCPServer.mdx +31 -15
- package/.docs/raw/reference/core/getMCPServerById.mdx +81 -0
- package/.docs/raw/reference/core/getScorer.mdx +3 -3
- package/.docs/raw/reference/core/getScorerById.mdx +79 -0
- package/.docs/raw/reference/core/getServer.mdx +2 -2
- package/.docs/raw/reference/core/getStorage.mdx +2 -2
- package/.docs/raw/reference/core/getTelemetry.mdx +2 -2
- package/.docs/raw/reference/core/getVector.mdx +2 -2
- package/.docs/raw/reference/core/getWorkflow.mdx +1 -1
- package/.docs/raw/reference/core/listAgents.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +2 -2
- package/.docs/raw/reference/core/listLogsByRunId.mdx +2 -2
- package/.docs/raw/reference/core/listMCPServers.mdx +65 -0
- package/.docs/raw/reference/core/listScorers.mdx +3 -3
- package/.docs/raw/reference/core/listVectors.mdx +36 -0
- package/.docs/raw/reference/core/listWorkflows.mdx +6 -6
- package/.docs/raw/reference/core/mastra-class.mdx +3 -2
- package/.docs/raw/reference/core/setLogger.mdx +2 -2
- package/.docs/raw/reference/core/setStorage.mdx +3 -2
- package/.docs/raw/reference/core/setTelemetry.mdx +2 -2
- package/.docs/raw/reference/deployer/cloudflare.mdx +2 -2
- package/.docs/raw/reference/deployer/deployer.mdx +0 -6
- package/.docs/raw/reference/deployer/netlify.mdx +2 -2
- package/.docs/raw/reference/deployer/vercel.mdx +3 -3
- package/.docs/raw/reference/evals/answer-relevancy.mdx +164 -126
- package/.docs/raw/reference/{scorers → evals}/answer-similarity.mdx +27 -27
- package/.docs/raw/reference/evals/bias.mdx +149 -115
- package/.docs/raw/reference/evals/completeness.mdx +148 -117
- package/.docs/raw/reference/evals/content-similarity.mdx +126 -113
- package/.docs/raw/reference/evals/context-precision.mdx +290 -133
- package/.docs/raw/reference/{scorers → evals}/context-relevance.mdx +6 -6
- package/.docs/raw/reference/{scorers → evals}/create-scorer.mdx +11 -11
- package/.docs/raw/reference/evals/faithfulness.mdx +163 -121
- package/.docs/raw/reference/evals/hallucination.mdx +159 -132
- package/.docs/raw/reference/evals/keyword-coverage.mdx +169 -125
- package/.docs/raw/reference/{scorers → evals}/mastra-scorer.mdx +5 -5
- package/.docs/raw/reference/{scorers → evals}/noise-sensitivity.mdx +9 -9
- package/.docs/raw/reference/evals/prompt-alignment.mdx +604 -182
- package/.docs/raw/reference/{scorers/run-experiment.mdx → evals/run-evals.mdx} +17 -18
- package/.docs/raw/reference/evals/textual-difference.mdx +149 -117
- package/.docs/raw/reference/evals/tone-consistency.mdx +149 -125
- package/.docs/raw/reference/{scorers → evals}/tool-call-accuracy.mdx +8 -6
- package/.docs/raw/reference/evals/toxicity.mdx +152 -96
- package/.docs/raw/reference/{observability/logging → logging}/pino-logger.mdx +2 -2
- package/.docs/raw/reference/memory/createThread.mdx +5 -5
- package/.docs/raw/reference/memory/deleteMessages.mdx +7 -7
- package/.docs/raw/reference/memory/getThreadById.mdx +4 -4
- package/.docs/raw/reference/memory/listThreadsByResourceId.mdx +110 -0
- package/.docs/raw/reference/memory/memory-class.mdx +13 -9
- package/.docs/raw/reference/memory/query.mdx +58 -57
- package/.docs/raw/reference/memory/recall.mdx +185 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +245 -0
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/arize.mdx +13 -13
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +11 -8
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/cloud-exporter.mdx +21 -19
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/console-exporter.mdx +49 -17
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/default-exporter.mdx +42 -41
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langfuse.mdx +10 -7
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +10 -7
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/exporters/otel.mdx +5 -5
- package/.docs/raw/reference/observability/tracing/instances.mdx +168 -0
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/interfaces.mdx +115 -89
- package/.docs/raw/reference/observability/{ai-tracing → tracing}/processors/sensitive-data-filter.mdx +3 -3
- package/.docs/raw/reference/observability/{ai-tracing/span.mdx → tracing/spans.mdx} +59 -41
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
- package/.docs/raw/reference/processors/language-detector.mdx +1 -1
- package/.docs/raw/reference/processors/moderation-processor.mdx +1 -1
- package/.docs/raw/reference/processors/pii-detector.mdx +1 -1
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +1 -1
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +1 -1
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +1 -1
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
- package/.docs/raw/reference/rag/chunk.mdx +1 -8
- package/.docs/raw/reference/rag/database-config.mdx +7 -7
- package/.docs/raw/reference/rag/metadata-filters.mdx +14 -11
- package/.docs/raw/reference/storage/libsql.mdx +2 -0
- package/.docs/raw/reference/storage/mssql.mdx +5 -0
- package/.docs/raw/reference/storage/postgresql.mdx +6 -0
- package/.docs/raw/reference/storage/upstash.mdx +1 -0
- package/.docs/raw/reference/streaming/agents/stream.mdx +12 -12
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +8 -8
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +3 -3
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +6 -6
- package/.docs/raw/reference/streaming/workflows/stream.mdx +10 -10
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +11 -11
- package/.docs/raw/reference/templates/overview.mdx +2 -2
- package/.docs/raw/reference/tools/create-tool.mdx +52 -35
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +15 -15
- package/.docs/raw/reference/tools/mcp-client.mdx +1 -1
- package/.docs/raw/reference/tools/mcp-server.mdx +119 -35
- package/.docs/raw/reference/tools/vector-query-tool.mdx +27 -26
- package/.docs/raw/reference/vectors/libsql.mdx +1 -0
- package/.docs/raw/reference/vectors/pg.mdx +3 -0
- package/.docs/raw/reference/vectors/upstash.mdx +1 -0
- package/.docs/raw/reference/voice/google-gemini-live.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addTools.mdx +3 -3
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +4 -4
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +14 -14
- package/.docs/raw/reference/workflows/run-methods/start.mdx +17 -17
- package/.docs/raw/reference/workflows/run.mdx +1 -8
- package/.docs/raw/reference/workflows/step.mdx +5 -5
- package/.docs/raw/reference/workflows/workflow-methods/branch.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/commit.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/create-run.mdx +7 -13
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +5 -0
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow.mdx +1 -1
- package/.docs/raw/server-db/custom-api-routes.mdx +2 -2
- package/.docs/raw/server-db/mastra-client.mdx +19 -18
- package/.docs/raw/server-db/middleware.mdx +7 -7
- package/.docs/raw/server-db/production-server.mdx +4 -4
- package/.docs/raw/server-db/{runtime-context.mdx → request-context.mdx} +46 -45
- package/.docs/raw/server-db/storage.mdx +29 -21
- package/.docs/raw/streaming/events.mdx +3 -3
- package/.docs/raw/streaming/overview.mdx +5 -5
- package/.docs/raw/streaming/tool-streaming.mdx +18 -17
- package/.docs/raw/streaming/workflow-streaming.mdx +1 -1
- package/.docs/raw/tools-mcp/advanced-usage.mdx +5 -4
- package/.docs/raw/tools-mcp/mcp-overview.mdx +32 -19
- package/.docs/raw/tools-mcp/overview.mdx +11 -11
- package/.docs/raw/voice/overview.mdx +63 -43
- package/.docs/raw/voice/speech-to-speech.mdx +5 -3
- package/.docs/raw/voice/speech-to-text.mdx +9 -8
- package/.docs/raw/voice/text-to-speech.mdx +12 -11
- package/.docs/raw/workflows/agents-and-tools.mdx +9 -5
- package/.docs/raw/workflows/control-flow.mdx +3 -3
- package/.docs/raw/workflows/error-handling.mdx +2 -21
- package/.docs/raw/workflows/human-in-the-loop.mdx +7 -4
- package/.docs/raw/workflows/inngest-workflow.mdx +2 -2
- package/.docs/raw/workflows/input-data-mapping.mdx +107 -0
- package/.docs/raw/workflows/overview.mdx +17 -16
- package/.docs/raw/workflows/snapshots.mdx +13 -11
- package/.docs/raw/workflows/suspend-and-resume.mdx +23 -15
- package/CHANGELOG.md +52 -57
- package/README.md +11 -2
- package/dist/{chunk-TUAHUTTB.js → chunk-5NJC7NRO.js} +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/prompts/migration.d.ts +6 -0
- package/dist/prompts/migration.d.ts.map +1 -0
- package/dist/stdio.js +402 -30
- package/dist/tools/migration.d.ts +40 -0
- package/dist/tools/migration.d.ts.map +1 -0
- package/package.json +8 -12
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +0 -302
- package/.docs/raw/observability/nextjs-tracing.mdx +0 -109
- package/.docs/raw/observability/otel-tracing.mdx +0 -189
- package/.docs/raw/reference/agents/getScorers.mdx +0 -69
- package/.docs/raw/reference/agents/getTools.mdx +0 -69
- package/.docs/raw/reference/agents/getWorkflows.mdx +0 -69
- package/.docs/raw/reference/client-js/workflows-legacy.mdx +0 -143
- package/.docs/raw/reference/core/getAgents.mdx +0 -35
- package/.docs/raw/reference/core/getLogs.mdx +0 -96
- package/.docs/raw/reference/core/getLogsByRunId.mdx +0 -87
- package/.docs/raw/reference/core/getMCPServers.mdx +0 -36
- package/.docs/raw/reference/core/getMemory.mdx +0 -36
- package/.docs/raw/reference/core/getScorerByName.mdx +0 -78
- package/.docs/raw/reference/core/getScorers.mdx +0 -43
- package/.docs/raw/reference/core/getVectors.mdx +0 -36
- package/.docs/raw/reference/core/getWorkflows.mdx +0 -45
- package/.docs/raw/reference/evals/context-position.mdx +0 -197
- package/.docs/raw/reference/evals/context-relevancy.mdx +0 -196
- package/.docs/raw/reference/evals/contextual-recall.mdx +0 -196
- package/.docs/raw/reference/evals/summarization.mdx +0 -212
- package/.docs/raw/reference/legacyWorkflows/after.mdx +0 -89
- package/.docs/raw/reference/legacyWorkflows/afterEvent.mdx +0 -79
- package/.docs/raw/reference/legacyWorkflows/commit.mdx +0 -33
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +0 -76
- package/.docs/raw/reference/legacyWorkflows/else.mdx +0 -68
- package/.docs/raw/reference/legacyWorkflows/events.mdx +0 -305
- package/.docs/raw/reference/legacyWorkflows/execute.mdx +0 -110
- package/.docs/raw/reference/legacyWorkflows/if.mdx +0 -108
- package/.docs/raw/reference/legacyWorkflows/resume.mdx +0 -158
- package/.docs/raw/reference/legacyWorkflows/resumeWithEvent.mdx +0 -133
- package/.docs/raw/reference/legacyWorkflows/snapshots.mdx +0 -207
- package/.docs/raw/reference/legacyWorkflows/start.mdx +0 -87
- package/.docs/raw/reference/legacyWorkflows/step-class.mdx +0 -100
- package/.docs/raw/reference/legacyWorkflows/step-condition.mdx +0 -137
- package/.docs/raw/reference/legacyWorkflows/step-function.mdx +0 -93
- package/.docs/raw/reference/legacyWorkflows/step-options.mdx +0 -69
- package/.docs/raw/reference/legacyWorkflows/step-retries.mdx +0 -196
- package/.docs/raw/reference/legacyWorkflows/suspend.mdx +0 -70
- package/.docs/raw/reference/legacyWorkflows/then.mdx +0 -72
- package/.docs/raw/reference/legacyWorkflows/until.mdx +0 -168
- package/.docs/raw/reference/legacyWorkflows/watch.mdx +0 -124
- package/.docs/raw/reference/legacyWorkflows/while.mdx +0 -168
- package/.docs/raw/reference/legacyWorkflows/workflow.mdx +0 -234
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +0 -79
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +0 -110
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +0 -185
- package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +0 -238
- package/.docs/raw/reference/observability/otel-tracing/otel-config.mdx +0 -117
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-ax.mdx +0 -81
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-phoenix.mdx +0 -121
- package/.docs/raw/reference/observability/otel-tracing/providers/braintrust.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/dash0.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +0 -20
- package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +0 -73
- package/.docs/raw/reference/observability/otel-tracing/providers/laminar.mdx +0 -41
- package/.docs/raw/reference/observability/otel-tracing/providers/langfuse.mdx +0 -84
- package/.docs/raw/reference/observability/otel-tracing/providers/langsmith.mdx +0 -48
- package/.docs/raw/reference/observability/otel-tracing/providers/langwatch.mdx +0 -43
- package/.docs/raw/reference/observability/otel-tracing/providers/new-relic.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/signoz.mdx +0 -40
- package/.docs/raw/reference/observability/otel-tracing/providers/traceloop.mdx +0 -40
- package/.docs/raw/reference/scorers/answer-relevancy.mdx +0 -227
- package/.docs/raw/reference/scorers/bias.mdx +0 -228
- package/.docs/raw/reference/scorers/completeness.mdx +0 -214
- package/.docs/raw/reference/scorers/content-similarity.mdx +0 -197
- package/.docs/raw/reference/scorers/context-precision.mdx +0 -352
- package/.docs/raw/reference/scorers/faithfulness.mdx +0 -241
- package/.docs/raw/reference/scorers/hallucination.mdx +0 -252
- package/.docs/raw/reference/scorers/keyword-coverage.mdx +0 -229
- package/.docs/raw/reference/scorers/prompt-alignment.mdx +0 -668
- package/.docs/raw/reference/scorers/textual-difference.mdx +0 -203
- package/.docs/raw/reference/scorers/tone-consistency.mdx +0 -211
- package/.docs/raw/reference/scorers/toxicity.mdx +0 -228
- package/.docs/raw/reference/workflows/run-methods/watch.mdx +0 -73
- package/.docs/raw/scorers/evals-old-api/custom-eval.mdx +0 -24
- package/.docs/raw/scorers/evals-old-api/overview.mdx +0 -106
- package/.docs/raw/scorers/evals-old-api/running-in-ci.mdx +0 -85
- package/.docs/raw/scorers/evals-old-api/textual-evals.mdx +0 -58
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +0 -50
- package/.docs/raw/workflows-legacy/control-flow.mdx +0 -774
- package/.docs/raw/workflows-legacy/dynamic-workflows.mdx +0 -239
- package/.docs/raw/workflows-legacy/error-handling.mdx +0 -187
- package/.docs/raw/workflows-legacy/nested-workflows.mdx +0 -360
- package/.docs/raw/workflows-legacy/overview.mdx +0 -182
- package/.docs/raw/workflows-legacy/runtime-variables.mdx +0 -156
- package/.docs/raw/workflows-legacy/steps.mdx +0 -115
- package/.docs/raw/workflows-legacy/suspend-and-resume.mdx +0 -406
- package/.docs/raw/workflows-legacy/variables.mdx +0 -318
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Reference: Context Precision Scorer | Scorers | Mastra Docs"
|
|
3
|
-
description: Documentation for the Context Precision Scorer in Mastra. Evaluates the relevance and precision of retrieved context for generating expected outputs using Mean Average Precision.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import PropertiesTable from "@site/src/components/PropertiesTable";
|
|
7
|
-
|
|
8
|
-
# Context Precision Scorer
|
|
9
|
-
|
|
10
|
-
The `createContextPrecisionScorer()` function creates a scorer that evaluates how relevant and well-positioned retrieved context pieces are for generating expected outputs. It uses **Mean Average Precision (MAP)** to reward systems that place relevant context earlier in the sequence.
|
|
11
|
-
|
|
12
|
-
It is especially useful for these use cases:
|
|
13
|
-
|
|
14
|
-
**RAG System Evaluation**
|
|
15
|
-
|
|
16
|
-
Ideal for evaluating retrieved context in RAG pipelines where:
|
|
17
|
-
|
|
18
|
-
- Context ordering matters for model performance
|
|
19
|
-
- You need to measure retrieval quality beyond simple relevance
|
|
20
|
-
- Early relevant context is more valuable than later relevant context
|
|
21
|
-
|
|
22
|
-
**Context Window Optimization**
|
|
23
|
-
|
|
24
|
-
Use when optimizing context selection for:
|
|
25
|
-
|
|
26
|
-
- Limited context windows
|
|
27
|
-
- Token budget constraints
|
|
28
|
-
- Multi-step reasoning tasks
|
|
29
|
-
|
|
30
|
-
## Parameters
|
|
31
|
-
|
|
32
|
-
<PropertiesTable
|
|
33
|
-
content={[
|
|
34
|
-
{
|
|
35
|
-
name: "model",
|
|
36
|
-
type: "MastraModelConfig",
|
|
37
|
-
description: "The language model to use for evaluating context relevance",
|
|
38
|
-
required: true,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "options",
|
|
42
|
-
type: "ContextPrecisionMetricOptions",
|
|
43
|
-
description: "Configuration options for the scorer",
|
|
44
|
-
required: true,
|
|
45
|
-
children: [
|
|
46
|
-
{
|
|
47
|
-
name: "context",
|
|
48
|
-
type: "string[]",
|
|
49
|
-
description: "Array of context pieces to evaluate for relevance",
|
|
50
|
-
required: false,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: "contextExtractor",
|
|
54
|
-
type: "(input, output) => string[]",
|
|
55
|
-
description:
|
|
56
|
-
"Function to dynamically extract context from the run input and output",
|
|
57
|
-
required: false,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "scale",
|
|
61
|
-
type: "number",
|
|
62
|
-
description: "Scale factor to multiply the final score (default: 1)",
|
|
63
|
-
required: false,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
]}
|
|
68
|
-
/>
|
|
69
|
-
|
|
70
|
-
**Note**: Either `context` or `contextExtractor` must be provided. If both are provided, `contextExtractor` takes precedence.
|
|
71
|
-
|
|
72
|
-
## .run() Returns
|
|
73
|
-
|
|
74
|
-
<PropertiesTable
|
|
75
|
-
content={[
|
|
76
|
-
{
|
|
77
|
-
name: "score",
|
|
78
|
-
type: "number",
|
|
79
|
-
description:
|
|
80
|
-
"Mean Average Precision score between 0 and scale (default 0-1)",
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: "reason",
|
|
84
|
-
type: "string",
|
|
85
|
-
description:
|
|
86
|
-
"Human-readable explanation of the context precision evaluation",
|
|
87
|
-
},
|
|
88
|
-
]}
|
|
89
|
-
/>
|
|
90
|
-
|
|
91
|
-
## Scoring Details
|
|
92
|
-
|
|
93
|
-
### Mean Average Precision (MAP)
|
|
94
|
-
|
|
95
|
-
Context Precision uses **Mean Average Precision** to evaluate both relevance and positioning:
|
|
96
|
-
|
|
97
|
-
1. **Context Evaluation**: Each context piece is classified as relevant or irrelevant for generating the expected output
|
|
98
|
-
2. **Precision Calculation**: For each relevant context at position `i`, precision = `relevant_items_so_far / (i + 1)`
|
|
99
|
-
3. **Average Precision**: Sum all precision values and divide by total relevant items
|
|
100
|
-
4. **Final Score**: Multiply by scale factor and round to 2 decimals
|
|
101
|
-
|
|
102
|
-
### Scoring Formula
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
MAP = (Σ Precision@k) / R
|
|
106
|
-
|
|
107
|
-
Where:
|
|
108
|
-
- Precision@k = (relevant items in positions 1...k) / k
|
|
109
|
-
- R = total number of relevant items
|
|
110
|
-
- Only calculated at positions where relevant items appear
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Score Interpretation
|
|
114
|
-
|
|
115
|
-
- **0.9-1.0**: Excellent precision - all relevant context early in sequence
|
|
116
|
-
- **0.7-0.8**: Good precision - most relevant context well-positioned
|
|
117
|
-
- **0.4-0.6**: Moderate precision - relevant context mixed with irrelevant
|
|
118
|
-
- **0.1-0.3**: Poor precision - little relevant context or poorly positioned
|
|
119
|
-
- **0.0**: No relevant context found
|
|
120
|
-
|
|
121
|
-
### Reason analysis
|
|
122
|
-
|
|
123
|
-
The reason field explains:
|
|
124
|
-
|
|
125
|
-
- Which context pieces were deemed relevant/irrelevant
|
|
126
|
-
- How positioning affected the MAP calculation
|
|
127
|
-
- Specific relevance criteria used in evaluation
|
|
128
|
-
|
|
129
|
-
### Optimization insights
|
|
130
|
-
|
|
131
|
-
Use results to:
|
|
132
|
-
|
|
133
|
-
- **Improve retrieval**: Filter out irrelevant context before ranking
|
|
134
|
-
- **Optimize ranking**: Ensure relevant context appears early
|
|
135
|
-
- **Tune chunk size**: Balance context detail vs. relevance precision
|
|
136
|
-
- **Evaluate embeddings**: Test different embedding models for better retrieval
|
|
137
|
-
|
|
138
|
-
### Example Calculation
|
|
139
|
-
|
|
140
|
-
Given context: `[relevant, irrelevant, relevant, irrelevant]`
|
|
141
|
-
|
|
142
|
-
- Position 0: Relevant → Precision = 1/1 = 1.0
|
|
143
|
-
- Position 1: Skip (irrelevant)
|
|
144
|
-
- Position 2: Relevant → Precision = 2/3 = 0.67
|
|
145
|
-
- Position 3: Skip (irrelevant)
|
|
146
|
-
|
|
147
|
-
MAP = (1.0 + 0.67) / 2 = 0.835 ≈ **0.83**
|
|
148
|
-
|
|
149
|
-
## Scorer configuration
|
|
150
|
-
|
|
151
|
-
### Dynamic context extraction
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
const scorer = createContextPrecisionScorer({
|
|
155
|
-
model: "openai/gpt-4o-mini",
|
|
156
|
-
options: {
|
|
157
|
-
contextExtractor: (input, output) => {
|
|
158
|
-
// Extract context dynamically based on the query
|
|
159
|
-
const query = input?.inputMessages?.[0]?.content || "";
|
|
160
|
-
|
|
161
|
-
// Example: Retrieve from a vector database
|
|
162
|
-
const searchResults = vectorDB.search(query, { limit: 10 });
|
|
163
|
-
return searchResults.map((result) => result.content);
|
|
164
|
-
},
|
|
165
|
-
scale: 1,
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### Large context evaluation
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
const scorer = createContextPrecisionScorer({
|
|
174
|
-
model: "openai/gpt-4o-mini",
|
|
175
|
-
options: {
|
|
176
|
-
context: [
|
|
177
|
-
// Simulate retrieved documents from vector database
|
|
178
|
-
"Document 1: Highly relevant content...",
|
|
179
|
-
"Document 2: Somewhat related content...",
|
|
180
|
-
"Document 3: Tangentially related...",
|
|
181
|
-
"Document 4: Not relevant...",
|
|
182
|
-
"Document 5: Highly relevant content...",
|
|
183
|
-
// ... up to dozens of context pieces
|
|
184
|
-
],
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
## Examples
|
|
190
|
-
|
|
191
|
-
### High precision example
|
|
192
|
-
|
|
193
|
-
This example shows perfect context precision where all relevant context appears early:
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
import { createContextPrecisionScorer } from "@mastra/evals";
|
|
197
|
-
|
|
198
|
-
const scorer = createContextPrecisionScorer({
|
|
199
|
-
model: "openai/gpt-4o-mini",
|
|
200
|
-
options: {
|
|
201
|
-
context: [
|
|
202
|
-
"Photosynthesis is the process by which plants convert sunlight, carbon dioxide, and water into glucose and oxygen.",
|
|
203
|
-
"The process occurs in the chloroplasts of plant cells, specifically in the thylakoids.",
|
|
204
|
-
"Light-dependent reactions happen in the thylakoid membranes, while the Calvin cycle occurs in the stroma.",
|
|
205
|
-
],
|
|
206
|
-
scale: 1,
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const result = await scorer.run({
|
|
211
|
-
input: {
|
|
212
|
-
inputMessages: [
|
|
213
|
-
{
|
|
214
|
-
id: "1",
|
|
215
|
-
role: "user",
|
|
216
|
-
content: "How does photosynthesis work in plants?",
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
},
|
|
220
|
-
output: [
|
|
221
|
-
{
|
|
222
|
-
id: "2",
|
|
223
|
-
role: "assistant",
|
|
224
|
-
content:
|
|
225
|
-
"Photosynthesis is the process where plants convert sunlight, CO2, and water into glucose and oxygen using chloroplasts.",
|
|
226
|
-
},
|
|
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
|
-
{
|
|
271
|
-
id: "2",
|
|
272
|
-
role: "assistant",
|
|
273
|
-
content:
|
|
274
|
-
"Exercise provides cardiovascular benefits, improves mood through endorphin release, and helps maintain healthy body composition.",
|
|
275
|
-
},
|
|
276
|
-
],
|
|
277
|
-
});
|
|
278
|
-
|
|
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
|
-
// }
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### Low precision example
|
|
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
|
-
});
|
|
327
|
-
|
|
328
|
-
console.log(result);
|
|
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
|
-
```
|
|
335
|
-
|
|
336
|
-
## Comparison with Context Relevance
|
|
337
|
-
|
|
338
|
-
Choose the right scorer for your needs:
|
|
339
|
-
|
|
340
|
-
| Use Case | Context Relevance | Context Precision |
|
|
341
|
-
| ------------------------ | -------------------- | ------------------------- |
|
|
342
|
-
| **RAG evaluation** | When usage matters | When ranking matters |
|
|
343
|
-
| **Context quality** | Nuanced levels | Binary relevance |
|
|
344
|
-
| **Missing detection** | ✓ Identifies gaps | ✗ Not evaluated |
|
|
345
|
-
| **Usage tracking** | ✓ Tracks utilization | ✗ Not considered |
|
|
346
|
-
| **Position sensitivity** | ✗ Position agnostic | ✓ Rewards early placement |
|
|
347
|
-
|
|
348
|
-
## Related
|
|
349
|
-
|
|
350
|
-
- [Answer Relevancy Scorer](/reference/scorers/answer-relevancy) - Evaluates if answers address the question
|
|
351
|
-
- [Faithfulness Scorer](/reference/scorers/faithfulness) - Measures answer groundedness in context
|
|
352
|
-
- [Custom Scorers](/docs/scorers/custom-scorers) - Creating your own evaluation metrics
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Reference: Faithfulness Scorer | Scorers | Mastra Docs"
|
|
3
|
-
description: Documentation for the Faithfulness Scorer in Mastra, which evaluates the factual accuracy of LLM outputs compared to the provided context.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Faithfulness Scorer
|
|
7
|
-
|
|
8
|
-
The `createFaithfulnessScorer()` function evaluates how factually accurate an LLM's output is compared to the provided context. It extracts claims from the output and verifies them against the context, making it essential to measure RAG pipeline responses' reliability.
|
|
9
|
-
|
|
10
|
-
## Parameters
|
|
11
|
-
|
|
12
|
-
The `createFaithfulnessScorer()` function accepts a single options object with the following properties:
|
|
13
|
-
|
|
14
|
-
<PropertiesTable
|
|
15
|
-
content={[
|
|
16
|
-
{
|
|
17
|
-
name: "model",
|
|
18
|
-
type: "LanguageModel",
|
|
19
|
-
required: true,
|
|
20
|
-
description: "Configuration for the model used to evaluate faithfulness.",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: "context",
|
|
24
|
-
type: "string[]",
|
|
25
|
-
required: true,
|
|
26
|
-
description:
|
|
27
|
-
"Array of context chunks against which the output's claims will be verified.",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: "scale",
|
|
31
|
-
type: "number",
|
|
32
|
-
required: false,
|
|
33
|
-
defaultValue: "1",
|
|
34
|
-
description:
|
|
35
|
-
"The maximum score value. The final score will be normalized to this scale.",
|
|
36
|
-
},
|
|
37
|
-
]}
|
|
38
|
-
/>
|
|
39
|
-
|
|
40
|
-
This function returns an instance of the MastraScorer class. The `.run()` method accepts the same input as other scorers (see the [MastraScorer reference](./mastra-scorer)), but the return value includes LLM-specific fields as documented below.
|
|
41
|
-
|
|
42
|
-
## .run() Returns
|
|
43
|
-
|
|
44
|
-
<PropertiesTable
|
|
45
|
-
content={[
|
|
46
|
-
{
|
|
47
|
-
name: "runId",
|
|
48
|
-
type: "string",
|
|
49
|
-
description: "The id of the run (optional).",
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "preprocessStepResult",
|
|
53
|
-
type: "string[]",
|
|
54
|
-
description: "Array of extracted claims from the output.",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "preprocessPrompt",
|
|
58
|
-
type: "string",
|
|
59
|
-
description:
|
|
60
|
-
"The prompt sent to the LLM for the preprocess step (optional).",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "analyzeStepResult",
|
|
64
|
-
type: "object",
|
|
65
|
-
description:
|
|
66
|
-
"Object with verdicts: { verdicts: Array<{ verdict: 'yes' | 'no' | 'unsure', reason: string }> }",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "analyzePrompt",
|
|
70
|
-
type: "string",
|
|
71
|
-
description:
|
|
72
|
-
"The prompt sent to the LLM for the analyze step (optional).",
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: "score",
|
|
76
|
-
type: "number",
|
|
77
|
-
description:
|
|
78
|
-
"A score between 0 and the configured scale, representing the proportion of claims that are supported by the context.",
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: "reason",
|
|
82
|
-
type: "string",
|
|
83
|
-
description:
|
|
84
|
-
"A detailed explanation of the score, including which claims were supported, contradicted, or marked as unsure.",
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "generateReasonPrompt",
|
|
88
|
-
type: "string",
|
|
89
|
-
description:
|
|
90
|
-
"The prompt sent to the LLM for the generateReason step (optional).",
|
|
91
|
-
},
|
|
92
|
-
]}
|
|
93
|
-
/>
|
|
94
|
-
|
|
95
|
-
## Scoring Details
|
|
96
|
-
|
|
97
|
-
The scorer evaluates faithfulness through claim verification against provided context.
|
|
98
|
-
|
|
99
|
-
### Scoring Process
|
|
100
|
-
|
|
101
|
-
1. Analyzes claims and context:
|
|
102
|
-
- Extracts all claims (factual and speculative)
|
|
103
|
-
- Verifies each claim against context
|
|
104
|
-
- Assigns one of three verdicts:
|
|
105
|
-
- "yes" - claim supported by context
|
|
106
|
-
- "no" - claim contradicts context
|
|
107
|
-
- "unsure" - claim unverifiable
|
|
108
|
-
2. Calculates faithfulness score:
|
|
109
|
-
- Counts supported claims
|
|
110
|
-
- Divides by total claims
|
|
111
|
-
- Scales to configured range
|
|
112
|
-
|
|
113
|
-
Final score: `(supported_claims / total_claims) * scale`
|
|
114
|
-
|
|
115
|
-
### Score interpretation
|
|
116
|
-
|
|
117
|
-
A faithfulness score between 0 and 1:
|
|
118
|
-
|
|
119
|
-
- **1.0**: All claims are accurate and directly supported by the context.
|
|
120
|
-
- **0.7–0.9**: Most claims are correct, with minor additions or omissions.
|
|
121
|
-
- **0.4–0.6**: Some claims are supported, but others are unverifiable.
|
|
122
|
-
- **0.1–0.3**: Most of the content is inaccurate or unsupported.
|
|
123
|
-
- **0.0**: All claims are false or contradict the context.
|
|
124
|
-
|
|
125
|
-
## Examples
|
|
126
|
-
|
|
127
|
-
### High faithfulness example
|
|
128
|
-
|
|
129
|
-
In this example, the response closely aligns with the context. Each statement in the output is verifiable and supported by the provided context entries, resulting in a high score.
|
|
130
|
-
|
|
131
|
-
```typescript title="src/example-high-faithfulness.ts" showLineNumbers copy
|
|
132
|
-
import { createFaithfulnessScorer } from "@mastra/evals/scorers/llm";
|
|
133
|
-
|
|
134
|
-
const scorer = createFaithfulnessScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
135
|
-
context: [
|
|
136
|
-
"The Tesla Model 3 was launched in 2017.",
|
|
137
|
-
"It has a range of up to 358 miles.",
|
|
138
|
-
"The base model accelerates 0-60 mph in 5.8 seconds."
|
|
139
|
-
]
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const query = "Tell me about the Tesla Model 3.";
|
|
143
|
-
const response = "The Tesla Model 3 was introduced in 2017. It can travel up to 358 miles on a single charge and the base version goes from 0 to 60 mph in 5.8 seconds.";
|
|
144
|
-
|
|
145
|
-
const result = await scorer.run({
|
|
146
|
-
input: [{ role: 'user', content: query }],
|
|
147
|
-
output: { text: response },
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
console.log(result);
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
#### High faithfulness output
|
|
154
|
-
|
|
155
|
-
The output receives a score of 1 because all the information it provides can be directly traced to the context. There are no missing or contradictory facts.
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
{
|
|
159
|
-
score: 1,
|
|
160
|
-
reason: 'The score is 1 because all claims made in the output are supported by the provided context.'
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Mixed faithfulness example
|
|
165
|
-
|
|
166
|
-
In this example, there are a mix of supported and unsupported claims. Some parts of the response are backed by the context, while others introduce new information not found in the source material.
|
|
167
|
-
|
|
168
|
-
```typescript title="src/example-mixed-faithfulness.ts" showLineNumbers copy
|
|
169
|
-
import { createFaithfulnessScorer } from "@mastra/evals/scorers/llm";
|
|
170
|
-
|
|
171
|
-
const scorer = createFaithfulnessScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
172
|
-
context: [
|
|
173
|
-
"Python was created by Guido van Rossum.",
|
|
174
|
-
"The first version was released in 1991.",
|
|
175
|
-
"Python emphasizes code readability."
|
|
176
|
-
]
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const query = "What can you tell me about Python?";
|
|
180
|
-
const response = "Python was created by Guido van Rossum and released in 1991. It is the most popular programming language today and is used by millions of developers worldwide.";
|
|
181
|
-
|
|
182
|
-
const result = await scorer.run({
|
|
183
|
-
input: [{ role: 'user', content: query }],
|
|
184
|
-
output: { text: response },
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
console.log(result);
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
#### Mixed faithfulness output
|
|
191
|
-
|
|
192
|
-
The score is lower because only a portion of the response is verifiable. While some claims match the context, others are unconfirmed or out of scope, reducing the overall faithfulness.
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
{
|
|
196
|
-
score: 0.5,
|
|
197
|
-
reason: "The score is 0.5 because while two claims are supported by the context (Python was created by Guido van Rossum and Python was released in 1991), the other two claims regarding Python's popularity and usage cannot be verified as they are not mentioned in the context."
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Low faithfulness example
|
|
202
|
-
|
|
203
|
-
In this example, the response directly contradicts the context. None of the claims are supported, and several conflict with the facts provided.
|
|
204
|
-
|
|
205
|
-
```typescript title="src/example-low-faithfulness.ts" showLineNumbers copy
|
|
206
|
-
import { createFaithfulnessScorer } from "@mastra/evals/scorers/llm";
|
|
207
|
-
|
|
208
|
-
const scorer = createFaithfulnessScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
209
|
-
context: [
|
|
210
|
-
"Mars is the fourth planet from the Sun.",
|
|
211
|
-
"It has a thin atmosphere of mostly carbon dioxide.",
|
|
212
|
-
"Two small moons orbit Mars: Phobos and Deimos."
|
|
213
|
-
]
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
const query = "What do we know about Mars?";
|
|
217
|
-
const response = "Mars is the third planet from the Sun. It has a thick atmosphere rich in oxygen and nitrogen, and is orbited by three large moons.";
|
|
218
|
-
|
|
219
|
-
const result = await scorer.run({
|
|
220
|
-
input: [{ role: 'user', content: query }],
|
|
221
|
-
output: { text: response },
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
console.log(result);
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
#### Low faithfulness output
|
|
228
|
-
|
|
229
|
-
Each claim is inaccurate or conflicts with the context, resulting in a score of 0.
|
|
230
|
-
|
|
231
|
-
```typescript
|
|
232
|
-
{
|
|
233
|
-
score: 0,
|
|
234
|
-
reason: "The score is 0 because all claims made in the output contradict the provided context. The output states that Mars is the third planet from the Sun, while the context clearly states it is the fourth. Additionally, it claims that Mars has a thick atmosphere rich in oxygen and nitrogen, contradicting the context's description of a thin atmosphere mostly composed of carbon dioxide. Finally, the output mentions that Mars is orbited by three large moons, while the context specifies that it has only two small moons, Phobos and Deimos. Therefore, there are no supported claims, leading to a score of 0."
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
## Related
|
|
239
|
-
|
|
240
|
-
- [Answer Relevancy Scorer](./answer-relevancy)
|
|
241
|
-
- [Hallucination Scorer](./hallucination)
|