@nestim/koishi-plugin-qq-group-manager 1.4.12 → 1.4.13
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 +8 -0
- package/lib/ai/engine.js +12 -2
- package/lib/ai/learn.js +2 -2
- package/package.json +1 -1
- package/src/ai/engine.ts +12 -2
- package/src/ai/learn.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
本文件记录所有值得注意的变更。版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
|
4
4
|
|
|
5
|
+
## 1.4.13
|
|
6
|
+
|
|
7
|
+
### 修复
|
|
8
|
+
|
|
9
|
+
- 主动话题的最近聊天标注「最后一条 X 分钟前」,避免把很久以前的消息当成当前话题;
|
|
10
|
+
- 主动话题的联网搜索会先去掉 `[图片]`、`[表情]` 等占位符,避免拿占位符当搜索词;
|
|
11
|
+
- 归纳解析会去掉 `**` 等 Markdown 残留,分类名更干净。
|
|
12
|
+
|
|
5
13
|
## 1.4.12
|
|
6
14
|
|
|
7
15
|
### 改进
|
package/lib/ai/engine.js
CHANGED
|
@@ -1302,6 +1302,11 @@ class AiEngine {
|
|
|
1302
1302
|
const contextText = records
|
|
1303
1303
|
.map((record) => (0, prompt_1.renderRecordLine)(record, this.selfName))
|
|
1304
1304
|
.join('\n');
|
|
1305
|
+
const lastAt = records.length ? Number(records[records.length - 1].at) || 0 : 0;
|
|
1306
|
+
const gapMinutes = lastAt ? Math.max(0, Math.round((this.now() - lastAt) / 60000)) : 0;
|
|
1307
|
+
const contextLabel = gapMinutes
|
|
1308
|
+
? `【最近聊天】(最后一条 ${gapMinutes} 分钟前)`
|
|
1309
|
+
: '【最近聊天】';
|
|
1305
1310
|
// 相关记忆:用最近几句话做查询;没有上下文就取最近两条
|
|
1306
1311
|
let memories = [];
|
|
1307
1312
|
try {
|
|
@@ -1323,7 +1328,12 @@ class AiEngine {
|
|
|
1323
1328
|
let searchSection = '';
|
|
1324
1329
|
if (this.config.aiIdleTopicWebSearch !== false) {
|
|
1325
1330
|
const lastText = records.length ? String(records[records.length - 1].text || '') : '';
|
|
1326
|
-
const
|
|
1331
|
+
const cleanLast = lastText
|
|
1332
|
+
.replace(/\[[^\]]{1,16}\]/g, ' ')
|
|
1333
|
+
.replace(/[图片表情视频语音文件]/g, ' ')
|
|
1334
|
+
.replace(/\s+/g, ' ')
|
|
1335
|
+
.trim();
|
|
1336
|
+
const seed = cleanLast.length >= 4 ? cleanLast : '今天有什么热点话题';
|
|
1327
1337
|
try {
|
|
1328
1338
|
searchSection = await this.webSearch({ text: seed }, session, true);
|
|
1329
1339
|
}
|
|
@@ -1335,7 +1345,7 @@ class AiEngine {
|
|
|
1335
1345
|
personaOverride || this.personaPrompt,
|
|
1336
1346
|
`现在是 ${nowText}。`,
|
|
1337
1347
|
'群里已经很久没人说话了。主动抛一个轻松、具体、能接话的话题,一句话。',
|
|
1338
|
-
contextText ?
|
|
1348
|
+
contextText ? `${contextLabel}\n${contextText}` : '',
|
|
1339
1349
|
memories.length ? `【相关记忆】\n${memories.map((item) => `- ${item}`).join('\n')}` : '',
|
|
1340
1350
|
searchSection,
|
|
1341
1351
|
'要求:',
|
package/lib/ai/learn.js
CHANGED
|
@@ -45,7 +45,7 @@ const CATEGORY_ALIASES = {
|
|
|
45
45
|
其他: '其他',
|
|
46
46
|
};
|
|
47
47
|
function normalizeMemoryCategory(raw) {
|
|
48
|
-
const value = String(raw || '').trim().replace(/[
|
|
48
|
+
const value = String(raw || '').trim().replace(/[\s*_`「」【】\[\]]/g, '');
|
|
49
49
|
if (!value)
|
|
50
50
|
return '其他';
|
|
51
51
|
if (exports.MEMORY_CATEGORIES.includes(value))
|
|
@@ -201,7 +201,7 @@ function parseSummaryEntries(raw, maxChars = exports.MAX_SUMMARY_CHARS) {
|
|
|
201
201
|
category = normalizeMemoryCategory(match[1]);
|
|
202
202
|
body = match[2];
|
|
203
203
|
}
|
|
204
|
-
const cleaned = cleanSummary(body, maxChars);
|
|
204
|
+
const cleaned = cleanSummary(body.replace(/\*\*/g, ''), maxChars);
|
|
205
205
|
if (!cleaned)
|
|
206
206
|
continue;
|
|
207
207
|
const key = `${category}|${cleaned}`;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestim/koishi-plugin-qq-group-manager",
|
|
3
3
|
"description": "Koishi QQ群管理插件(OneBot/LLOneBot):群管命令、权限校验、图片菜单、状态卡片、复读、AI群聊回复、记忆库、识图与自动管控(禁言/踢人)。",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.13",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
package/src/ai/engine.ts
CHANGED
|
@@ -1373,6 +1373,11 @@ export class AiEngine {
|
|
|
1373
1373
|
const contextText = records
|
|
1374
1374
|
.map((record) => renderRecordLine(record, this.selfName))
|
|
1375
1375
|
.join('\n');
|
|
1376
|
+
const lastAt = records.length ? Number(records[records.length - 1].at) || 0 : 0;
|
|
1377
|
+
const gapMinutes = lastAt ? Math.max(0, Math.round((this.now() - lastAt) / 60000)) : 0;
|
|
1378
|
+
const contextLabel = gapMinutes
|
|
1379
|
+
? `【最近聊天】(最后一条 ${gapMinutes} 分钟前)`
|
|
1380
|
+
: '【最近聊天】';
|
|
1376
1381
|
|
|
1377
1382
|
// 相关记忆:用最近几句话做查询;没有上下文就取最近两条
|
|
1378
1383
|
let memories: string[] = [];
|
|
@@ -1395,7 +1400,12 @@ export class AiEngine {
|
|
|
1395
1400
|
let searchSection = '';
|
|
1396
1401
|
if (this.config.aiIdleTopicWebSearch !== false) {
|
|
1397
1402
|
const lastText = records.length ? String(records[records.length - 1].text || '') : '';
|
|
1398
|
-
const
|
|
1403
|
+
const cleanLast = lastText
|
|
1404
|
+
.replace(/\[[^\]]{1,16}\]/g, ' ')
|
|
1405
|
+
.replace(/[图片表情视频语音文件]/g, ' ')
|
|
1406
|
+
.replace(/\s+/g, ' ')
|
|
1407
|
+
.trim();
|
|
1408
|
+
const seed = cleanLast.length >= 4 ? cleanLast : '今天有什么热点话题';
|
|
1399
1409
|
try {
|
|
1400
1410
|
searchSection = await this.webSearch({ text: seed } as ChatRecord, session, true);
|
|
1401
1411
|
} catch { /* ignore */ }
|
|
@@ -1407,7 +1417,7 @@ export class AiEngine {
|
|
|
1407
1417
|
personaOverride || this.personaPrompt,
|
|
1408
1418
|
`现在是 ${nowText}。`,
|
|
1409
1419
|
'群里已经很久没人说话了。主动抛一个轻松、具体、能接话的话题,一句话。',
|
|
1410
|
-
contextText ?
|
|
1420
|
+
contextText ? `${contextLabel}\n${contextText}` : '',
|
|
1411
1421
|
memories.length ? `【相关记忆】\n${memories.map((item) => `- ${item}`).join('\n')}` : '',
|
|
1412
1422
|
searchSection,
|
|
1413
1423
|
'要求:',
|
package/src/ai/learn.ts
CHANGED
|
@@ -36,7 +36,7 @@ const CATEGORY_ALIASES: Record<string, string> = {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export function normalizeMemoryCategory(raw: string): string {
|
|
39
|
-
const value = String(raw || '').trim().replace(/[
|
|
39
|
+
const value = String(raw || '').trim().replace(/[\s*_`「」【】\[\]]/g, '');
|
|
40
40
|
if (!value) return '其他';
|
|
41
41
|
if ((MEMORY_CATEGORIES as readonly string[]).includes(value)) return value;
|
|
42
42
|
for (const key of Object.keys(CATEGORY_ALIASES)) {
|
|
@@ -213,7 +213,7 @@ export function parseSummaryEntries(raw: string, maxChars = MAX_SUMMARY_CHARS):
|
|
|
213
213
|
category = normalizeMemoryCategory(match[1]);
|
|
214
214
|
body = match[2];
|
|
215
215
|
}
|
|
216
|
-
const cleaned = cleanSummary(body, maxChars);
|
|
216
|
+
const cleaned = cleanSummary(body.replace(/\*\*/g, ''), maxChars);
|
|
217
217
|
if (!cleaned) continue;
|
|
218
218
|
const key = `${category}|${cleaned}`;
|
|
219
219
|
if (seen.has(key)) continue;
|