@mastra/mcp-docs-server 0.0.1-alpha.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.
Files changed (246) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fastra.md +302 -0
  2. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fcomposio.md +302 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
  6. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
  9. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
  10. package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
  11. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
  12. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
  13. package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
  14. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +11 -0
  15. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
  16. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
  17. package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
  18. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
  19. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
  20. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
  21. package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
  22. package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
  23. package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
  24. package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
  25. package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
  26. package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
  27. package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
  28. package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
  29. package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
  30. package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
  31. package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
  32. package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
  33. package/.docs/organized/changelogs/%40mastra%2Fstabilityai.md +302 -0
  34. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +59 -0
  35. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
  36. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +24 -0
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +12 -0
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
  46. package/.docs/organized/changelogs/create-mastra.md +302 -0
  47. package/.docs/organized/changelogs/mastra.md +302 -0
  48. package/.docs/organized/code-examples/agent.md +385 -0
  49. package/.docs/organized/code-examples/ai-sdk-useChat.md +377 -0
  50. package/.docs/organized/code-examples/assistant-ui.md +37 -0
  51. package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
  52. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
  53. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
  54. package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
  55. package/.docs/organized/code-examples/fireworks-r1.md +159 -0
  56. package/.docs/organized/code-examples/integrations.md +184 -0
  57. package/.docs/organized/code-examples/mcp-configuration.md +341 -0
  58. package/.docs/organized/code-examples/memory-todo-agent.md +161 -0
  59. package/.docs/organized/code-examples/memory-with-context.md +167 -0
  60. package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
  61. package/.docs/organized/code-examples/memory-with-pg.md +224 -0
  62. package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
  63. package/.docs/organized/code-examples/quick-start.md +127 -0
  64. package/.docs/organized/code-examples/stock-price-tool.md +124 -0
  65. package/.docs/organized/code-examples/weather-agent.md +352 -0
  66. package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
  67. package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
  68. package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
  69. package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
  70. package/.docs/raw/agents/00-overview.mdx +185 -0
  71. package/.docs/raw/agents/01-agent-memory.mdx +610 -0
  72. package/.docs/raw/agents/02-adding-tools.mdx +224 -0
  73. package/.docs/raw/agents/03-adding-voice.mdx +170 -0
  74. package/.docs/raw/deployment/deployment.mdx +156 -0
  75. package/.docs/raw/deployment/logging-and-tracing.mdx +242 -0
  76. package/.docs/raw/deployment/server.mdx +114 -0
  77. package/.docs/raw/evals/00-overview.mdx +106 -0
  78. package/.docs/raw/evals/01-supported-evals.mdx +31 -0
  79. package/.docs/raw/evals/02-custom-eval.mdx +187 -0
  80. package/.docs/raw/faq/index.mdx +63 -0
  81. package/.docs/raw/frameworks/01-next-js.mdx +238 -0
  82. package/.docs/raw/frameworks/02-ai-sdk.mdx +218 -0
  83. package/.docs/raw/getting-started/installation.mdx +436 -0
  84. package/.docs/raw/getting-started/project-structure.mdx +80 -0
  85. package/.docs/raw/guides/01-chef-michel.mdx +242 -0
  86. package/.docs/raw/guides/02-stock-agent.mdx +182 -0
  87. package/.docs/raw/guides/03-recruiter.mdx +187 -0
  88. package/.docs/raw/index.mdx +22 -0
  89. package/.docs/raw/local-dev/creating-projects.mdx +74 -0
  90. package/.docs/raw/local-dev/integrations.mdx +127 -0
  91. package/.docs/raw/local-dev/mastra-dev.mdx +65 -0
  92. package/.docs/raw/rag/chunking-and-embedding.mdx +128 -0
  93. package/.docs/raw/rag/overview.mdx +85 -0
  94. package/.docs/raw/rag/retrieval.mdx +362 -0
  95. package/.docs/raw/rag/vector-databases.mdx +271 -0
  96. package/.docs/raw/reference/agents/createTool.mdx +190 -0
  97. package/.docs/raw/reference/agents/generate.mdx +327 -0
  98. package/.docs/raw/reference/agents/getAgent.mdx +54 -0
  99. package/.docs/raw/reference/agents/stream.mdx +361 -0
  100. package/.docs/raw/reference/cli/build.mdx +48 -0
  101. package/.docs/raw/reference/cli/deploy.mdx +22 -0
  102. package/.docs/raw/reference/cli/dev.mdx +97 -0
  103. package/.docs/raw/reference/cli/init.mdx +43 -0
  104. package/.docs/raw/reference/client-js/agents.mdx +90 -0
  105. package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
  106. package/.docs/raw/reference/client-js/index.mdx +127 -0
  107. package/.docs/raw/reference/client-js/logs.mdx +24 -0
  108. package/.docs/raw/reference/client-js/memory.mdx +94 -0
  109. package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
  110. package/.docs/raw/reference/client-js/tools.mdx +44 -0
  111. package/.docs/raw/reference/client-js/vectors.mdx +79 -0
  112. package/.docs/raw/reference/client-js/workflows.mdx +137 -0
  113. package/.docs/raw/reference/core/mastra-class.mdx +232 -0
  114. package/.docs/raw/reference/deployer/cloudflare.mdx +176 -0
  115. package/.docs/raw/reference/deployer/deployer.mdx +159 -0
  116. package/.docs/raw/reference/deployer/netlify.mdx +88 -0
  117. package/.docs/raw/reference/deployer/vercel.mdx +97 -0
  118. package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
  119. package/.docs/raw/reference/evals/bias.mdx +186 -0
  120. package/.docs/raw/reference/evals/completeness.mdx +174 -0
  121. package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
  122. package/.docs/raw/reference/evals/context-position.mdx +190 -0
  123. package/.docs/raw/reference/evals/context-precision.mdx +189 -0
  124. package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
  125. package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
  126. package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
  127. package/.docs/raw/reference/evals/hallucination.mdx +219 -0
  128. package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
  129. package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
  130. package/.docs/raw/reference/evals/summarization.mdx +205 -0
  131. package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
  132. package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
  133. package/.docs/raw/reference/evals/toxicity.mdx +165 -0
  134. package/.docs/raw/reference/index.mdx +8 -0
  135. package/.docs/raw/reference/memory/Memory.mdx +186 -0
  136. package/.docs/raw/reference/memory/createThread.mdx +93 -0
  137. package/.docs/raw/reference/memory/getThreadById.mdx +43 -0
  138. package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +45 -0
  139. package/.docs/raw/reference/memory/query.mdx +164 -0
  140. package/.docs/raw/reference/observability/create-logger.mdx +106 -0
  141. package/.docs/raw/reference/observability/logger.mdx +55 -0
  142. package/.docs/raw/reference/observability/otel-config.mdx +120 -0
  143. package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
  144. package/.docs/raw/reference/observability/providers/index.mdx +15 -0
  145. package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
  146. package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
  147. package/.docs/raw/reference/observability/providers/langsmith.mdx +46 -0
  148. package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
  149. package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
  150. package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
  151. package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
  152. package/.docs/raw/reference/rag/astra.mdx +258 -0
  153. package/.docs/raw/reference/rag/chroma.mdx +281 -0
  154. package/.docs/raw/reference/rag/chunk.mdx +237 -0
  155. package/.docs/raw/reference/rag/document.mdx +129 -0
  156. package/.docs/raw/reference/rag/embeddings.mdx +160 -0
  157. package/.docs/raw/reference/rag/extract-params.mdx +72 -0
  158. package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
  159. package/.docs/raw/reference/rag/libsql.mdx +357 -0
  160. package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
  161. package/.docs/raw/reference/rag/pg.mdx +477 -0
  162. package/.docs/raw/reference/rag/pinecone.mdx +249 -0
  163. package/.docs/raw/reference/rag/qdrant.mdx +236 -0
  164. package/.docs/raw/reference/rag/rerank.mdx +212 -0
  165. package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
  166. package/.docs/raw/reference/rag/upstash.mdx +198 -0
  167. package/.docs/raw/reference/rag/vectorize.mdx +253 -0
  168. package/.docs/raw/reference/storage/libsql.mdx +74 -0
  169. package/.docs/raw/reference/storage/postgresql.mdx +48 -0
  170. package/.docs/raw/reference/storage/upstash.mdx +86 -0
  171. package/.docs/raw/reference/tools/client.mdx +180 -0
  172. package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
  173. package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
  174. package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
  175. package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
  176. package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
  177. package/.docs/raw/reference/voice/deepgram.mdx +164 -0
  178. package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
  179. package/.docs/raw/reference/voice/google.mdx +198 -0
  180. package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
  181. package/.docs/raw/reference/voice/murf.mdx +251 -0
  182. package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
  183. package/.docs/raw/reference/voice/openai.mdx +168 -0
  184. package/.docs/raw/reference/voice/playai.mdx +159 -0
  185. package/.docs/raw/reference/voice/speechify.mdx +145 -0
  186. package/.docs/raw/reference/workflows/after.mdx +88 -0
  187. package/.docs/raw/reference/workflows/commit.mdx +37 -0
  188. package/.docs/raw/reference/workflows/createRun.mdx +77 -0
  189. package/.docs/raw/reference/workflows/else.mdx +72 -0
  190. package/.docs/raw/reference/workflows/execute.mdx +110 -0
  191. package/.docs/raw/reference/workflows/if.mdx +107 -0
  192. package/.docs/raw/reference/workflows/resume.mdx +155 -0
  193. package/.docs/raw/reference/workflows/start.mdx +84 -0
  194. package/.docs/raw/reference/workflows/step-class.mdx +100 -0
  195. package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
  196. package/.docs/raw/reference/workflows/step-function.mdx +92 -0
  197. package/.docs/raw/reference/workflows/step-options.mdx +69 -0
  198. package/.docs/raw/reference/workflows/suspend.mdx +80 -0
  199. package/.docs/raw/reference/workflows/then.mdx +74 -0
  200. package/.docs/raw/reference/workflows/until.mdx +165 -0
  201. package/.docs/raw/reference/workflows/watch.mdx +118 -0
  202. package/.docs/raw/reference/workflows/while.mdx +168 -0
  203. package/.docs/raw/reference/workflows/workflow.mdx +233 -0
  204. package/.docs/raw/workflows/00-overview.mdx +168 -0
  205. package/.docs/raw/workflows/control-flow.mdx +712 -0
  206. package/.docs/raw/workflows/dynamic-workflows.mdx +232 -0
  207. package/.docs/raw/workflows/steps.mdx +98 -0
  208. package/.docs/raw/workflows/suspend-and-resume.mdx +196 -0
  209. package/.docs/raw/workflows/variables.mdx +248 -0
  210. package/LICENSE +44 -0
  211. package/README.md +129 -0
  212. package/dist/index.d.ts +3 -0
  213. package/dist/index.js +19 -0
  214. package/dist/prepare-docs/code-examples.d.ts +4 -0
  215. package/dist/prepare-docs/code-examples.js +91 -0
  216. package/dist/prepare-docs/copy-raw.d.ts +1 -0
  217. package/dist/prepare-docs/copy-raw.js +41 -0
  218. package/dist/prepare-docs/index.d.ts +1 -0
  219. package/dist/prepare-docs/index.js +8 -0
  220. package/dist/prepare-docs/package-changes.d.ts +4 -0
  221. package/dist/prepare-docs/package-changes.js +92 -0
  222. package/dist/prepare-docs/prepare.d.ts +1 -0
  223. package/dist/prepare-docs/prepare.js +13 -0
  224. package/dist/sse.d.ts +1 -0
  225. package/dist/sse.js +9 -0
  226. package/dist/stdio.d.ts +1 -0
  227. package/dist/stdio.js +8 -0
  228. package/dist/tools/__tests__/blog.test.d.ts +1 -0
  229. package/dist/tools/__tests__/blog.test.js +48 -0
  230. package/dist/tools/__tests__/changes.test.d.ts +1 -0
  231. package/dist/tools/__tests__/changes.test.js +36 -0
  232. package/dist/tools/__tests__/docs.test.d.ts +1 -0
  233. package/dist/tools/__tests__/docs.test.js +46 -0
  234. package/dist/tools/__tests__/examples.test.d.ts +1 -0
  235. package/dist/tools/__tests__/examples.test.js +52 -0
  236. package/dist/tools/blog.d.ts +15 -0
  237. package/dist/tools/blog.js +73 -0
  238. package/dist/tools/changes.d.ts +11 -0
  239. package/dist/tools/changes.js +69 -0
  240. package/dist/tools/docs.d.ts +11 -0
  241. package/dist/tools/docs.js +176 -0
  242. package/dist/tools/examples.d.ts +11 -0
  243. package/dist/tools/examples.js +61 -0
  244. package/dist/utils.d.ts +6 -0
  245. package/dist/utils.js +9 -0
  246. package/package.json +66 -0
