koishi-plugin-best-cave 2.7.14 → 2.7.15

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 +7 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1159,7 +1159,7 @@ var AIManager = class {
1159
1159
  } catch (error) {
1160
1160
  const caveIds = caves.map((c) => c.id).join(", ");
1161
1161
  this.logger.error(`分析回声洞 (${caveIds}) 出错:`, error);
1162
- return 0;
1162
+ throw error;
1163
1163
  }
1164
1164
  }
1165
1165
  /**
@@ -1251,11 +1251,14 @@ var AIManager = class {
1251
1251
  };
1252
1252
  this.requestCount++;
1253
1253
  const response = await this.http.post(fullUrl, payload, { headers, timeout: 9e4 });
1254
- const content = response.choices?.[0]?.message?.content;
1255
- this.logger.info("原始响应:", content);
1254
+ const content = response?.choices?.[0]?.message?.content;
1255
+ if (typeof content !== "string" || !content.trim()) {
1256
+ this.logger.error("原始响应:", JSON.stringify(response, null, 2));
1257
+ throw new Error("响应无效");
1258
+ }
1256
1259
  try {
1257
1260
  const jsonRegex = /```json\s*([\s\S]*?)\s*```/;
1258
- const match = content?.match(jsonRegex);
1261
+ const match = content.match(jsonRegex);
1259
1262
  let jsonString = "";
1260
1263
  if (match && match[1]) {
1261
1264
  jsonString = match[1];
@@ -1265,7 +1268,6 @@ var AIManager = class {
1265
1268
  return JSON.parse(jsonString);
1266
1269
  } catch (error) {
1267
1270
  this.logger.error("解析 JSON 失败:", error);
1268
- this.logger.error("原始响应:", content);
1269
1271
  throw new Error("解析失败");
1270
1272
  }
1271
1273
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-best-cave",
3
3
  "description": "功能强大、高度可定制的回声洞。支持丰富的媒体类型、内容查重、人工审核、用户昵称、数据迁移以及本地/S3 双重文件存储后端。",
4
- "version": "2.7.14",
4
+ "version": "2.7.15",
5
5
  "contributors": [
6
6
  "Yis_Rime <yis_rime@outlook.com>"
7
7
  ],