@mastra/pg 1.32.0-alpha.4 → 1.32.0-alpha.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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +20 -0
- package/dist/docs/references/reference-memory-memory-class.md +2 -0
- package/dist/index.cjs +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/trace-aggregate.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/trace-query.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/docs/SKILL.md
CHANGED
|
@@ -405,6 +405,26 @@ Multilingual E5 produces 1024-dimensional vectors. Your vector index must be cre
|
|
|
405
405
|
|
|
406
406
|
FastEmbed models embed at most 512 tokens per input (roughly 2,000 to 2,500 characters of English text). Longer inputs are truncated, so text past the limit doesn't affect the embedding and can't be found by semantic recall. The AI SDK v3 FastEmbed models return a warning when this happens. The legacy v1 and v2 models don't. If you embed long documents with FastEmbed, chunk them to fit the window, for example with `maxSize: 1500` in `MDocument.chunk()`.
|
|
407
407
|
|
|
408
|
+
### Setting the embedding dimension
|
|
409
|
+
|
|
410
|
+
To name the vector index, Memory needs the embedder's output dimension. By default it finds the dimension by embedding a short probe string the first time semantic recall is set up, once per `Memory` instance. If you already know the dimension, set `embeddingDimension`. Memory then skips the probe, so startup makes no embedding call and doesn't depend on the embedding provider being reachable:
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
import { Memory } from '@mastra/memory'
|
|
414
|
+
|
|
415
|
+
const memory = new Memory({
|
|
416
|
+
embedder: 'openai/text-embedding-3-small',
|
|
417
|
+
embeddingDimension: 1536,
|
|
418
|
+
options: {
|
|
419
|
+
semanticRecall: true,
|
|
420
|
+
},
|
|
421
|
+
})
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
The index name is the same whether the dimension is configured or probed, so existing indexes keep working.
|
|
425
|
+
|
|
426
|
+
The value must match the vectors the embedder returns. Memory compares it with the first real embedding, and on a mismatch it throws a `MASTRA_MEMORY_EMBEDDING_DIMENSION_MISMATCH` error naming both values before creating or querying any index. Update `embeddingDimension` whenever you change the embedding model or its output dimension.
|
|
427
|
+
|
|
408
428
|
## PostgreSQL index optimization
|
|
409
429
|
|
|
410
430
|
When using PostgreSQL as your vector store, you can optimize semantic recall performance by configuring the vector index. This is particularly important for large-scale deployments with thousands of messages.
|
|
@@ -37,6 +37,8 @@ export const agent = new Agent({
|
|
|
37
37
|
|
|
38
38
|
**embedder** (`EmbeddingModel<string> | EmbeddingModelV2<string>`): Embedder instance for vector embeddings. Required when semantic recall is enabled.
|
|
39
39
|
|
|
40
|
+
**embeddingDimension** (`number`): Output dimension of the embedder, as a positive integer. When set, Memory uses it to name the semantic recall index instead of embedding a probe string on first use. It must match the vectors the embedder returns: a mismatch throws a MASTRA\_MEMORY\_EMBEDDING\_DIMENSION\_MISMATCH error before any index is created. See Setting the embedding dimension.
|
|
41
|
+
|
|
40
42
|
**options** (`MemoryConfig`): Memory configuration options.
|
|
41
43
|
|
|
42
44
|
**options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to false to disable the message history feature entirely (messages are not loaded into context or saved). Use Number.MAX\_SAFE\_INTEGER to retrieve all messages with no limit. To load messages without saving new ones, use the readOnly option. The window slides forward on every request, so once a thread exceeds the limit, each turn invalidates the provider prompt cache. For long-running conversations, use Observational Memory instead.
|
package/dist/index.cjs
CHANGED
|
@@ -19246,6 +19246,7 @@ const TRACE_FIELDS = {
|
|
|
19246
19246
|
endedAt: "r.\"endedAt\"",
|
|
19247
19247
|
durationMs: durationMsSql("r.\"startedAt\"", "r.\"endedAt\""),
|
|
19248
19248
|
timeToFirstChunkMs: "r.\"timeToFirstChunkMs\"",
|
|
19249
|
+
entityId: "r.\"entityId\"",
|
|
19249
19250
|
entityName: "r.\"entityName\"",
|
|
19250
19251
|
entityType: "r.\"entityType\"",
|
|
19251
19252
|
name: "r.\"name\"",
|
|
@@ -19547,6 +19548,7 @@ const ROOT_PUSHDOWN_FIELDS = /* @__PURE__ */ new Set([
|
|
|
19547
19548
|
"organizationId",
|
|
19548
19549
|
"startedAt",
|
|
19549
19550
|
"endedAt",
|
|
19551
|
+
"entityId",
|
|
19550
19552
|
"entityName",
|
|
19551
19553
|
"entityType",
|
|
19552
19554
|
"name",
|
|
@@ -20632,6 +20634,7 @@ const DIMENSION_SQL = {
|
|
|
20632
20634
|
entityName: "r.\"entityName\"",
|
|
20633
20635
|
name: "r.\"name\"",
|
|
20634
20636
|
spanType: "r.\"spanType\"",
|
|
20637
|
+
entityId: "r.\"entityId\"",
|
|
20635
20638
|
environment: "r.\"environment\"",
|
|
20636
20639
|
status: TRACE_STATUS_SQL,
|
|
20637
20640
|
serviceName: "r.\"serviceName\"",
|
|
@@ -21866,7 +21869,8 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
|
|
|
21866
21869
|
"feedback",
|
|
21867
21870
|
"trace-query-context-ids",
|
|
21868
21871
|
...timeToFirstChunkFeatures,
|
|
21869
|
-
"trace-query-root-span-fields"
|
|
21872
|
+
"trace-query-root-span-fields",
|
|
21873
|
+
"trace-query-root-entity-id"
|
|
21870
21874
|
];
|
|
21871
21875
|
return [
|
|
21872
21876
|
"metrics",
|
|
@@ -21889,7 +21893,8 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
|
|
|
21889
21893
|
"feedback",
|
|
21890
21894
|
"trace-query-context-ids",
|
|
21891
21895
|
...timeToFirstChunkFeatures,
|
|
21892
|
-
"trace-query-root-span-fields"
|
|
21896
|
+
"trace-query-root-span-fields",
|
|
21897
|
+
"trace-query-root-entity-id"
|
|
21893
21898
|
];
|
|
21894
21899
|
}
|
|
21895
21900
|
async #run(op, fn, details) {
|