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.
- package/lib/index.js +12 -5
- 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
|
-
|
|
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
|
-
|
|
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.
|
|
220
|
+
if (i == this.config.maxRetryTimes) {
|
|
216
221
|
return this.handleAPIError(error);
|
|
217
222
|
}
|
|
218
|
-
|
|
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修改)"),
|