@mastra/mcp-docs-server 1.1.4 → 1.1.5
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/CHANGELOG.md +14 -0
- package/package.json +5 -5
- package/.docs/docs/agents/adding-voice.md +0 -353
- package/.docs/docs/agents/agent-approval.md +0 -377
- package/.docs/docs/agents/agent-memory.md +0 -212
- package/.docs/docs/agents/guardrails.md +0 -382
- package/.docs/docs/agents/network-approval.md +0 -275
- package/.docs/docs/agents/networks.md +0 -290
- package/.docs/docs/agents/overview.md +0 -309
- package/.docs/docs/agents/processors.md +0 -632
- package/.docs/docs/agents/structured-output.md +0 -271
- package/.docs/docs/agents/using-tools.md +0 -214
- package/.docs/docs/build-with-ai/mcp-docs-server.md +0 -241
- package/.docs/docs/build-with-ai/skills.md +0 -35
- package/.docs/docs/community/contributing-templates.md +0 -3
- package/.docs/docs/community/discord.md +0 -9
- package/.docs/docs/community/licensing.md +0 -66
- package/.docs/docs/deployment/cloud-providers.md +0 -15
- package/.docs/docs/deployment/mastra-server.md +0 -122
- package/.docs/docs/deployment/monorepo.md +0 -142
- package/.docs/docs/deployment/overview.md +0 -62
- package/.docs/docs/deployment/studio.md +0 -234
- package/.docs/docs/deployment/web-framework.md +0 -52
- package/.docs/docs/deployment/workflow-runners.md +0 -9
- package/.docs/docs/evals/built-in-scorers.md +0 -47
- package/.docs/docs/evals/custom-scorers.md +0 -519
- package/.docs/docs/evals/overview.md +0 -146
- package/.docs/docs/evals/running-in-ci.md +0 -106
- package/.docs/docs/getting-started/build-with-ai.md +0 -68
- package/.docs/docs/getting-started/manual-install.md +0 -226
- package/.docs/docs/getting-started/project-structure.md +0 -60
- package/.docs/docs/getting-started/start.md +0 -28
- package/.docs/docs/getting-started/studio.md +0 -101
- package/.docs/docs/index.md +0 -43
- package/.docs/docs/mastra-cloud/deployment.md +0 -77
- package/.docs/docs/mastra-cloud/observability.md +0 -38
- package/.docs/docs/mastra-cloud/overview.md +0 -23
- package/.docs/docs/mastra-cloud/setup.md +0 -42
- package/.docs/docs/mastra-cloud/studio.md +0 -24
- package/.docs/docs/mcp/overview.md +0 -370
- package/.docs/docs/mcp/publishing-mcp-server.md +0 -95
- package/.docs/docs/memory/memory-processors.md +0 -316
- package/.docs/docs/memory/message-history.md +0 -260
- package/.docs/docs/memory/observational-memory.md +0 -246
- package/.docs/docs/memory/overview.md +0 -45
- package/.docs/docs/memory/semantic-recall.md +0 -272
- package/.docs/docs/memory/storage.md +0 -261
- package/.docs/docs/memory/working-memory.md +0 -400
- package/.docs/docs/observability/datasets/overview.md +0 -188
- package/.docs/docs/observability/datasets/running-experiments.md +0 -266
- package/.docs/docs/observability/logging.md +0 -99
- package/.docs/docs/observability/overview.md +0 -70
- package/.docs/docs/observability/tracing/bridges/otel.md +0 -209
- package/.docs/docs/observability/tracing/exporters/arize.md +0 -274
- package/.docs/docs/observability/tracing/exporters/braintrust.md +0 -111
- package/.docs/docs/observability/tracing/exporters/cloud.md +0 -129
- package/.docs/docs/observability/tracing/exporters/datadog.md +0 -187
- package/.docs/docs/observability/tracing/exporters/default.md +0 -211
- package/.docs/docs/observability/tracing/exporters/laminar.md +0 -100
- package/.docs/docs/observability/tracing/exporters/langfuse.md +0 -217
- package/.docs/docs/observability/tracing/exporters/langsmith.md +0 -202
- package/.docs/docs/observability/tracing/exporters/otel.md +0 -479
- package/.docs/docs/observability/tracing/exporters/posthog.md +0 -148
- package/.docs/docs/observability/tracing/exporters/sentry.md +0 -208
- package/.docs/docs/observability/tracing/overview.md +0 -1114
- package/.docs/docs/observability/tracing/processors/sensitive-data-filter.md +0 -303
- package/.docs/docs/rag/chunking-and-embedding.md +0 -183
- package/.docs/docs/rag/graph-rag.md +0 -215
- package/.docs/docs/rag/overview.md +0 -72
- package/.docs/docs/rag/retrieval.md +0 -521
- package/.docs/docs/rag/vector-databases.md +0 -648
- package/.docs/docs/server/auth/auth0.md +0 -222
- package/.docs/docs/server/auth/better-auth.md +0 -203
- package/.docs/docs/server/auth/clerk.md +0 -132
- package/.docs/docs/server/auth/composite-auth.md +0 -234
- package/.docs/docs/server/auth/custom-auth-provider.md +0 -513
- package/.docs/docs/server/auth/firebase.md +0 -272
- package/.docs/docs/server/auth/jwt.md +0 -110
- package/.docs/docs/server/auth/simple-auth.md +0 -178
- package/.docs/docs/server/auth/supabase.md +0 -117
- package/.docs/docs/server/auth/workos.md +0 -190
- package/.docs/docs/server/auth.md +0 -38
- package/.docs/docs/server/custom-adapters.md +0 -374
- package/.docs/docs/server/custom-api-routes.md +0 -267
- package/.docs/docs/server/mastra-client.md +0 -243
- package/.docs/docs/server/mastra-server.md +0 -71
- package/.docs/docs/server/middleware.md +0 -228
- package/.docs/docs/server/request-context.md +0 -478
- package/.docs/docs/server/server-adapters.md +0 -547
- package/.docs/docs/streaming/events.md +0 -247
- package/.docs/docs/streaming/overview.md +0 -181
- package/.docs/docs/streaming/tool-streaming.md +0 -178
- package/.docs/docs/streaming/workflow-streaming.md +0 -109
- package/.docs/docs/voice/overview.md +0 -979
- package/.docs/docs/voice/speech-to-speech.md +0 -103
- package/.docs/docs/voice/speech-to-text.md +0 -80
- package/.docs/docs/voice/text-to-speech.md +0 -84
- package/.docs/docs/workflows/agents-and-tools.md +0 -170
- package/.docs/docs/workflows/control-flow.md +0 -823
- package/.docs/docs/workflows/error-handling.md +0 -360
- package/.docs/docs/workflows/human-in-the-loop.md +0 -213
- package/.docs/docs/workflows/overview.md +0 -372
- package/.docs/docs/workflows/snapshots.md +0 -238
- package/.docs/docs/workflows/suspend-and-resume.md +0 -205
- package/.docs/docs/workflows/time-travel.md +0 -309
- package/.docs/docs/workflows/workflow-state.md +0 -181
- package/.docs/docs/workspace/filesystem.md +0 -162
- package/.docs/docs/workspace/overview.md +0 -239
- package/.docs/docs/workspace/sandbox.md +0 -63
- package/.docs/docs/workspace/search.md +0 -219
- package/.docs/docs/workspace/skills.md +0 -126
- package/.docs/guides/agent-frameworks/ai-sdk.md +0 -140
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +0 -1463
- package/.docs/guides/build-your-ui/assistant-ui.md +0 -156
- package/.docs/guides/build-your-ui/copilotkit.md +0 -292
- package/.docs/guides/deployment/amazon-ec2.md +0 -130
- package/.docs/guides/deployment/aws-lambda.md +0 -248
- package/.docs/guides/deployment/azure-app-services.md +0 -114
- package/.docs/guides/deployment/cloudflare.md +0 -99
- package/.docs/guides/deployment/digital-ocean.md +0 -168
- package/.docs/guides/deployment/inngest.md +0 -685
- package/.docs/guides/deployment/netlify.md +0 -77
- package/.docs/guides/deployment/vercel.md +0 -101
- package/.docs/guides/getting-started/astro.md +0 -408
- package/.docs/guides/getting-started/electron.md +0 -504
- package/.docs/guides/getting-started/express.md +0 -251
- package/.docs/guides/getting-started/hono.md +0 -191
- package/.docs/guides/getting-started/next-js.md +0 -355
- package/.docs/guides/getting-started/nuxt.md +0 -476
- package/.docs/guides/getting-started/quickstart.md +0 -67
- package/.docs/guides/getting-started/sveltekit.md +0 -300
- package/.docs/guides/getting-started/vite-react.md +0 -439
- package/.docs/guides/guide/ai-recruiter.md +0 -227
- package/.docs/guides/guide/chef-michel.md +0 -215
- package/.docs/guides/guide/code-review-bot.md +0 -221
- package/.docs/guides/guide/dev-assistant.md +0 -304
- package/.docs/guides/guide/docs-manager.md +0 -238
- package/.docs/guides/guide/github-actions-pr-description.md +0 -236
- package/.docs/guides/guide/notes-mcp-server.md +0 -425
- package/.docs/guides/guide/research-assistant.md +0 -349
- package/.docs/guides/guide/stock-agent.md +0 -134
- package/.docs/guides/guide/web-search.md +0 -326
- package/.docs/guides/guide/whatsapp-chat-bot.md +0 -416
- package/.docs/guides/index.md +0 -3
- package/.docs/guides/migrations/agentnetwork.md +0 -101
- package/.docs/guides/migrations/ai-sdk-v4-to-v5.md +0 -112
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +0 -404
- package/.docs/guides/migrations/upgrade-to-v1/cli.md +0 -57
- package/.docs/guides/migrations/upgrade-to-v1/client.md +0 -337
- package/.docs/guides/migrations/upgrade-to-v1/deployment.md +0 -37
- package/.docs/guides/migrations/upgrade-to-v1/evals.md +0 -239
- package/.docs/guides/migrations/upgrade-to-v1/mastra.md +0 -143
- package/.docs/guides/migrations/upgrade-to-v1/mcp.md +0 -97
- package/.docs/guides/migrations/upgrade-to-v1/memory.md +0 -285
- package/.docs/guides/migrations/upgrade-to-v1/overview.md +0 -119
- package/.docs/guides/migrations/upgrade-to-v1/processors.md +0 -68
- package/.docs/guides/migrations/upgrade-to-v1/rag.md +0 -42
- package/.docs/guides/migrations/upgrade-to-v1/storage.md +0 -553
- package/.docs/guides/migrations/upgrade-to-v1/tools.md +0 -180
- package/.docs/guides/migrations/upgrade-to-v1/tracing.md +0 -417
- package/.docs/guides/migrations/upgrade-to-v1/vectors.md +0 -87
- package/.docs/guides/migrations/upgrade-to-v1/voice.md +0 -30
- package/.docs/guides/migrations/upgrade-to-v1/workflows.md +0 -341
- package/.docs/guides/migrations/vnext-to-standard-apis.md +0 -364
- package/.docs/models/embeddings.md +0 -161
- package/.docs/models/gateways/azure-openai.md +0 -128
- package/.docs/models/gateways/custom-gateways.md +0 -545
- package/.docs/models/gateways/netlify.md +0 -88
- package/.docs/models/gateways/openrouter.md +0 -219
- package/.docs/models/gateways/vercel.md +0 -225
- package/.docs/models/gateways.md +0 -14
- package/.docs/models/index.md +0 -286
- package/.docs/models/providers/302ai.md +0 -134
- package/.docs/models/providers/abacus.md +0 -125
- package/.docs/models/providers/agentrouter.md +0 -90
- package/.docs/models/providers/aihubmix.md +0 -107
- package/.docs/models/providers/alibaba-cn.md +0 -135
- package/.docs/models/providers/alibaba.md +0 -111
- package/.docs/models/providers/amazon-bedrock.md +0 -33
- package/.docs/models/providers/anthropic.md +0 -153
- package/.docs/models/providers/azure.md +0 -33
- package/.docs/models/providers/bailing.md +0 -72
- package/.docs/models/providers/baseten.md +0 -77
- package/.docs/models/providers/berget.md +0 -78
- package/.docs/models/providers/cerebras.md +0 -101
- package/.docs/models/providers/chutes.md +0 -136
- package/.docs/models/providers/cloudflare-ai-gateway.md +0 -33
- package/.docs/models/providers/cloudflare-workers-ai.md +0 -109
- package/.docs/models/providers/cohere.md +0 -33
- package/.docs/models/providers/cortecs.md +0 -91
- package/.docs/models/providers/deepinfra.md +0 -112
- package/.docs/models/providers/deepseek.md +0 -88
- package/.docs/models/providers/fastrouter.md +0 -84
- package/.docs/models/providers/fireworks-ai.md +0 -89
- package/.docs/models/providers/firmware.md +0 -85
- package/.docs/models/providers/friendli.md +0 -78
- package/.docs/models/providers/github-models.md +0 -125
- package/.docs/models/providers/google-vertex.md +0 -33
- package/.docs/models/providers/google.md +0 -159
- package/.docs/models/providers/groq.md +0 -107
- package/.docs/models/providers/helicone.md +0 -161
- package/.docs/models/providers/huggingface.md +0 -90
- package/.docs/models/providers/iflowcn.md +0 -84
- package/.docs/models/providers/inception.md +0 -72
- package/.docs/models/providers/inference.md +0 -79
- package/.docs/models/providers/io-intelligence.md +0 -87
- package/.docs/models/providers/io-net.md +0 -87
- package/.docs/models/providers/jiekou.md +0 -131
- package/.docs/models/providers/kilo.md +0 -333
- package/.docs/models/providers/kimi-for-coding.md +0 -100
- package/.docs/models/providers/kuae-cloud-coding-plan.md +0 -71
- package/.docs/models/providers/llama.md +0 -77
- package/.docs/models/providers/lmstudio.md +0 -73
- package/.docs/models/providers/lucidquery.md +0 -72
- package/.docs/models/providers/minimax-cn-coding-plan.md +0 -102
- package/.docs/models/providers/minimax-cn.md +0 -102
- package/.docs/models/providers/minimax-coding-plan.md +0 -102
- package/.docs/models/providers/minimax.md +0 -104
- package/.docs/models/providers/mistral.md +0 -124
- package/.docs/models/providers/moark.md +0 -72
- package/.docs/models/providers/modelscope.md +0 -77
- package/.docs/models/providers/moonshotai-cn.md +0 -76
- package/.docs/models/providers/moonshotai.md +0 -76
- package/.docs/models/providers/morph.md +0 -73
- package/.docs/models/providers/nano-gpt.md +0 -103
- package/.docs/models/providers/nebius.md +0 -116
- package/.docs/models/providers/nova.md +0 -72
- package/.docs/models/providers/novita-ai.md +0 -154
- package/.docs/models/providers/nvidia.md +0 -141
- package/.docs/models/providers/ollama-cloud.md +0 -103
- package/.docs/models/providers/ollama.md +0 -33
- package/.docs/models/providers/openai.md +0 -193
- package/.docs/models/providers/opencode.md +0 -100
- package/.docs/models/providers/ovhcloud.md +0 -83
- package/.docs/models/providers/perplexity.md +0 -100
- package/.docs/models/providers/poe.md +0 -183
- package/.docs/models/providers/privatemode-ai.md +0 -75
- package/.docs/models/providers/requesty.md +0 -90
- package/.docs/models/providers/scaleway.md +0 -84
- package/.docs/models/providers/siliconflow-cn.md +0 -138
- package/.docs/models/providers/siliconflow.md +0 -140
- package/.docs/models/providers/stackit.md +0 -78
- package/.docs/models/providers/stepfun.md +0 -73
- package/.docs/models/providers/submodel.md +0 -79
- package/.docs/models/providers/synthetic.md +0 -96
- package/.docs/models/providers/togetherai.md +0 -115
- package/.docs/models/providers/upstage.md +0 -73
- package/.docs/models/providers/venice.md +0 -95
- package/.docs/models/providers/vivgrid.md +0 -106
- package/.docs/models/providers/vultr.md +0 -75
- package/.docs/models/providers/wandb.md +0 -80
- package/.docs/models/providers/xai.md +0 -141
- package/.docs/models/providers/xiaomi.md +0 -71
- package/.docs/models/providers/zai-coding-plan.md +0 -80
- package/.docs/models/providers/zai.md +0 -79
- package/.docs/models/providers/zenmux.md +0 -161
- package/.docs/models/providers/zhipuai-coding-plan.md +0 -79
- package/.docs/models/providers/zhipuai.md +0 -79
- package/.docs/models/providers.md +0 -81
- package/.docs/reference/agents/agent.md +0 -142
- package/.docs/reference/agents/generate.md +0 -174
- package/.docs/reference/agents/generateLegacy.md +0 -176
- package/.docs/reference/agents/getDefaultGenerateOptions.md +0 -36
- package/.docs/reference/agents/getDefaultOptions.md +0 -34
- package/.docs/reference/agents/getDefaultStreamOptions.md +0 -36
- package/.docs/reference/agents/getDescription.md +0 -21
- package/.docs/reference/agents/getInstructions.md +0 -34
- package/.docs/reference/agents/getLLM.md +0 -37
- package/.docs/reference/agents/getMemory.md +0 -34
- package/.docs/reference/agents/getModel.md +0 -34
- package/.docs/reference/agents/getTools.md +0 -29
- package/.docs/reference/agents/getVoice.md +0 -34
- package/.docs/reference/agents/listAgents.md +0 -35
- package/.docs/reference/agents/listScorers.md +0 -34
- package/.docs/reference/agents/listTools.md +0 -34
- package/.docs/reference/agents/listWorkflows.md +0 -34
- package/.docs/reference/agents/network.md +0 -134
- package/.docs/reference/ai-sdk/chat-route.md +0 -82
- package/.docs/reference/ai-sdk/handle-chat-stream.md +0 -53
- package/.docs/reference/ai-sdk/handle-network-stream.md +0 -37
- package/.docs/reference/ai-sdk/handle-workflow-stream.md +0 -55
- package/.docs/reference/ai-sdk/network-route.md +0 -74
- package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +0 -232
- package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +0 -79
- package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +0 -73
- package/.docs/reference/ai-sdk/with-mastra.md +0 -59
- package/.docs/reference/ai-sdk/workflow-route.md +0 -79
- package/.docs/reference/auth/auth0.md +0 -73
- package/.docs/reference/auth/better-auth.md +0 -71
- package/.docs/reference/auth/clerk.md +0 -36
- package/.docs/reference/auth/firebase.md +0 -80
- package/.docs/reference/auth/jwt.md +0 -26
- package/.docs/reference/auth/supabase.md +0 -33
- package/.docs/reference/auth/workos.md +0 -84
- package/.docs/reference/cli/create-mastra.md +0 -137
- package/.docs/reference/cli/mastra.md +0 -336
- package/.docs/reference/client-js/agents.md +0 -438
- package/.docs/reference/client-js/error-handling.md +0 -16
- package/.docs/reference/client-js/logs.md +0 -24
- package/.docs/reference/client-js/mastra-client.md +0 -63
- package/.docs/reference/client-js/memory.md +0 -225
- package/.docs/reference/client-js/observability.md +0 -72
- package/.docs/reference/client-js/telemetry.md +0 -20
- package/.docs/reference/client-js/tools.md +0 -44
- package/.docs/reference/client-js/vectors.md +0 -79
- package/.docs/reference/client-js/workflows.md +0 -199
- package/.docs/reference/configuration.md +0 -749
- package/.docs/reference/core/addGateway.md +0 -42
- package/.docs/reference/core/getAgent.md +0 -21
- package/.docs/reference/core/getAgentById.md +0 -21
- package/.docs/reference/core/getDeployer.md +0 -22
- package/.docs/reference/core/getGateway.md +0 -38
- package/.docs/reference/core/getGatewayById.md +0 -41
- package/.docs/reference/core/getLogger.md +0 -22
- package/.docs/reference/core/getMCPServer.md +0 -45
- package/.docs/reference/core/getMCPServerById.md +0 -53
- package/.docs/reference/core/getMemory.md +0 -50
- package/.docs/reference/core/getScorer.md +0 -54
- package/.docs/reference/core/getScorerById.md +0 -54
- package/.docs/reference/core/getServer.md +0 -22
- package/.docs/reference/core/getStorage.md +0 -22
- package/.docs/reference/core/getStoredAgentById.md +0 -89
- package/.docs/reference/core/getTelemetry.md +0 -22
- package/.docs/reference/core/getVector.md +0 -22
- package/.docs/reference/core/getWorkflow.md +0 -40
- package/.docs/reference/core/listAgents.md +0 -21
- package/.docs/reference/core/listGateways.md +0 -40
- package/.docs/reference/core/listLogs.md +0 -38
- package/.docs/reference/core/listLogsByRunId.md +0 -36
- package/.docs/reference/core/listMCPServers.md +0 -51
- package/.docs/reference/core/listMemory.md +0 -56
- package/.docs/reference/core/listScorers.md +0 -29
- package/.docs/reference/core/listStoredAgents.md +0 -93
- package/.docs/reference/core/listVectors.md +0 -22
- package/.docs/reference/core/listWorkflows.md +0 -21
- package/.docs/reference/core/mastra-class.md +0 -66
- package/.docs/reference/core/mastra-model-gateway.md +0 -153
- package/.docs/reference/core/setLogger.md +0 -26
- package/.docs/reference/core/setStorage.md +0 -27
- package/.docs/reference/datasets/addItem.md +0 -35
- package/.docs/reference/datasets/addItems.md +0 -33
- package/.docs/reference/datasets/compareExperiments.md +0 -48
- package/.docs/reference/datasets/create.md +0 -49
- package/.docs/reference/datasets/dataset.md +0 -78
- package/.docs/reference/datasets/datasets-manager.md +0 -84
- package/.docs/reference/datasets/delete.md +0 -23
- package/.docs/reference/datasets/deleteExperiment.md +0 -25
- package/.docs/reference/datasets/deleteItem.md +0 -25
- package/.docs/reference/datasets/deleteItems.md +0 -27
- package/.docs/reference/datasets/get.md +0 -29
- package/.docs/reference/datasets/getDetails.md +0 -45
- package/.docs/reference/datasets/getExperiment.md +0 -28
- package/.docs/reference/datasets/getItem.md +0 -31
- package/.docs/reference/datasets/getItemHistory.md +0 -29
- package/.docs/reference/datasets/list.md +0 -29
- package/.docs/reference/datasets/listExperimentResults.md +0 -37
- package/.docs/reference/datasets/listExperiments.md +0 -31
- package/.docs/reference/datasets/listItems.md +0 -44
- package/.docs/reference/datasets/listVersions.md +0 -31
- package/.docs/reference/datasets/startExperiment.md +0 -60
- package/.docs/reference/datasets/startExperimentAsync.md +0 -41
- package/.docs/reference/datasets/update.md +0 -46
- package/.docs/reference/datasets/updateItem.md +0 -36
- package/.docs/reference/deployer/cloudflare.md +0 -79
- package/.docs/reference/deployer/netlify.md +0 -82
- package/.docs/reference/deployer/vercel.md +0 -91
- package/.docs/reference/deployer.md +0 -100
- package/.docs/reference/evals/answer-relevancy.md +0 -105
- package/.docs/reference/evals/answer-similarity.md +0 -99
- package/.docs/reference/evals/bias.md +0 -120
- package/.docs/reference/evals/completeness.md +0 -137
- package/.docs/reference/evals/content-similarity.md +0 -101
- package/.docs/reference/evals/context-precision.md +0 -196
- package/.docs/reference/evals/context-relevance.md +0 -536
- package/.docs/reference/evals/create-scorer.md +0 -270
- package/.docs/reference/evals/faithfulness.md +0 -114
- package/.docs/reference/evals/hallucination.md +0 -220
- package/.docs/reference/evals/keyword-coverage.md +0 -128
- package/.docs/reference/evals/mastra-scorer.md +0 -123
- package/.docs/reference/evals/noise-sensitivity.md +0 -685
- package/.docs/reference/evals/prompt-alignment.md +0 -619
- package/.docs/reference/evals/run-evals.md +0 -138
- package/.docs/reference/evals/scorer-utils.md +0 -330
- package/.docs/reference/evals/textual-difference.md +0 -113
- package/.docs/reference/evals/tone-consistency.md +0 -119
- package/.docs/reference/evals/tool-call-accuracy.md +0 -533
- package/.docs/reference/evals/toxicity.md +0 -123
- package/.docs/reference/harness/harness-class.md +0 -645
- package/.docs/reference/index.md +0 -276
- package/.docs/reference/logging/pino-logger.md +0 -117
- package/.docs/reference/memory/clone-utilities.md +0 -199
- package/.docs/reference/memory/cloneThread.md +0 -130
- package/.docs/reference/memory/createThread.md +0 -68
- package/.docs/reference/memory/deleteMessages.md +0 -40
- package/.docs/reference/memory/getThreadById.md +0 -24
- package/.docs/reference/memory/listThreads.md +0 -145
- package/.docs/reference/memory/memory-class.md +0 -147
- package/.docs/reference/memory/observational-memory.md +0 -565
- package/.docs/reference/memory/recall.md +0 -91
- package/.docs/reference/observability/tracing/bridges/otel.md +0 -131
- package/.docs/reference/observability/tracing/configuration.md +0 -178
- package/.docs/reference/observability/tracing/exporters/arize.md +0 -141
- package/.docs/reference/observability/tracing/exporters/braintrust.md +0 -93
- package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +0 -163
- package/.docs/reference/observability/tracing/exporters/console-exporter.md +0 -138
- package/.docs/reference/observability/tracing/exporters/datadog.md +0 -116
- package/.docs/reference/observability/tracing/exporters/default-exporter.md +0 -174
- package/.docs/reference/observability/tracing/exporters/laminar.md +0 -78
- package/.docs/reference/observability/tracing/exporters/langfuse.md +0 -134
- package/.docs/reference/observability/tracing/exporters/langsmith.md +0 -110
- package/.docs/reference/observability/tracing/exporters/otel.md +0 -199
- package/.docs/reference/observability/tracing/exporters/posthog.md +0 -92
- package/.docs/reference/observability/tracing/exporters/sentry.md +0 -184
- package/.docs/reference/observability/tracing/instances.md +0 -109
- package/.docs/reference/observability/tracing/interfaces.md +0 -749
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +0 -144
- package/.docs/reference/observability/tracing/spans.md +0 -224
- package/.docs/reference/processors/batch-parts-processor.md +0 -61
- package/.docs/reference/processors/language-detector.md +0 -81
- package/.docs/reference/processors/message-history-processor.md +0 -85
- package/.docs/reference/processors/moderation-processor.md +0 -104
- package/.docs/reference/processors/pii-detector.md +0 -107
- package/.docs/reference/processors/processor-interface.md +0 -525
- package/.docs/reference/processors/prompt-injection-detector.md +0 -71
- package/.docs/reference/processors/semantic-recall-processor.md +0 -123
- package/.docs/reference/processors/system-prompt-scrubber.md +0 -80
- package/.docs/reference/processors/token-limiter-processor.md +0 -113
- package/.docs/reference/processors/tool-call-filter.md +0 -85
- package/.docs/reference/processors/tool-search-processor.md +0 -113
- package/.docs/reference/processors/unicode-normalizer.md +0 -62
- package/.docs/reference/processors/working-memory-processor.md +0 -154
- package/.docs/reference/rag/chunk.md +0 -221
- package/.docs/reference/rag/database-config.md +0 -264
- package/.docs/reference/rag/document.md +0 -114
- package/.docs/reference/rag/embeddings.md +0 -92
- package/.docs/reference/rag/extract-params.md +0 -168
- package/.docs/reference/rag/graph-rag.md +0 -111
- package/.docs/reference/rag/metadata-filters.md +0 -216
- package/.docs/reference/rag/rerank.md +0 -80
- package/.docs/reference/rag/rerankWithScorer.md +0 -80
- package/.docs/reference/server/create-route.md +0 -260
- package/.docs/reference/server/express-adapter.md +0 -176
- package/.docs/reference/server/fastify-adapter.md +0 -90
- package/.docs/reference/server/hono-adapter.md +0 -162
- package/.docs/reference/server/koa-adapter.md +0 -127
- package/.docs/reference/server/mastra-server.md +0 -298
- package/.docs/reference/server/register-api-route.md +0 -249
- package/.docs/reference/server/routes.md +0 -306
- package/.docs/reference/storage/cloudflare-d1.md +0 -218
- package/.docs/reference/storage/cloudflare.md +0 -88
- package/.docs/reference/storage/composite.md +0 -235
- package/.docs/reference/storage/convex.md +0 -161
- package/.docs/reference/storage/dynamodb.md +0 -282
- package/.docs/reference/storage/lance.md +0 -131
- package/.docs/reference/storage/libsql.md +0 -135
- package/.docs/reference/storage/mongodb.md +0 -262
- package/.docs/reference/storage/mssql.md +0 -155
- package/.docs/reference/storage/overview.md +0 -121
- package/.docs/reference/storage/postgresql.md +0 -529
- package/.docs/reference/storage/upstash.md +0 -160
- package/.docs/reference/streaming/ChunkType.md +0 -292
- package/.docs/reference/streaming/agents/MastraModelOutput.md +0 -182
- package/.docs/reference/streaming/agents/stream.md +0 -212
- package/.docs/reference/streaming/agents/streamLegacy.md +0 -142
- package/.docs/reference/streaming/workflows/observeStream.md +0 -42
- package/.docs/reference/streaming/workflows/resumeStream.md +0 -61
- package/.docs/reference/streaming/workflows/stream.md +0 -88
- package/.docs/reference/streaming/workflows/timeTravelStream.md +0 -142
- package/.docs/reference/templates/overview.md +0 -194
- package/.docs/reference/tools/create-tool.md +0 -237
- package/.docs/reference/tools/document-chunker-tool.md +0 -89
- package/.docs/reference/tools/graph-rag-tool.md +0 -185
- package/.docs/reference/tools/mcp-client.md +0 -962
- package/.docs/reference/tools/mcp-server.md +0 -1275
- package/.docs/reference/tools/vector-query-tool.md +0 -459
- package/.docs/reference/vectors/astra.md +0 -121
- package/.docs/reference/vectors/chroma.md +0 -267
- package/.docs/reference/vectors/convex.md +0 -303
- package/.docs/reference/vectors/couchbase.md +0 -226
- package/.docs/reference/vectors/duckdb.md +0 -318
- package/.docs/reference/vectors/elasticsearch.md +0 -189
- package/.docs/reference/vectors/lance.md +0 -220
- package/.docs/reference/vectors/libsql.md +0 -305
- package/.docs/reference/vectors/mongodb.md +0 -295
- package/.docs/reference/vectors/opensearch.md +0 -99
- package/.docs/reference/vectors/pg.md +0 -408
- package/.docs/reference/vectors/pinecone.md +0 -168
- package/.docs/reference/vectors/qdrant.md +0 -222
- package/.docs/reference/vectors/s3vectors.md +0 -277
- package/.docs/reference/vectors/turbopuffer.md +0 -157
- package/.docs/reference/vectors/upstash.md +0 -294
- package/.docs/reference/vectors/vectorize.md +0 -147
- package/.docs/reference/voice/azure.md +0 -148
- package/.docs/reference/voice/cloudflare.md +0 -83
- package/.docs/reference/voice/composite-voice.md +0 -121
- package/.docs/reference/voice/deepgram.md +0 -79
- package/.docs/reference/voice/elevenlabs.md +0 -98
- package/.docs/reference/voice/google-gemini-live.md +0 -378
- package/.docs/reference/voice/google.md +0 -228
- package/.docs/reference/voice/mastra-voice.md +0 -313
- package/.docs/reference/voice/murf.md +0 -122
- package/.docs/reference/voice/openai-realtime.md +0 -203
- package/.docs/reference/voice/openai.md +0 -88
- package/.docs/reference/voice/playai.md +0 -80
- package/.docs/reference/voice/sarvam.md +0 -126
- package/.docs/reference/voice/speechify.md +0 -75
- package/.docs/reference/voice/voice.addInstructions.md +0 -56
- package/.docs/reference/voice/voice.addTools.md +0 -67
- package/.docs/reference/voice/voice.answer.md +0 -54
- package/.docs/reference/voice/voice.close.md +0 -51
- package/.docs/reference/voice/voice.connect.md +0 -94
- package/.docs/reference/voice/voice.events.md +0 -37
- package/.docs/reference/voice/voice.getSpeakers.md +0 -129
- package/.docs/reference/voice/voice.listen.md +0 -164
- package/.docs/reference/voice/voice.off.md +0 -54
- package/.docs/reference/voice/voice.on.md +0 -111
- package/.docs/reference/voice/voice.send.md +0 -65
- package/.docs/reference/voice/voice.speak.md +0 -157
- package/.docs/reference/voice/voice.updateConfig.md +0 -60
- package/.docs/reference/workflows/run-methods/cancel.md +0 -86
- package/.docs/reference/workflows/run-methods/restart.md +0 -33
- package/.docs/reference/workflows/run-methods/resume.md +0 -59
- package/.docs/reference/workflows/run-methods/start.md +0 -58
- package/.docs/reference/workflows/run-methods/startAsync.md +0 -67
- package/.docs/reference/workflows/run-methods/timeTravel.md +0 -142
- package/.docs/reference/workflows/run.md +0 -59
- package/.docs/reference/workflows/step.md +0 -119
- package/.docs/reference/workflows/workflow-methods/branch.md +0 -25
- package/.docs/reference/workflows/workflow-methods/commit.md +0 -17
- package/.docs/reference/workflows/workflow-methods/create-run.md +0 -63
- package/.docs/reference/workflows/workflow-methods/dountil.md +0 -25
- package/.docs/reference/workflows/workflow-methods/dowhile.md +0 -25
- package/.docs/reference/workflows/workflow-methods/foreach.md +0 -118
- package/.docs/reference/workflows/workflow-methods/map.md +0 -93
- package/.docs/reference/workflows/workflow-methods/parallel.md +0 -21
- package/.docs/reference/workflows/workflow-methods/sleep.md +0 -35
- package/.docs/reference/workflows/workflow-methods/sleepUntil.md +0 -35
- package/.docs/reference/workflows/workflow-methods/then.md +0 -21
- package/.docs/reference/workflows/workflow.md +0 -157
- package/.docs/reference/workspace/e2b-sandbox.md +0 -288
- package/.docs/reference/workspace/filesystem.md +0 -202
- package/.docs/reference/workspace/gcs-filesystem.md +0 -170
- package/.docs/reference/workspace/local-filesystem.md +0 -327
- package/.docs/reference/workspace/local-sandbox.md +0 -285
- package/.docs/reference/workspace/s3-filesystem.md +0 -169
- package/.docs/reference/workspace/sandbox.md +0 -81
- package/.docs/reference/workspace/workspace-class.md +0 -226
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
# Building a Research Paper Assistant with RAG
|
|
2
|
-
|
|
3
|
-
In this guide, you'll create an AI research assistant that can analyze academic papers and answer specific questions about their content using Retrieval Augmented Generation (RAG).
|
|
4
|
-
|
|
5
|
-
You'll use the foundational Transformer paper ["Attention Is All You Need"](https://arxiv.org/html/1706.03762) as your example. As a database you'll use a local libSQL database.
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
- Node.js `v22.13.0` or later installed
|
|
10
|
-
- An API key from a supported [Model Provider](https://mastra.ai/models)
|
|
11
|
-
- An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
|
|
12
|
-
|
|
13
|
-
## How RAG works
|
|
14
|
-
|
|
15
|
-
Let's understand how RAG works and how you'll implement each component.
|
|
16
|
-
|
|
17
|
-
### Knowledge Store/Index
|
|
18
|
-
|
|
19
|
-
- Converting text into vector representations
|
|
20
|
-
- Creating numerical representations of content
|
|
21
|
-
- **Implementation**: You'll use OpenAI's `text-embedding-3-small` to create embeddings and store them in LibSQLVector
|
|
22
|
-
|
|
23
|
-
### Retriever
|
|
24
|
-
|
|
25
|
-
- Finding relevant content via similarity search
|
|
26
|
-
- Matching query embeddings with stored vectors
|
|
27
|
-
- **Implementation**: You'll use LibSQLVector to perform similarity searches on the stored embeddings
|
|
28
|
-
|
|
29
|
-
### Generator
|
|
30
|
-
|
|
31
|
-
- Processing retrieved content with an LLM
|
|
32
|
-
- Creating contextually informed responses
|
|
33
|
-
- **Implementation**: You'll use GPT-4o-mini to generate answers based on retrieved content
|
|
34
|
-
|
|
35
|
-
Your implementation will:
|
|
36
|
-
|
|
37
|
-
1. Process the Transformer paper into embeddings
|
|
38
|
-
2. Store them in LibSQLVector for quick retrieval
|
|
39
|
-
3. Use similarity search to find relevant sections
|
|
40
|
-
4. Generate accurate responses using retrieved context
|
|
41
|
-
|
|
42
|
-
## Creating the Agent
|
|
43
|
-
|
|
44
|
-
Let's define the agent's behavior, connect it to your Mastra project, and create the vector store.
|
|
45
|
-
|
|
46
|
-
1. Install additional dependencies
|
|
47
|
-
|
|
48
|
-
After running the [installation guide](https://mastra.ai/guides/getting-started/quickstart) you'll need to install additional dependencies:
|
|
49
|
-
|
|
50
|
-
**npm**:
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
npm install @mastra/rag@latest ai
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**pnpm**:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
pnpm add @mastra/rag@latest ai
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Yarn**:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
yarn add @mastra/rag@latest ai
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**Bun**:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
bun add @mastra/rag@latest ai
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
2. Now you'll create your RAG-enabled research assistant. The agent uses:
|
|
75
|
-
|
|
76
|
-
- A [Vector Query Tool](https://mastra.ai/reference/tools/vector-query-tool) for performing semantic search over the vector store to find relevant content in papers
|
|
77
|
-
- GPT-4o-mini for understanding queries and generating responses
|
|
78
|
-
- Custom instructions that guide the agent on how to analyze papers, use retrieved content effectively, and acknowledge limitations
|
|
79
|
-
|
|
80
|
-
Create a new file `src/mastra/agents/researchAgent.ts` and define your agent:
|
|
81
|
-
|
|
82
|
-
```ts
|
|
83
|
-
import { Agent } from "@mastra/core/agent";
|
|
84
|
-
import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
85
|
-
import { createVectorQueryTool } from "@mastra/rag";
|
|
86
|
-
|
|
87
|
-
// Create a tool for semantic search over the paper embeddings
|
|
88
|
-
const vectorQueryTool = createVectorQueryTool({
|
|
89
|
-
vectorStoreName: "libSqlVector",
|
|
90
|
-
indexName: "papers",
|
|
91
|
-
model: new ModelRouterEmbeddingModel("openai/text-embedding-3-small"),
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
export const researchAgent = new Agent({
|
|
95
|
-
id: "research-agent",
|
|
96
|
-
name: "Research Assistant",
|
|
97
|
-
instructions: `You are a helpful research assistant that analyzes academic papers and technical documents.
|
|
98
|
-
Use the provided vector query tool to find relevant information from your knowledge base,
|
|
99
|
-
and provide accurate, well-supported answers based on the retrieved content.
|
|
100
|
-
Focus on the specific content available in the tool and acknowledge if you cannot find sufficient information to answer a question.
|
|
101
|
-
Base your responses only on the content provided, not on general knowledge.`,
|
|
102
|
-
model: "openai/gpt-5.1",
|
|
103
|
-
tools: {
|
|
104
|
-
vectorQueryTool,
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
3. In the root of your project, grab the absolute path with the `pwd` command. The path might be similar to this:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
> pwd
|
|
113
|
-
/Users/your-name/guides/research-assistant
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
In your `src/mastra/index.ts` file, add the following to your existing file and configuration:
|
|
117
|
-
|
|
118
|
-
```ts
|
|
119
|
-
import { Mastra } from "@mastra/core";
|
|
120
|
-
import { LibSQLVector } from "@mastra/libsql";
|
|
121
|
-
|
|
122
|
-
const libSqlVector = new LibSQLVector({
|
|
123
|
-
id: 'research-vectors',
|
|
124
|
-
url: "file:/Users/your-name/guides/research-assistant/vector.db",
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
export const mastra = new Mastra({
|
|
128
|
-
vectors: { libSqlVector },
|
|
129
|
-
});
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
For the `url` use the absolute path you got from the `pwd` command. This way the `vector.db` file is created at the root of your project.
|
|
133
|
-
|
|
134
|
-
> **Note:** For the purpose of this guide you are using a hardcoded absolute path to your local libSQL file, however for production usage this won't work. You should use a remote persistent database then.
|
|
135
|
-
|
|
136
|
-
4. In the `src/mastra/index.ts` file, add the agent to Mastra:
|
|
137
|
-
|
|
138
|
-
```ts
|
|
139
|
-
import { Mastra } from "@mastra/core";
|
|
140
|
-
import { LibSQLVector } from "@mastra/libsql";
|
|
141
|
-
import { researchAgent } from "./agents/researchAgent";
|
|
142
|
-
|
|
143
|
-
const libSqlVector = new LibSQLVector({
|
|
144
|
-
id: 'research-vectors',
|
|
145
|
-
url: "file:/Users/your-name/guides/research-assistant/vector.db",
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
export const mastra = new Mastra({
|
|
149
|
-
agents: { researchAgent },
|
|
150
|
-
vectors: { libSqlVector },
|
|
151
|
-
});
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Processing documents
|
|
155
|
-
|
|
156
|
-
In the following steps you'll fetch the research paper, split it into smaller chunks, generate embeddings for them, and store these chunks of information into the vector database.
|
|
157
|
-
|
|
158
|
-
1. In this step the research paper is retrieved by providing an URL, then converted to a document object, and split into smaller, manageable chunks. By splitting into chunks the processing is faster and more efficient.
|
|
159
|
-
|
|
160
|
-
Create a new file `src/store.ts` and add the following:
|
|
161
|
-
|
|
162
|
-
```ts
|
|
163
|
-
import { MDocument } from "@mastra/rag";
|
|
164
|
-
|
|
165
|
-
// Load the paper
|
|
166
|
-
const paperUrl = "https://arxiv.org/html/1706.03762";
|
|
167
|
-
const response = await fetch(paperUrl);
|
|
168
|
-
const paperText = await response.text();
|
|
169
|
-
|
|
170
|
-
// Create document and chunk it
|
|
171
|
-
const doc = MDocument.fromText(paperText);
|
|
172
|
-
const chunks = await doc.chunk({
|
|
173
|
-
strategy: "recursive",
|
|
174
|
-
maxSize: 512,
|
|
175
|
-
overlap: 50,
|
|
176
|
-
separators: ["\n\n", "\n", " "],
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
console.log("Number of chunks:", chunks.length);
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
Run the file in your terminal:
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
npx bun src/store.ts
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
You should get back this response:
|
|
189
|
-
|
|
190
|
-
```bash
|
|
191
|
-
Number of chunks: 892
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
2. Finally, you'll prepare the content for RAG by:
|
|
195
|
-
|
|
196
|
-
1. Generating embeddings for each chunk of text
|
|
197
|
-
2. Creating a vector store index to hold the embeddings
|
|
198
|
-
3. Storing both the embeddings and metadata (original text and source information) in the vector database
|
|
199
|
-
|
|
200
|
-
> **Note:** This metadata is crucial as it allows for returning the actual content when the vector store finds relevant matches.
|
|
201
|
-
|
|
202
|
-
This allows the agent to efficiently search and retrieve relevant information.
|
|
203
|
-
|
|
204
|
-
Open the `src/store.ts` file and add the following:
|
|
205
|
-
|
|
206
|
-
```ts
|
|
207
|
-
import { MDocument } from "@mastra/rag";
|
|
208
|
-
import { embedMany } from "ai";
|
|
209
|
-
import { mastra } from "./mastra";
|
|
210
|
-
|
|
211
|
-
// Load the paper
|
|
212
|
-
const paperUrl = "https://arxiv.org/html/1706.03762";
|
|
213
|
-
const response = await fetch(paperUrl);
|
|
214
|
-
const paperText = await response.text();
|
|
215
|
-
|
|
216
|
-
// Create document and chunk it
|
|
217
|
-
const doc = MDocument.fromText(paperText);
|
|
218
|
-
const chunks = await doc.chunk({
|
|
219
|
-
strategy: "recursive",
|
|
220
|
-
maxSize: 512,
|
|
221
|
-
overlap: 50,
|
|
222
|
-
separators: ["\n\n", "\n", " "],
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
// Generate embeddings
|
|
226
|
-
const { embeddings } = await embedMany({
|
|
227
|
-
model: new ModelRouterEmbeddingModel("openai/text-embedding-3-small"),
|
|
228
|
-
values: chunks.map((chunk) => chunk.text),
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
// Get the vector store instance from Mastra
|
|
232
|
-
const vectorStore = mastra.getVector("libSqlVector");
|
|
233
|
-
|
|
234
|
-
// Create an index for paper chunks
|
|
235
|
-
await vectorStore.createIndex({
|
|
236
|
-
indexName: "papers",
|
|
237
|
-
dimension: 1536,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// Store embeddings
|
|
241
|
-
await vectorStore.upsert({
|
|
242
|
-
indexName: "papers",
|
|
243
|
-
vectors: embeddings,
|
|
244
|
-
metadata: chunks.map((chunk) => ({
|
|
245
|
-
text: chunk.text,
|
|
246
|
-
source: "transformer-paper",
|
|
247
|
-
})),
|
|
248
|
-
});
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
Lastly, you'll now need to store the embeddings by running the script again:
|
|
252
|
-
|
|
253
|
-
```bash
|
|
254
|
-
npx bun src/store.ts
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
If the operation was successful you should see no output/errors in your terminal.
|
|
258
|
-
|
|
259
|
-
## Test the Assistant
|
|
260
|
-
|
|
261
|
-
Now that the vector database has all embeddings, you can test the research assistant with different types of queries.
|
|
262
|
-
|
|
263
|
-
Create a new file `src/ask-agent.ts` and add different types of queries:
|
|
264
|
-
|
|
265
|
-
```ts
|
|
266
|
-
import { mastra } from "./mastra";
|
|
267
|
-
const agent = mastra.getAgent("researchAgent");
|
|
268
|
-
|
|
269
|
-
// Basic query about concepts
|
|
270
|
-
const query1 =
|
|
271
|
-
"What problems does sequence modeling face with neural networks?";
|
|
272
|
-
const response1 = await agent.generate(query1);
|
|
273
|
-
console.log("\nQuery:", query1);
|
|
274
|
-
console.log("Response:", response1.text);
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
Run the script:
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
npx bun src/ask-agent.ts
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
You should see output like:
|
|
284
|
-
|
|
285
|
-
```bash
|
|
286
|
-
Query: What problems does sequence modeling face with neural networks?
|
|
287
|
-
Response: Sequence modeling with neural networks faces several key challenges:
|
|
288
|
-
1. Vanishing and exploding gradients during training, especially with long sequences
|
|
289
|
-
2. Difficulty handling long-term dependencies in the input
|
|
290
|
-
3. Limited computational efficiency due to sequential processing
|
|
291
|
-
4. Challenges in parallelizing computations, resulting in longer training times
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
Try another question:
|
|
295
|
-
|
|
296
|
-
```ts
|
|
297
|
-
import { mastra } from "./mastra";
|
|
298
|
-
const agent = mastra.getAgent("researchAgent");
|
|
299
|
-
|
|
300
|
-
// Query about specific findings
|
|
301
|
-
const query2 = "What improvements were achieved in translation quality?";
|
|
302
|
-
const response2 = await agent.generate(query2);
|
|
303
|
-
console.log("\nQuery:", query2);
|
|
304
|
-
console.log("Response:", response2.text);
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
Output:
|
|
308
|
-
|
|
309
|
-
```text
|
|
310
|
-
Query: What improvements were achieved in translation quality?
|
|
311
|
-
Response: The model showed significant improvements in translation quality, achieving more than 2.0
|
|
312
|
-
BLEU points improvement over previously reported models on the WMT 2014 English-to-German translation
|
|
313
|
-
task, while also reducing training costs.
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
### Serve the Application
|
|
317
|
-
|
|
318
|
-
Start the Mastra server to expose your research assistant via API:
|
|
319
|
-
|
|
320
|
-
```bash
|
|
321
|
-
mastra dev
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
Your research assistant will be available at:
|
|
325
|
-
|
|
326
|
-
```text
|
|
327
|
-
http://localhost:4111/api/agents/researchAgent/generate
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
Test with curl:
|
|
331
|
-
|
|
332
|
-
```bash
|
|
333
|
-
curl -X POST http://localhost:4111/api/agents/researchAgent/generate \
|
|
334
|
-
-H "Content-Type: application/json" \
|
|
335
|
-
-d '{
|
|
336
|
-
"messages": [
|
|
337
|
-
{ "role": "user", "content": "What were the main findings about model parallelization?" }
|
|
338
|
-
]
|
|
339
|
-
}'
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
## Advanced RAG Examples
|
|
343
|
-
|
|
344
|
-
Explore these examples for more advanced RAG techniques:
|
|
345
|
-
|
|
346
|
-
- [Filter RAG](https://github.com/mastra-ai/mastra/tree/main/examples/basics/rag/filter-rag) for filtering results using metadata
|
|
347
|
-
- [Cleanup RAG](https://github.com/mastra-ai/mastra/tree/main/examples/basics/rag/cleanup-rag) for optimizing information density
|
|
348
|
-
- [Chain of Thought RAG](https://github.com/mastra-ai/mastra/tree/main/examples/basics/rag/cot-rag) for complex reasoning queries using workflows
|
|
349
|
-
- [Rerank RAG](https://github.com/mastra-ai/mastra/tree/main/examples/basics/rag/rerank-rag) for improved result relevance
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# Building an AI Stock Agent
|
|
2
|
-
|
|
3
|
-
In this guide, you're going to create a simple agent that fetches the last day's closing stock price for a given symbol. You'll learn how to create a tool, add it to an agent, and use the agent to fetch stock prices.
|
|
4
|
-
|
|
5
|
-
[YouTube video player](https://www.youtube-nocookie.com/embed/rIaZ4l7y9wo)
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
- Node.js `v22.13.0` or later installed
|
|
10
|
-
- An API key from a supported [Model Provider](https://mastra.ai/models)
|
|
11
|
-
- An existing Mastra project (Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) to set up a new project)
|
|
12
|
-
|
|
13
|
-
## Creating the Agent
|
|
14
|
-
|
|
15
|
-
To create an agent in Mastra use the `Agent` class to define it and then register it with Mastra.
|
|
16
|
-
|
|
17
|
-
1. Create a new file `src/mastra/agents/stockAgent.ts` and define your agent:
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { Agent } from "@mastra/core/agent";
|
|
21
|
-
|
|
22
|
-
export const stockAgent = new Agent({
|
|
23
|
-
id: "stock-agent",
|
|
24
|
-
name: "Stock Agent",
|
|
25
|
-
instructions:
|
|
26
|
-
"You are a helpful assistant that provides current stock prices. When asked about a stock, use the stock price tool to fetch the stock price.",
|
|
27
|
-
model: "openai/gpt-5.1",
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
2. In your `src/mastra/index.ts` file, register the agent:
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
import { Mastra } from "@mastra/core";
|
|
35
|
-
import { stockAgent } from "./agents/stockAgent";
|
|
36
|
-
|
|
37
|
-
export const mastra = new Mastra({
|
|
38
|
-
agents: { stockAgent },
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Creating the Stock Price Tool
|
|
43
|
-
|
|
44
|
-
So far the Stock Agent doesn't know anything about the current stock prices. To change this, create a tool and add it to the agent.
|
|
45
|
-
|
|
46
|
-
1. Create a new file `src/mastra/tools/stockPrices.ts`. Inside, add a `stockPrices` tool that will fetch the last day's closing stock price for a given symbol:
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
import { createTool } from "@mastra/core/tools";
|
|
50
|
-
import { z } from "zod";
|
|
51
|
-
|
|
52
|
-
const getStockPrice = async (symbol: string) => {
|
|
53
|
-
const data = await fetch(
|
|
54
|
-
`https://mastra-stock-data.vercel.app/api/stock-data?symbol=${symbol}`,
|
|
55
|
-
).then((r) => r.json());
|
|
56
|
-
return data.prices["4. close"];
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const stockPrices = createTool({
|
|
60
|
-
id: "Get Stock Price",
|
|
61
|
-
inputSchema: z.object({
|
|
62
|
-
symbol: z.string(),
|
|
63
|
-
}),
|
|
64
|
-
description: `Fetches the last day's closing stock price for a given symbol`,
|
|
65
|
-
execute: async (inputData) => {
|
|
66
|
-
console.log("Using tool to fetch stock price for", inputData.symbol);
|
|
67
|
-
return {
|
|
68
|
-
symbol: inputData.symbol,
|
|
69
|
-
currentPrice: await getStockPrice(inputData.symbol),
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
2. Inside `src/mastra/agents/stockAgent.ts` import your newly created `stockPrices` tool and add it to the agent.
|
|
76
|
-
|
|
77
|
-
```ts
|
|
78
|
-
import { Agent } from "@mastra/core/agent";
|
|
79
|
-
import { stockPrices } from "../tools/stockPrices";
|
|
80
|
-
|
|
81
|
-
export const stockAgent = new Agent({
|
|
82
|
-
id: "stock-agent",
|
|
83
|
-
name: "Stock Agent",
|
|
84
|
-
instructions:
|
|
85
|
-
"You are a helpful assistant that provides current stock prices. When asked about a stock, use the stock price tool to fetch the stock price.",
|
|
86
|
-
model: "openai/gpt-5.1",
|
|
87
|
-
tools: {
|
|
88
|
-
stockPrices,
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Running the Agent Server
|
|
94
|
-
|
|
95
|
-
Learn how to interact with your agent through Mastra's API.
|
|
96
|
-
|
|
97
|
-
1. You can run your agent as a service using the `mastra dev` command:
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
mastra dev
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
This will start a server exposing endpoints to interact with your registered agents. Within [Studio](https://mastra.ai/docs/getting-started/studio) you can test your `stockAgent` and `stockPrices` tool through a UI.
|
|
104
|
-
|
|
105
|
-
2. By default, `mastra dev` runs on `http://localhost:4111`. Your Stock agent will be available at:
|
|
106
|
-
|
|
107
|
-
```text
|
|
108
|
-
POST http://localhost:4111/api/agents/stockAgent/generate
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
3. You can interact with the agent using `curl` from the command line:
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
curl -X POST http://localhost:4111/api/agents/stockAgent/generate \
|
|
115
|
-
-H "Content-Type: application/json" \
|
|
116
|
-
-d '{
|
|
117
|
-
"messages": [
|
|
118
|
-
{ "role": "user", "content": "What is the current stock price of Apple (AAPL)?" }
|
|
119
|
-
]
|
|
120
|
-
}'
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**Expected Response:**
|
|
124
|
-
|
|
125
|
-
You should receive a JSON response similar to:
|
|
126
|
-
|
|
127
|
-
```json
|
|
128
|
-
{
|
|
129
|
-
"text": "The current price of Apple (AAPL) is $174.55.",
|
|
130
|
-
"agent": "Stock Agent"
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
This indicates that your agent successfully processed the request, used the `stockPrices` tool to fetch the stock price, and returned the result.
|