koishi-plugin-chatluna-long-memory 1.2.4 → 1.2.5
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/lib/index.cjs +9 -14
- package/lib/index.mjs +9 -14
- package/lib/plugins/tool.d.ts +45 -6
- package/package.json +6 -6
package/lib/index.cjs
CHANGED
|
@@ -1377,8 +1377,7 @@ async function apply8(ctx, config, plugin) {
|
|
|
1377
1377
|
selector(history) {
|
|
1378
1378
|
return true;
|
|
1379
1379
|
},
|
|
1380
|
-
|
|
1381
|
-
async createTool(params, session) {
|
|
1380
|
+
async createTool(params) {
|
|
1382
1381
|
return new MemorySearchTool(ctx, params);
|
|
1383
1382
|
}
|
|
1384
1383
|
});
|
|
@@ -1386,8 +1385,7 @@ async function apply8(ctx, config, plugin) {
|
|
|
1386
1385
|
selector(history) {
|
|
1387
1386
|
return true;
|
|
1388
1387
|
},
|
|
1389
|
-
|
|
1390
|
-
async createTool(params, session) {
|
|
1388
|
+
async createTool(params) {
|
|
1391
1389
|
return new MemoryAddTool(ctx, params);
|
|
1392
1390
|
}
|
|
1393
1391
|
});
|
|
@@ -1395,8 +1393,7 @@ async function apply8(ctx, config, plugin) {
|
|
|
1395
1393
|
selector(history) {
|
|
1396
1394
|
return true;
|
|
1397
1395
|
},
|
|
1398
|
-
|
|
1399
|
-
async createTool(params, session) {
|
|
1396
|
+
async createTool(params) {
|
|
1400
1397
|
return new MemoryDeleteTool(ctx, params);
|
|
1401
1398
|
}
|
|
1402
1399
|
});
|
|
@@ -1422,13 +1419,12 @@ var MemorySearchTool = class extends import_tools.StructuredTool {
|
|
|
1422
1419
|
import_zod.z.literal("global")
|
|
1423
1420
|
])
|
|
1424
1421
|
).describe("The layer of the memory")
|
|
1425
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1426
1422
|
});
|
|
1427
1423
|
/** @ignore */
|
|
1428
|
-
async _call(input) {
|
|
1424
|
+
async _call(input, _, config) {
|
|
1429
1425
|
try {
|
|
1430
1426
|
const result = await this.ctx.chatluna_long_memory.retrieveMemory(
|
|
1431
|
-
|
|
1427
|
+
config.metadata.conversationId,
|
|
1432
1428
|
input.content,
|
|
1433
1429
|
input.layer != null ? input.layer.map(
|
|
1434
1430
|
(layer) => MemoryRetrievalLayerType[layer.toUpperCase()]
|
|
@@ -1477,10 +1473,9 @@ var MemoryAddTool = class extends import_tools.StructuredTool {
|
|
|
1477
1473
|
import_zod.z.literal("global")
|
|
1478
1474
|
])
|
|
1479
1475
|
).describe("The layer of the memory")
|
|
1480
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1481
1476
|
});
|
|
1482
1477
|
/** @ignore */
|
|
1483
|
-
async _call(input) {
|
|
1478
|
+
async _call(input, _, config) {
|
|
1484
1479
|
try {
|
|
1485
1480
|
const enhancedMemories = input.memories.map((memory) => {
|
|
1486
1481
|
return {
|
|
@@ -1494,7 +1489,7 @@ var MemoryAddTool = class extends import_tools.StructuredTool {
|
|
|
1494
1489
|
};
|
|
1495
1490
|
});
|
|
1496
1491
|
await this.ctx.chatluna_long_memory.addMemories(
|
|
1497
|
-
|
|
1492
|
+
config.metadata.conversationId,
|
|
1498
1493
|
enhancedMemories,
|
|
1499
1494
|
input.layer != null ? input.layer.map(
|
|
1500
1495
|
(layer) => MemoryRetrievalLayerType[layer.toUpperCase()]
|
|
@@ -1546,10 +1541,10 @@ var MemoryDeleteTool = class extends import_tools.StructuredTool {
|
|
|
1546
1541
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1547
1542
|
});
|
|
1548
1543
|
/** @ignore */
|
|
1549
|
-
async _call(input) {
|
|
1544
|
+
async _call(input, _, config) {
|
|
1550
1545
|
try {
|
|
1551
1546
|
await this.ctx.chatluna_long_memory.deleteMemories(
|
|
1552
|
-
|
|
1547
|
+
config.metadata.conversationId,
|
|
1553
1548
|
input.memoryIds,
|
|
1554
1549
|
input.layer != null ? input.layer.map(
|
|
1555
1550
|
(layer) => MemoryRetrievalLayerType[layer.toUpperCase()]
|
package/lib/index.mjs
CHANGED
|
@@ -1343,8 +1343,7 @@ async function apply8(ctx, config, plugin) {
|
|
|
1343
1343
|
selector(history) {
|
|
1344
1344
|
return true;
|
|
1345
1345
|
},
|
|
1346
|
-
|
|
1347
|
-
async createTool(params, session) {
|
|
1346
|
+
async createTool(params) {
|
|
1348
1347
|
return new MemorySearchTool(ctx, params);
|
|
1349
1348
|
}
|
|
1350
1349
|
});
|
|
@@ -1352,8 +1351,7 @@ async function apply8(ctx, config, plugin) {
|
|
|
1352
1351
|
selector(history) {
|
|
1353
1352
|
return true;
|
|
1354
1353
|
},
|
|
1355
|
-
|
|
1356
|
-
async createTool(params, session) {
|
|
1354
|
+
async createTool(params) {
|
|
1357
1355
|
return new MemoryAddTool(ctx, params);
|
|
1358
1356
|
}
|
|
1359
1357
|
});
|
|
@@ -1361,8 +1359,7 @@ async function apply8(ctx, config, plugin) {
|
|
|
1361
1359
|
selector(history) {
|
|
1362
1360
|
return true;
|
|
1363
1361
|
},
|
|
1364
|
-
|
|
1365
|
-
async createTool(params, session) {
|
|
1362
|
+
async createTool(params) {
|
|
1366
1363
|
return new MemoryDeleteTool(ctx, params);
|
|
1367
1364
|
}
|
|
1368
1365
|
});
|
|
@@ -1388,13 +1385,12 @@ var MemorySearchTool = class extends StructuredTool {
|
|
|
1388
1385
|
z.literal("global")
|
|
1389
1386
|
])
|
|
1390
1387
|
).describe("The layer of the memory")
|
|
1391
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1392
1388
|
});
|
|
1393
1389
|
/** @ignore */
|
|
1394
|
-
async _call(input) {
|
|
1390
|
+
async _call(input, _, config) {
|
|
1395
1391
|
try {
|
|
1396
1392
|
const result = await this.ctx.chatluna_long_memory.retrieveMemory(
|
|
1397
|
-
|
|
1393
|
+
config.metadata.conversationId,
|
|
1398
1394
|
input.content,
|
|
1399
1395
|
input.layer != null ? input.layer.map(
|
|
1400
1396
|
(layer) => MemoryRetrievalLayerType[layer.toUpperCase()]
|
|
@@ -1443,10 +1439,9 @@ var MemoryAddTool = class extends StructuredTool {
|
|
|
1443
1439
|
z.literal("global")
|
|
1444
1440
|
])
|
|
1445
1441
|
).describe("The layer of the memory")
|
|
1446
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1447
1442
|
});
|
|
1448
1443
|
/** @ignore */
|
|
1449
|
-
async _call(input) {
|
|
1444
|
+
async _call(input, _, config) {
|
|
1450
1445
|
try {
|
|
1451
1446
|
const enhancedMemories = input.memories.map((memory) => {
|
|
1452
1447
|
return {
|
|
@@ -1460,7 +1455,7 @@ var MemoryAddTool = class extends StructuredTool {
|
|
|
1460
1455
|
};
|
|
1461
1456
|
});
|
|
1462
1457
|
await this.ctx.chatluna_long_memory.addMemories(
|
|
1463
|
-
|
|
1458
|
+
config.metadata.conversationId,
|
|
1464
1459
|
enhancedMemories,
|
|
1465
1460
|
input.layer != null ? input.layer.map(
|
|
1466
1461
|
(layer) => MemoryRetrievalLayerType[layer.toUpperCase()]
|
|
@@ -1512,10 +1507,10 @@ var MemoryDeleteTool = class extends StructuredTool {
|
|
|
1512
1507
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1513
1508
|
});
|
|
1514
1509
|
/** @ignore */
|
|
1515
|
-
async _call(input) {
|
|
1510
|
+
async _call(input, _, config) {
|
|
1516
1511
|
try {
|
|
1517
1512
|
await this.ctx.chatluna_long_memory.deleteMemories(
|
|
1518
|
-
|
|
1513
|
+
config.metadata.conversationId,
|
|
1519
1514
|
input.memoryIds,
|
|
1520
1515
|
input.layer != null ? input.layer.map(
|
|
1521
1516
|
(layer) => MemoryRetrievalLayerType[layer.toUpperCase()]
|
package/lib/plugins/tool.d.ts
CHANGED
|
@@ -2,27 +2,66 @@ import { StructuredTool } from '@langchain/core/tools';
|
|
|
2
2
|
import { Context } from 'koishi';
|
|
3
3
|
import { ChatLunaPlugin } from 'koishi-plugin-chatluna/services/chat';
|
|
4
4
|
import { Config } from '../index';
|
|
5
|
-
import { CreateToolParams } from 'koishi-plugin-chatluna/llm-core/platform/types';
|
|
5
|
+
import { ChatLunaToolRunnable, CreateToolParams } from 'koishi-plugin-chatluna/llm-core/platform/types';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
+
import { MemoryType } from '../types';
|
|
7
8
|
export declare function apply(ctx: Context, config: Config, plugin: ChatLunaPlugin): Promise<void>;
|
|
8
9
|
export declare class MemorySearchTool extends StructuredTool {
|
|
9
10
|
private ctx;
|
|
10
11
|
private params;
|
|
11
12
|
name: string;
|
|
12
|
-
schema:
|
|
13
|
+
schema: z.ZodObject<{
|
|
14
|
+
content: z.ZodString;
|
|
15
|
+
layer: z.ZodArray<z.ZodUnion<[z.ZodLiteral<"user">, z.ZodLiteral<"preset_user">, z.ZodLiteral<"preset">, z.ZodLiteral<"global">]>, "many">;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
content?: string;
|
|
18
|
+
layer?: ("user" | "preset_user" | "preset" | "global")[];
|
|
19
|
+
}, {
|
|
20
|
+
content?: string;
|
|
21
|
+
layer?: ("user" | "preset_user" | "preset" | "global")[];
|
|
22
|
+
}>;
|
|
13
23
|
constructor(ctx: Context, params: CreateToolParams);
|
|
14
24
|
/** @ignore */
|
|
15
|
-
_call(input: z.infer<typeof this.schema
|
|
25
|
+
_call(input: z.infer<typeof this.schema>, _: any, config: ChatLunaToolRunnable): Promise<string>;
|
|
16
26
|
description: string;
|
|
17
27
|
}
|
|
18
28
|
export declare class MemoryAddTool extends StructuredTool {
|
|
19
29
|
private ctx;
|
|
20
30
|
private params;
|
|
21
31
|
name: string;
|
|
22
|
-
schema:
|
|
32
|
+
schema: z.ZodObject<{
|
|
33
|
+
memories: z.ZodArray<z.ZodObject<{
|
|
34
|
+
content: z.ZodString;
|
|
35
|
+
type: z.ZodNativeEnum<typeof MemoryType>;
|
|
36
|
+
importance: z.ZodNumber;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
content?: string;
|
|
39
|
+
type?: MemoryType;
|
|
40
|
+
importance?: number;
|
|
41
|
+
}, {
|
|
42
|
+
content?: string;
|
|
43
|
+
type?: MemoryType;
|
|
44
|
+
importance?: number;
|
|
45
|
+
}>, "many">;
|
|
46
|
+
layer: z.ZodArray<z.ZodUnion<[z.ZodLiteral<"user">, z.ZodLiteral<"preset_user">, z.ZodLiteral<"preset">, z.ZodLiteral<"global">]>, "many">;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
layer?: ("user" | "preset_user" | "preset" | "global")[];
|
|
49
|
+
memories?: {
|
|
50
|
+
content?: string;
|
|
51
|
+
type?: MemoryType;
|
|
52
|
+
importance?: number;
|
|
53
|
+
}[];
|
|
54
|
+
}, {
|
|
55
|
+
layer?: ("user" | "preset_user" | "preset" | "global")[];
|
|
56
|
+
memories?: {
|
|
57
|
+
content?: string;
|
|
58
|
+
type?: MemoryType;
|
|
59
|
+
importance?: number;
|
|
60
|
+
}[];
|
|
61
|
+
}>;
|
|
23
62
|
constructor(ctx: Context, params: CreateToolParams);
|
|
24
63
|
/** @ignore */
|
|
25
|
-
_call(input: z.infer<typeof this.schema
|
|
64
|
+
_call(input: z.infer<typeof this.schema>, _: any, config: ChatLunaToolRunnable): Promise<string>;
|
|
26
65
|
description: string;
|
|
27
66
|
}
|
|
28
67
|
export declare class MemoryDeleteTool extends StructuredTool {
|
|
@@ -32,6 +71,6 @@ export declare class MemoryDeleteTool extends StructuredTool {
|
|
|
32
71
|
schema: any;
|
|
33
72
|
constructor(ctx: Context, params: CreateToolParams);
|
|
34
73
|
/** @ignore */
|
|
35
|
-
_call(input: z.infer<typeof this.schema
|
|
74
|
+
_call(input: z.infer<typeof this.schema>, _: any, config: ChatLunaToolRunnable): Promise<string>;
|
|
36
75
|
description: string;
|
|
37
76
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna-long-memory",
|
|
3
3
|
"description": "long memory for chatluna",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.5",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"search"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@langchain/core": "
|
|
51
|
+
"@langchain/core": "0.3.62",
|
|
52
52
|
"jieba-wasm": "^2.2.0",
|
|
53
53
|
"stopwords-iso": "^1.1.0",
|
|
54
54
|
"tiny-segmenter": "^0.2.0",
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"koishi": "^4.18.7",
|
|
66
|
-
"koishi-plugin-chatluna": "^1.3.0-alpha.
|
|
66
|
+
"koishi-plugin-chatluna": "^1.3.0-alpha.26"
|
|
67
67
|
},
|
|
68
68
|
"resolutions": {
|
|
69
|
-
"@langchain/core": "0.3.
|
|
69
|
+
"@langchain/core": "0.3.62",
|
|
70
70
|
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.19"
|
|
71
71
|
},
|
|
72
72
|
"overrides": {
|
|
73
|
-
"@langchain/core": "0.3.
|
|
73
|
+
"@langchain/core": "0.3.62",
|
|
74
74
|
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.19"
|
|
75
75
|
},
|
|
76
76
|
"pnpm": {
|
|
77
77
|
"overrides": {
|
|
78
|
-
"@langchain/core": "0.3.
|
|
78
|
+
"@langchain/core": "0.3.62",
|
|
79
79
|
"js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.19"
|
|
80
80
|
}
|
|
81
81
|
},
|