@mastra/lance 1.1.2 → 1.2.0-alpha.0
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 +25 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-rag-vector-databases.md +7 -2
- package/dist/index.cjs +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +13 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @mastra/lance
|
|
2
2
|
|
|
3
|
+
## 1.2.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added exact metadata filtering to message history queries across Memory APIs and supported storage providers. ([#19991](https://github.com/mastra-ai/mastra/pull/19991))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const messages = await memory.recall({
|
|
11
|
+
threadId: 'thread-1',
|
|
12
|
+
filter: {
|
|
13
|
+
metadata: {
|
|
14
|
+
status: 'done',
|
|
15
|
+
priority: 'high',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Multiple fields use AND semantics. Supported values are strings, finite numbers, booleans, and `null`.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`0dca9d0`](https://github.com/mastra-ai/mastra/commit/0dca9d0b1356024a53b72ea6f040db528b126caa)]:
|
|
26
|
+
- @mastra/core@1.54.0-alpha.0
|
|
27
|
+
|
|
3
28
|
## 1.1.2
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -14,7 +14,7 @@ import { MongoDBVector } from '@mastra/mongodb'
|
|
|
14
14
|
const store = new MongoDBVector({
|
|
15
15
|
id: 'mongodb-vector',
|
|
16
16
|
uri: process.env.MONGODB_URI,
|
|
17
|
-
dbName: process.env.
|
|
17
|
+
dbName: process.env.MONGODB_DB_NAME,
|
|
18
18
|
})
|
|
19
19
|
await store.createIndex({
|
|
20
20
|
indexName: 'myCollection',
|
|
@@ -27,10 +27,14 @@ await store.upsert({
|
|
|
27
27
|
})
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
### Using MongoDB Atlas Vector
|
|
30
|
+
### Using MongoDB Atlas Vector Search
|
|
31
31
|
|
|
32
32
|
For detailed setup instructions and best practices, see the [official MongoDB Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/?utm_campaign=devrel\&utm_source=third-party-content\&utm_medium=cta\&utm_content=mastra-docs).
|
|
33
33
|
|
|
34
|
+
### Using VoyageAI with MongoDB
|
|
35
|
+
|
|
36
|
+
MongoDB works seamlessly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb).
|
|
37
|
+
|
|
34
38
|
**PgVector**:
|
|
35
39
|
|
|
36
40
|
```ts
|
|
@@ -359,6 +363,7 @@ The dimension size must match the output dimension of your chosen embedding mode
|
|
|
359
363
|
|
|
360
364
|
- `OpenAI text-embedding-3-small`: 1536 dimensions (or custom, e.g., 256)
|
|
361
365
|
- `Cohere embed-multilingual-v3`: 1024 dimensions
|
|
366
|
+
- `VoyageAI voyage-3.5`: 1024 dimensions (or custom: 256, 512, 1024, 2048)
|
|
362
367
|
- `Google gemini-embedding-001`: 768 dimensions (or custom)
|
|
363
368
|
|
|
364
369
|
> **Warning:** Index dimensions can't be changed after creation. To use a different model, delete and recreate the index with the new dimension size.
|
package/dist/index.cjs
CHANGED
|
@@ -1030,6 +1030,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
1030
1030
|
}
|
|
1031
1031
|
const perPage = storage.normalizePerPage(perPageInput, 40);
|
|
1032
1032
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1033
|
+
const metadataFilter = storage.validateStorageMetadataFilter(filter?.metadata);
|
|
1033
1034
|
try {
|
|
1034
1035
|
if (page < 0) {
|
|
1035
1036
|
throw new error.MastraError(
|
|
@@ -1074,9 +1075,14 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
1074
1075
|
hasMore: false
|
|
1075
1076
|
};
|
|
1076
1077
|
}
|
|
1077
|
-
const total = await table.countRows(whereClause);
|
|
1078
1078
|
const query = table.query().where(whereClause);
|
|
1079
1079
|
let allRecords = await query.toArray();
|
|
1080
|
+
if (metadataFilter) {
|
|
1081
|
+
allRecords = allRecords.filter(
|
|
1082
|
+
(row) => storage.storageMessageMatchesMetadataFilter(this.normalizeMessage(row).content, metadataFilter)
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
const total = allRecords.length;
|
|
1080
1086
|
allRecords.sort((a, b) => {
|
|
1081
1087
|
const aValue = field === "createdAt" ? a.createdAt : a[field];
|
|
1082
1088
|
const bValue = field === "createdAt" ? b.createdAt : b[field];
|
|
@@ -1099,6 +1105,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
1099
1105
|
hasMore: false
|
|
1100
1106
|
};
|
|
1101
1107
|
}
|
|
1108
|
+
const primaryPageCount = messages.length;
|
|
1102
1109
|
const messageIds = new Set(messages.map((m) => m.id));
|
|
1103
1110
|
if (include && include.length > 0) {
|
|
1104
1111
|
const includedMessages = await this._getIncludedMessages(table, include);
|
|
@@ -1112,10 +1119,11 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
1112
1119
|
const list = new agent.MessageList().add(messages, "memory");
|
|
1113
1120
|
let finalMessages = list.get.all.db();
|
|
1114
1121
|
finalMessages = this._sortMessages(finalMessages, field, direction);
|
|
1115
|
-
const
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1118
|
-
|
|
1122
|
+
const threadIdSet = new Set(threadIds);
|
|
1123
|
+
const returnedThreadMessageIds = new Set(
|
|
1124
|
+
finalMessages.filter((message) => message.threadId && threadIdSet.has(message.threadId)).map((message) => message.id)
|
|
1125
|
+
);
|
|
1126
|
+
const hasMore = perPageInput !== false && (metadataFilter || returnedThreadMessageIds.size < total) && offset + primaryPageCount < total;
|
|
1119
1127
|
return {
|
|
1120
1128
|
messages: finalMessages,
|
|
1121
1129
|
total,
|