@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.
@@ -1,22 +1,22 @@
1
1
 
2
- > @mastra/memory@0.1.3-alpha.1 build /home/runner/work/mastra/mastra/packages/memory
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.3-alpha.1 check /home/runner/work/mastra/mastra/packages/memory
6
+ > @mastra/memory@0.1.4 check /home/runner/work/mastra/mastra/packages/memory
7
7
  > tsc --noEmit
8
8
 
9
9
  CLI Building entry: src/index.ts
10
10
  CLI Using tsconfig: tsconfig.json
11
11
  CLI tsup v8.3.6
12
12
  TSC Build start
13
- TSC ⚡️ Build success in 7433ms
13
+ TSC ⚡️ Build success in 4427ms
14
14
  DTS Build start
15
15
  CLI Target: es2022
16
16
  Analysis will use the bundled TypeScript version 5.7.3
17
17
  Writing package typings: /home/runner/work/mastra/mastra/packages/memory/dist/_tsup-dts-rollup.d.ts
18
- DTS ⚡️ Build success in 6146ms
18
+ DTS ⚡️ Build success in 3839ms
19
19
  CLI Cleaning output folder
20
20
  ESM Build start
21
- ESM dist/index.js 9.10 KB
22
- ESM ⚡️ Build success in 430ms
21
+ ESM dist/index.js 9.23 KB
22
+ ESM ⚡️ 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({ messages }) {
123
+ async saveMessages({
124
+ messages,
125
+ memoryConfig
126
+ }) {
124
127
  await this.saveWorkingMemory(messages);
125
128
  this.mutateMessagesToHideWorkingMemory(messages);
126
- if (this.vector) {
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",
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.0"
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({ messages }: { messages: MessageType[] }): Promise<MessageType[]> {
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
- if (this.vector) {
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) {