@aigne/default-memory 1.1.18 → 1.2.1
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 +27 -0
- package/lib/cjs/memory.d.ts +0 -6
- package/lib/cjs/memory.js +1 -30
- package/lib/dts/memory.d.ts +0 -6
- package/lib/esm/memory.d.ts +0 -6
- package/lib/esm/memory.js +2 -31
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.2.1](https://github.com/AIGNE-io/aigne-framework/compare/default-memory-v1.2.0...default-memory-v1.2.1) (2025-09-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Dependencies
|
|
7
|
+
|
|
8
|
+
* The following workspace dependencies were updated
|
|
9
|
+
* dependencies
|
|
10
|
+
* @aigne/core bumped to 1.58.1
|
|
11
|
+
* devDependencies
|
|
12
|
+
* @aigne/openai bumped to 0.14.1
|
|
13
|
+
|
|
14
|
+
## [1.2.0](https://github.com/AIGNE-io/aigne-framework/compare/default-memory-v1.1.18...default-memory-v1.2.0) (2025-09-05)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add modalities support for chat model ([#454](https://github.com/AIGNE-io/aigne-framework/issues/454)) ([70d1bf6](https://github.com/AIGNE-io/aigne-framework/commit/70d1bf631f4e711235d89c6df8ee210a19179b30))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Dependencies
|
|
23
|
+
|
|
24
|
+
* The following workspace dependencies were updated
|
|
25
|
+
* dependencies
|
|
26
|
+
* @aigne/core bumped to 1.58.0
|
|
27
|
+
* devDependencies
|
|
28
|
+
* @aigne/openai bumped to 0.14.0
|
|
29
|
+
|
|
3
30
|
## [1.1.18](https://github.com/AIGNE-io/aigne-framework/compare/default-memory-v1.1.17...default-memory-v1.1.18) (2025-09-01)
|
|
4
31
|
|
|
5
32
|
|
package/lib/cjs/memory.d.ts
CHANGED
|
@@ -13,10 +13,7 @@ export interface DefaultMemoryRetrieverOptions extends AgentOptions<MemoryRetrie
|
|
|
13
13
|
retrieveMemoryCount?: number;
|
|
14
14
|
retrieveRecentMemoryCount?: number;
|
|
15
15
|
inputKey?: string | string[];
|
|
16
|
-
outputKey?: string | string[];
|
|
17
16
|
getSearchPattern?: DefaultMemoryRetriever["getSearchPattern"];
|
|
18
|
-
formatMessage?: DefaultMemoryRetriever["formatMessage"];
|
|
19
|
-
formatMemory?: DefaultMemoryRetriever["formatMemory"];
|
|
20
17
|
}
|
|
21
18
|
export declare class DefaultMemoryRetriever extends MemoryRetriever {
|
|
22
19
|
constructor(options: DefaultMemoryRetrieverOptions);
|
|
@@ -24,10 +21,7 @@ export declare class DefaultMemoryRetriever extends MemoryRetriever {
|
|
|
24
21
|
private retrieveMemoryCount?;
|
|
25
22
|
private retrieveRecentMemoryCount?;
|
|
26
23
|
private inputKey?;
|
|
27
|
-
private outputKey?;
|
|
28
24
|
private getSearchPattern;
|
|
29
|
-
private formatMessage;
|
|
30
|
-
private formatMemory;
|
|
31
25
|
process(input: MemoryRetrieverInput, options: AgentInvokeOptions): Promise<MemoryRetrieverOutput>;
|
|
32
26
|
}
|
|
33
27
|
export interface DefaultMemoryRecorderOptions extends AgentOptions<MemoryRecorderInput, MemoryRecorderOutput> {
|
package/lib/cjs/memory.js
CHANGED
|
@@ -35,19 +35,13 @@ class DefaultMemoryRetriever extends core_1.MemoryRetriever {
|
|
|
35
35
|
this.retrieveMemoryCount = options.retrieveMemoryCount;
|
|
36
36
|
this.retrieveRecentMemoryCount = options.retrieveRecentMemoryCount;
|
|
37
37
|
this.inputKey = (0, type_utils_js_1.flat)(options.inputKey);
|
|
38
|
-
this.outputKey = (0, type_utils_js_1.flat)(options.outputKey);
|
|
39
38
|
if (options.getSearchPattern)
|
|
40
39
|
this.getSearchPattern = options.getSearchPattern;
|
|
41
|
-
if (options.formatMessage)
|
|
42
|
-
this.formatMessage = options.formatMessage;
|
|
43
|
-
if (options.formatMemory)
|
|
44
|
-
this.formatMemory = options.formatMemory;
|
|
45
40
|
}
|
|
46
41
|
storage;
|
|
47
42
|
retrieveMemoryCount;
|
|
48
43
|
retrieveRecentMemoryCount;
|
|
49
44
|
inputKey;
|
|
50
|
-
outputKey;
|
|
51
45
|
getSearchPattern = (search) => {
|
|
52
46
|
if (!search || typeof search === "string")
|
|
53
47
|
return search;
|
|
@@ -56,24 +50,6 @@ class DefaultMemoryRetriever extends core_1.MemoryRetriever {
|
|
|
56
50
|
.map((v) => (typeof v === "string" ? v : undefined))
|
|
57
51
|
.join("\n");
|
|
58
52
|
};
|
|
59
|
-
formatMessage = (content, key) => {
|
|
60
|
-
if (!(0, type_utils_js_1.isRecord)(content))
|
|
61
|
-
return content;
|
|
62
|
-
const obj = !key?.length ? content : (0, type_utils_js_1.pick)(content, key);
|
|
63
|
-
return Object.values(obj)
|
|
64
|
-
.map((v) => (typeof v === "string" ? v : undefined))
|
|
65
|
-
.join("\n");
|
|
66
|
-
};
|
|
67
|
-
formatMemory = (content) => {
|
|
68
|
-
if ((0, type_utils_js_1.isRecord)(content) && "input" in content && "output" in content) {
|
|
69
|
-
return {
|
|
70
|
-
input: this.formatMessage(content.input, this.inputKey),
|
|
71
|
-
output: this.formatMessage(content.output, this.outputKey),
|
|
72
|
-
source: content.source,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return content;
|
|
76
|
-
};
|
|
77
53
|
async process(input, options) {
|
|
78
54
|
const limit = input.limit ?? this.retrieveMemoryCount ?? DEFAULT_RETRIEVE_MEMORY_COUNT;
|
|
79
55
|
const search = this.getSearchPattern(input.search);
|
|
@@ -96,12 +72,7 @@ class DefaultMemoryRetriever extends core_1.MemoryRetriever {
|
|
|
96
72
|
.filter((i) => !recentSet.has(i.id))
|
|
97
73
|
.concat(recent)
|
|
98
74
|
.slice(-limit);
|
|
99
|
-
return {
|
|
100
|
-
memories: memories.map((i) => ({
|
|
101
|
-
...i,
|
|
102
|
-
content: this.formatMemory(i.content),
|
|
103
|
-
})),
|
|
104
|
-
};
|
|
75
|
+
return { memories };
|
|
105
76
|
}
|
|
106
77
|
}
|
|
107
78
|
exports.DefaultMemoryRetriever = DefaultMemoryRetriever;
|
package/lib/dts/memory.d.ts
CHANGED
|
@@ -13,10 +13,7 @@ export interface DefaultMemoryRetrieverOptions extends AgentOptions<MemoryRetrie
|
|
|
13
13
|
retrieveMemoryCount?: number;
|
|
14
14
|
retrieveRecentMemoryCount?: number;
|
|
15
15
|
inputKey?: string | string[];
|
|
16
|
-
outputKey?: string | string[];
|
|
17
16
|
getSearchPattern?: DefaultMemoryRetriever["getSearchPattern"];
|
|
18
|
-
formatMessage?: DefaultMemoryRetriever["formatMessage"];
|
|
19
|
-
formatMemory?: DefaultMemoryRetriever["formatMemory"];
|
|
20
17
|
}
|
|
21
18
|
export declare class DefaultMemoryRetriever extends MemoryRetriever {
|
|
22
19
|
constructor(options: DefaultMemoryRetrieverOptions);
|
|
@@ -24,10 +21,7 @@ export declare class DefaultMemoryRetriever extends MemoryRetriever {
|
|
|
24
21
|
private retrieveMemoryCount?;
|
|
25
22
|
private retrieveRecentMemoryCount?;
|
|
26
23
|
private inputKey?;
|
|
27
|
-
private outputKey?;
|
|
28
24
|
private getSearchPattern;
|
|
29
|
-
private formatMessage;
|
|
30
|
-
private formatMemory;
|
|
31
25
|
process(input: MemoryRetrieverInput, options: AgentInvokeOptions): Promise<MemoryRetrieverOutput>;
|
|
32
26
|
}
|
|
33
27
|
export interface DefaultMemoryRecorderOptions extends AgentOptions<MemoryRecorderInput, MemoryRecorderOutput> {
|
package/lib/esm/memory.d.ts
CHANGED
|
@@ -13,10 +13,7 @@ export interface DefaultMemoryRetrieverOptions extends AgentOptions<MemoryRetrie
|
|
|
13
13
|
retrieveMemoryCount?: number;
|
|
14
14
|
retrieveRecentMemoryCount?: number;
|
|
15
15
|
inputKey?: string | string[];
|
|
16
|
-
outputKey?: string | string[];
|
|
17
16
|
getSearchPattern?: DefaultMemoryRetriever["getSearchPattern"];
|
|
18
|
-
formatMessage?: DefaultMemoryRetriever["formatMessage"];
|
|
19
|
-
formatMemory?: DefaultMemoryRetriever["formatMemory"];
|
|
20
17
|
}
|
|
21
18
|
export declare class DefaultMemoryRetriever extends MemoryRetriever {
|
|
22
19
|
constructor(options: DefaultMemoryRetrieverOptions);
|
|
@@ -24,10 +21,7 @@ export declare class DefaultMemoryRetriever extends MemoryRetriever {
|
|
|
24
21
|
private retrieveMemoryCount?;
|
|
25
22
|
private retrieveRecentMemoryCount?;
|
|
26
23
|
private inputKey?;
|
|
27
|
-
private outputKey?;
|
|
28
24
|
private getSearchPattern;
|
|
29
|
-
private formatMessage;
|
|
30
|
-
private formatMemory;
|
|
31
25
|
process(input: MemoryRetrieverInput, options: AgentInvokeOptions): Promise<MemoryRetrieverOutput>;
|
|
32
26
|
}
|
|
33
27
|
export interface DefaultMemoryRecorderOptions extends AgentOptions<MemoryRecorderInput, MemoryRecorderOutput> {
|
package/lib/esm/memory.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MemoryAgent, MemoryRecorder, MemoryRetriever, } from "@aigne/core";
|
|
2
|
-
import { flat,
|
|
2
|
+
import { flat, pick } from "@aigne/core/utils/type-utils.js";
|
|
3
3
|
import { DefaultMemoryStorage, } from "./default-memory-storage/index.js";
|
|
4
4
|
import { MemoryStorage } from "./storage.js";
|
|
5
5
|
const DEFAULT_RETRIEVE_MEMORY_COUNT = 10;
|
|
@@ -31,19 +31,13 @@ export class DefaultMemoryRetriever extends MemoryRetriever {
|
|
|
31
31
|
this.retrieveMemoryCount = options.retrieveMemoryCount;
|
|
32
32
|
this.retrieveRecentMemoryCount = options.retrieveRecentMemoryCount;
|
|
33
33
|
this.inputKey = flat(options.inputKey);
|
|
34
|
-
this.outputKey = flat(options.outputKey);
|
|
35
34
|
if (options.getSearchPattern)
|
|
36
35
|
this.getSearchPattern = options.getSearchPattern;
|
|
37
|
-
if (options.formatMessage)
|
|
38
|
-
this.formatMessage = options.formatMessage;
|
|
39
|
-
if (options.formatMemory)
|
|
40
|
-
this.formatMemory = options.formatMemory;
|
|
41
36
|
}
|
|
42
37
|
storage;
|
|
43
38
|
retrieveMemoryCount;
|
|
44
39
|
retrieveRecentMemoryCount;
|
|
45
40
|
inputKey;
|
|
46
|
-
outputKey;
|
|
47
41
|
getSearchPattern = (search) => {
|
|
48
42
|
if (!search || typeof search === "string")
|
|
49
43
|
return search;
|
|
@@ -52,24 +46,6 @@ export class DefaultMemoryRetriever extends MemoryRetriever {
|
|
|
52
46
|
.map((v) => (typeof v === "string" ? v : undefined))
|
|
53
47
|
.join("\n");
|
|
54
48
|
};
|
|
55
|
-
formatMessage = (content, key) => {
|
|
56
|
-
if (!isRecord(content))
|
|
57
|
-
return content;
|
|
58
|
-
const obj = !key?.length ? content : pick(content, key);
|
|
59
|
-
return Object.values(obj)
|
|
60
|
-
.map((v) => (typeof v === "string" ? v : undefined))
|
|
61
|
-
.join("\n");
|
|
62
|
-
};
|
|
63
|
-
formatMemory = (content) => {
|
|
64
|
-
if (isRecord(content) && "input" in content && "output" in content) {
|
|
65
|
-
return {
|
|
66
|
-
input: this.formatMessage(content.input, this.inputKey),
|
|
67
|
-
output: this.formatMessage(content.output, this.outputKey),
|
|
68
|
-
source: content.source,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return content;
|
|
72
|
-
};
|
|
73
49
|
async process(input, options) {
|
|
74
50
|
const limit = input.limit ?? this.retrieveMemoryCount ?? DEFAULT_RETRIEVE_MEMORY_COUNT;
|
|
75
51
|
const search = this.getSearchPattern(input.search);
|
|
@@ -92,12 +68,7 @@ export class DefaultMemoryRetriever extends MemoryRetriever {
|
|
|
92
68
|
.filter((i) => !recentSet.has(i.id))
|
|
93
69
|
.concat(recent)
|
|
94
70
|
.slice(-limit);
|
|
95
|
-
return {
|
|
96
|
-
memories: memories.map((i) => ({
|
|
97
|
-
...i,
|
|
98
|
-
content: this.formatMemory(i.content),
|
|
99
|
-
})),
|
|
100
|
-
};
|
|
71
|
+
return { memories };
|
|
101
72
|
}
|
|
102
73
|
}
|
|
103
74
|
export class DefaultMemoryRecorder extends MemoryRecorder {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/default-memory",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Default memory for AIGNE framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"uuid": "^11.1.0",
|
|
37
37
|
"yaml": "^2.8.0",
|
|
38
38
|
"zod": "^3.25.67",
|
|
39
|
-
"@aigne/core": "^1.
|
|
39
|
+
"@aigne/core": "^1.58.1",
|
|
40
40
|
"@aigne/sqlite": "^0.4.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"npm-run-all": "^4.1.5",
|
|
45
45
|
"rimraf": "^6.0.1",
|
|
46
46
|
"typescript": "^5.8.3",
|
|
47
|
-
"@aigne/openai": "^0.
|
|
47
|
+
"@aigne/openai": "^0.14.1"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"lint": "tsc --noEmit",
|