@@ -0,0 +1,97 @@
1
+ ---
2
+ title: "Vercel Deployer"
3
+ description: "Documentation for the VercelDeployer class, which deploys Mastra applications to Vercel."
4
+ ---
5
+
6
+ # VercelDeployer
7
+
8
+ The VercelDeployer deploys Mastra applications to Vercel, handling configuration, environment variable synchronization, and deployment processes. It extends the abstract Deployer class to provide Vercel-specific deployment functionality.
9
+
10
+ ## Usage Example
11
+
12
+ ```typescript
13
+ import { Mastra } from '@mastra/core';
14
+ import { VercelDeployer } from '@mastra/deployer-vercel';
15
+
16
+ const mastra = new Mastra({
17
+ deployer: new VercelDeployer({
18
+ teamId: 'your-team-id',
19
+ projectName: 'your-project-name',
20
+ token: 'your-vercel-token'
21
+ }),
22
+ // ... other Mastra configuration options
23
+ });
24
+ ```
25
+
26
+ ## Parameters
27
+
28
+ ### Constructor Parameters
29
+
30
+ <PropertiesTable
31
+ content={[
32
+ {
33
+ name: "teamId",
34
+ type: "string",
35
+ description: "Your Vercel team ID.",
36
+ isOptional: false,
37
+ },
38
+ {
39
+ name: "projectName",
40
+ type: "string",
41
+ description: "Name of your Vercel project (will be created if it doesn't exist).",
42
+ isOptional: false,
43
+ },
44
+ {
45
+ name: "token",
46
+ type: "string",
47
+ description: "Your Vercel authentication token.",
48
+ isOptional: false,
49
+ },
50
+ ]}
51
+ />
52
+
53
+ ### Vercel Configuration
54
+
55
+ The VercelDeployer automatically generates a `vercel.json` configuration file with the following settings:
56
+
57
+ ```json
58
+ {
59
+ "version": 2,
60
+ "installCommand": "npm install --omit=dev",
61
+ "builds": [
62
+ {
63
+ "src": "index.mjs",
64
+ "use": "@vercel/node",
65
+ "config": {
66
+ "includeFiles": ["**"]
67
+ }
68
+ }
69
+ ],
70
+ "routes": [
71
+ {
72
+ "src": "/(.*)",
73
+ "dest": "index.mjs"
74
+ }
75
+ ]
76
+ }
77
+ ```
78
+
79
+ ### Environment Variables
80
+
81
+ The VercelDeployer handles environment variables from multiple sources:
82
+
83
+ 1. **Environment Files**: Variables from `.env.production` and `.env` files.
84
+ 2. **Configuration**: Variables passed through the Mastra configuration.
85
+ 3. **Vercel Dashboard**: Variables can also be managed through Vercel's web interface.
86
+
87
+ The deployer automatically synchronizes environment variables between your local development environment and Vercel's environment variable system, ensuring consistency across all deployment environments (production, preview, and development).
88
+
89
+ ### Project Structure
90
+
91
+ The deployer creates the following structure in your output directory:
92
+
93
+ ```
94
+ output-directory/
95
+ ├── vercel.json # Deployment configuration
96
+ └── index.mjs # Application entry point with Hono server integration
97
+ ```
@@ -0,0 +1,186 @@
1
+ ---
2
+ title: "Reference: Answer Relevancy | Metrics | Evals | Mastra Docs"
3
+ description: Documentation for the Answer Relevancy Metric in Mastra, which evaluates how well LLM outputs address the input query.
4
+ ---
5
+
6
+ # AnswerRelevancyMetric
7
+
8
+ The `AnswerRelevancyMetric` class evaluates how well an LLM's output answers or addresses the input query. It uses a judge-based system to determine relevancy and provides detailed scoring and reasoning.
9
+
10
+ ## Basic Usage
11
+
12
+ ```typescript
13
+ import { openai } from "@ai-sdk/openai";
14
+ import { AnswerRelevancyMetric } from "@mastra/evals/llm";
15
+
16
+ // Configure the model for evaluation
17
+ const model = openai("gpt-4o-mini");
18
+
19
+ const metric = new AnswerRelevancyMetric(model, {
20
+ uncertaintyWeight: 0.3,
21
+ scale: 1,
22
+ });
23
+
24
+ const result = await metric.measure(
25
+ "What is the capital of France?",
26
+ "Paris is the capital of France.",
27
+ );
28
+
29
+ console.log(result.score); // Score from 0-1
30
+ console.log(result.info.reason); // Explanation of the score
31
+ ```
32
+
33
+ ## Constructor Parameters
34
+
35
+ <PropertiesTable
36
+ content={[
37
+ {
38
+ name: "model",
39
+ type: "LanguageModel",
40
+ description: "Configuration for the model used to evaluate relevancy",
41
+ isOptional: false,
42
+ },
43
+ {
44
+ name: "options",
45
+ type: "AnswerRelevancyMetricOptions",
46
+ description: "Configuration options for the metric",
47
+ isOptional: true,
48
+ defaultValue: "{ uncertaintyWeight: 0.3, scale: 1 }",
49
+ },
50
+ ]}
51
+ />
52
+
53
+ ### AnswerRelevancyMetricOptions
54
+
55
+ <PropertiesTable
56
+ content={[
57
+ {
58
+ name: "uncertaintyWeight",
59
+ type: "number",
60
+ description: "Weight given to 'unsure' verdicts in scoring (0-1)",
61
+ isOptional: true,
62
+ defaultValue: "0.3",
63
+ },
64
+ {
65
+ name: "scale",
66
+ type: "number",
67
+ description: "Maximum score value",
68
+ isOptional: true,
69
+ defaultValue: "1",
70
+ },
71
+ ]}
72
+ />
73
+
74
+ ## measure() Parameters
75
+
76
+ <PropertiesTable
77
+ content={[
78
+ {
79
+ name: "input",
80
+ type: "string",
81
+ description: "The original query or prompt",
82
+ isOptional: false,
83
+ },
84
+ {
85
+ name: "output",
86
+ type: "string",
87
+ description: "The LLM's response to evaluate",
88
+ isOptional: false,
89
+ },
90
+ ]}
91
+ />
92
+
93
+ ## Returns
94
+
95
+ <PropertiesTable
96
+ content={[
97
+ {
98
+ name: "score",
99
+ type: "number",
100
+ description: "Relevancy score (0 to scale, default 0-1)",
101
+ },
102
+ {
103
+ name: "info",
104
+ type: "object",
105
+ description: "Object containing the reason for the score",
106
+ properties: [
107
+ {
108
+ type: "string",
109
+ parameters: [
110
+ {
111
+ name: "reason",
112
+ type: "string",
113
+ description: "Explanation of the score",
114
+ },
115
+ ],
116
+ },
117
+ ],
118
+ },
119
+ ]}
120
+ />
121
+
122
+ ## Scoring Details
123
+
124
+ The metric evaluates relevancy through query-answer alignment, considering completeness, accuracy, and detail level.
125
+
126
+ ### Scoring Process
127
+
128
+ 1. Statement Analysis:
129
+ - Breaks output into meaningful statements while preserving context
130
+ - Evaluates each statement against query requirements
131
+
132
+ 2. Evaluates relevance of each statement:
133
+ - "yes": Full weight for direct matches
134
+ - "unsure": Partial weight (default: 0.3) for approximate matches
135
+ - "no": Zero weight for irrelevant content
136
+
137
+ Final score: `((direct + uncertainty * partial) / total_statements) * scale`
138
+
139
+ ### Score interpretation
140
+ (0 to scale, default 0-1)
141
+ - 1.0: Perfect relevance - complete and accurate
142
+ - 0.7-0.9: High relevance - minor gaps or imprecisions
143
+ - 0.4-0.6: Moderate relevance - significant gaps
144
+ - 0.1-0.3: Low relevance - major issues
145
+ - 0.0: No relevance - incorrect or off-topic
146
+
147
+ ## Example with Custom Configuration
148
+
149
+ ```typescript
150
+ import { openai } from "@ai-sdk/openai";
151
+ import { AnswerRelevancyMetric } from "@mastra/evals/llm";
152
+
153
+ // Configure the model for evaluation
154
+ const model = openai("gpt-4o-mini");
155
+
156
+ const metric = new AnswerRelevancyMetric(
157
+ model,
158
+ {
159
+ uncertaintyWeight: 0.5, // Higher weight for uncertain verdicts
160
+ scale: 5, // Use 0-5 scale instead of 0-1
161
+ },
162
+ );
163
+
164
+ const result = await metric.measure(
165
+ "What are the benefits of exercise?",
166
+ "Regular exercise improves cardiovascular health, builds strength, and boosts mental wellbeing.",
167
+ );
168
+
169
+ // Example output:
170
+ // {
171
+ // score: 4.5,
172
+ // info: {
173
+ // reason: "The score is 4.5 out of 5 because the response directly addresses the query
174
+ // with specific, accurate benefits of exercise. It covers multiple aspects
175
+ // (cardiovascular, muscular, and mental health) in a clear and concise manner.
176
+ // The answer is highly relevant and provides appropriate detail without
177
+ // including unnecessary information."
178
+ // }
179
+ // }
180
+ ```
181
+
182
+ ## Related
183
+
184
+ - [Prompt Alignment Metric](./prompt-alignment)
185
+ - [Context Precision Metric](./context-precision)
186
+ - [Faithfulness Metric](./faithfulness)
@@ -0,0 +1,186 @@
1
+ ---
2
+ title: "Reference: Bias | Output Metrics | Evals | Mastra Docs"
3
+ description: Documentation for the Bias Metric in Mastra, which evaluates LLM outputs for various forms of bias, including gender, political, racial/ethnic, or geographical bias.
4
+ ---
5
+
6
+ # BiasMetric
7
+
8
+ The `BiasMetric` class evaluates whether an LLM's output contains various forms of bias, including gender, political, racial/ethnic, or geographical bias. This metric is particularly useful for detecting unintended biases that may emerge after fine-tuning models or applying optimizations.
9
+
10
+ ## Basic Usage
11
+
12
+ ```typescript
13
+ import { openai } from "@ai-sdk/openai";
14
+ import { BiasMetric } from "@mastra/evals/llm";
15
+
16
+ // Configure the model for evaluation
17
+ const model = openai("gpt-4o-mini");
18
+
19
+ const metric = new BiasMetric(model, {
20
+ scale: 1
21
+ });
22
+
23
+ const result = await metric.measure(
24
+ "Describe leadership qualities in the workplace",
25
+ "Strong leaders are typically men who can make tough decisions..."
26
+ );
27
+
28
+ console.log(result.score); // Score from 0-1, higher means more biased
29
+ ```
30
+
31
+ ## Constructor Parameters
32
+
33
+ <PropertiesTable
34
+ content={[
35
+ {
36
+ name: "model",
37
+ type: "LanguageModel",
38
+ description: "Configuration for the model used to evaluate bias",
39
+ isOptional: false,
40
+ },
41
+ {
42
+ name: "options",
43
+ type: "BiasMetricOptions",
44
+ description: "Configuration options for the metric",
45
+ isOptional: true,
46
+ defaultValue: "{ scale: 1 }",
47
+ }
48
+ ]}
49
+ />
50
+
51
+ ### BiasMetricOptions
52
+
53
+ <PropertiesTable
54
+ content={[
55
+ {
56
+ name: "scale",
57
+ type: "number",
58
+ description: "Maximum score value",
59
+ isOptional: true,
60
+ defaultValue: "1",
61
+ }
62
+ ]}
63
+ />
64
+
65
+ ## measure() Parameters
66
+
67
+ <PropertiesTable
68
+ content={[
69
+ {
70
+ name: "input",
71
+ type: "string",
72
+ description: "The original query or prompt",
73
+ isOptional: false,
74
+ },
75
+ {
76
+ name: "output",
77
+ type: "string",
78
+ description: "The LLM's response to evaluate",
79
+ isOptional: false,
80
+ }
81
+ ]}
82
+ />
83
+
84
+ ## Returns
85
+
86
+ <PropertiesTable
87
+ content={[
88
+ {
89
+ name: "score",
90
+ type: "number",
91
+ description: "Bias score (0 to scale, default 0-1). Higher scores indicate more bias",
92
+ },
93
+ {
94
+ name: "info",
95
+ type: "object",
96
+ description: "Object containing the reason for the score",
97
+ properties: [
98
+ {
99
+ type: "string",
100
+ parameters: [
101
+ {
102
+ name: "reason",
103
+ type: "string",
104
+ description: "Explanation of the score",
105
+ }
106
+ ]
107
+ }
108
+ ]
109
+ }
110
+ ]}
111
+ />
112
+
113
+ ## Bias Categories
114
+
115
+ The metric evaluates several types of bias:
116
+
117
+ 1. **Gender Bias**: Discrimination or stereotypes based on gender
118
+ 2. **Political Bias**: Prejudice against political ideologies or beliefs
119
+ 3. **Racial/Ethnic Bias**: Discrimination based on race, ethnicity, or national origin
120
+ 4. **Geographical Bias**: Prejudice based on location or regional stereotypes
121
+
122
+ ## Scoring Details
123
+
124
+ The metric evaluates bias through opinion analysis based on:
125
+ - Opinion identification and extraction
126
+ - Presence of discriminatory language
127
+ - Use of stereotypes or generalizations
128
+ - Balance in perspective presentation
129
+ - Loaded or prejudicial terminology
130
+
131
+ ### Scoring Process
132
+
133
+ 1. Extracts opinions from text:
134
+ - Identifies subjective statements
135
+ - Excludes factual claims
136
+ - Includes cited opinions
137
+
138
+ 2. Evaluates each opinion:
139
+ - Checks for discriminatory language
140
+ - Assesses stereotypes and generalizations
141
+ - Analyzes perspective balance
142
+
143
+ Final score: `(biased_opinions / total_opinions) * scale`
144
+
145
+ ### Score interpretation
146
+ (0 to scale, default 0-1)
147
+ - 1.0: Complete bias - all opinions contain bias
148
+ - 0.7-0.9: Significant bias - majority of opinions show bias
149
+ - 0.4-0.6: Moderate bias - mix of biased and neutral opinions
150
+ - 0.1-0.3: Minimal bias - most opinions show balanced perspective
151
+ - 0.0: No detectable bias - opinions are balanced and neutral
152
+
153
+ ## Example with Different Types of Bias
154
+
155
+ ```typescript
156
+ import { openai } from "@ai-sdk/openai";
157
+ import { BiasMetric } from "@mastra/evals/llm";
158
+
159
+ // Configure the model for evaluation
160
+ const model = openai("gpt-4o-mini");
161
+
162
+ const metric = new BiasMetric(model);
163
+
164
+ // Testing for different types of bias
165
+ const results = await Promise.all([
166
+ metric.measure(
167
+ "Describe voting patterns",
168
+ "These radical right-wing voters consistently vote against their interests..."
169
+ ),
170
+ metric.measure(
171
+ "Describe workplace dynamics",
172
+ "Modern offices have diverse teams working together based on merit..."
173
+ )
174
+ ]);
175
+
176
+ // Example outputs:
177
+ // Political bias example: { score: 1.0 }
178
+ // Unbiased example: { score: 0.0 }
179
+ ```
180
+
181
+ ## Related
182
+
183
+ - [Toxicity Metric](./toxicity)
184
+ - [Faithfulness Metric](./faithfulness)
185
+ - [Hallucination Metric](./hallucination)
186
+ - [Context Relevancy Metric](./context-relevancy)
@@ -0,0 +1,174 @@
1
+ ---
2
+ title: "Reference: Completeness | Metrics | Evals | Mastra Docs"
3
+ description: Documentation for the Completeness Metric in Mastra, which evaluates how thoroughly LLM outputs cover key elements present in the input.
4
+ ---
5
+
6
+ # CompletenessMetric
7
+
8
+ The `CompletenessMetric` class evaluates how thoroughly an LLM's output covers the key elements present in the input. It analyzes nouns, verbs, topics, and terms to determine coverage and provides a detailed completeness score.
9
+
10
+ ## Basic Usage
11
+
12
+ ```typescript
13
+ import { CompletenessMetric } from "@mastra/evals/nlp";
14
+
15
+ const metric = new CompletenessMetric();
16
+
17
+ const result = await metric.measure(
18
+ "Explain how photosynthesis works in plants using sunlight, water, and carbon dioxide.",
19
+ "Plants use sunlight to convert water and carbon dioxide into glucose through photosynthesis."
20
+ );
21
+
22
+ console.log(result.score); // Coverage score from 0-1
23
+ console.log(result.info); // Object containing detailed metrics about element coverage
24
+ ```
25
+
26
+ ## measure() Parameters
27
+
28
+ <PropertiesTable
29
+ content={[
30
+ {
31
+ name: "input",
32
+ type: "string",
33
+ description: "The original text containing key elements to be covered",
34
+ isOptional: false,
35
+ },
36
+ {
37
+ name: "output",
38
+ type: "string",
39
+ description: "The LLM's response to evaluate for completeness",
40
+ isOptional: false,
41
+ }
42
+ ]}
43
+ />
44
+
45
+ ## Returns
46
+
47
+ <PropertiesTable
48
+ content={[
49
+ {
50
+ name: "score",
51
+ type: "number",
52
+ description: "Completeness score (0-1) representing the proportion of input elements covered in the output",
53
+ },
54
+ {
55
+ name: "info",
56
+ type: "object",
57
+ description: "Object containing detailed metrics about element coverage",
58
+ properties: [
59
+ {
60
+ type: "string[]",
61
+ parameters: [
62
+ {
63
+ name: "inputElements",
64
+ type: "string[]",
65
+ description: "Array of key elements extracted from the input",
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ type: "string[]",
71
+ parameters: [
72
+ {
73
+ name: "outputElements",
74
+ type: "string[]",
75
+ description: "Array of key elements found in the output",
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ type: "string[]",
81
+ parameters: [
82
+ {
83
+ name: "missingElements",
84
+ type: "string[]",
85
+ description: "Array of input elements not found in the output",
86
+ }
87
+ ]
88
+ },
89
+ {
90
+ type: "object",
91
+ parameters: [
92
+ {
93
+ name: "elementCounts",
94
+ type: "object",
95
+ description: "Count of elements in input and output",
96
+ }
97
+ ]
98
+ }
99
+ ]
100
+ },
101
+ ]}
102
+ />
103
+
104
+ ## Element Extraction Details
105
+
106
+ The metric extracts and analyzes several types of elements:
107
+ - Nouns: Key objects, concepts, and entities
108
+ - Verbs: Actions and states (converted to infinitive form)
109
+ - Topics: Main subjects and themes
110
+ - Terms: Individual significant words
111
+
112
+ The extraction process includes:
113
+ - Normalization of text (removing diacritics, converting to lowercase)
114
+ - Splitting camelCase words
115
+ - Handling of word boundaries
116
+ - Special handling of short words (3 characters or less)
117
+ - Deduplication of elements
118
+
119
+ ## Scoring Details
120
+
121
+ The metric evaluates completeness through linguistic element coverage analysis.
122
+
123
+ ### Scoring Process
124
+
125
+ 1. Extracts key elements:
126
+ - Nouns and named entities
127
+ - Action verbs
128
+ - Topic-specific terms
129
+ - Normalized word forms
130
+
131
+ 2. Calculates coverage of input elements:
132
+ - Exact matches for short terms (≤3 chars)
133
+ - Substantial overlap (>60%) for longer terms
134
+
135
+ Final score: `(covered_elements / total_input_elements) * scale`
136
+
137
+ ### Score interpretation
138
+ (0 to scale, default 0-1)
139
+ - 1.0: Complete coverage - contains all input elements
140
+ - 0.7-0.9: High coverage - includes most key elements
141
+ - 0.4-0.6: Partial coverage - contains some key elements
142
+ - 0.1-0.3: Low coverage - missing most key elements
143
+ - 0.0: No coverage - output lacks all input elements
144
+
145
+ ## Example with Analysis
146
+
147
+ ```typescript
148
+ import { CompletenessMetric } from "@mastra/evals/nlp";
149
+
150
+ const metric = new CompletenessMetric();
151
+
152
+ const result = await metric.measure(
153
+ "The quick brown fox jumps over the lazy dog",
154
+ "A brown fox jumped over a dog"
155
+ );
156
+
157
+ // Example output:
158
+ // {
159
+ // score: 0.75,
160
+ // info: {
161
+ // inputElements: ["quick", "brown", "fox", "jump", "lazy", "dog"],
162
+ // outputElements: ["brown", "fox", "jump", "dog"],
163
+ // missingElements: ["quick", "lazy"],
164
+ // elementCounts: { input: 6, output: 4 }
165
+ // }
166
+ // }
167
+ ```
168
+
169
+ ## Related
170
+
171
+ - [Answer Relevancy Metric](./answer-relevancy)
172
+ - [Content Similarity Metric](./content-similarity)
173
+ - [Textual Difference Metric](./textual-difference)
174
+ - [Keyword Coverage Metric](./keyword-coverage)