koishi-plugin-satori-ai 1.2.1-alpha.0 → 1.2.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.
Files changed (2) hide show
  1. package/lib/index.js +12 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -208,16 +208,23 @@ var APIClient = class {
208
208
  // 发送辅助聊天请求
209
209
  async auxiliaryChat(messages) {
210
210
  const AuxiliaryPayload = this.createAuxiliaryPayload(messages, this.config.auxiliary_LLM);
211
- for (let i = 0; i < this.config.keys.length; i++) {
211
+ const url = `${trimSlash(this.config.auxiliary_LLM_URL)}/chat/completions`;
212
+ const headers = this.createHeaders(this.config.auxiliary_LLM_key);
213
+ let content;
214
+ for (let i = 1; i <= this.config.maxRetryTimes; i++) {
212
215
  try {
213
- return await this.tryRequest(this.config.auxiliary_LLM_URL, AuxiliaryPayload, this.config.auxiliary_LLM_key);
216
+ const response = await this.ctx.http.post(url, AuxiliaryPayload, { headers, timeout: 36e5 });
217
+ content = response.choices[0].message.content;
218
+ return { content, error: false };
214
219
  } catch (error) {
215
- if (i == this.config.keys.length - 1) {
220
+ if (i == this.config.maxRetryTimes) {
216
221
  return this.handleAPIError(error);
217
222
  }
218
- this.rotateKey();
223
+ logger2.warn(`辅助模型API请求失败(${error}),重试(第${i}次)中...`);
224
+ continue;
219
225
  }
220
226
  }
227
+ return { content: "unreachable", error: true };
221
228
  }
222
229
  // 发送生成用户画像请求
223
230
  async generateUserPortrait(user, messages) {
@@ -1077,7 +1084,7 @@ var Sat = class extends import_koishi5.Service {
1077
1084
  }).description("对话设置"),
1078
1085
  import_koishi5.Schema.object({
1079
1086
  enable_favorability: import_koishi5.Schema.boolean().default(false).description("是否开启好感度系统(每次对话默认+1好感度)"),
1080
- max_favorability_perday: import_koishi5.Schema.number().default(100).description("每日有效(引发好感度变化)对话次数上限"),
1087
+ max_favorability_perday: import_koishi5.Schema.number().default(100).description("每日有效(引发好感度增长)对话次数上限"),
1081
1088
  input_censor_favorability: import_koishi5.Schema.boolean().default(false).description("是否开启好感度审查(通过输入屏蔽词扣除好感)"),
1082
1089
  value_of_input_favorability: import_koishi5.Schema.number().default(15).description("输入触发屏蔽词每次扣除的好感度"),
1083
1090
  output_censor_favorability: import_koishi5.Schema.boolean().default(false).description("通过输出屏蔽词扣除好感,在dataDir中的output_censor.txt修改)"),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-satori-ai",
3
3
  "description": "基于 Satori 适配器的智能对话插件,具备长期记忆、常识管理和好感度系统",
4
- "version": "1.2.1-alpha.0",
4
+ "version": "1.2.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "types": "lib/index.d.ts",