@easynet/agent-memory 1.0.55 → 1.0.56
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/README.md +28 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,34 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
`@easynet/agent-memory` provides the memory layer for agents. It manages `thread`, `cross_thread`, and `knowledge` memory and registers the memory client into the default `AgentContext`.
|
|
6
6
|
|
|
7
|
-
## Exposed
|
|
7
|
+
## Exposed Interfaces
|
|
8
8
|
|
|
9
9
|
| Export | Type | Purpose |
|
|
10
10
|
| --- | --- | --- |
|
|
11
|
-
| `createAgentMemory` | function |
|
|
12
|
-
| `CreateAgentMemoryOptions` | type | Options for
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm i @easynet/agent-memory
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import { createAgentMemory } from "@easynet/agent-memory";
|
|
22
|
-
|
|
23
|
-
const memory = await createAgentMemory("./config/memory.yaml");
|
|
24
|
-
|
|
25
|
-
await memory.memorize("user:demo", "cross_thread", "User prefers concise answers.");
|
|
26
|
-
const result = await memory.recall({
|
|
27
|
-
namespace: "user:demo",
|
|
28
|
-
query: "user preference",
|
|
29
|
-
types: ["cross_thread"],
|
|
30
|
-
topK: 5,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
console.log(result.injectedText);
|
|
34
|
-
```
|
|
11
|
+
| `createAgentMemory` | function | Create the memory service and register it into the default `AgentContext`. |
|
|
12
|
+
| `CreateAgentMemoryOptions` | type | Options for memory initialization. |
|
|
35
13
|
|
|
36
14
|
## Configuration
|
|
37
15
|
|
|
@@ -47,27 +25,39 @@ spec:
|
|
|
47
25
|
thread:
|
|
48
26
|
store:
|
|
49
27
|
type: in_memory
|
|
50
|
-
allowWrite: true
|
|
51
|
-
maxItems: 20
|
|
52
|
-
|
|
53
28
|
cross_thread:
|
|
54
29
|
store:
|
|
55
30
|
type: in_memory
|
|
56
|
-
allowWrite: true
|
|
57
|
-
maxItems: 20
|
|
58
|
-
|
|
59
31
|
knowledge:
|
|
60
32
|
store:
|
|
61
33
|
type: in_memory
|
|
62
|
-
allowWrite: true
|
|
63
|
-
maxItems: 20
|
|
64
34
|
```
|
|
65
35
|
|
|
66
36
|
Key fields:
|
|
67
37
|
|
|
68
|
-
- `spec.memory.thread`: current
|
|
69
|
-
- `spec.memory.cross_thread`: long-term memory
|
|
38
|
+
- `spec.memory.thread`: current-thread memory
|
|
39
|
+
- `spec.memory.cross_thread`: shared long-term memory
|
|
70
40
|
- `spec.memory.knowledge`: document and knowledge memory
|
|
71
|
-
- `store.type`:
|
|
72
|
-
|
|
73
|
-
|
|
41
|
+
- `store.type`: backend type
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm i @easynet/agent-memory
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { createAgentMemory } from "@easynet/agent-memory";
|
|
51
|
+
|
|
52
|
+
const memory = await createAgentMemory("./config/memory.yaml");
|
|
53
|
+
|
|
54
|
+
await memory.memorize("user:demo", "cross_thread", "User prefers concise answers.");
|
|
55
|
+
const result = await memory.recall({
|
|
56
|
+
namespace: "user:demo",
|
|
57
|
+
query: "user preference",
|
|
58
|
+
types: ["cross_thread"],
|
|
59
|
+
topK: 5,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
console.log(result.injectedText);
|
|
63
|
+
```
|