koishi-plugin-group-memory 1.1.0 → 1.1.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/package.json +1 -1
- package/src/index.js +10 -20
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const { Schema } = require('koishi');
|
|
1
|
+
const { Schema } = require('koishi');
|
|
2
2
|
|
|
3
3
|
exports.name = 'group-memory';
|
|
4
4
|
exports.usage = '自动记录群聊上下文,并在用户@机器人或回复机器人时,将前情提要注入给 AI 插件';
|
|
5
5
|
|
|
6
|
-
// ---
|
|
6
|
+
// --- 修复:移除所有可能导致错误的 UI 方法 ---
|
|
7
7
|
exports.Config = Schema.object({
|
|
8
8
|
// --- 记忆设置 ---
|
|
9
9
|
maxContext: Schema.number()
|
|
@@ -41,21 +41,12 @@ exports.Config = Schema.object({
|
|
|
41
41
|
.default(true)
|
|
42
42
|
.description('是否移除图片/媒体占位符 (如 [图片])。'),
|
|
43
43
|
|
|
44
|
-
prefixTemplate: Schema.string()
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"\n---\n请结合以上上下文回答以下问题:";
|
|
51
|
-
})
|
|
52
|
-
.textarea()
|
|
53
|
-
.rows(5)
|
|
54
|
-
.description(
|
|
55
|
-
'自定义前情提要的模板字符串。注意:网页配置不支持动态 JS 函数,' +
|
|
56
|
-
'如果需要动态模板,可在配置文件中直接写函数。' +
|
|
57
|
-
'可用变量: {history} (JSON 格式的历史记录数组)'
|
|
58
|
-
),
|
|
44
|
+
// prefixTemplate: Schema.string() // 这个配置项比较复杂,不适合用 Schema.string() 来定义
|
|
45
|
+
// .default(...)
|
|
46
|
+
// .textarea() // 导致错误
|
|
47
|
+
// .rows(5) // 导致错误
|
|
48
|
+
// ...
|
|
49
|
+
// 我们将其移除,让其成为一个纯粹的代码逻辑,默认值直接在 apply 函数中硬编码。
|
|
59
50
|
|
|
60
51
|
// --- 调试 ---
|
|
61
52
|
verbose: Schema.boolean()
|
|
@@ -154,9 +145,8 @@ exports.apply = (ctx, config) => {
|
|
|
154
145
|
|
|
155
146
|
if (history.length === 0) return next();
|
|
156
147
|
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
// 更复杂的模板应该由用户在配置文件中定义函数来实现
|
|
148
|
+
// --- 修复:将 prefixTemplate 的逻辑移回 apply 函数内部 ---
|
|
149
|
+
// 由于 Schema 无法处理函数类型的配置,我们将模板逻辑放在这里
|
|
160
150
|
const contextLines = history.map(msg => `${msg.timeStr} ${msg.user}: ${msg.content}`);
|
|
161
151
|
const contextPrefix = `【群聊前情提要】\n${contextLines.join('\n')}\n---\n请结合以上上下文回答以下问题:`;
|
|
162
152
|
|