koishi-plugin-best-cave 2.7.20 → 2.7.22
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 +4 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1154,7 +1154,7 @@ var AIManager = class {
|
|
|
1154
1154
|
if (cavesToAnalyze.length === 0) return "无需分析回声洞";
|
|
1155
1155
|
await session.send(`开始分析 ${cavesToAnalyze.length} 个回声洞...`);
|
|
1156
1156
|
let successCount = 0;
|
|
1157
|
-
const batchSize =
|
|
1157
|
+
const batchSize = 25;
|
|
1158
1158
|
for (let i = 0; i < cavesToAnalyze.length; i += batchSize) {
|
|
1159
1159
|
const batch = cavesToAnalyze.slice(i, i + batchSize);
|
|
1160
1160
|
this.logger.info(`[${i + 1}/${cavesToAnalyze.length}] 正在分析 ${batch.length} 条回声洞...`);
|
|
@@ -1349,13 +1349,13 @@ ${combinedText}` }, ...images];
|
|
|
1349
1349
|
const content = response?.choices?.[0]?.message?.content;
|
|
1350
1350
|
if (typeof content !== "string" || !content.trim()) throw new Error();
|
|
1351
1351
|
try {
|
|
1352
|
-
const jsonRegex = /```json\s*([\s\S]*?)\s
|
|
1352
|
+
const jsonRegex = /```json\s*([\s\S]*?)\s*```/i;
|
|
1353
1353
|
const match = content.match(jsonRegex);
|
|
1354
1354
|
const jsonString = match && match[1] ? match[1] : content;
|
|
1355
1355
|
return JSON.parse(jsonString);
|
|
1356
1356
|
} catch (error) {
|
|
1357
|
-
this.logger.error("
|
|
1358
|
-
throw
|
|
1357
|
+
this.logger.error("解析失败:", error, "原始响应:", JSON.stringify(response, null, 2));
|
|
1358
|
+
throw error;
|
|
1359
1359
|
}
|
|
1360
1360
|
}
|
|
1361
1361
|
};
|