@nestim/koishi-plugin-qqgm-chat-style 1.0.4 → 1.0.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/compact.js +7 -1
- package/package.json +1 -1
package/lib/compact.js
CHANGED
|
@@ -45,6 +45,11 @@ function cleanCard(raw, maxChars) {
|
|
|
45
45
|
);
|
|
46
46
|
text = cut >= Math.floor(limit * 0.5) ? slice.slice(0, cut + 1) : `${slice}…`;
|
|
47
47
|
}
|
|
48
|
+
// 模型在字数上限处截断时,可能停在一个逗号/顿号上:退回到最近的完整句
|
|
49
|
+
if (/[,、:;,;]$/.test(text)) {
|
|
50
|
+
const cut = Math.max(text.lastIndexOf('。'), text.lastIndexOf('\n'));
|
|
51
|
+
if (cut > text.length * 0.6) text = text.slice(0, cut + 1).trim();
|
|
52
|
+
}
|
|
48
53
|
return text.trim();
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -67,6 +72,7 @@ function buildCompactPrompt(skill, maxChars) {
|
|
|
67
72
|
'',
|
|
68
73
|
'输出要求:',
|
|
69
74
|
`- 一张纯文本风格卡,不超过 ${maxChars} 字;`,
|
|
75
|
+
'- 接近字数上限时用一句完整的话收尾,不要截断在半句;',
|
|
70
76
|
'- 用第二人称写(“你说话……”),像给演员的角色提示;',
|
|
71
77
|
'- 不要标题、编号、列表、Markdown、代码块;',
|
|
72
78
|
'- 不要新增原说明里没有的设定。',
|
|
@@ -167,7 +173,7 @@ class StyleCardStore {
|
|
|
167
173
|
system: prompt.system,
|
|
168
174
|
user: prompt.user,
|
|
169
175
|
temperature: 0.2,
|
|
170
|
-
maxTokens: Math.max(
|
|
176
|
+
maxTokens: Math.max(800, Math.min(3000, this.maxChars * 4)),
|
|
171
177
|
model: this.model || undefined,
|
|
172
178
|
});
|
|
173
179
|
if (!result || !result.ok) {
|
package/package.json
CHANGED