@mastra/mcp-docs-server 0.13.39 → 1.0.0-beta.1
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 +220 -220
- 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 +210 -210
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +69 -69
- 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 +56 -56
- 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 +216 -216
- 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 +66 -66
- 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 +203 -203
- 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 +29 -29
- package/.docs/organized/changelogs/mastra.md +93 -93
- 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 +24 -16
- package/.docs/raw/agents/guardrails.mdx +33 -12
- package/.docs/raw/agents/networks.mdx +8 -4
- package/.docs/raw/agents/overview.mdx +23 -17
- package/.docs/raw/agents/using-tools.mdx +11 -8
- package/.docs/raw/auth/auth0.mdx +9 -9
- package/.docs/raw/auth/clerk.mdx +7 -7
- package/.docs/raw/auth/firebase.mdx +9 -9
- package/.docs/raw/auth/index.mdx +6 -6
- package/.docs/raw/auth/jwt.mdx +7 -7
- package/.docs/raw/auth/supabase.mdx +8 -8
- package/.docs/raw/auth/workos.mdx +9 -9
- package/.docs/raw/community/contributing-templates.mdx +3 -3
- package/.docs/raw/community/discord.mdx +1 -1
- package/.docs/raw/course/01-first-agent/03-verifying-installation.md +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/02-installing-mcp.md +1 -1
- package/.docs/raw/course/02-agent-tools-mcp/31-enhancing-memory-configuration.md +2 -0
- package/.docs/raw/course/03-agent-memory/03-installing-memory.md +1 -1
- 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 +6 -6
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +8 -6
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +5 -5
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +5 -5
- 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 +5 -5
- package/.docs/raw/deployment/serverless-platforms/index.mdx +10 -7
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +5 -5
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +5 -5
- 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 +9 -9
- package/.docs/raw/evals/running-in-ci.mdx +113 -0
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +26 -25
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +1 -1
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +17 -17
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +4 -1
- package/.docs/raw/frameworks/servers/express.mdx +11 -10
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +18 -18
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +7 -7
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +16 -16
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +7 -7
- package/.docs/raw/getting-started/installation.mdx +26 -25
- 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 +6 -6
- 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 +380 -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/guides/quickstarts/nextjs.mdx +275 -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 +10 -6
- package/.docs/raw/memory/semantic-recall.mdx +13 -8
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +12 -7
- package/.docs/raw/memory/storage/memory-with-pg.mdx +11 -6
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +11 -6
- 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 +11 -19
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/braintrust.mdx +8 -17
- 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 +8 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/langsmith.mdx +8 -17
- package/.docs/raw/observability/{ai-tracing → tracing}/exporters/otel.mdx +12 -21
- 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 +35 -30
- 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/create-mastra.mdx +10 -10
- 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 +69 -60
- 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 +7 -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 +9 -3
- package/.docs/raw/reference/processors/language-detector.mdx +9 -3
- package/.docs/raw/reference/processors/moderation-processor.mdx +9 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +9 -3
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +9 -3
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +9 -3
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +9 -3
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +9 -3
- 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/cloudflare-d1.mdx +1 -1
- package/.docs/raw/reference/storage/cloudflare.mdx +1 -1
- package/.docs/raw/reference/storage/dynamodb.mdx +3 -3
- package/.docs/raw/reference/storage/lance.mdx +1 -1
- package/.docs/raw/reference/storage/libsql.mdx +3 -1
- package/.docs/raw/reference/storage/mongodb.mdx +1 -1
- package/.docs/raw/reference/storage/mssql.mdx +6 -1
- package/.docs/raw/reference/storage/postgresql.mdx +7 -1
- package/.docs/raw/reference/storage/upstash.mdx +2 -1
- 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 +3 -3
- 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/couchbase.mdx +8 -2
- package/.docs/raw/reference/vectors/libsql.mdx +2 -1
- package/.docs/raw/reference/vectors/mongodb.mdx +7 -1
- package/.docs/raw/reference/vectors/pg.mdx +3 -0
- package/.docs/raw/reference/vectors/s3vectors.mdx +1 -1
- 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 +23 -22
- 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 +33 -20
- 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 +10 -9
- package/.docs/raw/voice/text-to-speech.mdx +13 -12
- 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 +3 -3
- 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 +55 -53
- 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,252 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Reference: Hallucination Scorer | Scorers | Mastra Docs"
|
|
3
|
-
description: Documentation for the Hallucination Scorer in Mastra, which evaluates the factual correctness of LLM outputs by identifying contradictions with provided context.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Hallucination Scorer
|
|
7
|
-
|
|
8
|
-
The `createHallucinationScorer()` function evaluates whether an LLM generates factually correct information by comparing its output against the provided context. This scorer measures hallucination by identifying direct contradictions between the context and the output.
|
|
9
|
-
|
|
10
|
-
## Parameters
|
|
11
|
-
|
|
12
|
-
The `createHallucinationScorer()` 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:
|
|
21
|
-
"Configuration for the model used to evaluate hallucination.",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "scale",
|
|
25
|
-
type: "number",
|
|
26
|
-
required: false,
|
|
27
|
-
defaultValue: "1",
|
|
28
|
-
description: "Maximum score value.",
|
|
29
|
-
},
|
|
30
|
-
]}
|
|
31
|
-
/>
|
|
32
|
-
|
|
33
|
-
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.
|
|
34
|
-
|
|
35
|
-
## .run() Returns
|
|
36
|
-
|
|
37
|
-
<PropertiesTable
|
|
38
|
-
content={[
|
|
39
|
-
{
|
|
40
|
-
name: "runId",
|
|
41
|
-
type: "string",
|
|
42
|
-
description: "The id of the run (optional).",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "preprocessStepResult",
|
|
46
|
-
type: "object",
|
|
47
|
-
description: "Object with extracted claims: { claims: string[] }",
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "preprocessPrompt",
|
|
51
|
-
type: "string",
|
|
52
|
-
description:
|
|
53
|
-
"The prompt sent to the LLM for the preprocess step (optional).",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: "analyzeStepResult",
|
|
57
|
-
type: "object",
|
|
58
|
-
description:
|
|
59
|
-
"Object with verdicts: { verdicts: Array<{ statement: string, verdict: 'yes' | 'no', reason: string }> }",
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: "analyzePrompt",
|
|
63
|
-
type: "string",
|
|
64
|
-
description:
|
|
65
|
-
"The prompt sent to the LLM for the analyze step (optional).",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "score",
|
|
69
|
-
type: "number",
|
|
70
|
-
description: "Hallucination score (0 to scale, default 0-1).",
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "reason",
|
|
74
|
-
type: "string",
|
|
75
|
-
description:
|
|
76
|
-
"Detailed explanation of the score and identified contradictions.",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: "generateReasonPrompt",
|
|
80
|
-
type: "string",
|
|
81
|
-
description:
|
|
82
|
-
"The prompt sent to the LLM for the generateReason step (optional).",
|
|
83
|
-
},
|
|
84
|
-
]}
|
|
85
|
-
/>
|
|
86
|
-
|
|
87
|
-
## Scoring Details
|
|
88
|
-
|
|
89
|
-
The scorer evaluates hallucination through contradiction detection and unsupported claim analysis.
|
|
90
|
-
|
|
91
|
-
### Scoring Process
|
|
92
|
-
|
|
93
|
-
1. Analyzes factual content:
|
|
94
|
-
- Extracts statements from context
|
|
95
|
-
- Identifies numerical values and dates
|
|
96
|
-
- Maps statement relationships
|
|
97
|
-
2. Analyzes output for hallucinations:
|
|
98
|
-
- Compares against context statements
|
|
99
|
-
- Marks direct conflicts as hallucinations
|
|
100
|
-
- Identifies unsupported claims as hallucinations
|
|
101
|
-
- Evaluates numerical accuracy
|
|
102
|
-
- Considers approximation context
|
|
103
|
-
3. Calculates hallucination score:
|
|
104
|
-
- Counts hallucinated statements (contradictions and unsupported claims)
|
|
105
|
-
- Divides by total statements
|
|
106
|
-
- Scales to configured range
|
|
107
|
-
|
|
108
|
-
Final score: `(hallucinated_statements / total_statements) * scale`
|
|
109
|
-
|
|
110
|
-
### Important Considerations
|
|
111
|
-
|
|
112
|
-
- Claims not present in context are treated as hallucinations
|
|
113
|
-
- Subjective claims are hallucinations unless explicitly supported
|
|
114
|
-
- Speculative language ("might", "possibly") about facts IN context is allowed
|
|
115
|
-
- Speculative language about facts NOT in context is treated as hallucination
|
|
116
|
-
- Empty outputs result in zero hallucinations
|
|
117
|
-
- Numerical evaluation considers:
|
|
118
|
-
- Scale-appropriate precision
|
|
119
|
-
- Contextual approximations
|
|
120
|
-
- Explicit precision indicators
|
|
121
|
-
|
|
122
|
-
### Score interpretation
|
|
123
|
-
|
|
124
|
-
A hallucination score between 0 and 1:
|
|
125
|
-
|
|
126
|
-
- **0.0**: No hallucination — all claims match the context.
|
|
127
|
-
- **0.3–0.4**: Low hallucination — a few contradictions.
|
|
128
|
-
- **0.5–0.6**: Mixed hallucination — several contradictions.
|
|
129
|
-
- **0.7–0.8**: High hallucination — many contradictions.
|
|
130
|
-
- **0.9–1.0**: Complete hallucination — most or all claims contradict the context.
|
|
131
|
-
|
|
132
|
-
**Note:** The score represents the degree of hallucination - lower scores indicate better factual alignment with the provided context
|
|
133
|
-
|
|
134
|
-
## Examples
|
|
135
|
-
|
|
136
|
-
### No hallucination example
|
|
137
|
-
|
|
138
|
-
In this example, the response is fully aligned with the provided context. All claims are factually correct and directly supported by the source material, resulting in a low hallucination score.
|
|
139
|
-
|
|
140
|
-
```typescript title="src/example-no-hallucination.ts" showLineNumbers copy
|
|
141
|
-
import { createHallucinationScorer } from "@mastra/evals/scorers/llm";
|
|
142
|
-
|
|
143
|
-
const scorer = createHallucinationScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
144
|
-
context: [
|
|
145
|
-
"The iPhone was first released in 2007.",
|
|
146
|
-
"Steve Jobs unveiled it at Macworld.",
|
|
147
|
-
"The original model had a 3.5-inch screen."
|
|
148
|
-
]
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const query = "When was the first iPhone released?";
|
|
152
|
-
const response = "The iPhone was first released in 2007, when Steve Jobs unveiled it at Macworld. The original iPhone featured a 3.5-inch screen.";
|
|
153
|
-
|
|
154
|
-
const result = await scorer.run({
|
|
155
|
-
input: [{ role: 'user', content: query }],
|
|
156
|
-
output: { text: response },
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
console.log(result);
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
#### No hallucination output
|
|
163
|
-
|
|
164
|
-
The response receives a score of 0 because there are no contradictions. Every statement is consistent with the context, and no new or fabricated information has been introduced.
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
{
|
|
168
|
-
score: 0,
|
|
169
|
-
reason: 'The score is 0 because none of the statements from the context were contradicted by the output.'
|
|
170
|
-
}
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### Mixed hallucination example
|
|
174
|
-
|
|
175
|
-
In this example, the response includes both accurate and inaccurate claims. Some details align with the context, while others directly contradict it—such as inflated numbers or incorrect locations. These contradictions increase the hallucination score.
|
|
176
|
-
|
|
177
|
-
```typescript title="src/example-mixed-hallucination.ts" showLineNumbers copy
|
|
178
|
-
import { createHallucinationScorer } from "@mastra/evals/scorers/llm";
|
|
179
|
-
|
|
180
|
-
const scorer = createHallucinationScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
181
|
-
context: [
|
|
182
|
-
"The first Star Wars movie was released in 1977.",
|
|
183
|
-
"It was directed by George Lucas.",
|
|
184
|
-
"The film earned $775 million worldwide.",
|
|
185
|
-
"The movie was filmed in Tunisia and England."
|
|
186
|
-
]
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const query = "Tell me about the first Star Wars movie.";
|
|
190
|
-
const response = "The first Star Wars movie came out in 1977 and was directed by George Lucas. It made over $1 billion at the box office and was filmed entirely in California.";
|
|
191
|
-
|
|
192
|
-
const result = await scorer.run({
|
|
193
|
-
input: [{ role: 'user', content: query }],
|
|
194
|
-
output: { text: response },
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
console.log(result);
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
#### Mixed hallucination output
|
|
201
|
-
|
|
202
|
-
The Scorer assigns a mid-range score because parts of the response conflict with the context. While some facts are correct, others are inaccurate or fabricated, reducing overall reliability.
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
{
|
|
206
|
-
score: 0.5,
|
|
207
|
-
reason: 'The score is 0.5 because two out of four statements from the output were contradicted by claims in the context, indicating a balance of accurate and inaccurate information.'
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Complete hallucination example
|
|
212
|
-
|
|
213
|
-
In this example, the response contradicts every key fact in the context. None of the claims can be verified, and all presented details are factually incorrect.
|
|
214
|
-
|
|
215
|
-
```typescript title="src/example-complete-hallucination.ts" showLineNumbers copy
|
|
216
|
-
import { createHallucinationScorer } from "@mastra/evals/scorers/llm";
|
|
217
|
-
|
|
218
|
-
const scorer = createHallucinationScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
219
|
-
context: [
|
|
220
|
-
"The Wright brothers made their first flight in 1903.",
|
|
221
|
-
"The flight lasted 12 seconds.",
|
|
222
|
-
"It covered a distance of 120 feet."
|
|
223
|
-
]
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
const query = "When did the Wright brothers first fly?";
|
|
227
|
-
const response = "The Wright brothers achieved their historic first flight in 1908. The flight lasted about 2 minutes and covered nearly a mile.";
|
|
228
|
-
|
|
229
|
-
const result = await scorer.run({
|
|
230
|
-
input: [{ role: 'user', content: query }],
|
|
231
|
-
output: { text: response },
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
console.log(result);
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
#### Complete hallucination output
|
|
239
|
-
|
|
240
|
-
The Scorer assigns a score of 1 because every statement in the response conflicts with the context. The details are fabricated or inaccurate across the board.
|
|
241
|
-
|
|
242
|
-
```typescript
|
|
243
|
-
{
|
|
244
|
-
score: 1,
|
|
245
|
-
reason: 'The score is 1.0 because all three statements from the output directly contradict the context: the first flight was in 1903, not 1908; it lasted 12 seconds, not about 2 minutes; and it covered 120 feet, not nearly a mile.'
|
|
246
|
-
}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
## Related
|
|
250
|
-
|
|
251
|
-
- [Faithfulness Scorer](./faithfulness)
|
|
252
|
-
- [Answer Relevancy Scorer](./answer-relevancy)
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Reference: Keyword Coverage Scorer | Scorers | Mastra Docs"
|
|
3
|
-
description: Documentation for the Keyword Coverage Scorer in Mastra, which evaluates how well LLM outputs cover important keywords from the input.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Keyword Coverage Scorer
|
|
7
|
-
|
|
8
|
-
The `createKeywordCoverageScorer()` function evaluates how well an LLM's output covers the important keywords from the input. It analyzes keyword presence and matches while ignoring common words and stop words.
|
|
9
|
-
|
|
10
|
-
## Parameters
|
|
11
|
-
|
|
12
|
-
The `createKeywordCoverageScorer()` function does not take any options.
|
|
13
|
-
|
|
14
|
-
This function returns an instance of the MastraScorer class. See the [MastraScorer reference](./mastra-scorer) for details on the `.run()` method and its input/output.
|
|
15
|
-
|
|
16
|
-
## .run() Returns
|
|
17
|
-
|
|
18
|
-
<PropertiesTable
|
|
19
|
-
content={[
|
|
20
|
-
{
|
|
21
|
-
name: "runId",
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "The id of the run (optional).",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "preprocessStepResult",
|
|
27
|
-
type: "object",
|
|
28
|
-
description:
|
|
29
|
-
"Object with extracted keywords: { referenceKeywords: Set<string>, responseKeywords: Set<string> }",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: "analyzeStepResult",
|
|
33
|
-
type: "object",
|
|
34
|
-
description:
|
|
35
|
-
"Object with keyword coverage: { totalKeywords: number, matchedKeywords: number }",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: "score",
|
|
39
|
-
type: "number",
|
|
40
|
-
description:
|
|
41
|
-
"Coverage score (0-1) representing the proportion of matched keywords.",
|
|
42
|
-
},
|
|
43
|
-
]}
|
|
44
|
-
/>
|
|
45
|
-
|
|
46
|
-
`.run()` returns a result in the following shape:
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
{
|
|
50
|
-
runId: string,
|
|
51
|
-
extractStepResult: {
|
|
52
|
-
referenceKeywords: Set<string>,
|
|
53
|
-
responseKeywords: Set<string>
|
|
54
|
-
},
|
|
55
|
-
analyzeStepResult: {
|
|
56
|
-
totalKeywords: number,
|
|
57
|
-
matchedKeywords: number
|
|
58
|
-
},
|
|
59
|
-
score: number
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Scoring Details
|
|
64
|
-
|
|
65
|
-
The scorer evaluates keyword coverage by matching keywords with the following features:
|
|
66
|
-
|
|
67
|
-
- Common word and stop word filtering (e.g., "the", "a", "and")
|
|
68
|
-
- Case-insensitive matching
|
|
69
|
-
- Word form variation handling
|
|
70
|
-
- Special handling of technical terms and compound words
|
|
71
|
-
|
|
72
|
-
### Scoring Process
|
|
73
|
-
|
|
74
|
-
1. Processes keywords from input and output:
|
|
75
|
-
- Filters out common words and stop words
|
|
76
|
-
- Normalizes case and word forms
|
|
77
|
-
- Handles special terms and compounds
|
|
78
|
-
2. Calculates keyword coverage:
|
|
79
|
-
- Matches keywords between texts
|
|
80
|
-
- Counts successful matches
|
|
81
|
-
- Computes coverage ratio
|
|
82
|
-
|
|
83
|
-
Final score: `(matched_keywords / total_keywords) * scale`
|
|
84
|
-
|
|
85
|
-
### Score interpretation
|
|
86
|
-
|
|
87
|
-
A coverage score between 0 and 1:
|
|
88
|
-
|
|
89
|
-
- **1.0**: Complete coverage – all keywords present.
|
|
90
|
-
- **0.7–0.9**: High coverage – most keywords included.
|
|
91
|
-
- **0.4–0.6**: Partial coverage – some keywords present.
|
|
92
|
-
- **0.1–0.3**: Low coverage – few keywords matched.
|
|
93
|
-
- **0.0**: No coverage – no keywords found.
|
|
94
|
-
|
|
95
|
-
### Special Cases
|
|
96
|
-
|
|
97
|
-
The scorer handles several special cases:
|
|
98
|
-
|
|
99
|
-
- Empty input/output: Returns score of 1.0 if both empty, 0.0 if only one is empty
|
|
100
|
-
- Single word: Treated as a single keyword
|
|
101
|
-
- Technical terms: Preserves compound technical terms (e.g., "React.js", "machine learning")
|
|
102
|
-
- Case differences: "JavaScript" matches "javascript"
|
|
103
|
-
- Common words: Ignored in scoring to focus on meaningful keywords
|
|
104
|
-
|
|
105
|
-
## Examples
|
|
106
|
-
|
|
107
|
-
### Full coverage example
|
|
108
|
-
|
|
109
|
-
In this example, the response fully reflects the key terms from the input. All required keywords are present, resulting in complete coverage with no omissions.
|
|
110
|
-
|
|
111
|
-
```typescript title="src/example-full-keyword-coverage.ts" showLineNumbers copy
|
|
112
|
-
import { createKeywordCoverageScorer } from "@mastra/evals/scorers/code";
|
|
113
|
-
|
|
114
|
-
const scorer = createKeywordCoverageScorer();
|
|
115
|
-
|
|
116
|
-
const input = "JavaScript frameworks like React and Vue";
|
|
117
|
-
const output =
|
|
118
|
-
"Popular JavaScript frameworks include React and Vue for web development";
|
|
119
|
-
|
|
120
|
-
const result = await scorer.run({
|
|
121
|
-
input: [{ role: "user", content: input }],
|
|
122
|
-
output: { role: "assistant", text: output },
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
console.log("Score:", result.score);
|
|
126
|
-
console.log("AnalyzeStepResult:", result.analyzeStepResult);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
#### Full coverage output
|
|
130
|
-
|
|
131
|
-
A score of 1 indicates that all expected keywords were found in the response. The `analyzeStepResult` field confirms that the number of matched keywords equals the total number extracted from the input.
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
{
|
|
135
|
-
score: 1,
|
|
136
|
-
analyzeStepResult: {
|
|
137
|
-
totalKeywords: 4,
|
|
138
|
-
matchedKeywords: 4
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Partial coverage example
|
|
144
|
-
|
|
145
|
-
In this example, the response includes some, but not all, of the important keywords from the input. The score reflects partial coverage, with key terms either missing or only partially matched.
|
|
146
|
-
|
|
147
|
-
```typescript title="src/example-partial-keyword-coverage.ts" showLineNumbers copy
|
|
148
|
-
import { createKeywordCoverageScorer } from "@mastra/evals/scorers/code";
|
|
149
|
-
|
|
150
|
-
const scorer = createKeywordCoverageScorer();
|
|
151
|
-
|
|
152
|
-
const input = "TypeScript offers interfaces, generics, and type inference";
|
|
153
|
-
const output = "TypeScript provides type inference and some advanced features";
|
|
154
|
-
|
|
155
|
-
const result = await scorer.run({
|
|
156
|
-
input: [{ role: "user", content: input }],
|
|
157
|
-
output: { role: "assistant", text: output },
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
console.log("Score:", result.score);
|
|
161
|
-
console.log("AnalyzeStepResult:", result.analyzeStepResult);
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
#### Partial coverage output
|
|
165
|
-
|
|
166
|
-
A score of 0.5 indicates that only half of the expected keywords were found in the response. The `analyzeStepResult` field shows how many terms were matched compared to the total identified in the input.
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
{
|
|
170
|
-
score: 0.5,
|
|
171
|
-
analyzeStepResult: {
|
|
172
|
-
totalKeywords: 6,
|
|
173
|
-
matchedKeywords: 3
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Minimal coverage example
|
|
179
|
-
|
|
180
|
-
In this example, the response includes very few of the important keywords from the input. The score reflects minimal coverage, with most key terms missing or unaccounted for.
|
|
181
|
-
|
|
182
|
-
```typescript title="src/example-minimal-keyword-coverage.ts" showLineNumbers copy
|
|
183
|
-
import { createKeywordCoverageScorer } from "@mastra/evals/scorers/code";
|
|
184
|
-
|
|
185
|
-
const scorer = createKeywordCoverageScorer();
|
|
186
|
-
|
|
187
|
-
const input =
|
|
188
|
-
"Machine learning models require data preprocessing, feature engineering, and hyperparameter tuning";
|
|
189
|
-
const output = "Data preparation is important for models";
|
|
190
|
-
|
|
191
|
-
const result = await scorer.run({
|
|
192
|
-
input: [{ role: "user", content: input }],
|
|
193
|
-
output: { role: "assistant", text: output },
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
console.log("Score:", result.score);
|
|
197
|
-
console.log("AnalyzeStepResult:", result.analyzeStepResult);
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
#### Minimal coverage output
|
|
201
|
-
|
|
202
|
-
A low score indicates that only a small number of the expected keywords were present in the response. The `analyzeStepResult` field highlights the gap between total and matched keywords, signaling insufficient coverage.
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
{
|
|
206
|
-
score: 0.2,
|
|
207
|
-
analyzeStepResult: {
|
|
208
|
-
totalKeywords: 10,
|
|
209
|
-
matchedKeywords: 2
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Metric configuration
|
|
215
|
-
|
|
216
|
-
You can create a `KeywordCoverageMetric` instance with default settings. No additional configuration is required.
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
const metric = new KeywordCoverageMetric();
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
> See [KeywordCoverageScorer](/reference/scorers/keyword-coverage) for a full list of configuration options.
|
|
223
|
-
|
|
224
|
-
## Related
|
|
225
|
-
|
|
226
|
-
- [Completeness Scorer](./completeness)
|
|
227
|
-
- [Content Similarity Scorer](./content-similarity)
|
|
228
|
-
- [Answer Relevancy Scorer](./answer-relevancy)
|
|
229
|
-
- [Textual Difference Scorer](./textual-difference)
|