@mastra/memory 0.1.3 → 0.1.4
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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +10 -0
- package/dist/_tsup-dts-rollup.d.ts +2 -1
- package/dist/index.js +7 -3
- package/package.json +2 -2
- package/src/index.ts +11 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/memory@0.1.
|
|
2
|
+
> @mastra/memory@0.1.4 build /home/runner/work/mastra/mastra/packages/memory
|
|
3
3
|
> pnpm run check && tsup src/index.ts --format esm --experimental-dts --clean --treeshake
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @mastra/memory@0.1.
|
|
6
|
+
> @mastra/memory@0.1.4 check /home/runner/work/mastra/mastra/packages/memory
|
|
7
7
|
> tsc --noEmit
|
|
8
8
|
|
|
9
9
|
[34mCLI[39m Building entry: src/index.ts
|
|
10
10
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
11
11
|
[34mCLI[39m tsup v8.3.6
|
|
12
12
|
[34mTSC[39m Build start
|
|
13
|
-
[32mTSC[39m ⚡️ Build success in
|
|
13
|
+
[32mTSC[39m ⚡️ Build success in 4427ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
15
|
[34mCLI[39m Target: es2022
|
|
16
16
|
Analysis will use the bundled TypeScript version 5.7.3
|
|
17
17
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/memory/dist/_tsup-dts-rollup.d.ts[39m
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 3839ms
|
|
19
19
|
[34mCLI[39m Cleaning output folder
|
|
20
20
|
[34mESM[39m Build start
|
|
21
|
-
[32mESM[39m [1mdist/index.js [22m[32m9.
|
|
22
|
-
[32mESM[39m ⚡️ Build success in
|
|
21
|
+
[32mESM[39m [1mdist/index.js [22m[32m9.23 KB[39m
|
|
22
|
+
[32mESM[39m ⚡️ Build success in 269ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ce44b9b: Fixed a bug where embeddings were being created for memory even when semanticRecall was turned off
|
|
8
|
+
- Updated dependencies [ce44b9b]
|
|
9
|
+
- Updated dependencies [967da43]
|
|
10
|
+
- Updated dependencies [b405f08]
|
|
11
|
+
- @mastra/core@0.4.1
|
|
12
|
+
|
|
3
13
|
## 0.1.3
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -41,8 +41,9 @@ export declare class Memory extends MastraMemory {
|
|
|
41
41
|
metadata: Record<string, unknown>;
|
|
42
42
|
}): Promise<StorageThreadType>;
|
|
43
43
|
deleteThread(threadId: string): Promise<void>;
|
|
44
|
-
saveMessages({ messages }: {
|
|
44
|
+
saveMessages({ messages, memoryConfig, }: {
|
|
45
45
|
messages: MessageType[];
|
|
46
|
+
memoryConfig?: MemoryConfig;
|
|
46
47
|
}): Promise<MessageType[]>;
|
|
47
48
|
protected mutateMessagesToHideWorkingMemory(messages: MessageType[]): void;
|
|
48
49
|
protected parseWorkingMemory(text: string): string | null;
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var Memory = class extends MastraMemory {
|
|
|
33
33
|
topK: config?.semanticRecall?.topK ?? 2,
|
|
34
34
|
messageRange: config?.semanticRecall?.messageRange ?? { before: 2, after: 2 }
|
|
35
35
|
};
|
|
36
|
-
if (selectBy?.vectorSearchString && this.vector) {
|
|
36
|
+
if (config?.semanticRecall && selectBy?.vectorSearchString && this.vector) {
|
|
37
37
|
const { embedding } = await embed({
|
|
38
38
|
value: selectBy.vectorSearchString,
|
|
39
39
|
model: this.embedder
|
|
@@ -120,10 +120,14 @@ var Memory = class extends MastraMemory {
|
|
|
120
120
|
async deleteThread(threadId) {
|
|
121
121
|
await this.storage.__deleteThread({ threadId });
|
|
122
122
|
}
|
|
123
|
-
async saveMessages({
|
|
123
|
+
async saveMessages({
|
|
124
|
+
messages,
|
|
125
|
+
memoryConfig
|
|
126
|
+
}) {
|
|
124
127
|
await this.saveWorkingMemory(messages);
|
|
125
128
|
this.mutateMessagesToHideWorkingMemory(messages);
|
|
126
|
-
|
|
129
|
+
const config = this.getMergedThreadConfig(memoryConfig);
|
|
130
|
+
if (this.vector && config.semanticRecall) {
|
|
127
131
|
const { indexName } = await this.createEmbeddingIndex();
|
|
128
132
|
for (const message of messages) {
|
|
129
133
|
if (typeof message.content !== `string`) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"pg-pool": "^3.7.0",
|
|
37
37
|
"postgres": "^3.4.5",
|
|
38
38
|
"redis": "^4.7.0",
|
|
39
|
-
"@mastra/core": "^0.4.
|
|
39
|
+
"@mastra/core": "^0.4.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@microsoft/api-extractor": "^7.49.2",
|
package/src/index.ts
CHANGED
|
@@ -56,7 +56,7 @@ export class Memory extends MastraMemory {
|
|
|
56
56
|
messageRange: config?.semanticRecall?.messageRange ?? { before: 2, after: 2 },
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
if (selectBy?.vectorSearchString && this.vector) {
|
|
59
|
+
if (config?.semanticRecall && selectBy?.vectorSearchString && this.vector) {
|
|
60
60
|
const { embedding } = await embed({
|
|
61
61
|
value: selectBy.vectorSearchString,
|
|
62
62
|
model: this.embedder,
|
|
@@ -187,14 +187,22 @@ export class Memory extends MastraMemory {
|
|
|
187
187
|
// }
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
async saveMessages({
|
|
190
|
+
async saveMessages({
|
|
191
|
+
messages,
|
|
192
|
+
memoryConfig,
|
|
193
|
+
}: {
|
|
194
|
+
messages: MessageType[];
|
|
195
|
+
memoryConfig?: MemoryConfig;
|
|
196
|
+
}): Promise<MessageType[]> {
|
|
191
197
|
// First save working memory from any messages
|
|
192
198
|
await this.saveWorkingMemory(messages);
|
|
193
199
|
|
|
194
200
|
// Then strip working memory tags from all messages
|
|
195
201
|
this.mutateMessagesToHideWorkingMemory(messages);
|
|
196
202
|
|
|
197
|
-
|
|
203
|
+
const config = this.getMergedThreadConfig(memoryConfig);
|
|
204
|
+
|
|
205
|
+
if (this.vector && config.semanticRecall) {
|
|
198
206
|
const { indexName } = await this.createEmbeddingIndex();
|
|
199
207
|
|
|
200
208
|
for (const message of messages) {
|