fix issues
This commit is contained in:
@@ -60,11 +60,17 @@ async function analyzeWithDeepSeek(text, historyMessages, username, isAdmin) {
|
||||
];
|
||||
const content = await callDeepSeek(messages, 0.1);
|
||||
console.log('🤖 AI 返回:', content);
|
||||
const parsed = JSON.parse(content.replace(/```json|```/g, '').trim());
|
||||
normalize(parsed);
|
||||
const v = validate(parsed);
|
||||
if (!v.valid) console.warn('⚠️ AI 返回校验失败:', v.error);
|
||||
return parsed;
|
||||
try {
|
||||
const parsed = JSON.parse(content.replace(/```json|```/g, '').trim());
|
||||
normalize(parsed);
|
||||
const v = validate(parsed);
|
||||
if (!v.valid) console.warn('⚠️ AI 返回校验失败:', v.error);
|
||||
return parsed;
|
||||
} catch (e) {
|
||||
// AI 返回非 JSON(如纯文本回复图片消息)→ 降级为 chat
|
||||
console.warn('⚠️ AI 返回非 JSON,降级为 chat:', content.substring(0, 50));
|
||||
return { action: 'chat', reply: content };
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user