koishi-plugin-chatluna-long-memory 1.1.0 → 1.1.2

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 CHANGED
@@ -293,7 +293,7 @@ function calculateSimilarity(str1, str2) {
293
293
  __name(calculateSimilarity, "calculateSimilarity");
294
294
  async function filterSimilarMemoryByVectorStore(memoryArray, vectorStore, similarityThreshold) {
295
295
  const result = [];
296
- const existingMemories = await vectorStore.similaritySearch("", 1e3);
296
+ const existingMemories = await vectorStore.similaritySearch("test", 1e3);
297
297
  for (const memory of memoryArray) {
298
298
  let isSimilar = false;
299
299
  for (const existingMemory of existingMemories) {
@@ -310,7 +310,7 @@ async function filterSimilarMemoryByVectorStore(memoryArray, vectorStore, simila
310
310
  result.push(memory);
311
311
  } else {
312
312
  import_koishi_plugin_chatluna.logger?.debug(
313
- `Skip similar memory: ${memory.content}, threshold: ${similarityThreshold}`
313
+ `Skip memory: ${memory.content}, threshold: ${similarityThreshold}`
314
314
  );
315
315
  }
316
316
  }
@@ -911,7 +911,7 @@ async function generateNewQuestion(ctx, config, chatHistory, question) {
911
911
  const prompt = `
912
912
  Given the following conversation history and the user's question, generate a new search query that will help retrieve relevant information from a long-term memory database. The search query should be concise and focused on the key information needs.
913
913
 
914
- If you think the user's question is a casual greeting, a simple question that doesn't need memory retrieval, just respond with "[skip]".
914
+ If you think the user's question is a casual greeting, or a simple question that doesn't need more info, just respond with "[skip]".
915
915
 
916
916
  Conversation History:
917
917
  ${chatHistory}
@@ -984,7 +984,6 @@ async function extractMemoriesFromChat(ctx, config, chatInterface, chatHistory)
984
984
  if (!memories || memories.length === 0) {
985
985
  return [];
986
986
  }
987
- logger2?.debug(`Long memory extract: ${JSON.stringify(memories)}`);
988
987
  return memories;
989
988
  }
990
989
  __name(extractMemoriesFromChat, "extractMemoriesFromChat");
@@ -1065,6 +1064,11 @@ function apply2(ctx, config) {
1065
1064
  message.id,
1066
1065
  config.longMemoryInterval
1067
1066
  );
1067
+ import_koishi_plugin_chatluna_long_memory.logger?.debug(
1068
+ `Long memory search content: ${searchContent}, chat history: ${JSON.stringify(
1069
+ chatHistory
1070
+ )}`
1071
+ );
1068
1072
  searchContent = await generateNewQuestion(
1069
1073
  ctx,
1070
1074
  config,
@@ -1102,7 +1106,7 @@ function apply2(ctx, config) {
1102
1106
  import_koishi_plugin_chatluna_long_memory.MemoryRetrievalLayerType.PRESET_USER
1103
1107
  )) {
1104
1108
  import_koishi_plugin_chatluna_long_memory.logger?.warn(
1105
- "Long memory preset-user layer is not supported, only support preset-user layer"
1109
+ `Long memory ${ctx.chatluna_long_memory.defaultLayerTypes.join(", ")} layer is not supported, only support preset-user layer`
1106
1110
  );
1107
1111
  return void 0;
1108
1112
  }
package/lib/index.mjs CHANGED
@@ -256,7 +256,7 @@ function calculateSimilarity(str1, str2) {
256
256
  __name(calculateSimilarity, "calculateSimilarity");
257
257
  async function filterSimilarMemoryByVectorStore(memoryArray, vectorStore, similarityThreshold) {
258
258
  const result = [];
259
- const existingMemories = await vectorStore.similaritySearch("", 1e3);
259
+ const existingMemories = await vectorStore.similaritySearch("test", 1e3);
260
260
  for (const memory of memoryArray) {
261
261
  let isSimilar = false;
262
262
  for (const existingMemory of existingMemories) {
@@ -273,7 +273,7 @@ async function filterSimilarMemoryByVectorStore(memoryArray, vectorStore, simila
273
273
  result.push(memory);
274
274
  } else {
275
275
  logger?.debug(
276
- `Skip similar memory: ${memory.content}, threshold: ${similarityThreshold}`
276
+ `Skip memory: ${memory.content}, threshold: ${similarityThreshold}`
277
277
  );
278
278
  }
279
279
  }
@@ -877,7 +877,7 @@ async function generateNewQuestion(ctx, config, chatHistory, question) {
877
877
  const prompt = `
878
878
  Given the following conversation history and the user's question, generate a new search query that will help retrieve relevant information from a long-term memory database. The search query should be concise and focused on the key information needs.
879
879
 
880
- If you think the user's question is a casual greeting, a simple question that doesn't need memory retrieval, just respond with "[skip]".
880
+ If you think the user's question is a casual greeting, or a simple question that doesn't need more info, just respond with "[skip]".
881
881
 
882
882
  Conversation History:
883
883
  ${chatHistory}
@@ -950,7 +950,6 @@ async function extractMemoriesFromChat(ctx, config, chatInterface, chatHistory)
950
950
  if (!memories || memories.length === 0) {
951
951
  return [];
952
952
  }
953
- logger2?.debug(`Long memory extract: ${JSON.stringify(memories)}`);
954
953
  return memories;
955
954
  }
956
955
  __name(extractMemoriesFromChat, "extractMemoriesFromChat");
@@ -1031,6 +1030,11 @@ function apply2(ctx, config) {
1031
1030
  message.id,
1032
1031
  config.longMemoryInterval
1033
1032
  );
1033
+ logger4?.debug(
1034
+ `Long memory search content: ${searchContent}, chat history: ${JSON.stringify(
1035
+ chatHistory
1036
+ )}`
1037
+ );
1034
1038
  searchContent = await generateNewQuestion(
1035
1039
  ctx,
1036
1040
  config,
@@ -1068,7 +1072,7 @@ function apply2(ctx, config) {
1068
1072
  MemoryRetrievalLayerType2.PRESET_USER
1069
1073
  )) {
1070
1074
  logger4?.warn(
1071
- "Long memory preset-user layer is not supported, only support preset-user layer"
1075
+ `Long memory ${ctx.chatluna_long_memory.defaultLayerTypes.join(", ")} layer is not supported, only support preset-user layer`
1072
1076
  );
1073
1077
  return void 0;
1074
1078
  }
@@ -15,10 +15,10 @@ export declare class MemorySearchTool extends StructuredTool {
15
15
  layer: z.ZodArray<z.ZodUnion<[z.ZodLiteral<"user">, z.ZodLiteral<"preset_user">, z.ZodLiteral<"preset">, z.ZodLiteral<"global">]>, "many">;
16
16
  }, "strip", z.ZodTypeAny, {
17
17
  content?: string;
18
- layer?: ("global" | "user" | "preset" | "preset_user")[];
18
+ layer?: ("global" | "preset" | "user" | "preset_user")[];
19
19
  }, {
20
20
  content?: string;
21
- layer?: ("global" | "user" | "preset" | "preset_user")[];
21
+ layer?: ("global" | "preset" | "user" | "preset_user")[];
22
22
  }>;
23
23
  constructor(ctx: Context, params: CreateToolParams);
24
24
  /** @ignore */
@@ -45,14 +45,14 @@ export declare class MemoryAddTool extends StructuredTool {
45
45
  }>, "many">;
46
46
  layer: z.ZodArray<z.ZodUnion<[z.ZodLiteral<"user">, z.ZodLiteral<"preset_user">, z.ZodLiteral<"preset">, z.ZodLiteral<"global">]>, "many">;
47
47
  }, "strip", z.ZodTypeAny, {
48
- layer?: ("global" | "user" | "preset" | "preset_user")[];
48
+ layer?: ("global" | "preset" | "user" | "preset_user")[];
49
49
  memories?: {
50
50
  importance?: number;
51
51
  type?: MemoryType;
52
52
  content?: string;
53
53
  }[];
54
54
  }, {
55
- layer?: ("global" | "user" | "preset" | "preset_user")[];
55
+ layer?: ("global" | "preset" | "user" | "preset_user")[];
56
56
  memories?: {
57
57
  importance?: number;
58
58
  type?: MemoryType;
@@ -72,10 +72,10 @@ export declare class MemoryDeleteTool extends StructuredTool {
72
72
  memoryIds: z.ZodArray<z.ZodString, "many">;
73
73
  layer: z.ZodArray<z.ZodUnion<[z.ZodLiteral<"user">, z.ZodLiteral<"preset_user">, z.ZodLiteral<"preset">, z.ZodLiteral<"global">]>, "many">;
74
74
  }, "strip", z.ZodTypeAny, {
75
- layer?: ("global" | "user" | "preset" | "preset_user")[];
75
+ layer?: ("global" | "preset" | "user" | "preset_user")[];
76
76
  memoryIds?: string[];
77
77
  }, {
78
- layer?: ("global" | "user" | "preset" | "preset_user")[];
78
+ layer?: ("global" | "preset" | "user" | "preset_user")[];
79
79
  memoryIds?: string[];
80
80
  }>;
81
81
  constructor(ctx: Context, params: CreateToolParams);
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.1.0",
4
+ "version": "1.1.2",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "peerDependencies": {
65
65
  "koishi": "^4.18.1",
66
- "koishi-plugin-chatluna": "^1.1.0"
66
+ "koishi-plugin-chatluna": "^1.1.2"
67
67
  },
68
68
  "resolutions": {
69
69
  "@langchain/core": "0.3.18",