@mastra/mcp-docs-server 1.0.0-beta.5 → 1.0.0-beta.7
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/%40mastra%2Fagent-builder.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +67 -67
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +110 -110
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +60 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +358 -358
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +79 -79
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +61 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Flance.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +55 -55
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +125 -125
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +36 -36
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +59 -59
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +77 -77
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Frag.md +43 -43
- package/.docs/organized/changelogs/%40mastra%2Freact.md +16 -0
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +113 -113
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +57 -57
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +19 -19
- package/.docs/organized/changelogs/create-mastra.md +15 -15
- package/.docs/organized/changelogs/mastra.md +30 -30
- package/.docs/organized/code-examples/agui.md +1 -0
- package/.docs/organized/code-examples/ai-elements.md +1 -1
- package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
- package/.docs/organized/code-examples/ai-sdk-v5.md +2 -1
- package/.docs/organized/code-examples/assistant-ui.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
- package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
- package/.docs/organized/code-examples/mcp-server-adapters.md +721 -0
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/organized/code-examples/server-express-adapter.md +87 -0
- package/.docs/organized/code-examples/server-hono-adapter.md +85 -0
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/guardrails.mdx +13 -9
- package/.docs/raw/agents/networks.mdx +1 -0
- package/.docs/raw/agents/overview.mdx +8 -152
- package/.docs/raw/agents/processors.mdx +279 -0
- package/.docs/raw/agents/structured-output.mdx +224 -0
- package/.docs/raw/deployment/cloud-providers/index.mdx +19 -26
- package/.docs/raw/deployment/cloud-providers/netlify-deployer.mdx +44 -13
- package/.docs/raw/evals/running-in-ci.mdx +0 -2
- package/.docs/raw/{guides/getting-started → getting-started}/manual-install.mdx +2 -2
- package/.docs/raw/getting-started/start.mdx +1 -1
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +8 -0
- package/.docs/raw/guides/getting-started/quickstart.mdx +1 -1
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +11 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +37 -0
- package/.docs/raw/index.mdx +1 -1
- package/.docs/raw/memory/memory-processors.mdx +265 -79
- package/.docs/raw/memory/working-memory.mdx +11 -2
- package/.docs/raw/observability/overview.mdx +0 -1
- package/.docs/raw/observability/tracing/bridges/otel.mdx +200 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +36 -0
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +19 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +83 -0
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +12 -0
- package/.docs/raw/observability/tracing/exporters/otel.mdx +34 -22
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +20 -0
- package/.docs/raw/observability/tracing/overview.mdx +76 -6
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +0 -1
- package/.docs/raw/rag/retrieval.mdx +23 -6
- package/.docs/raw/rag/vector-databases.mdx +93 -2
- package/.docs/raw/reference/agents/generate.mdx +55 -6
- package/.docs/raw/reference/agents/network.mdx +44 -0
- package/.docs/raw/reference/client-js/memory.mdx +43 -0
- package/.docs/raw/reference/client-js/workflows.mdx +92 -63
- package/.docs/raw/reference/deployer/netlify.mdx +1 -2
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +177 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +29 -0
- package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +43 -0
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +17 -1
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +33 -43
- package/.docs/raw/reference/observability/tracing/instances.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +29 -4
- package/.docs/raw/reference/observability/tracing/spans.mdx +0 -4
- package/.docs/raw/reference/processors/language-detector.mdx +9 -2
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +10 -3
- package/.docs/raw/reference/processors/pii-detector.mdx +10 -3
- package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +9 -2
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/server/create-route.mdx +314 -0
- package/.docs/raw/reference/server/express-adapter.mdx +193 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +174 -0
- package/.docs/raw/reference/server/mastra-server.mdx +316 -0
- package/.docs/raw/reference/server/routes.mdx +250 -0
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/lance.mdx +33 -0
- package/.docs/raw/reference/storage/libsql.mdx +37 -0
- package/.docs/raw/reference/storage/mongodb.mdx +39 -0
- package/.docs/raw/reference/storage/mssql.mdx +37 -0
- package/.docs/raw/reference/storage/postgresql.mdx +37 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +56 -1
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +7 -9
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +83 -24
- package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
- package/.docs/raw/reference/tools/mcp-client.mdx +128 -18
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/voice/google.mdx +159 -20
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/start.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
- package/.docs/raw/reference/workflows/run.mdx +27 -5
- package/.docs/raw/reference/workflows/step.mdx +13 -0
- package/.docs/raw/reference/workflows/workflow.mdx +19 -0
- package/.docs/raw/server-db/custom-adapters.mdx +380 -0
- package/.docs/raw/server-db/mastra-server.mdx +16 -8
- package/.docs/raw/server-db/request-context.mdx +0 -1
- package/.docs/raw/server-db/server-adapters.mdx +286 -0
- package/.docs/raw/server-db/storage.mdx +11 -0
- package/.docs/raw/streaming/overview.mdx +6 -6
- package/.docs/raw/streaming/tool-streaming.mdx +2 -2
- package/.docs/raw/streaming/workflow-streaming.mdx +5 -11
- package/.docs/raw/workflows/error-handling.mdx +1 -0
- package/.docs/raw/workflows/human-in-the-loop.mdx +4 -4
- package/.docs/raw/workflows/overview.mdx +56 -44
- package/.docs/raw/workflows/snapshots.mdx +1 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +85 -16
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +191 -0
- package/CHANGELOG.md +16 -0
- package/package.json +4 -4
- package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +0 -91
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
|
@@ -182,10 +182,46 @@ new ArizeExporter({
|
|
|
182
182
|
});
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
+
### Custom metadata
|
|
186
|
+
|
|
187
|
+
Non-reserved span attributes are serialized into the OpenInference `metadata` payload and surface in Arize/Phoenix. You can add them via `tracingOptions.metadata`:
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
await agent.generate(input, {
|
|
191
|
+
tracingOptions: {
|
|
192
|
+
metadata: {
|
|
193
|
+
companyId: "acme-co",
|
|
194
|
+
tier: "enterprise",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Reserved fields such as `input`, `output`, `sessionId`, thread/user IDs, and OpenInference IDs are excluded automatically.
|
|
201
|
+
|
|
185
202
|
## OpenInference Semantic Conventions
|
|
186
203
|
|
|
187
204
|
This exporter implements the [OpenInference Semantic Conventions](https://github.com/Arize-ai/openinference/tree/main/spec) for generative AI applications, providing standardized trace structure across different observability platforms.
|
|
188
205
|
|
|
206
|
+
## Using Tags
|
|
207
|
+
|
|
208
|
+
Tags help you categorize and filter traces in Phoenix and Arize AX. Add tags when executing agents or workflows:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
const result = await agent.generate({
|
|
212
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
213
|
+
tracingOptions: {
|
|
214
|
+
tags: ["production", "experiment-v2", "user-request"],
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Tags appear as the `tag.tags` attribute following OpenInference conventions and can be used to filter and search traces. Common use cases include:
|
|
220
|
+
|
|
221
|
+
- Environment labels: `"production"`, `"staging"`
|
|
222
|
+
- Experiment tracking: `"experiment-v1"`, `"control-group"`
|
|
223
|
+
- Priority levels: `"priority-high"`, `"batch-job"`
|
|
224
|
+
|
|
189
225
|
## Related
|
|
190
226
|
|
|
191
227
|
- [Tracing Overview](/docs/v1/observability/tracing/overview)
|
|
@@ -65,6 +65,25 @@ new BraintrustExporter({
|
|
|
65
65
|
});
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
## Using Tags
|
|
69
|
+
|
|
70
|
+
Tags help you categorize and filter traces in the Braintrust dashboard. Add tags when executing agents or workflows:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const result = await agent.generate({
|
|
74
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
75
|
+
tracingOptions: {
|
|
76
|
+
tags: ["production", "experiment-v2", "user-request"],
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Tags appear in Braintrust's trace view and can be used to filter and search traces. Common use cases include:
|
|
82
|
+
|
|
83
|
+
- Environment labels: `"production"`, `"staging"`
|
|
84
|
+
- Experiment tracking: `"experiment-v1"`, `"control-group"`
|
|
85
|
+
- Priority levels: `"priority-high"`, `"batch-job"`
|
|
86
|
+
|
|
68
87
|
## Related
|
|
69
88
|
|
|
70
89
|
- [Tracing Overview](/docs/v1/observability/tracing/overview)
|
|
@@ -107,7 +107,90 @@ new LangfuseExporter({
|
|
|
107
107
|
});
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
## Prompt Linking
|
|
111
|
+
|
|
112
|
+
You can link LLM generations to prompts stored in [Langfuse Prompt Management](https://langfuse.com/docs/prompt-management). This enables version tracking and metrics for your prompts.
|
|
113
|
+
|
|
114
|
+
### Using the Helper (Recommended)
|
|
115
|
+
|
|
116
|
+
Use `withLangfusePrompt` with `buildTracingOptions` for the cleanest API:
|
|
117
|
+
|
|
118
|
+
```typescript title="src/agents/support-agent.ts"
|
|
119
|
+
import { Agent } from "@mastra/core/agent";
|
|
120
|
+
import { openai } from "@ai-sdk/openai";
|
|
121
|
+
import { buildTracingOptions } from "@mastra/observability";
|
|
122
|
+
import { withLangfusePrompt } from "@mastra/langfuse";
|
|
123
|
+
import { Langfuse } from "langfuse";
|
|
124
|
+
|
|
125
|
+
const langfuse = new Langfuse({
|
|
126
|
+
publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
|
|
127
|
+
secretKey: process.env.LANGFUSE_SECRET_KEY!,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Fetch the prompt from Langfuse Prompt Management
|
|
131
|
+
const prompt = await langfuse.getPrompt("customer-support");
|
|
132
|
+
|
|
133
|
+
export const supportAgent = new Agent({
|
|
134
|
+
name: "support-agent",
|
|
135
|
+
instructions: prompt.prompt, // Use the prompt text from Langfuse
|
|
136
|
+
model: openai("gpt-4o"),
|
|
137
|
+
defaultGenerateOptions: {
|
|
138
|
+
tracingOptions: buildTracingOptions(withLangfusePrompt(prompt)),
|
|
139
|
+
## Using Tags
|
|
140
|
+
|
|
141
|
+
Tags help you categorize and filter traces in the Langfuse dashboard. Add tags when executing agents or workflows:
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
const result = await agent.generate({
|
|
145
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
146
|
+
tracingOptions: {
|
|
147
|
+
tags: ["production", "experiment-v2", "user-request"],
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The `withLangfusePrompt` helper automatically extracts `name`, `version`, and `id` from the Langfuse prompt object.
|
|
153
|
+
|
|
154
|
+
### Manual Fields
|
|
155
|
+
|
|
156
|
+
You can also pass manual fields if you're not using the Langfuse SDK:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
const tracingOptions = buildTracingOptions(
|
|
160
|
+
withLangfusePrompt({ name: "my-prompt", version: 1 }),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
// Or with just an ID
|
|
164
|
+
const tracingOptions = buildTracingOptions(
|
|
165
|
+
withLangfusePrompt({ id: "prompt-uuid-12345" }),
|
|
166
|
+
);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Prompt Object Fields
|
|
170
|
+
|
|
171
|
+
The prompt object supports these fields:
|
|
172
|
+
|
|
173
|
+
| Field | Type | Description |
|
|
174
|
+
|-------|------|-------------|
|
|
175
|
+
| `name` | string | The prompt name in Langfuse |
|
|
176
|
+
| `version` | number | The prompt version number |
|
|
177
|
+
| `id` | string | The prompt UUID for direct linking |
|
|
178
|
+
|
|
179
|
+
You can link prompts using either:
|
|
180
|
+
- `id` alone (the UUID uniquely identifies a prompt version)
|
|
181
|
+
- `name` + `version` together
|
|
182
|
+
- All three fields
|
|
183
|
+
|
|
184
|
+
When set on a `MODEL_GENERATION` span, the Langfuse exporter automatically links the generation to the corresponding prompt.
|
|
185
|
+
Tags appear in Langfuse's trace view and can be used to filter and search traces. Common use cases include:
|
|
186
|
+
|
|
187
|
+
- Environment labels: `"production"`, `"staging"`
|
|
188
|
+
- Experiment tracking: `"experiment-v1"`, `"control-group"`
|
|
189
|
+
- Priority levels: `"priority-high"`, `"batch-job"`
|
|
190
|
+
- User segments: `"beta-user"`, `"enterprise"`
|
|
191
|
+
|
|
110
192
|
## Related
|
|
111
193
|
|
|
112
194
|
- [Tracing Overview](/docs/v1/observability/tracing/overview)
|
|
113
195
|
- [Langfuse Documentation](https://langfuse.com/docs)
|
|
196
|
+
- [Langfuse Prompt Management](https://langfuse.com/docs/prompt-management)
|
|
@@ -23,6 +23,7 @@ npm install @mastra/langsmith@beta
|
|
|
23
23
|
|
|
24
24
|
```bash title=".env"
|
|
25
25
|
LANGSMITH_API_KEY=ls-xxxxxxxxxxxx
|
|
26
|
+
LANGCHAIN_PROJECT=my-project # Optional: default project for traces
|
|
26
27
|
LANGSMITH_BASE_URL=https://api.smith.langchain.com # Optional for self-hosted
|
|
27
28
|
```
|
|
28
29
|
|
|
@@ -60,6 +61,7 @@ new LangSmithExporter({
|
|
|
60
61
|
|
|
61
62
|
// Optional settings
|
|
62
63
|
apiUrl: process.env.LANGSMITH_BASE_URL, // Default: https://api.smith.langchain.com
|
|
64
|
+
projectName: "my-project", // Project to send traces to (overrides LANGCHAIN_PROJECT env var)
|
|
63
65
|
callerOptions: {
|
|
64
66
|
// HTTP client options
|
|
65
67
|
timeout: 30000, // Request timeout in ms
|
|
@@ -73,6 +75,16 @@ new LangSmithExporter({
|
|
|
73
75
|
});
|
|
74
76
|
```
|
|
75
77
|
|
|
78
|
+
### Environment Variables
|
|
79
|
+
|
|
80
|
+
| Variable | Description |
|
|
81
|
+
|----------|-------------|
|
|
82
|
+
| `LANGSMITH_API_KEY` | Your LangSmith API key (required) |
|
|
83
|
+
| `LANGCHAIN_PROJECT` | Default project name for traces (optional, defaults to "default") |
|
|
84
|
+
| `LANGSMITH_BASE_URL` | API URL for self-hosted instances (optional) |
|
|
85
|
+
|
|
86
|
+
The `projectName` config option takes precedence over the `LANGCHAIN_PROJECT` environment variable, allowing you to programmatically route traces to different projects.
|
|
87
|
+
|
|
76
88
|
## Related
|
|
77
89
|
|
|
78
90
|
- [Tracing Overview](/docs/v1/observability/tracing/overview)
|
|
@@ -5,13 +5,13 @@ description: "Send traces to any OpenTelemetry-compatible observability platform
|
|
|
5
5
|
|
|
6
6
|
# OpenTelemetry Exporter
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The OpenTelemetry (OTEL) exporter sends your traces to any OTEL-compatible observability platform using standardized [OpenTelemetry Semantic Conventions for GenAI](https://opentelemetry.io/docs/specs/semconv/gen-ai/). This ensures broad compatibility with platforms like Datadog, New Relic, SigNoz, MLflow, Dash0, Traceloop, Laminar, and more.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
:::info Looking for bidirectional OTEL integration?
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
If you have existing OpenTelemetry instrumentation and want Mastra traces to inherit context from active OTEL spans, see the [OpenTelemetry Bridge](/docs/v1/observability/tracing/bridges/otel) instead.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
:::
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -198,33 +198,26 @@ new OtelExporter({
|
|
|
198
198
|
|
|
199
199
|
## OpenTelemetry Semantic Conventions
|
|
200
200
|
|
|
201
|
-
The exporter follows [OpenTelemetry Semantic Conventions for GenAI](https://
|
|
201
|
+
The exporter follows [OpenTelemetry Semantic Conventions for GenAI v1.38.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.38.0/docs/gen-ai), ensuring compatibility with observability platforms:
|
|
202
202
|
|
|
203
203
|
### Span Naming
|
|
204
204
|
|
|
205
|
-
- **LLM Operations**: `chat {model}`
|
|
206
|
-
- **Tool Execution**: `
|
|
207
|
-
- **Agent Runs**: `
|
|
208
|
-
- **Workflow Runs**: `
|
|
205
|
+
- **LLM Operations**: `chat {model}`
|
|
206
|
+
- **Tool Execution**: `execute_tool {tool_name}`
|
|
207
|
+
- **Agent Runs**: `invoke_agent {agent_id}`
|
|
208
|
+
- **Workflow Runs**: `invoke_workflow {workflow_id}`
|
|
209
209
|
|
|
210
210
|
### Key Attributes
|
|
211
211
|
|
|
212
212
|
- `gen_ai.operation.name` - Operation type (chat, tool.execute, etc.)
|
|
213
|
-
- `gen_ai.
|
|
213
|
+
- `gen_ai.provider.name` - AI provider (openai, anthropic, etc.)
|
|
214
214
|
- `gen_ai.request.model` - Model identifier
|
|
215
|
+
- `gen_ai.input.messages` - Chat history provided to the model
|
|
216
|
+
- `gen_ai.output.messages` - Messages returned by the model
|
|
215
217
|
- `gen_ai.usage.input_tokens` - Number of input tokens
|
|
216
218
|
- `gen_ai.usage.output_tokens` - Number of output tokens
|
|
217
219
|
- `gen_ai.request.temperature` - Sampling temperature
|
|
218
|
-
- `gen_ai.response.finish_reasons` - Completion
|
|
219
|
-
|
|
220
|
-
## Buffering Strategy
|
|
221
|
-
|
|
222
|
-
The exporter buffers spans until a trace is complete:
|
|
223
|
-
|
|
224
|
-
1. Collects all spans for a trace
|
|
225
|
-
2. Waits 5 seconds after root span completes
|
|
226
|
-
3. Exports complete trace with preserved parent-child relationships
|
|
227
|
-
4. Ensures no orphaned spans
|
|
220
|
+
- `gen_ai.response.finish_reasons` - Completion reasons
|
|
228
221
|
|
|
229
222
|
## Protocol Selection Guide
|
|
230
223
|
|
|
@@ -264,10 +257,29 @@ Install the suggested package for your provider.
|
|
|
264
257
|
1. **Wrong protocol package**: Verify you installed the correct exporter for your provider
|
|
265
258
|
2. **Invalid endpoint**: Check endpoint format matches provider requirements
|
|
266
259
|
3. **Authentication failures**: Verify API keys and headers are correct
|
|
267
|
-
|
|
260
|
+
|
|
261
|
+
## Using Tags
|
|
262
|
+
|
|
263
|
+
Tags help you categorize and filter traces in your observability platform. Add tags when executing agents or workflows:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
const result = await agent.generate({
|
|
267
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
268
|
+
tracingOptions: {
|
|
269
|
+
tags: ["production", "experiment-v2", "user-request"],
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Tags are exported as a JSON string in the `mastra.tags` span attribute for broad backend compatibility. Common use cases include:
|
|
275
|
+
|
|
276
|
+
- Environment labels: `"production"`, `"staging"`
|
|
277
|
+
- Experiment tracking: `"experiment-v1"`, `"control-group"`
|
|
278
|
+
- Priority levels: `"priority-high"`, `"batch-job"`
|
|
268
279
|
|
|
269
280
|
## Related
|
|
270
281
|
|
|
271
282
|
- [Tracing Overview](/docs/v1/observability/tracing/overview)
|
|
272
|
-
- [OpenTelemetry
|
|
283
|
+
- [OpenTelemetry Bridge](/docs/v1/observability/tracing/bridges/otel)
|
|
284
|
+
- [OpenTelemetry Semantic Conventions for GenAI v1.38.0](https://github.com/open-telemetry/semantic-conventions/tree/v1.38.0/docs/gen-ai)
|
|
273
285
|
- [OTEL Exporter Reference](/reference/v1/observability/tracing/exporters/otel)
|
|
@@ -101,6 +101,26 @@ new PosthogExporter({
|
|
|
101
101
|
});
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
## Using Tags
|
|
105
|
+
|
|
106
|
+
Tags help you categorize and filter traces in PostHog's AI analytics. Add tags when executing agents or workflows:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const result = await agent.generate({
|
|
110
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
111
|
+
tracingOptions: {
|
|
112
|
+
tags: ["production", "experiment-v2", "user-request"],
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Tags are added as event properties where the tag name is the key and the value is set to `true`. In PostHog's trace view, filter by a tag using the `is set` filter (e.g., "production is set" shows all traces with the production tag). Common use cases include:
|
|
118
|
+
|
|
119
|
+
- Environment labels: `"production"`, `"staging"`
|
|
120
|
+
- Experiment tracking: `"experiment-v1"`, `"control-group"`
|
|
121
|
+
- Priority levels: `"priority-high"`, `"batch-job"`
|
|
122
|
+
- User segments: `"beta-user"`, `"enterprise"`
|
|
123
|
+
|
|
104
124
|
## Related
|
|
105
125
|
|
|
106
126
|
- [Tracing Overview](/docs/v1/observability/tracing/overview)
|
|
@@ -99,6 +99,23 @@ In addition to the internal exporters, Mastra supports integration with popular
|
|
|
99
99
|
- **[OpenTelemetry](/docs/v1/observability/tracing/exporters/otel)** - Deliver traces to any OpenTelemetry-compatible observability system
|
|
100
100
|
- Supports: Dash0, MLflow, Laminar, New Relic, SigNoz, Traceloop, Zipkin, and others!
|
|
101
101
|
|
|
102
|
+
## Bridges
|
|
103
|
+
|
|
104
|
+
Bridges provide bidirectional integration with external tracing systems. Unlike exporters that send trace data to external platforms, bridges create native spans in external systems and inherit context from them. This enables Mastra operations to participate in existing distributed traces.
|
|
105
|
+
|
|
106
|
+
- **[OpenTelemetry Bridge](/docs/v1/observability/tracing/bridges/otel)** - Integrate with existing OpenTelemetry infrastructure
|
|
107
|
+
|
|
108
|
+
### Bridges vs Exporters
|
|
109
|
+
|
|
110
|
+
| Feature | Bridges | Exporters |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| Creates native spans in external systems | Yes | No |
|
|
113
|
+
| Inherits context from external systems | Yes | No |
|
|
114
|
+
| Sends data to backends | Via external SDK | Directly |
|
|
115
|
+
| Use case | Existing distributed tracing | Standalone Mastra tracing |
|
|
116
|
+
|
|
117
|
+
You can use both together — a bridge for context propagation and exporters to send traces to additional destinations.
|
|
118
|
+
|
|
102
119
|
## Sampling Strategies
|
|
103
120
|
|
|
104
121
|
Sampling allows you to control which traces are collected, helping you balance between observability needs and resource costs. In production environments with high traffic, collecting every trace can be expensive and unnecessary. Sampling strategies let you capture a representative subset of traces while ensuring you don't miss critical information about errors or important operations.
|
|
@@ -200,7 +217,6 @@ Use `configSelector` to choose the appropriate tracing configuration based on re
|
|
|
200
217
|
```ts title="src/mastra/index.ts" showLineNumbers copy
|
|
201
218
|
export const mastra = new Mastra({
|
|
202
219
|
observability: new Observability({
|
|
203
|
-
default: { enabled: true }, // Provides 'default' instance
|
|
204
220
|
configs: {
|
|
205
221
|
langfuse: {
|
|
206
222
|
serviceName: "langfuse-service",
|
|
@@ -233,7 +249,7 @@ export const mastra = new Mastra({
|
|
|
233
249
|
return "langfuse";
|
|
234
250
|
}
|
|
235
251
|
|
|
236
|
-
|
|
252
|
+
throw new Error('no config found')
|
|
237
253
|
},
|
|
238
254
|
}),
|
|
239
255
|
});
|
|
@@ -448,6 +464,60 @@ requestContext.set("session", { data: { experimentId: "exp-999" } });
|
|
|
448
464
|
3. **Child Span Extraction**: Child spans can also extract metadata if you pass `requestContext` when creating them
|
|
449
465
|
4. **Metadata Precedence**: Explicit metadata passed to span options always takes precedence over extracted metadata
|
|
450
466
|
|
|
467
|
+
### Adding Tags to Traces
|
|
468
|
+
|
|
469
|
+
Tags are string labels that help you categorize and filter traces. Unlike metadata (which contains structured key-value data), tags are simple strings designed for quick filtering and organization.
|
|
470
|
+
|
|
471
|
+
Use `tracingOptions.tags` to add tags when executing agents or workflows:
|
|
472
|
+
|
|
473
|
+
```ts showLineNumbers copy
|
|
474
|
+
// With agents
|
|
475
|
+
const result = await agent.generate({
|
|
476
|
+
messages: [{ role: "user", content: "Hello" }],
|
|
477
|
+
tracingOptions: {
|
|
478
|
+
tags: ["production", "experiment-v2", "user-request"],
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
// With workflows
|
|
483
|
+
const run = await mastra.getWorkflow("myWorkflow").createRun();
|
|
484
|
+
const result = await run.start({
|
|
485
|
+
inputData: { data: "process this" },
|
|
486
|
+
tracingOptions: {
|
|
487
|
+
tags: ["batch-processing", "priority-high"],
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
#### How Tags Work
|
|
493
|
+
|
|
494
|
+
- **Root span only**: Tags are applied only to the root span of a trace (the agent run or workflow run span)
|
|
495
|
+
- **Widely supported**: Tags are supported by most exporters for filtering and searching traces:
|
|
496
|
+
- **Braintrust** - Native `tags` field
|
|
497
|
+
- **Langfuse** - Native `tags` field on traces
|
|
498
|
+
- **ArizeExporter** - `tag.tags` OpenInference attribute
|
|
499
|
+
- **OtelExporter** - `mastra.tags` span attribute
|
|
500
|
+
- **OtelBridge** - `mastra.tags` span attribute
|
|
501
|
+
- **Combinable with metadata**: You can use both `tags` and `metadata` in the same `tracingOptions`
|
|
502
|
+
|
|
503
|
+
```ts showLineNumbers copy
|
|
504
|
+
const result = await agent.generate({
|
|
505
|
+
messages: [{ role: "user", content: "Analyze this" }],
|
|
506
|
+
tracingOptions: {
|
|
507
|
+
tags: ["production", "analytics"],
|
|
508
|
+
metadata: { userId: "user-123", experimentId: "exp-456" },
|
|
509
|
+
},
|
|
510
|
+
});
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
#### Common Tag Patterns
|
|
514
|
+
|
|
515
|
+
- **Environment**: `"production"`, `"staging"`, `"development"`
|
|
516
|
+
- **Feature flags**: `"feature-x-enabled"`, `"beta-user"`
|
|
517
|
+
- **Request types**: `"user-request"`, `"batch-job"`, `"scheduled-task"`
|
|
518
|
+
- **Priority levels**: `"priority-high"`, `"priority-low"`
|
|
519
|
+
- **Experiments**: `"experiment-v1"`, `"control-group"`, `"treatment-a"`
|
|
520
|
+
|
|
451
521
|
#### Child Spans and Metadata Extraction
|
|
452
522
|
|
|
453
523
|
When creating child spans within tools or workflow steps, you can pass the `requestContext` parameter to enable metadata extraction:
|
|
@@ -751,10 +821,6 @@ Mastra automatically creates spans for:
|
|
|
751
821
|
|
|
752
822
|
## See Also
|
|
753
823
|
|
|
754
|
-
### Examples
|
|
755
|
-
|
|
756
|
-
- [Basic Tracing Example](/examples/v1/observability/basic-ai-tracing) - Working implementation
|
|
757
|
-
|
|
758
824
|
### Reference Documentation
|
|
759
825
|
|
|
760
826
|
- [Configuration API](/reference/v1/observability/tracing/configuration) - ObservabilityConfig details
|
|
@@ -773,6 +839,10 @@ Mastra automatically creates spans for:
|
|
|
773
839
|
- [MLflow](/reference/v1/observability/tracing/exporters/otel#mlflow) - MLflow OTLP endpoint setup
|
|
774
840
|
- [OpenTelemetry](/reference/v1/observability/tracing/exporters/otel) - OTEL-compatible platforms
|
|
775
841
|
|
|
842
|
+
### Bridges
|
|
843
|
+
|
|
844
|
+
- [OpenTelemetry Bridge](/reference/v1/observability/tracing/bridges/otel) - OTEL context integration
|
|
845
|
+
|
|
776
846
|
### Processors
|
|
777
847
|
|
|
778
848
|
- [Sensitive Data Filter](/docs/v1/observability/tracing/processors/sensitive-data-filter) - Data redaction
|
|
@@ -293,4 +293,3 @@ This ensures that processing errors don't prevent traces from being exported or
|
|
|
293
293
|
## Related
|
|
294
294
|
|
|
295
295
|
- [SensitiveDataFilter API](/reference/v1/observability/tracing/processors/sensitive-data-filter)
|
|
296
|
-
- [Basic Tracing Example](/examples/v1/observability/basic-ai-tracing)
|
|
@@ -52,6 +52,8 @@ const results = await pgVector.query({
|
|
|
52
52
|
console.log(results);
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
The `topK` parameter specifies the maximum number of most similar results to return from the vector search.
|
|
56
|
+
|
|
55
57
|
Results include both the text content and a similarity score:
|
|
56
58
|
|
|
57
59
|
```ts showLineNumbers copy
|
|
@@ -70,8 +72,6 @@ Results include both the text content and a similarity score:
|
|
|
70
72
|
];
|
|
71
73
|
```
|
|
72
74
|
|
|
73
|
-
For an example of how to use the basic retrieval method, see the [Retrieve Results](/examples/v1/rag/query/retrieve-results) example.
|
|
74
|
-
|
|
75
75
|
## Advanced Retrieval options
|
|
76
76
|
|
|
77
77
|
### Metadata Filtering
|
|
@@ -170,7 +170,14 @@ This is particularly useful when:
|
|
|
170
170
|
|
|
171
171
|
#### Database-Specific Configurations
|
|
172
172
|
|
|
173
|
-
The Vector Query Tool supports database-specific configurations that enable you to leverage unique features and optimizations of different vector stores
|
|
173
|
+
The Vector Query Tool supports database-specific configurations that enable you to leverage unique features and optimizations of different vector stores.
|
|
174
|
+
|
|
175
|
+
:::note
|
|
176
|
+
These configurations are for **query-time options** like namespaces, performance tuning, and filtering—not for database connection setup.
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
Connection credentials (URLs, auth tokens) are configured when you instantiate the vector store class (e.g., `new LibSQLVector({ connectionUrl: '...' })`).
|
|
180
|
+
:::
|
|
174
181
|
|
|
175
182
|
```ts showLineNumbers copy
|
|
176
183
|
// Pinecone with namespace
|
|
@@ -510,13 +517,25 @@ const relevanceProvider = new MastraAgentRelevanceScorer('relevance-scorer', "op
|
|
|
510
517
|
const rerankedResults = await rerank({
|
|
511
518
|
results: initialResults,
|
|
512
519
|
query,
|
|
513
|
-
|
|
520
|
+
scorer: relevanceProvider,
|
|
514
521
|
options: {
|
|
522
|
+
weights: {
|
|
523
|
+
semantic: 0.5, // How well the content matches the query semantically
|
|
524
|
+
vector: 0.3, // Original vector similarity score
|
|
525
|
+
position: 0.2, // Preserves original result ordering
|
|
526
|
+
},
|
|
515
527
|
topK: 10,
|
|
516
528
|
},
|
|
517
529
|
);
|
|
518
530
|
```
|
|
519
531
|
|
|
532
|
+
The weights control how different factors influence the final ranking:
|
|
533
|
+
|
|
534
|
+
- `semantic`: Higher values prioritize semantic understanding and relevance to the query
|
|
535
|
+
- `vector`: Higher values favor the original vector similarity scores
|
|
536
|
+
- `position`: Higher values help maintain the original ordering of results
|
|
537
|
+
|
|
538
|
+
|
|
520
539
|
> **Note:** For semantic scoring to work properly during re-ranking, each result must include the text content in its `metadata.text` field.
|
|
521
540
|
|
|
522
541
|
You can also use other relevance score providers like Cohere or ZeroEntropy:
|
|
@@ -533,8 +552,6 @@ The re-ranked results combine vector similarity with semantic understanding to i
|
|
|
533
552
|
|
|
534
553
|
For more details about re-ranking, see the [rerank()](/reference/v1/rag/rerankWithScorer) method.
|
|
535
554
|
|
|
536
|
-
For an example of how to use the re-ranking method, see the Re-ranking Results example in the examples section.
|
|
537
|
-
|
|
538
555
|
### Graph-based Retrieval
|
|
539
556
|
|
|
540
557
|
For documents with complex relationships, graph-based retrieval can follow connections between chunks. This helps when:
|
|
@@ -252,6 +252,27 @@ await store.createIndex({
|
|
|
252
252
|
dimension: 1536,
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
+
await store.upsert({
|
|
256
|
+
indexName: "my-collection",
|
|
257
|
+
vectors: embeddings,
|
|
258
|
+
metadata: chunks.map((chunk) => ({ text: chunk.text })),
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
</TabItem>
|
|
263
|
+
|
|
264
|
+
<TabItem value="elasticsearch" label="ElasticSearch">
|
|
265
|
+
|
|
266
|
+
```ts title="vector-store.ts" showLineNumbers copy
|
|
267
|
+
import { ElasticSearchVector } from "@mastra/elasticsearch";
|
|
268
|
+
|
|
269
|
+
const store = new ElasticSearchVector({ url: process.env.ELASTICSEARCH_URL });
|
|
270
|
+
|
|
271
|
+
await store.createIndex({
|
|
272
|
+
indexName: "my-collection",
|
|
273
|
+
dimension: 1536,
|
|
274
|
+
});
|
|
275
|
+
|
|
255
276
|
await store.upsert({
|
|
256
277
|
indexName: "my-collection",
|
|
257
278
|
vectors: embeddings,
|
|
@@ -459,6 +480,20 @@ Each vector database enforces specific naming conventions for indexes and collec
|
|
|
459
480
|
- Example: `My_Index` is not valid (contains uppercase letters)
|
|
460
481
|
- Example: `_myindex` is not valid (begins with underscore)
|
|
461
482
|
</TabItem>
|
|
483
|
+
<TabItem value="elasticsearch" label="ElasticSearch">
|
|
484
|
+
Index names must:
|
|
485
|
+
- Use only lowercase letters
|
|
486
|
+
- Not exceed 255 bytes (counting multi-byte characters)
|
|
487
|
+
- Not begin with underscores, hyphens, or plus signs
|
|
488
|
+
- Not contain spaces, commas
|
|
489
|
+
- Not contain special characters (e.g. `:`, `"`, `*`, `+`, `/`, `\`, `|`, `?`, `#`, `>`, `<`)
|
|
490
|
+
- Not be "." or ".."
|
|
491
|
+
- Not start with "." (deprecated except for system/hidden indices)
|
|
492
|
+
- Example: `my-index-123` is valid
|
|
493
|
+
- Example: `My_Index` is not valid (contains uppercase letters)
|
|
494
|
+
- Example: `_myindex` is not valid (begins with underscore)
|
|
495
|
+
- Example: `.myindex` is not valid (begins with dot, deprecated)
|
|
496
|
+
</TabItem>
|
|
462
497
|
<TabItem value="s3vectors" label="S3 Vectors">
|
|
463
498
|
Index names must:
|
|
464
499
|
- Be unique within the same vector bucket
|
|
@@ -496,8 +531,6 @@ The upsert operation:
|
|
|
496
531
|
- Creates new vectors if they don't exist
|
|
497
532
|
- Automatically handles batching for large datasets
|
|
498
533
|
|
|
499
|
-
For complete examples of upserting embeddings in different vector stores, see the [Upsert Embeddings](/examples/v1/rag/upsert/upsert-embeddings) guide.
|
|
500
|
-
|
|
501
534
|
## Adding Metadata
|
|
502
535
|
|
|
503
536
|
Vector stores support rich metadata (any JSON-serializable fields) for filtering and organization. Since metadata is stored with no fixed schema, use consistent field naming to avoid unexpected query results.
|
|
@@ -536,6 +569,64 @@ Key metadata considerations:
|
|
|
536
569
|
- Only include fields you plan to filter or sort by - extra fields add overhead
|
|
537
570
|
- Add timestamps (e.g., 'createdAt', 'lastUpdated') to track content freshness
|
|
538
571
|
|
|
572
|
+
## Deleting Vectors
|
|
573
|
+
|
|
574
|
+
When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it easy to remove all embeddings associated with a specific document.
|
|
575
|
+
|
|
576
|
+
### Delete by Metadata Filter
|
|
577
|
+
|
|
578
|
+
The most common use case is deleting all vectors for a specific document when a user deletes it:
|
|
579
|
+
|
|
580
|
+
```ts title="delete-vectors.ts" showLineNumbers copy
|
|
581
|
+
// Delete all vectors for a specific document
|
|
582
|
+
await store.deleteVectors({
|
|
583
|
+
indexName: "myCollection",
|
|
584
|
+
filter: { docId: "document-123" },
|
|
585
|
+
});
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
This is particularly useful when:
|
|
589
|
+
- A user deletes a document and you need to remove all its chunks
|
|
590
|
+
- You're re-indexing a document and want to remove old vectors first
|
|
591
|
+
- You need to clean up vectors for a specific user or tenant
|
|
592
|
+
|
|
593
|
+
### Delete Multiple Documents
|
|
594
|
+
|
|
595
|
+
You can also use complex filters to delete vectors matching multiple conditions:
|
|
596
|
+
|
|
597
|
+
```ts title="delete-vectors-advanced.ts" showLineNumbers copy
|
|
598
|
+
// Delete all vectors for multiple documents
|
|
599
|
+
await store.deleteVectors({
|
|
600
|
+
indexName: "myCollection",
|
|
601
|
+
filter: {
|
|
602
|
+
docId: { $in: ["doc-1", "doc-2", "doc-3"] },
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
// Delete vectors for a specific user's documents
|
|
607
|
+
await store.deleteVectors({
|
|
608
|
+
indexName: "myCollection",
|
|
609
|
+
filter: {
|
|
610
|
+
$and: [
|
|
611
|
+
{ userId: "user-123" },
|
|
612
|
+
{ status: "archived" },
|
|
613
|
+
],
|
|
614
|
+
},
|
|
615
|
+
});
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
### Delete by Vector IDs
|
|
619
|
+
|
|
620
|
+
If you have specific vector IDs to delete, you can pass them directly:
|
|
621
|
+
|
|
622
|
+
```ts title="delete-by-ids.ts" showLineNumbers copy
|
|
623
|
+
// Delete specific vectors by their IDs
|
|
624
|
+
await store.deleteVectors({
|
|
625
|
+
indexName: "myCollection",
|
|
626
|
+
ids: ["vec-1", "vec-2", "vec-3"],
|
|
627
|
+
});
|
|
628
|
+
```
|
|
629
|
+
|
|
539
630
|
## Best Practices
|
|
540
631
|
|
|
541
632
|
- Create indexes before bulk insertions
|