koishi-plugin-best-cave 2.7.21 → 2.7.23
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
|
@@ -1345,17 +1345,17 @@ ${combinedText}` }, ...images];
|
|
|
1345
1345
|
"Content-Type": "application/json",
|
|
1346
1346
|
"Authorization": `Bearer ${this.config.aiApiKey}`
|
|
1347
1347
|
};
|
|
1348
|
-
const response = await this.http.post(fullUrl, payload, { headers, timeout:
|
|
1348
|
+
const response = await this.http.post(fullUrl, payload, { headers, timeout: 6e5 });
|
|
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
|
};
|