koishi-plugin-satori-ai 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/lib/index.js +16 -20
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -122,7 +122,7 @@ var fs = __toESM(require("fs"));
122
122
  var path = __toESM(require("path"));
123
123
  var name = "satori-ai";
124
124
  var logger = new import_koishi2.Logger(name);
125
- var debug = 0;
125
+ var debug = 1;
126
126
  var SAt = class extends Sat {
127
127
  static {
128
128
  __name(this, "SAt");
@@ -232,7 +232,7 @@ var SAt = class extends Sat {
232
232
  return session.text("commands.sat.messages.duplicate-dialogue");
233
233
  }
234
234
  this.personality["人格"][0].content += "\n这是刚刚的对话内容:{\n" + recentDialogues.map((msg) => `${msg.role}: ${msg.content}`).join("\n") + "\n}";
235
- const charactersToRemove = ["的", "一", "是", "了", "什", "么", "我", "谁", "不", "人", "在", "他", "有", "这", "个", "上", "们", "来", "到", "时", "大", "地", "为", "子", "中", "你", "说", "生", "国", "年", "着", "就", "那", "和", "要", "她", "出", "也", "得", "里", "后", "自", "以", "会"];
235
+ const charactersToRemove = ["的", "一", "是", "了", "什", "么", "我", "谁", "不", "人", "在", "他", "有", "这", "个", "上", "们", "来", "到", "时", "大", "地", "为", "子", "中", "你", "说", "生", "国", "年", "着", "就", "那", "和", "要", "她", "出", "也", "得", "里", "后", "自", "以", "会", "id=", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
236
236
  const filePath = path.join(this.pluginConfig.dataDir, "dialogues", `${session.userId}.txt`);
237
237
  const notExists = await isTargetIdExists(this.ctx, session.userId);
238
238
  let tmp;
@@ -240,10 +240,11 @@ var SAt = class extends Sat {
240
240
  const user = await this.ctx.database.get("p_system", { userid: session.userId });
241
241
  tmp = (user[0].usersname + prompt).split("");
242
242
  } else {
243
- tmp = prompt.split("");
243
+ tmp = (session.username + prompt).split("");
244
244
  }
245
245
  const keywords = tmp.filter((word) => !charactersToRemove.includes(word));
246
246
  const fs2 = require("fs");
247
+ const USERID = [session.userId];
247
248
  let sortedMatches = searchKeywordsInFile(filePath, keywords);
248
249
  if (sortedMatches.length > 0) {
249
250
  this.personality["人格"][0].content += appendTopMatches(JSON.parse(fs2.readFileSync(filePath, "utf-8")), sortedMatches, 10, "这是你可能用到的较久之前的对话内容:");
@@ -258,7 +259,7 @@ var SAt = class extends Sat {
258
259
  }
259
260
  sortedMatches = searchKeywordsInFile(commonSenseFilePath, keywords);
260
261
  if (sortedMatches.length > 0) {
261
- this.personality["人格"][0].content += appendTopMatches(commonSenseContent, sortedMatches, 5, "这是你需要知道的信息:");
262
+ this.personality["人格"][0].content += appendTopMatches(commonSenseContent, sortedMatches, 10, "这是你需要知道的信息:");
262
263
  if (sortedMatches.length > 4) {
263
264
  for (let i = 0; i < 5; i++) {
264
265
  const matchContent = commonSenseContent[sortedMatches[i].index].content.split("").filter((word) => !charactersToRemove.includes(word));
@@ -291,44 +292,40 @@ var SAt = class extends Sat {
291
292
  level = levels[0];
292
293
  this.personality["人格"][0].content += `
293
294
  ${this.pluginConfig.prompt_0}
294
- 我的名字: ${user[0].usersname}`;
295
+ `;
295
296
  } else if (favorability < this.pluginConfig.favorability_div_2) {
296
297
  level = levels[1];
297
298
  this.personality["人格"][0].content += `
298
299
  ${this.pluginConfig.prompt_1}
299
- 我的名字: ${user[0].usersname}`;
300
+ `;
300
301
  } else if (favorability < this.pluginConfig.favorability_div_3) {
301
302
  level = levels[2];
302
303
  this.personality["人格"][0].content += `
303
304
  ${this.pluginConfig.prompt_2}
304
- 我的名字: ${user[0].usersname}`;
305
+ `;
305
306
  } else if (favorability < this.pluginConfig.favorability_div_4) {
306
307
  level = levels[3];
307
308
  this.personality["人格"][0].content += `
308
309
  ${this.pluginConfig.prompt_3}
309
- 我的名字: ${user[0].usersname}`;
310
+ `;
310
311
  } else {
311
312
  level = levels[4];
312
- const isPrivate = session.channelId.match(new RegExp("private", "g"))?.includes("private");
313
- if (isPrivate) {
314
- this.personality["人格"][0].content += `
313
+ this.personality["人格"][0].content += `
315
314
  ${this.pluginConfig.prompt_4}
316
315
  `;
317
- } else {
318
- this.personality["人格"][0].content += `
319
- ${this.pluginConfig.prompt_3}
320
- `;
321
- }
322
- this.personality["人格"][0].content += `我的名字: ${user[0].usersname}`;
323
316
  }
324
- logger.info(`名字: ${user[0].usersname}, 关系: ${level}`);
317
+ this.personality["人格"][0].content += `发言者的名字: ${session.username},发言者的id:${session.userId}`;
318
+ logger.info(`名字: ${session.username}, 关系: ${level}`);
325
319
  } else {
326
320
  this.personality["人格"][0].content += `
327
321
  ${this.pluginConfig.prompt_1}
328
- 我的名字: ${session.username}`;
322
+ 发言者的名字: ${session.username},发言者的id:${session.userId}`;
329
323
  logger.info(`名字: ${session.username}, 关系: 陌生`);
330
324
  }
331
325
  }
326
+ sortedMatches = searchKeywordsInFile(commonSenseFilePath, USERID);
327
+ if (sortedMatches.length > 0)
328
+ this.personality["人格"][0].content += appendTopMatches(commonSenseContent, sortedMatches, 1, "这是发言者的真实身份:");
332
329
  if (debug)
333
330
  logger.info(this.personality["人格"][0].content.slice(-1500));
334
331
  return await this.chat(censored_prompt, session.userId, session);
@@ -423,7 +420,6 @@ var SAt = class extends Sat {
423
420
  this.channelDialogues[channelId] = [];
424
421
  }
425
422
  this.channelDialogues[channelId].push({ "role": session.username, "content": msg });
426
- this.channelDialogues[channelId].push({ "role": "回复", "content": message });
427
423
  if (this.channelDialogues[channelId].length > this.pluginConfig.message_max_length) {
428
424
  this.channelDialogues[channelId].shift();
429
425
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-satori-ai",
3
- "description": "适用于satori的ai对话,请务必使用最新版本",
4
- "version": "1.0.3",
3
+ "description": "适用于satori的ai对话,具有长期记忆、常识写入和好感度功能,请务必使用最新版本",
4
+ "version": "1.0.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "types": "lib/index.d.ts",