fix issues

This commit is contained in:
2026-07-22 18:03:15 +08:00
parent 17385335fd
commit b7eabb1b11
2 changed files with 12 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ function buildSystemPrompt(username, isAdmin) {
const attachmentRules = `
⚠️ 附件规则:
- 图片+物品名("这是XX的图片")→ 只返回 purchase_item绝对不要 is_new/quantity/unit_price
- 引用历史图片("上面/前面/刚刚那张""存入附件/添加到附件/关联到")→ use_recent_image: true**同时必须提供** purchase_item
- 引用历史图片("上面/前面/刚刚那张""存入附件/添加到附件/加到XX的附件/关联到")→ use_recent_image: true**同时必须提供** purchase_item
- 纯图片+物品名不是新建采购,系统自动关联附件`;
const prohibitionRules = `

View File

@@ -125,6 +125,17 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) {
} 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);
let isNew = aiResult.is_new === true;