diff --git a/server/server.js b/server/server.js index c37fb15..9d72852 100644 --- a/server/server.js +++ b/server/server.js @@ -368,6 +368,9 @@ async function analyzeWithDeepSeek(text, historyMessages, username, isAdmin) { - 纯图片+指定物品名的请求不是新建采购,系统会自动关联附件到已有记录。 ⚠️ 采购规则: +- 只有用户明确表示"购买/采购/下单/付款/买了/花了"等消费意图时才返回 action="purchase"。 +- 如果用户只是陈述事实或描述物品(如"前天deep"),没有明确采购意图,必须返回 action="ignore"。 +- 如果信息不完整、无法确定具体物品名称,必须返回 action="ask" 追问,绝不允许猜测创建记录。 - 新建 vs 更新(极其重要): * 如果用户提到"昨天/今天/刚刚/又/再/新/另一批/另外"等时间或重复购买词汇,必须返回 "is_new": true,系统会强制创建新记录。 * "纯图片+物品名"的附件请求**不是**新建,不要返回 is_new。 @@ -440,7 +443,15 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) { return; } if (aiResult.action === 'purchase') { - console.log('🛒 purchase 分支, attachments:', JSON.stringify(attachments)); + const item = aiResult.purchase_item; + // 兜底拦截:物品名为空/null/undefined/过短(<2字符) → 拒绝创建 + if (!item || item === 'null' || item === 'undefined' || item.trim().length < 2) { + console.log('🚫 拒绝无效 purchase_item:', JSON.stringify(item)); + storeAndBroadcastText(roomId, '小财', '请提供具体的物品名称。'); + addToHistory(roomId, 'assistant', '请提供具体的物品名称。'); + return; + } + console.log('🛒 purchase 分支, item:', item, 'attachments:', JSON.stringify(attachments)); // 引用最近图片:用户要求把之前的图片关联到某采购 let usedRecentImage = false; if (aiResult.use_recent_image) {