@mastra/mcp-docs-server 0.13.37 → 0.13.38
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%2Fchangeset-cli.md +2 -0
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +2 -0
- package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +69 -69
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Freact.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +23 -23
- package/.docs/organized/changelogs/create-mastra.md +5 -5
- package/.docs/organized/changelogs/mastra.md +17 -17
- package/.docs/raw/agents/adding-voice.mdx +20 -9
- package/.docs/raw/agents/agent-memory.mdx +55 -39
- package/.docs/raw/agents/guardrails.mdx +68 -61
- package/.docs/raw/agents/networks.mdx +50 -46
- package/.docs/raw/agents/overview.mdx +125 -88
- package/.docs/raw/agents/using-tools.mdx +14 -15
- package/.docs/raw/auth/auth0.mdx +28 -27
- package/.docs/raw/auth/clerk.mdx +22 -20
- package/.docs/raw/auth/firebase.mdx +42 -39
- package/.docs/raw/auth/index.mdx +1 -1
- package/.docs/raw/auth/jwt.mdx +18 -16
- package/.docs/raw/auth/supabase.mdx +20 -18
- package/.docs/raw/auth/workos.mdx +32 -26
- package/.docs/raw/community/contributing-templates.mdx +7 -7
- package/.docs/raw/community/discord.mdx +2 -2
- package/.docs/raw/community/licensing.mdx +1 -1
- package/.docs/raw/course/03-agent-memory/26-updating-mastra-export-comprehensive.md +0 -32
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +41 -22
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +48 -29
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +52 -24
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +86 -55
- package/.docs/raw/deployment/cloud-providers/index.mdx +16 -13
- package/.docs/raw/deployment/monorepo.mdx +32 -42
- package/.docs/raw/deployment/overview.mdx +15 -15
- package/.docs/raw/deployment/server-deployment.mdx +18 -23
- package/.docs/raw/deployment/serverless-platforms/cloudflare-deployer.mdx +16 -17
- package/.docs/raw/deployment/serverless-platforms/index.mdx +15 -12
- package/.docs/raw/deployment/serverless-platforms/netlify-deployer.mdx +14 -23
- package/.docs/raw/deployment/serverless-platforms/vercel-deployer.mdx +16 -23
- package/.docs/raw/deployment/web-framework.mdx +14 -14
- package/.docs/raw/frameworks/agentic-uis/ai-sdk.mdx +138 -145
- package/.docs/raw/frameworks/agentic-uis/assistant-ui.mdx +54 -43
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +51 -36
- package/.docs/raw/frameworks/agentic-uis/copilotkit.mdx +161 -120
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +59 -48
- package/.docs/raw/frameworks/servers/express.mdx +45 -44
- package/.docs/raw/frameworks/web-frameworks/astro.mdx +245 -162
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +112 -69
- package/.docs/raw/frameworks/web-frameworks/sveltekit.mdx +189 -164
- package/.docs/raw/frameworks/web-frameworks/vite-react.mdx +94 -81
- package/.docs/raw/getting-started/installation.mdx +164 -133
- package/.docs/raw/getting-started/mcp-docs-server.mdx +36 -39
- package/.docs/raw/getting-started/project-structure.mdx +34 -42
- package/.docs/raw/getting-started/studio.mdx +40 -58
- package/.docs/raw/getting-started/templates.mdx +22 -27
- package/.docs/raw/index.mdx +9 -9
- package/.docs/raw/mastra-cloud/dashboard.mdx +10 -10
- package/.docs/raw/mastra-cloud/observability.mdx +7 -8
- package/.docs/raw/mastra-cloud/overview.mdx +16 -22
- package/.docs/raw/mastra-cloud/setting-up.mdx +33 -20
- package/.docs/raw/memory/conversation-history.mdx +2 -2
- package/.docs/raw/memory/overview.mdx +21 -23
- package/.docs/raw/memory/semantic-recall.mdx +14 -13
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +27 -28
- package/.docs/raw/memory/storage/memory-with-pg.mdx +26 -26
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +26 -27
- package/.docs/raw/memory/threads-and-resources.mdx +23 -20
- package/.docs/raw/memory/working-memory.mdx +27 -38
- package/.docs/raw/observability/ai-tracing/exporters/arize.mdx +30 -29
- package/.docs/raw/observability/ai-tracing/exporters/braintrust.mdx +8 -9
- package/.docs/raw/observability/ai-tracing/exporters/cloud.mdx +17 -16
- package/.docs/raw/observability/ai-tracing/exporters/default.mdx +31 -32
- package/.docs/raw/observability/ai-tracing/exporters/langfuse.mdx +18 -17
- package/.docs/raw/observability/ai-tracing/exporters/langsmith.mdx +14 -14
- package/.docs/raw/observability/ai-tracing/exporters/otel.mdx +56 -46
- package/.docs/raw/observability/ai-tracing/overview.mdx +145 -122
- package/.docs/raw/observability/ai-tracing/processors/sensitive-data-filter.mdx +57 -36
- package/.docs/raw/observability/logging.mdx +14 -17
- package/.docs/raw/observability/nextjs-tracing.mdx +5 -5
- package/.docs/raw/observability/otel-tracing.mdx +17 -18
- package/.docs/raw/observability/overview.mdx +14 -10
- package/.docs/raw/rag/chunking-and-embedding.mdx +10 -8
- package/.docs/raw/rag/overview.mdx +5 -5
- package/.docs/raw/rag/retrieval.mdx +125 -107
- package/.docs/raw/rag/vector-databases.mdx +232 -223
- package/.docs/raw/reference/agents/agent.mdx +54 -41
- package/.docs/raw/reference/agents/generate.mdx +367 -261
- package/.docs/raw/reference/agents/generateLegacy.mdx +260 -178
- package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +7 -5
- package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +7 -5
- package/.docs/raw/reference/agents/getDescription.mdx +3 -2
- package/.docs/raw/reference/agents/getInstructions.mdx +7 -5
- package/.docs/raw/reference/agents/getLLM.mdx +11 -7
- package/.docs/raw/reference/agents/getMemory.mdx +7 -5
- package/.docs/raw/reference/agents/getModel.mdx +7 -5
- package/.docs/raw/reference/agents/getScorers.mdx +7 -5
- package/.docs/raw/reference/agents/getTools.mdx +7 -5
- package/.docs/raw/reference/agents/getVoice.mdx +7 -5
- package/.docs/raw/reference/agents/getWorkflows.mdx +7 -5
- package/.docs/raw/reference/agents/listAgents.mdx +6 -4
- package/.docs/raw/reference/agents/network.mdx +171 -116
- package/.docs/raw/reference/auth/auth0.mdx +18 -14
- package/.docs/raw/reference/auth/clerk.mdx +15 -12
- package/.docs/raw/reference/auth/firebase.mdx +23 -16
- package/.docs/raw/reference/auth/jwt.mdx +7 -6
- package/.docs/raw/reference/auth/supabase.mdx +13 -10
- package/.docs/raw/reference/auth/workos.mdx +17 -13
- package/.docs/raw/reference/cli/create-mastra.mdx +61 -44
- package/.docs/raw/reference/cli/mastra.mdx +11 -11
- package/.docs/raw/reference/client-js/agents.mdx +40 -43
- package/.docs/raw/reference/client-js/error-handling.mdx +1 -1
- package/.docs/raw/reference/client-js/logs.mdx +1 -1
- package/.docs/raw/reference/client-js/mastra-client.mdx +21 -13
- package/.docs/raw/reference/client-js/memory.mdx +6 -2
- package/.docs/raw/reference/client-js/observability.mdx +10 -9
- package/.docs/raw/reference/client-js/telemetry.mdx +1 -1
- package/.docs/raw/reference/client-js/tools.mdx +1 -1
- package/.docs/raw/reference/client-js/vectors.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows-legacy.mdx +1 -1
- package/.docs/raw/reference/client-js/workflows.mdx +7 -7
- package/.docs/raw/reference/core/getAgent.mdx +6 -5
- package/.docs/raw/reference/core/getAgentById.mdx +5 -4
- package/.docs/raw/reference/core/getAgents.mdx +3 -3
- package/.docs/raw/reference/core/getDeployer.mdx +4 -3
- package/.docs/raw/reference/core/getLogger.mdx +4 -3
- package/.docs/raw/reference/core/getLogs.mdx +10 -6
- package/.docs/raw/reference/core/getLogsByRunId.mdx +8 -5
- package/.docs/raw/reference/core/getMCPServer.mdx +8 -5
- package/.docs/raw/reference/core/getMCPServers.mdx +4 -3
- package/.docs/raw/reference/core/getMemory.mdx +4 -3
- package/.docs/raw/reference/core/getScorer.mdx +15 -12
- package/.docs/raw/reference/core/getScorerByName.mdx +12 -9
- package/.docs/raw/reference/core/getScorers.mdx +3 -2
- package/.docs/raw/reference/core/getServer.mdx +4 -3
- package/.docs/raw/reference/core/getStorage.mdx +4 -3
- package/.docs/raw/reference/core/getTelemetry.mdx +4 -3
- package/.docs/raw/reference/core/getVector.mdx +6 -4
- package/.docs/raw/reference/core/getVectors.mdx +4 -3
- package/.docs/raw/reference/core/getWorkflow.mdx +7 -4
- package/.docs/raw/reference/core/getWorkflows.mdx +5 -3
- package/.docs/raw/reference/core/mastra-class.mdx +16 -16
- package/.docs/raw/reference/core/setLogger.mdx +6 -4
- package/.docs/raw/reference/core/setStorage.mdx +4 -4
- package/.docs/raw/reference/core/setTelemetry.mdx +4 -3
- package/.docs/raw/reference/deployer/cloudflare.mdx +11 -7
- package/.docs/raw/reference/deployer/deployer.mdx +2 -1
- package/.docs/raw/reference/deployer/netlify.mdx +4 -4
- package/.docs/raw/reference/deployer/vercel.mdx +6 -6
- package/.docs/raw/reference/evals/answer-relevancy.mdx +4 -5
- package/.docs/raw/reference/evals/bias.mdx +4 -5
- package/.docs/raw/reference/evals/completeness.mdx +4 -5
- package/.docs/raw/reference/evals/content-similarity.mdx +4 -5
- package/.docs/raw/reference/evals/context-position.mdx +4 -5
- package/.docs/raw/reference/evals/context-precision.mdx +4 -5
- package/.docs/raw/reference/evals/context-relevancy.mdx +4 -5
- package/.docs/raw/reference/evals/contextual-recall.mdx +4 -5
- package/.docs/raw/reference/evals/faithfulness.mdx +4 -5
- package/.docs/raw/reference/evals/hallucination.mdx +4 -6
- package/.docs/raw/reference/evals/keyword-coverage.mdx +4 -5
- package/.docs/raw/reference/evals/prompt-alignment.mdx +4 -6
- package/.docs/raw/reference/evals/summarization.mdx +4 -6
- package/.docs/raw/reference/evals/textual-difference.mdx +4 -5
- package/.docs/raw/reference/evals/tone-consistency.mdx +4 -7
- package/.docs/raw/reference/evals/toxicity.mdx +4 -5
- package/.docs/raw/reference/index.mdx +3 -3
- package/.docs/raw/reference/legacyWorkflows/after.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/afterEvent.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/commit.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/createRun.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/else.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/events.mdx +7 -7
- package/.docs/raw/reference/legacyWorkflows/execute.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/if.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/resume.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/resumeWithEvent.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/snapshots.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/start.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/step-class.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/step-condition.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/step-function.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/step-options.mdx +6 -6
- package/.docs/raw/reference/legacyWorkflows/step-retries.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/suspend.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/then.mdx +5 -5
- package/.docs/raw/reference/legacyWorkflows/until.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/watch.mdx +3 -3
- package/.docs/raw/reference/legacyWorkflows/while.mdx +4 -4
- package/.docs/raw/reference/legacyWorkflows/workflow.mdx +7 -7
- package/.docs/raw/reference/memory/createThread.mdx +10 -10
- package/.docs/raw/reference/memory/deleteMessages.mdx +7 -5
- package/.docs/raw/reference/memory/getThreadById.mdx +6 -5
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +11 -10
- package/.docs/raw/reference/memory/getThreadsByResourceIdPaginated.mdx +10 -9
- package/.docs/raw/reference/memory/{Memory.mdx → memory-class.mdx} +53 -46
- package/.docs/raw/reference/memory/query.mdx +39 -25
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +9 -5
- package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +26 -22
- package/.docs/raw/reference/observability/ai-tracing/exporters/arize.mdx +16 -12
- package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +14 -14
- package/.docs/raw/reference/observability/ai-tracing/exporters/cloud-exporter.mdx +16 -11
- package/.docs/raw/reference/observability/ai-tracing/exporters/console-exporter.mdx +10 -6
- package/.docs/raw/reference/observability/ai-tracing/exporters/default-exporter.mdx +23 -15
- package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +6 -6
- package/.docs/raw/reference/observability/ai-tracing/exporters/langsmith.mdx +13 -13
- package/.docs/raw/reference/observability/ai-tracing/exporters/otel.mdx +44 -36
- package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +115 -106
- package/.docs/raw/reference/observability/ai-tracing/processors/sensitive-data-filter.mdx +37 -32
- package/.docs/raw/reference/observability/ai-tracing/span.mdx +29 -26
- package/.docs/raw/reference/observability/logging/pino-logger.mdx +13 -15
- package/.docs/raw/reference/observability/otel-tracing/otel-config.mdx +2 -2
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-ax.mdx +3 -3
- package/.docs/raw/reference/observability/otel-tracing/providers/arize-phoenix.mdx +2 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/dash0.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +12 -14
- package/.docs/raw/reference/observability/otel-tracing/providers/keywordsai.mdx +3 -3
- package/.docs/raw/reference/observability/otel-tracing/providers/laminar.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/langfuse.mdx +4 -4
- package/.docs/raw/reference/observability/otel-tracing/providers/langsmith.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/langwatch.mdx +2 -2
- package/.docs/raw/reference/observability/otel-tracing/providers/new-relic.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/signoz.mdx +1 -1
- package/.docs/raw/reference/observability/otel-tracing/providers/traceloop.mdx +1 -1
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +13 -10
- package/.docs/raw/reference/processors/language-detector.mdx +27 -17
- package/.docs/raw/reference/processors/moderation-processor.mdx +26 -17
- package/.docs/raw/reference/processors/pii-detector.mdx +28 -18
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +25 -17
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +26 -17
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +22 -15
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +13 -12
- package/.docs/raw/reference/rag/chunk.mdx +41 -23
- package/.docs/raw/reference/rag/database-config.mdx +56 -38
- package/.docs/raw/reference/rag/document.mdx +1 -1
- package/.docs/raw/reference/rag/embeddings.mdx +1 -1
- package/.docs/raw/reference/rag/extract-params.mdx +1 -1
- package/.docs/raw/reference/rag/graph-rag.mdx +1 -1
- package/.docs/raw/reference/rag/metadata-filters.mdx +23 -26
- package/.docs/raw/reference/rag/rerank.mdx +1 -1
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +2 -2
- package/.docs/raw/reference/scorers/answer-relevancy.mdx +35 -17
- package/.docs/raw/reference/scorers/answer-similarity.mdx +84 -68
- package/.docs/raw/reference/scorers/bias.mdx +22 -19
- package/.docs/raw/reference/scorers/completeness.mdx +21 -16
- package/.docs/raw/reference/scorers/content-similarity.mdx +12 -10
- package/.docs/raw/reference/scorers/context-precision.mdx +73 -64
- package/.docs/raw/reference/scorers/context-relevance.mdx +142 -126
- package/.docs/raw/reference/scorers/create-scorer.mdx +93 -61
- package/.docs/raw/reference/scorers/faithfulness.mdx +21 -13
- package/.docs/raw/reference/scorers/hallucination.mdx +17 -12
- package/.docs/raw/reference/scorers/keyword-coverage.mdx +32 -27
- package/.docs/raw/reference/scorers/mastra-scorer.mdx +39 -33
- package/.docs/raw/reference/scorers/noise-sensitivity.mdx +203 -152
- package/.docs/raw/reference/scorers/prompt-alignment.mdx +186 -132
- package/.docs/raw/reference/scorers/run-experiment.mdx +40 -31
- package/.docs/raw/reference/scorers/textual-difference.mdx +25 -26
- package/.docs/raw/reference/scorers/tone-consistency.mdx +29 -26
- package/.docs/raw/reference/scorers/tool-call-accuracy.mdx +180 -176
- package/.docs/raw/reference/scorers/toxicity.mdx +35 -31
- 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 +1 -1
- package/.docs/raw/reference/storage/lance.mdx +1 -1
- package/.docs/raw/reference/storage/libsql.mdx +2 -2
- package/.docs/raw/reference/storage/mongodb.mdx +4 -5
- package/.docs/raw/reference/storage/mssql.mdx +5 -4
- package/.docs/raw/reference/storage/postgresql.mdx +35 -33
- package/.docs/raw/reference/storage/upstash.mdx +6 -5
- package/.docs/raw/reference/streaming/ChunkType.mdx +788 -314
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +265 -109
- package/.docs/raw/reference/streaming/agents/stream.mdx +375 -266
- package/.docs/raw/reference/streaming/agents/streamLegacy.mdx +233 -162
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +4 -4
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +5 -5
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +24 -20
- package/.docs/raw/reference/streaming/workflows/stream.mdx +35 -26
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +36 -27
- package/.docs/raw/reference/templates/overview.mdx +16 -39
- package/.docs/raw/reference/tools/client.mdx +1 -1
- package/.docs/raw/reference/tools/create-tool.mdx +45 -35
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +2 -2
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +12 -12
- package/.docs/raw/reference/tools/mcp-client.mdx +70 -64
- package/.docs/raw/reference/tools/mcp-server.mdx +91 -78
- package/.docs/raw/reference/tools/vector-query-tool.mdx +48 -38
- package/.docs/raw/reference/vectors/astra.mdx +1 -1
- package/.docs/raw/reference/vectors/chroma.mdx +25 -19
- package/.docs/raw/reference/vectors/couchbase.mdx +4 -4
- package/.docs/raw/reference/vectors/lance.mdx +5 -6
- package/.docs/raw/reference/vectors/libsql.mdx +1 -1
- package/.docs/raw/reference/vectors/mongodb.mdx +1 -1
- package/.docs/raw/reference/vectors/opensearch.mdx +1 -1
- package/.docs/raw/reference/vectors/pg.mdx +8 -4
- package/.docs/raw/reference/vectors/pinecone.mdx +1 -1
- package/.docs/raw/reference/vectors/qdrant.mdx +1 -1
- package/.docs/raw/reference/vectors/s3vectors.mdx +35 -27
- package/.docs/raw/reference/vectors/turbopuffer.mdx +1 -1
- package/.docs/raw/reference/vectors/upstash.mdx +33 -25
- package/.docs/raw/reference/vectors/vectorize.mdx +1 -1
- package/.docs/raw/reference/voice/azure.mdx +1 -1
- package/.docs/raw/reference/voice/cloudflare.mdx +1 -1
- package/.docs/raw/reference/voice/composite-voice.mdx +1 -1
- package/.docs/raw/reference/voice/deepgram.mdx +1 -1
- package/.docs/raw/reference/voice/elevenlabs.mdx +1 -1
- package/.docs/raw/reference/voice/google-gemini-live.mdx +6 -4
- package/.docs/raw/reference/voice/google.mdx +1 -1
- package/.docs/raw/reference/voice/mastra-voice.mdx +1 -1
- package/.docs/raw/reference/voice/murf.mdx +1 -1
- package/.docs/raw/reference/voice/openai-realtime.mdx +1 -1
- package/.docs/raw/reference/voice/openai.mdx +1 -1
- package/.docs/raw/reference/voice/playai.mdx +1 -1
- package/.docs/raw/reference/voice/sarvam.mdx +1 -1
- package/.docs/raw/reference/voice/speechify.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +1 -1
- package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
- package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
- package/.docs/raw/reference/voice/voice.close.mdx +1 -1
- package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
- package/.docs/raw/reference/voice/voice.events.mdx +1 -1
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +23 -30
- package/.docs/raw/reference/voice/voice.listen.mdx +1 -1
- package/.docs/raw/reference/voice/voice.off.mdx +1 -1
- package/.docs/raw/reference/voice/voice.on.mdx +1 -1
- package/.docs/raw/reference/voice/voice.send.mdx +1 -1
- package/.docs/raw/reference/voice/voice.speak.mdx +1 -1
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/cancel.mdx +4 -3
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +49 -34
- package/.docs/raw/reference/workflows/run-methods/start.mdx +43 -31
- package/.docs/raw/reference/workflows/run-methods/watch.mdx +7 -8
- package/.docs/raw/reference/workflows/run.mdx +7 -10
- package/.docs/raw/reference/workflows/step.mdx +15 -12
- 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 -7
- package/.docs/raw/reference/workflows/workflow-methods/dountil.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/dowhile.mdx +2 -2
- package/.docs/raw/reference/workflows/workflow-methods/foreach.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/map.mdx +3 -2
- package/.docs/raw/reference/workflows/workflow-methods/parallel.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/sendEvent.mdx +5 -5
- package/.docs/raw/reference/workflows/workflow-methods/sleep.mdx +3 -2
- package/.docs/raw/reference/workflows/workflow-methods/sleepUntil.mdx +3 -2
- package/.docs/raw/reference/workflows/workflow-methods/then.mdx +1 -1
- package/.docs/raw/reference/workflows/workflow-methods/waitForEvent.mdx +3 -3
- package/.docs/raw/reference/workflows/workflow.mdx +13 -10
- package/.docs/raw/scorers/custom-scorers.mdx +58 -48
- package/.docs/raw/scorers/evals-old-api/custom-eval.mdx +6 -8
- package/.docs/raw/scorers/evals-old-api/overview.mdx +8 -8
- package/.docs/raw/scorers/evals-old-api/running-in-ci.mdx +9 -9
- package/.docs/raw/scorers/evals-old-api/textual-evals.mdx +5 -5
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +3 -1
- package/.docs/raw/scorers/overview.mdx +20 -19
- package/.docs/raw/server-db/custom-api-routes.mdx +8 -8
- package/.docs/raw/server-db/mastra-client.mdx +56 -54
- package/.docs/raw/server-db/middleware.mdx +11 -7
- package/.docs/raw/server-db/production-server.mdx +5 -7
- package/.docs/raw/server-db/runtime-context.mdx +41 -38
- package/.docs/raw/server-db/storage.mdx +82 -87
- package/.docs/raw/streaming/events.mdx +24 -16
- package/.docs/raw/streaming/overview.mdx +17 -18
- package/.docs/raw/streaming/tool-streaming.mdx +9 -10
- package/.docs/raw/streaming/workflow-streaming.mdx +14 -12
- package/.docs/raw/tools-mcp/advanced-usage.mdx +2 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +92 -102
- package/.docs/raw/tools-mcp/overview.mdx +9 -14
- package/.docs/raw/voice/overview.mdx +273 -250
- package/.docs/raw/voice/speech-to-speech.mdx +14 -12
- package/.docs/raw/voice/speech-to-text.mdx +2 -2
- package/.docs/raw/voice/text-to-speech.mdx +2 -2
- package/.docs/raw/workflows/agents-and-tools.mdx +29 -28
- package/.docs/raw/workflows/control-flow.mdx +24 -24
- package/.docs/raw/workflows/error-handling.mdx +15 -17
- package/.docs/raw/workflows/human-in-the-loop.mdx +39 -39
- package/.docs/raw/workflows/inngest-workflow.mdx +33 -29
- package/.docs/raw/workflows/input-data-mapping.mdx +9 -9
- package/.docs/raw/workflows/overview.mdx +60 -60
- package/.docs/raw/workflows/snapshots.mdx +54 -36
- package/.docs/raw/workflows/suspend-and-resume.mdx +52 -57
- package/.docs/raw/workflows-legacy/control-flow.mdx +15 -17
- package/.docs/raw/workflows-legacy/dynamic-workflows.mdx +3 -1
- package/.docs/raw/workflows-legacy/error-handling.mdx +8 -6
- package/.docs/raw/workflows-legacy/nested-workflows.mdx +6 -0
- package/.docs/raw/workflows-legacy/overview.mdx +28 -26
- package/.docs/raw/workflows-legacy/runtime-variables.mdx +4 -2
- package/.docs/raw/workflows-legacy/steps.mdx +5 -3
- package/.docs/raw/workflows-legacy/suspend-and-resume.mdx +10 -8
- package/.docs/raw/workflows-legacy/variables.mdx +10 -8
- package/CHANGELOG.md +14 -0
- package/package.json +5 -5
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +0 -148
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference:
|
|
2
|
+
title: "Reference: createScorer | Scorers | Mastra Docs"
|
|
3
3
|
description: Documentation for creating custom scorers in Mastra, allowing users to define their own evaluation logic using either JavaScript functions or LLM-based prompts.
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -18,15 +18,21 @@ const scorer = createScorer({
|
|
|
18
18
|
type: "agent", // Optional: for agent evaluation with automatic typing
|
|
19
19
|
judge: {
|
|
20
20
|
model: myModel,
|
|
21
|
-
instructions: "You are an expert evaluator..."
|
|
22
|
-
}
|
|
21
|
+
instructions: "You are an expert evaluator...",
|
|
22
|
+
},
|
|
23
23
|
})
|
|
24
|
-
.preprocess({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
.preprocess({
|
|
25
|
+
/* step config */
|
|
26
|
+
})
|
|
27
|
+
.analyze({
|
|
28
|
+
/* step config */
|
|
29
|
+
})
|
|
30
|
+
.generateScore(({ run, results }) => {
|
|
31
|
+
// Return a number
|
|
32
|
+
})
|
|
33
|
+
.generateReason({
|
|
34
|
+
/* step config */
|
|
35
|
+
});
|
|
30
36
|
```
|
|
31
37
|
|
|
32
38
|
## createScorer Options
|
|
@@ -49,13 +55,15 @@ const scorer = createScorer({
|
|
|
49
55
|
name: "judge",
|
|
50
56
|
type: "object",
|
|
51
57
|
required: false,
|
|
52
|
-
description:
|
|
58
|
+
description:
|
|
59
|
+
"Optional judge configuration for LLM-based steps. See Judge Object section below.",
|
|
53
60
|
},
|
|
54
61
|
{
|
|
55
62
|
name: "type",
|
|
56
63
|
type: "string",
|
|
57
64
|
required: false,
|
|
58
|
-
description:
|
|
65
|
+
description:
|
|
66
|
+
"Type specification for input/output. Use 'agent' for automatic agent types. For custom types, use the generic approach instead.",
|
|
59
67
|
},
|
|
60
68
|
]}
|
|
61
69
|
/>
|
|
@@ -90,24 +98,24 @@ You can specify input/output types when creating scorers for better type inferen
|
|
|
90
98
|
For evaluating agents, use `type: 'agent'` to automatically get the correct types for agent input/output:
|
|
91
99
|
|
|
92
100
|
```typescript
|
|
93
|
-
import { createScorer } from
|
|
101
|
+
import { createScorer } from "@mastra/core/scorers";
|
|
94
102
|
|
|
95
103
|
// Agent scorer with automatic typing
|
|
96
104
|
const agentScorer = createScorer({
|
|
97
|
-
name:
|
|
98
|
-
description:
|
|
99
|
-
type:
|
|
100
|
-
})
|
|
101
|
-
.preprocess(({ run }) => {
|
|
102
|
-
// run.input is automatically typed as ScorerRunInputForAgent
|
|
103
|
-
const userMessage = run.input.inputMessages[0]?.content;
|
|
104
|
-
return { userMessage };
|
|
105
|
+
name: "Agent Response Quality",
|
|
106
|
+
description: "Evaluates agent responses",
|
|
107
|
+
type: "agent", // Automatically provides ScorerRunInputForAgent/ScorerRunOutputForAgent
|
|
105
108
|
})
|
|
106
|
-
.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
})
|
|
109
|
+
.preprocess(({ run }) => {
|
|
110
|
+
// run.input is automatically typed as ScorerRunInputForAgent
|
|
111
|
+
const userMessage = run.input.inputMessages[0]?.content;
|
|
112
|
+
return { userMessage };
|
|
113
|
+
})
|
|
114
|
+
.generateScore(({ run, results }) => {
|
|
115
|
+
// run.output is automatically typed as ScorerRunOutputForAgent
|
|
116
|
+
const response = run.output[0]?.content;
|
|
117
|
+
return response.length > 10 ? 1.0 : 0.5;
|
|
118
|
+
});
|
|
111
119
|
```
|
|
112
120
|
|
|
113
121
|
### Custom Types with Generics
|
|
@@ -115,16 +123,15 @@ const agentScorer = createScorer({
|
|
|
115
123
|
For custom input/output types, use the generic approach:
|
|
116
124
|
|
|
117
125
|
```typescript
|
|
118
|
-
import { createScorer } from
|
|
126
|
+
import { createScorer } from "@mastra/core/scorers";
|
|
119
127
|
|
|
120
128
|
type CustomInput = { query: string; context: string[] };
|
|
121
129
|
type CustomOutput = { answer: string; confidence: number };
|
|
122
130
|
|
|
123
131
|
const customScorer = createScorer<CustomInput, CustomOutput>({
|
|
124
|
-
name:
|
|
125
|
-
description:
|
|
126
|
-
})
|
|
127
|
-
.generateScore(({ run }) => {
|
|
132
|
+
name: "Custom Scorer",
|
|
133
|
+
description: "Evaluates custom data",
|
|
134
|
+
}).generateScore(({ run }) => {
|
|
128
135
|
// run.input is typed as CustomInput
|
|
129
136
|
// run.output is typed as CustomOutput
|
|
130
137
|
return run.output.confidence;
|
|
@@ -144,15 +151,14 @@ When you use `type: 'agent'`, your scorer is compatible for both adding directly
|
|
|
144
151
|
|
|
145
152
|
```typescript
|
|
146
153
|
const agentTraceScorer = createScorer({
|
|
147
|
-
name:
|
|
148
|
-
description:
|
|
149
|
-
type:
|
|
150
|
-
})
|
|
151
|
-
.generateScore(({ run }) => {
|
|
154
|
+
name: "Agent Trace Length",
|
|
155
|
+
description: "Evaluates agent response length",
|
|
156
|
+
type: "agent",
|
|
157
|
+
}).generateScore(({ run }) => {
|
|
152
158
|
// Trace data is automatically transformed to agent format
|
|
153
159
|
const userMessages = run.input.inputMessages;
|
|
154
160
|
const agentResponse = run.output[0]?.content;
|
|
155
|
-
|
|
161
|
+
|
|
156
162
|
// Score based on response length
|
|
157
163
|
return agentResponse?.length > 50 ? 0 : 1;
|
|
158
164
|
});
|
|
@@ -160,8 +166,8 @@ const agentTraceScorer = createScorer({
|
|
|
160
166
|
// Register with Mastra for trace scoring
|
|
161
167
|
const mastra = new Mastra({
|
|
162
168
|
scorers: {
|
|
163
|
-
agentTraceScorer
|
|
164
|
-
}
|
|
169
|
+
agentTraceScorer,
|
|
170
|
+
},
|
|
165
171
|
});
|
|
166
172
|
```
|
|
167
173
|
|
|
@@ -180,13 +186,15 @@ Function: `({ run, results }) => any`
|
|
|
180
186
|
name: "run.input",
|
|
181
187
|
type: "any",
|
|
182
188
|
required: true,
|
|
183
|
-
description:
|
|
189
|
+
description:
|
|
190
|
+
"Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. `[{ role: 'user', content: 'hello world' }]`. If the scorer is used in a workflow, this will be the input of the workflow.",
|
|
184
191
|
},
|
|
185
192
|
{
|
|
186
193
|
name: "run.output",
|
|
187
194
|
type: "any",
|
|
188
195
|
required: true,
|
|
189
|
-
description:
|
|
196
|
+
description:
|
|
197
|
+
"Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
|
|
190
198
|
},
|
|
191
199
|
{
|
|
192
200
|
name: "run.runId",
|
|
@@ -198,7 +206,8 @@ Function: `({ run, results }) => any`
|
|
|
198
206
|
name: "run.runtimeContext",
|
|
199
207
|
type: "object",
|
|
200
208
|
required: false,
|
|
201
|
-
description:
|
|
209
|
+
description:
|
|
210
|
+
"Runtime context from the agent or workflow step being evaluated (optional).",
|
|
202
211
|
},
|
|
203
212
|
{
|
|
204
213
|
name: "results",
|
|
@@ -213,6 +222,7 @@ Returns: `any`
|
|
|
213
222
|
The method can return any value. The returned value will be available to subsequent steps as `preprocessStepResult`.
|
|
214
223
|
|
|
215
224
|
**Prompt Object Mode:**
|
|
225
|
+
|
|
216
226
|
<PropertiesTable
|
|
217
227
|
content={[
|
|
218
228
|
{
|
|
@@ -231,13 +241,15 @@ The method can return any value. The returned value will be available to subsequ
|
|
|
231
241
|
name: "createPrompt",
|
|
232
242
|
type: "function",
|
|
233
243
|
required: true,
|
|
234
|
-
description:
|
|
244
|
+
description:
|
|
245
|
+
"Function: ({ run, results }) => string. Returns the prompt for the LLM.",
|
|
235
246
|
},
|
|
236
247
|
{
|
|
237
248
|
name: "judge",
|
|
238
249
|
type: "object",
|
|
239
250
|
required: false,
|
|
240
|
-
description:
|
|
251
|
+
description:
|
|
252
|
+
"(Optional) LLM judge for this step (can override main judge). See Judge Object section.",
|
|
241
253
|
},
|
|
242
254
|
]}
|
|
243
255
|
/>
|
|
@@ -255,13 +267,15 @@ Function: `({ run, results }) => any`
|
|
|
255
267
|
name: "run.input",
|
|
256
268
|
type: "any",
|
|
257
269
|
required: true,
|
|
258
|
-
description:
|
|
270
|
+
description:
|
|
271
|
+
"Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. `[{ role: 'user', content: 'hello world' }]`. If the scorer is used in a workflow, this will be the input of the workflow.",
|
|
259
272
|
},
|
|
260
273
|
{
|
|
261
274
|
name: "run.output",
|
|
262
275
|
type: "any",
|
|
263
276
|
required: true,
|
|
264
|
-
description:
|
|
277
|
+
description:
|
|
278
|
+
"Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
|
|
265
279
|
},
|
|
266
280
|
{
|
|
267
281
|
name: "run.runId",
|
|
@@ -273,7 +287,8 @@ Function: `({ run, results }) => any`
|
|
|
273
287
|
name: "run.runtimeContext",
|
|
274
288
|
type: "object",
|
|
275
289
|
required: false,
|
|
276
|
-
description:
|
|
290
|
+
description:
|
|
291
|
+
"Runtime context from the agent or workflow step being evaluated (optional).",
|
|
277
292
|
},
|
|
278
293
|
{
|
|
279
294
|
name: "results.preprocessStepResult",
|
|
@@ -288,6 +303,7 @@ Returns: `any`
|
|
|
288
303
|
The method can return any value. The returned value will be available to subsequent steps as `analyzeStepResult`.
|
|
289
304
|
|
|
290
305
|
**Prompt Object Mode:**
|
|
306
|
+
|
|
291
307
|
<PropertiesTable
|
|
292
308
|
content={[
|
|
293
309
|
{
|
|
@@ -306,13 +322,15 @@ The method can return any value. The returned value will be available to subsequ
|
|
|
306
322
|
name: "createPrompt",
|
|
307
323
|
type: "function",
|
|
308
324
|
required: true,
|
|
309
|
-
description:
|
|
325
|
+
description:
|
|
326
|
+
"Function: ({ run, results }) => string. Returns the prompt for the LLM.",
|
|
310
327
|
},
|
|
311
328
|
{
|
|
312
329
|
name: "judge",
|
|
313
330
|
type: "object",
|
|
314
331
|
required: false,
|
|
315
|
-
description:
|
|
332
|
+
description:
|
|
333
|
+
"(Optional) LLM judge for this step (can override main judge). See Judge Object section.",
|
|
316
334
|
},
|
|
317
335
|
]}
|
|
318
336
|
/>
|
|
@@ -330,13 +348,15 @@ Function: `({ run, results }) => number`
|
|
|
330
348
|
name: "run.input",
|
|
331
349
|
type: "any",
|
|
332
350
|
required: true,
|
|
333
|
-
description:
|
|
351
|
+
description:
|
|
352
|
+
"Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. `[{ role: 'user', content: 'hello world' }]`. If the scorer is used in a workflow, this will be the input of the workflow.",
|
|
334
353
|
},
|
|
335
354
|
{
|
|
336
355
|
name: "run.output",
|
|
337
356
|
type: "any",
|
|
338
357
|
required: true,
|
|
339
|
-
description:
|
|
358
|
+
description:
|
|
359
|
+
"Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
|
|
340
360
|
},
|
|
341
361
|
{
|
|
342
362
|
name: "run.runId",
|
|
@@ -348,7 +368,8 @@ Function: `({ run, results }) => number`
|
|
|
348
368
|
name: "run.runtimeContext",
|
|
349
369
|
type: "object",
|
|
350
370
|
required: false,
|
|
351
|
-
description:
|
|
371
|
+
description:
|
|
372
|
+
"Runtime context from the agent or workflow step being evaluated (optional).",
|
|
352
373
|
},
|
|
353
374
|
{
|
|
354
375
|
name: "results.preprocessStepResult",
|
|
@@ -369,6 +390,7 @@ Returns: `number`
|
|
|
369
390
|
The method must return a numerical score.
|
|
370
391
|
|
|
371
392
|
**Prompt Object Mode:**
|
|
393
|
+
|
|
372
394
|
<PropertiesTable
|
|
373
395
|
content={[
|
|
374
396
|
{
|
|
@@ -381,19 +403,22 @@ The method must return a numerical score.
|
|
|
381
403
|
name: "outputSchema",
|
|
382
404
|
type: "ZodSchema",
|
|
383
405
|
required: true,
|
|
384
|
-
description:
|
|
406
|
+
description:
|
|
407
|
+
"Zod schema for the expected output of the generateScore step.",
|
|
385
408
|
},
|
|
386
409
|
{
|
|
387
410
|
name: "createPrompt",
|
|
388
411
|
type: "function",
|
|
389
412
|
required: true,
|
|
390
|
-
description:
|
|
413
|
+
description:
|
|
414
|
+
"Function: ({ run, results }) => string. Returns the prompt for the LLM.",
|
|
391
415
|
},
|
|
392
416
|
{
|
|
393
417
|
name: "judge",
|
|
394
418
|
type: "object",
|
|
395
419
|
required: false,
|
|
396
|
-
description:
|
|
420
|
+
description:
|
|
421
|
+
"(Optional) LLM judge for this step (can override main judge). See Judge Object section.",
|
|
397
422
|
},
|
|
398
423
|
]}
|
|
399
424
|
/>
|
|
@@ -406,7 +431,8 @@ When using prompt object mode, you must also provide a `calculateScore` function
|
|
|
406
431
|
name: "calculateScore",
|
|
407
432
|
type: "function",
|
|
408
433
|
required: true,
|
|
409
|
-
description:
|
|
434
|
+
description:
|
|
435
|
+
"Function: ({ run, results, analyzeStepResult }) => number. Converts the LLM's structured output into a numerical score.",
|
|
410
436
|
},
|
|
411
437
|
]}
|
|
412
438
|
/>
|
|
@@ -424,13 +450,15 @@ Function: `({ run, results, score }) => string`
|
|
|
424
450
|
name: "run.input",
|
|
425
451
|
type: "any",
|
|
426
452
|
required: true,
|
|
427
|
-
description:
|
|
453
|
+
description:
|
|
454
|
+
"Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. `[{ role: 'user', content: 'hello world' }]`. If the scorer is used in a workflow, this will be the input of the workflow.",
|
|
428
455
|
},
|
|
429
456
|
{
|
|
430
457
|
name: "run.output",
|
|
431
458
|
type: "any",
|
|
432
459
|
required: true,
|
|
433
|
-
description:
|
|
460
|
+
description:
|
|
461
|
+
"Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
|
|
434
462
|
},
|
|
435
463
|
{
|
|
436
464
|
name: "run.runId",
|
|
@@ -442,7 +470,8 @@ Function: `({ run, results, score }) => string`
|
|
|
442
470
|
name: "run.runtimeContext",
|
|
443
471
|
type: "object",
|
|
444
472
|
required: false,
|
|
445
|
-
description:
|
|
473
|
+
description:
|
|
474
|
+
"Runtime context from the agent or workflow step being evaluated (optional).",
|
|
446
475
|
},
|
|
447
476
|
{
|
|
448
477
|
name: "results.preprocessStepResult",
|
|
@@ -469,6 +498,7 @@ Returns: `string`
|
|
|
469
498
|
The method must return a string explaining the score.
|
|
470
499
|
|
|
471
500
|
**Prompt Object Mode:**
|
|
501
|
+
|
|
472
502
|
<PropertiesTable
|
|
473
503
|
content={[
|
|
474
504
|
{
|
|
@@ -481,15 +511,17 @@ The method must return a string explaining the score.
|
|
|
481
511
|
name: "createPrompt",
|
|
482
512
|
type: "function",
|
|
483
513
|
required: true,
|
|
484
|
-
description:
|
|
514
|
+
description:
|
|
515
|
+
"Function: ({ run, results, score }) => string. Returns the prompt for the LLM.",
|
|
485
516
|
},
|
|
486
517
|
{
|
|
487
518
|
name: "judge",
|
|
488
519
|
type: "object",
|
|
489
520
|
required: false,
|
|
490
|
-
description:
|
|
521
|
+
description:
|
|
522
|
+
"(Optional) LLM judge for this step (can override main judge). See Judge Object section.",
|
|
491
523
|
},
|
|
492
524
|
]}
|
|
493
525
|
/>
|
|
494
526
|
|
|
495
|
-
All step functions can be async.
|
|
527
|
+
All step functions can be async.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Faithfulness | Scorers | Mastra Docs"
|
|
2
|
+
title: "Reference: Faithfulness Scorer | Scorers | Mastra Docs"
|
|
3
3
|
description: Documentation for the Faithfulness Scorer in Mastra, which evaluates the factual accuracy of LLM outputs compared to the provided context.
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -23,14 +23,16 @@ The `createFaithfulnessScorer()` function accepts a single options object with t
|
|
|
23
23
|
name: "context",
|
|
24
24
|
type: "string[]",
|
|
25
25
|
required: true,
|
|
26
|
-
description:
|
|
26
|
+
description:
|
|
27
|
+
"Array of context chunks against which the output's claims will be verified.",
|
|
27
28
|
},
|
|
28
29
|
{
|
|
29
30
|
name: "scale",
|
|
30
31
|
type: "number",
|
|
31
32
|
required: false,
|
|
32
33
|
defaultValue: "1",
|
|
33
|
-
description:
|
|
34
|
+
description:
|
|
35
|
+
"The maximum score value. The final score will be normalized to this scale.",
|
|
34
36
|
},
|
|
35
37
|
]}
|
|
36
38
|
/>
|
|
@@ -54,32 +56,38 @@ This function returns an instance of the MastraScorer class. The `.run()` method
|
|
|
54
56
|
{
|
|
55
57
|
name: "preprocessPrompt",
|
|
56
58
|
type: "string",
|
|
57
|
-
description:
|
|
59
|
+
description:
|
|
60
|
+
"The prompt sent to the LLM for the preprocess step (optional).",
|
|
58
61
|
},
|
|
59
62
|
{
|
|
60
63
|
name: "analyzeStepResult",
|
|
61
64
|
type: "object",
|
|
62
|
-
description:
|
|
65
|
+
description:
|
|
66
|
+
"Object with verdicts: { verdicts: Array<{ verdict: 'yes' | 'no' | 'unsure', reason: string }> }",
|
|
63
67
|
},
|
|
64
68
|
{
|
|
65
69
|
name: "analyzePrompt",
|
|
66
70
|
type: "string",
|
|
67
|
-
description:
|
|
71
|
+
description:
|
|
72
|
+
"The prompt sent to the LLM for the analyze step (optional).",
|
|
68
73
|
},
|
|
69
74
|
{
|
|
70
75
|
name: "score",
|
|
71
76
|
type: "number",
|
|
72
|
-
description:
|
|
77
|
+
description:
|
|
78
|
+
"A score between 0 and the configured scale, representing the proportion of claims that are supported by the context.",
|
|
73
79
|
},
|
|
74
80
|
{
|
|
75
81
|
name: "reason",
|
|
76
82
|
type: "string",
|
|
77
|
-
description:
|
|
83
|
+
description:
|
|
84
|
+
"A detailed explanation of the score, including which claims were supported, contradicted, or marked as unsure.",
|
|
78
85
|
},
|
|
79
86
|
{
|
|
80
87
|
name: "generateReasonPrompt",
|
|
81
88
|
type: "string",
|
|
82
|
-
description:
|
|
89
|
+
description:
|
|
90
|
+
"The prompt sent to the LLM for the generateReason step (optional).",
|
|
83
91
|
},
|
|
84
92
|
]}
|
|
85
93
|
/>
|
|
@@ -120,7 +128,7 @@ A faithfulness score between 0 and 1:
|
|
|
120
128
|
|
|
121
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.
|
|
122
130
|
|
|
123
|
-
```typescript
|
|
131
|
+
```typescript title="src/example-high-faithfulness.ts" showLineNumbers copy
|
|
124
132
|
import { createFaithfulnessScorer } from "@mastra/evals/scorers/llm";
|
|
125
133
|
|
|
126
134
|
const scorer = createFaithfulnessScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
@@ -157,7 +165,7 @@ The output receives a score of 1 because all the information it provides can be
|
|
|
157
165
|
|
|
158
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.
|
|
159
167
|
|
|
160
|
-
```typescript
|
|
168
|
+
```typescript title="src/example-mixed-faithfulness.ts" showLineNumbers copy
|
|
161
169
|
import { createFaithfulnessScorer } from "@mastra/evals/scorers/llm";
|
|
162
170
|
|
|
163
171
|
const scorer = createFaithfulnessScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
@@ -194,7 +202,7 @@ The score is lower because only a portion of the response is verifiable. While s
|
|
|
194
202
|
|
|
195
203
|
In this example, the response directly contradicts the context. None of the claims are supported, and several conflict with the facts provided.
|
|
196
204
|
|
|
197
|
-
```typescript
|
|
205
|
+
```typescript title="src/example-low-faithfulness.ts" showLineNumbers copy
|
|
198
206
|
import { createFaithfulnessScorer } from "@mastra/evals/scorers/llm";
|
|
199
207
|
|
|
200
208
|
const scorer = createFaithfulnessScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
@@ -230,4 +238,4 @@ Each claim is inaccurate or conflicts with the context, resulting in a score of
|
|
|
230
238
|
## Related
|
|
231
239
|
|
|
232
240
|
- [Answer Relevancy Scorer](./answer-relevancy)
|
|
233
|
-
- [Hallucination Scorer](./hallucination)
|
|
241
|
+
- [Hallucination Scorer](./hallucination)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Reference: Hallucination | Scorers | Mastra Docs"
|
|
2
|
+
title: "Reference: Hallucination Scorer | Scorers | Mastra Docs"
|
|
3
3
|
description: Documentation for the Hallucination Scorer in Mastra, which evaluates the factual correctness of LLM outputs by identifying contradictions with provided context.
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -17,7 +17,8 @@ The `createHallucinationScorer()` function accepts a single options object with
|
|
|
17
17
|
name: "model",
|
|
18
18
|
type: "LanguageModel",
|
|
19
19
|
required: true,
|
|
20
|
-
description:
|
|
20
|
+
description:
|
|
21
|
+
"Configuration for the model used to evaluate hallucination.",
|
|
21
22
|
},
|
|
22
23
|
{
|
|
23
24
|
name: "scale",
|
|
@@ -48,17 +49,20 @@ This function returns an instance of the MastraScorer class. The `.run()` method
|
|
|
48
49
|
{
|
|
49
50
|
name: "preprocessPrompt",
|
|
50
51
|
type: "string",
|
|
51
|
-
description:
|
|
52
|
+
description:
|
|
53
|
+
"The prompt sent to the LLM for the preprocess step (optional).",
|
|
52
54
|
},
|
|
53
55
|
{
|
|
54
56
|
name: "analyzeStepResult",
|
|
55
57
|
type: "object",
|
|
56
|
-
description:
|
|
58
|
+
description:
|
|
59
|
+
"Object with verdicts: { verdicts: Array<{ statement: string, verdict: 'yes' | 'no', reason: string }> }",
|
|
57
60
|
},
|
|
58
61
|
{
|
|
59
62
|
name: "analyzePrompt",
|
|
60
63
|
type: "string",
|
|
61
|
-
description:
|
|
64
|
+
description:
|
|
65
|
+
"The prompt sent to the LLM for the analyze step (optional).",
|
|
62
66
|
},
|
|
63
67
|
{
|
|
64
68
|
name: "score",
|
|
@@ -68,12 +72,14 @@ This function returns an instance of the MastraScorer class. The `.run()` method
|
|
|
68
72
|
{
|
|
69
73
|
name: "reason",
|
|
70
74
|
type: "string",
|
|
71
|
-
description:
|
|
75
|
+
description:
|
|
76
|
+
"Detailed explanation of the score and identified contradictions.",
|
|
72
77
|
},
|
|
73
78
|
{
|
|
74
79
|
name: "generateReasonPrompt",
|
|
75
80
|
type: "string",
|
|
76
|
-
description:
|
|
81
|
+
description:
|
|
82
|
+
"The prompt sent to the LLM for the generateReason step (optional).",
|
|
77
83
|
},
|
|
78
84
|
]}
|
|
79
85
|
/>
|
|
@@ -131,7 +137,7 @@ A hallucination score between 0 and 1:
|
|
|
131
137
|
|
|
132
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.
|
|
133
139
|
|
|
134
|
-
```typescript
|
|
140
|
+
```typescript title="src/example-no-hallucination.ts" showLineNumbers copy
|
|
135
141
|
import { createHallucinationScorer } from "@mastra/evals/scorers/llm";
|
|
136
142
|
|
|
137
143
|
const scorer = createHallucinationScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
@@ -168,7 +174,7 @@ The response receives a score of 0 because there are no contradictions. Every st
|
|
|
168
174
|
|
|
169
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.
|
|
170
176
|
|
|
171
|
-
```typescript
|
|
177
|
+
```typescript title="src/example-mixed-hallucination.ts" showLineNumbers copy
|
|
172
178
|
import { createHallucinationScorer } from "@mastra/evals/scorers/llm";
|
|
173
179
|
|
|
174
180
|
const scorer = createHallucinationScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
@@ -206,7 +212,7 @@ The Scorer assigns a mid-range score because parts of the response conflict with
|
|
|
206
212
|
|
|
207
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.
|
|
208
214
|
|
|
209
|
-
```typescript
|
|
215
|
+
```typescript title="src/example-complete-hallucination.ts" showLineNumbers copy
|
|
210
216
|
import { createHallucinationScorer } from "@mastra/evals/scorers/llm";
|
|
211
217
|
|
|
212
218
|
const scorer = createHallucinationScorer({ model: 'openai/gpt-4o-mini', options: {
|
|
@@ -240,8 +246,7 @@ The Scorer assigns a score of 1 because every statement in the response conflict
|
|
|
240
246
|
}
|
|
241
247
|
```
|
|
242
248
|
|
|
243
|
-
|
|
244
249
|
## Related
|
|
245
250
|
|
|
246
251
|
- [Faithfulness Scorer](./faithfulness)
|
|
247
|
-
- [Answer Relevancy Scorer](./answer-relevancy)
|
|
252
|
+
- [Answer Relevancy Scorer](./answer-relevancy)
|