fix issues
This commit is contained in:
@@ -28,7 +28,7 @@ function buildSystemPrompt(username, isAdmin) {
|
|||||||
const attachmentRules = `
|
const attachmentRules = `
|
||||||
⚠️ 附件规则:
|
⚠️ 附件规则:
|
||||||
- 图片+物品名("这是XX的图片")→ 只返回 purchase_item,绝对不要 is_new/quantity/unit_price
|
- 图片+物品名("这是XX的图片")→ 只返回 purchase_item,绝对不要 is_new/quantity/unit_price
|
||||||
- 引用历史图片("上面/前面/刚刚那张""存入附件/添加到附件/关联到")→ use_recent_image: true,**同时必须提供** purchase_item
|
- 引用历史图片("上面/前面/刚刚那张""存入附件/添加到附件/加到XX的附件/关联到")→ use_recent_image: true,**同时必须提供** purchase_item
|
||||||
- 纯图片+物品名不是新建采购,系统自动关联附件`;
|
- 纯图片+物品名不是新建采购,系统自动关联附件`;
|
||||||
|
|
||||||
const prohibitionRules = `
|
const prohibitionRules = `
|
||||||
|
|||||||
@@ -125,6 +125,17 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) {
|
|||||||
} catch(e) { console.error('❌ 解析附件失败:', e); }
|
} catch(e) { console.error('❌ 解析附件失败:', e); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 安全网:消息提到图片/附件但没带附件 → AI 忘设 use_recent_image,自动补
|
||||||
|
if (!usedRecentImage && !attachments?.length && /(图片|附件|加到|存入|关联|作为附件)/.test(originalText)) {
|
||||||
|
console.log('🔍 安全网: 文本提及附件但无附件,自动尝试 use_recent_image');
|
||||||
|
const recentMsg = db.prepare("SELECT attachments FROM messages WHERE room_id = ? AND attachments IS NOT NULL AND attachments != '' AND attachments != '[]' ORDER BY id DESC LIMIT 1").get(roomId);
|
||||||
|
if (recentMsg) {
|
||||||
|
try {
|
||||||
|
const files = JSON.parse(recentMsg.attachments);
|
||||||
|
if (files.length) { attachments = files; usedRecentImage = true; console.log('✅ 安全网引用图片:', files.length, '个'); }
|
||||||
|
} catch(e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const createdTime = normalizeTime(aiResult.created_time);
|
const createdTime = normalizeTime(aiResult.created_time);
|
||||||
let isNew = aiResult.is_new === true;
|
let isNew = aiResult.is_new === true;
|
||||||
|
|||||||
Reference in New Issue
Block a user