mioku-plugin-chat 2.4.0 → 2.4.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/db.ts +12 -1
- package/index.ts +16 -0
- package/package.json +1 -1
package/db.ts
CHANGED
|
@@ -29,7 +29,18 @@ function toChatMessage(row: any): ChatMessage {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function toTopicRecord(row: any): TopicRecord {
|
|
32
|
-
return
|
|
32
|
+
return {
|
|
33
|
+
id: row.id,
|
|
34
|
+
sessionId: row.session_id,
|
|
35
|
+
title: row.title,
|
|
36
|
+
keywords: row.keywords,
|
|
37
|
+
summary: row.summary,
|
|
38
|
+
messageCount: row.message_count,
|
|
39
|
+
windowStartAt: row.window_start_at ?? undefined,
|
|
40
|
+
windowEndAt: row.window_end_at ?? undefined,
|
|
41
|
+
createdAt: row.created_at,
|
|
42
|
+
updatedAt: row.updated_at,
|
|
43
|
+
};
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
function toExpressionRecord(row: any): ExpressionRecord {
|
package/index.ts
CHANGED
|
@@ -156,6 +156,22 @@ export default definePlugin({
|
|
|
156
156
|
});
|
|
157
157
|
aiService.setDefault("main");
|
|
158
158
|
|
|
159
|
+
const registerPersona = (persona: string) => {
|
|
160
|
+
mainAIInstance.registerPrompt("persona", persona);
|
|
161
|
+
workAIInstance.registerPrompt("persona", persona);
|
|
162
|
+
};
|
|
163
|
+
registerPersona(String(config.persona ?? ""));
|
|
164
|
+
if (configService) {
|
|
165
|
+
configService.onConfigChange("chat", "personalization", async () => {
|
|
166
|
+
try {
|
|
167
|
+
const p = await configService.getConfig("chat", "personalization");
|
|
168
|
+
registerPersona(String(p?.persona ?? ""));
|
|
169
|
+
} catch (err) {
|
|
170
|
+
ctx.logger.error(`更新 persona 提示词失败: ${err}`);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
159
175
|
const humanize = new HumanizeEngine(mainAIInstance, workAIInstance, config, db);
|
|
160
176
|
await humanize.init();
|
|
161
177
|
|