koishi-plugin-chatluna-character 0.0.44 → 0.0.45

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/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.name = exports.Config = exports.inject = exports.apply = void 0;
3
+ exports.name = exports.Config = exports.inject = void 0;
4
+ exports.apply = apply;
4
5
  /* eslint-disable max-len */
5
6
  const koishi_1 = require("koishi");
6
7
  const plugin_1 = require("./plugin");
@@ -42,7 +43,6 @@ function apply(ctx, config) {
42
43
  disposables.forEach((disposable) => disposable());
43
44
  });
44
45
  }
45
- exports.apply = apply;
46
46
  exports.inject = {
47
47
  required: ['chatluna', 'cache'],
48
48
  optional: ['chatluna_character', 'vits']
package/lib/plugin.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.plugins = void 0;
6
+ exports.plugins = plugins;
7
7
  const promises_1 = __importDefault(require("fs/promises"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  async function plugins(ctx, config) {
@@ -18,4 +18,3 @@ async function plugins(ctx, config) {
18
18
  }
19
19
  }
20
20
  }
21
- exports.plugins = plugins;
@@ -86,8 +86,8 @@ async function apply(ctx, config) {
86
86
  return;
87
87
  }
88
88
  temp.completionMessages.push(humanMessage, responseMessage);
89
- if (temp.completionMessages.length > 6) {
90
- while (temp.completionMessages.length <= 3) {
89
+ if (temp.completionMessages.length > 8) {
90
+ while (temp.completionMessages.length <= 4) {
91
91
  temp.completionMessages.shift();
92
92
  }
93
93
  }
@@ -107,7 +107,7 @@ async function apply(ctx, config) {
107
107
  parsedResponse.rawMessage.length * copyOfConfig.typingTime +
108
108
  100;
109
109
  await (0, koishi_1.sleep)(random.int(maxTime / 4, maxTime / 2));
110
- await session.send(await ctx.vits.say({ input: text }));
110
+ await session.send(await ctx.vits.say({ input: parsedResponse.rawMessage }));
111
111
  break;
112
112
  }
113
113
  try {
@@ -343,9 +343,11 @@ async function formatMessage(messages, config, model, systemPrompt, historyPromp
343
343
  currentTokens += await model.getNumTokens(systemPrompt);
344
344
  currentTokens += await model.getNumTokens(historyPrompt);
345
345
  const calculatedMessages = [];
346
+ const random = new koishi_1.Random();
346
347
  for (let i = messages.length - 1; i >= 0; i--) {
347
348
  const message = messages[i];
348
- const jsonMessage = `{"name":"${message.name}","id":"${message.id}","content":${JSON.stringify(message.content)}","type":"text"}`;
349
+ const voiceProbability = random.int(1, 10) > 5 ? 'voice' : 'text';
350
+ const jsonMessage = `{"name":"${message.name}","id":"${message.id}","content":${JSON.stringify(message.content)}","type":"${voiceProbability}"}`;
349
351
  const jsonMessageToken = await model.getNumTokens(jsonMessage);
350
352
  if (currentTokens + jsonMessageToken > maxTokens - 4) {
351
353
  break;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.apply = void 0;
3
+ exports.apply = apply;
4
4
  const filter_1 = require("./filter");
5
5
  function apply(ctx, config) {
6
6
  ctx.command('chatluna.character', '角色扮演相关命令');
@@ -22,4 +22,3 @@ function apply(ctx, config) {
22
22
  return `已清除群组 ${groupId} 的聊天记录`;
23
23
  });
24
24
  }
25
- exports.apply = apply;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.apply = void 0;
3
+ exports.apply = apply;
4
4
  const koishi_1 = require("koishi");
5
5
  const types_1 = require("koishi-plugin-chatluna/lib/llm-core/platform/types");
6
6
  async function apply(ctx, config) {
@@ -12,7 +12,6 @@ async function apply(ctx, config) {
12
12
  });
13
13
  ctx.schema.set('model', koishi_1.Schema.union(await getModelNames(ctx.chatluna.platform)));
14
14
  }
15
- exports.apply = apply;
16
15
  async function getModelNames(service) {
17
16
  return service.getAllModels(types_1.ModelType.llm).map((m) => koishi_1.Schema.const(m));
18
17
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.apply = exports.groupInfos = void 0;
3
+ exports.groupInfos = void 0;
4
+ exports.apply = apply;
4
5
  exports.groupInfos = {};
5
6
  async function apply(ctx, config) {
6
7
  const maxMessages = config.messageInterval;
@@ -90,4 +91,3 @@ async function apply(ctx, config) {
90
91
  return false;
91
92
  });
92
93
  }
93
- exports.apply = apply;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.apply = void 0;
3
+ exports.apply = apply;
4
4
  function apply(ctx, config) {
5
5
  ctx.on('chatluna/before-check-sender', async (session) => {
6
6
  const guildId = session.guildId;
@@ -33,4 +33,3 @@ function apply(ctx, config) {
33
33
  return config.disableChatLuna;
34
34
  });
35
35
  }
36
- exports.apply = apply;
package/lib/preset.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadPreset = exports.Preset = void 0;
6
+ exports.Preset = void 0;
7
+ exports.loadPreset = loadPreset;
7
8
  const prompts_1 = require("@langchain/core/prompts");
8
9
  const promises_1 = __importDefault(require("fs/promises"));
9
10
  const js_yaml_1 = require("js-yaml");
@@ -121,4 +122,3 @@ function loadPreset(text) {
121
122
  mute_keyword: rawPreset.mute_keyword ?? []
122
123
  };
123
124
  }
124
- exports.loadPreset = loadPreset;
@@ -105,6 +105,9 @@ class MessageCollector extends koishi_1.Service {
105
105
  else {
106
106
  this._messages = {};
107
107
  }
108
+ this._groupTemp[groupId] = {
109
+ completionMessages: []
110
+ };
108
111
  }
109
112
  async broadcastOnBot(session, elements) {
110
113
  if (session.isDirect) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chatluna-character",
3
3
  "description": "Let the large language model play a role, disguise as a group friend",
4
- "version": "0.0.44",
4
+ "version": "0.0.45",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
@@ -35,6 +35,7 @@
35
35
  "js-yaml": "^4.1.0"
36
36
  },
37
37
  "devDependencies": {
38
+ "@initencounter/vits": "^0.0.3",
38
39
  "@typescript-eslint/eslint-plugin": "^6.21.1-alpha.1",
39
40
  "@typescript-eslint/parser": "^6.21.1-alpha.1",
40
41
  "atsc": "^1.2.2",
@@ -47,7 +48,6 @@
47
48
  "eslint-plugin-n": "^16.6.2",
48
49
  "eslint-plugin-prettier": "^5.1.3",
49
50
  "eslint-plugin-promise": "^6.1.1",
50
- "@initencounter/vits": "^0.0.3",
51
51
  "koishi": "^4.17.2"
52
52
  },
53
53
  "peerDependencies": {