diff --git a/lib/ai/context-memory/target-resolution.ts b/lib/ai/context-memory/target-resolution.ts index f27745929..9eedb16b1 100644 --- a/lib/ai/context-memory/target-resolution.ts +++ b/lib/ai/context-memory/target-resolution.ts @@ -10,6 +10,8 @@ const ORIGINAL_IMAGE_REGEX = /(原图|上传图|参考图|最初那张|第一张图|素材图|源图|原始图片|原始那张|我发的那张|上传的那张|原来的图)/i; const LATEST_RESULT_REGEX = /(上一张|上一轮|刚生成|最新生成|这个结果|该结果|按这个结果|继续在这张|基于这张结果|延续上一次结果|上一版|刚才那张结果|生成的图|生成图|结果图|出图结果|刚出的图|上一张生成图|上一轮结果图|现在这张生成图)/i; +const DEICTIC_TARGET_REGEX = + /(这张图|这只|这个|这款|这套|当前这张|当前这个|当前这只|这一张|这一只|这个产品|这个物体|这只猫|这只狗)/i; const SELECTION_REGEX = /(选中的|当前这张|我选的|这几张|这些图|选中图)/i; const ACTIONABLE_EDIT_REGEX = /(改|调整|优化|换|替换|去掉|抠|重绘|增强|修|处理|按照|按|保留|统一|色差|背景|清晰|风格|亮一点|暗一点|白底|透明底)/i; @@ -284,6 +286,42 @@ export function resolveTargetAssets( }); } + if (DEICTIC_TARGET_REGEX.test(text)) { + if (selectedRefs.length > 0) { + return buildResolvedTargetAssets({ + targetRefs: selectedRefs, + candidateRefs, + resolutionMode: "explicit_selection", + confidence: 93, + needsClarification: false, + reason: "用户使用“这张/这只/这个”等指代表达,且当前存在明确选中目标图", + fromHistory: true, + }); + } + + if (candidateRefs.length === 1) { + return buildResolvedTargetAssets({ + targetRefs: [candidateRefs[0]], + candidateRefs, + resolutionMode: "text_reference", + confidence: 84, + needsClarification: false, + reason: "用户使用指代表达,且当前仅有一张候选图", + fromHistory: true, + }); + } + + return buildResolvedTargetAssets({ + targetRefs: [], + candidateRefs, + resolutionMode: "clarification", + confidence: 0, + needsClarification: true, + reason: "用户使用“这张/这只/这个”等指代表达,但当前没有明确选中唯一目标图", + fromHistory: true, + }); + } + if ( ACTIONABLE_EDIT_REGEX.test(text) && currentRefs.length === 0 &&