Tighten multi-image reference handling
This commit is contained in:
parent
f0e17dfffe
commit
6f8c939be2
@ -6630,7 +6630,9 @@ export function CanvasChatPanel({
|
||||
return lines.join("\n");
|
||||
}, [nodes, selectedImageNodes]);
|
||||
|
||||
const buildContextPayload = useCallback(() => {
|
||||
const buildContextPayload = useCallback((textOverride?: string) => {
|
||||
const contextText =
|
||||
typeof textOverride === "string" ? textOverride : input;
|
||||
const pendingAnnotationTargetNode = resolvePendingCanvasAgentTargetNode({
|
||||
nodes,
|
||||
pendingTarget: pendingCanvasAgentAnnotationEditTargetRef.current,
|
||||
@ -6660,7 +6662,7 @@ export function CanvasChatPanel({
|
||||
const shouldIsolateDirectModeContext = effectiveComposerMode !== "agent";
|
||||
const shouldPreserveCanvasControlContext =
|
||||
shouldBypassCanvasImagePointsPrecheckForAgentControl({
|
||||
text: input,
|
||||
text: contextText,
|
||||
activeComposerMode: effectiveComposerMode,
|
||||
attachmentCount: attachments.length,
|
||||
hasSkillTag: Boolean(selectedSkillTag),
|
||||
@ -6673,7 +6675,7 @@ export function CanvasChatPanel({
|
||||
).length;
|
||||
const shouldPreserveSelectedSlotContext =
|
||||
shouldPreserveCanvasAgentSlotOnlyContext({
|
||||
text: input,
|
||||
text: contextText,
|
||||
activeComposerMode: effectiveComposerMode,
|
||||
selectedAgentSlotCount: selectedAgentSlotCountForContext,
|
||||
attachmentCount: attachments.length,
|
||||
@ -6697,7 +6699,7 @@ export function CanvasChatPanel({
|
||||
|
||||
if (shouldIsolateDirectModeContext) {
|
||||
selectedImageNodesForContext = resolveMultiImageReferenceContext({
|
||||
text: input,
|
||||
text: contextText,
|
||||
selectedItems: selectedImageNodesForContext,
|
||||
candidateItems: imageNodes,
|
||||
getItemId: (node) => node.id,
|
||||
@ -9699,7 +9701,7 @@ export function CanvasChatPanel({
|
||||
const autoContext = buildAutoContext();
|
||||
autoContextRef.current =
|
||||
clampChatRequestText(autoContext, MAX_CHAT_AUTO_CONTEXT_LENGTH) || null;
|
||||
contextPayloadRef.current = buildContextPayload() || null;
|
||||
contextPayloadRef.current = buildContextPayload(textContent) || null;
|
||||
|
||||
if (textContent) {
|
||||
parts.push({ type: "text" as const, text: textContent });
|
||||
|
||||
@ -5,7 +5,7 @@ export function buildSnapgenReferenceOrderPrompt(prompt: string, imageUrls: stri
|
||||
|
||||
return [
|
||||
`参考图顺序说明:本次请求包含 ${referenceCount} 张参考图,顺序与上传/选中顺序一致。`,
|
||||
"用户提示中的“第一张图/图1”对应第 1 张参考图,“第二张图/图2”对应第 2 张参考图,依次类推。",
|
||||
"用户提示中的“第一张图/图1/图一/图片1/图片一”对应第 1 张参考图,“第二张图/图2/图二/图片2/图片二”对应第 2 张参考图,依次类推。",
|
||||
"本说明只用于明确图片编号,不改变用户对主体、风格、构图、权重或融合方式的要求;若用户指定主参考或融合方式,以用户提示为准。",
|
||||
normalizedPrompt,
|
||||
]
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
const ORDINAL_REFERENCE_PATTERNS = [
|
||||
/(?:第一|第\s*1|图\s*1|图片\s*1|照片\s*1|first\s+(?:image|photo|reference)|1st\s+(?:image|photo|reference))[\s\S]{0,120}(?:第二|第\s*2|图\s*2|图片\s*2|照片\s*2|second\s+(?:image|photo|reference)|2nd\s+(?:image|photo|reference))/i,
|
||||
/(?:第二|第\s*2|图\s*2|图片\s*2|照片\s*2|second\s+(?:image|photo|reference)|2nd\s+(?:image|photo|reference))[\s\S]{0,120}(?:第一|第\s*1|图\s*1|图片\s*1|照片\s*1|first\s+(?:image|photo|reference)|1st\s+(?:image|photo|reference))/i,
|
||||
/(?:第三|第\s*3|图\s*3|图片\s*3|照片\s*3|third\s+(?:image|photo|reference)|3rd\s+(?:image|photo|reference))/i,
|
||||
/(?:第四|第\s*4|图\s*4|图片\s*4|照片\s*4|fourth\s+(?:image|photo|reference)|4th\s+(?:image|photo|reference))/i,
|
||||
/(?:第一|第\s*1|图片\s*(?:1|一)|照片\s*(?:1|一)|图\s*(?:1|一)|first\s+(?:image|photo|reference)|1st\s+(?:image|photo|reference))[\s\S]{0,120}(?:第二|第\s*(?:2|二|两)|图片\s*(?:2|二|两)|照片\s*(?:2|二|两)|图\s*(?:2|二|两)|second\s+(?:image|photo|reference)|2nd\s+(?:image|photo|reference))/i,
|
||||
/(?:第二|第\s*(?:2|二|两)|图片\s*(?:2|二|两)|照片\s*(?:2|二|两)|图\s*(?:2|二|两)|second\s+(?:image|photo|reference)|2nd\s+(?:image|photo|reference))[\s\S]{0,120}(?:第一|第\s*1|图片\s*(?:1|一)|照片\s*(?:1|一)|图\s*(?:1|一)|first\s+(?:image|photo|reference)|1st\s+(?:image|photo|reference))/i,
|
||||
/(?:第三|第\s*(?:3|三)|图片\s*(?:3|三)|照片\s*(?:3|三)|图\s*(?:3|三)|third\s+(?:image|photo|reference)|3rd\s+(?:image|photo|reference))/i,
|
||||
/(?:第四|第\s*(?:4|四)|图片\s*(?:4|四)|照片\s*(?:4|四)|图\s*(?:4|四)|fourth\s+(?:image|photo|reference)|4th\s+(?:image|photo|reference))/i,
|
||||
];
|
||||
|
||||
const MULTI_IMAGE_REFERENCE_PATTERNS = [
|
||||
@ -11,7 +11,7 @@ const MULTI_IMAGE_REFERENCE_PATTERNS = [
|
||||
/(?:这|这些|这几|上述|以上|下面|上传|给的|参考|选中|画布|原图|素材)[\s\S]{0,18}(?:两|俩|二|三|四|五|六|七|八|2|3|4|5|6|7|8|多|几)[\s\S]{0,12}(?:张|个)?(?:图|图片|照片|参考图|素材)/i,
|
||||
/(?:两|俩|二|三|四|五|六|七|八|2|3|4|5|6|7|8|多|几)[\s\S]{0,8}(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图)/i,
|
||||
/(?:两|俩|二|三|四|五|六|七|八|2|3|4|5|6|7|8|多|几)[\s\S]{0,8}(?:张|个)?(?:图|图片|照片)[\s\S]{0,28}(?:合成|融合|拼接|对比|混合|组合|参考|编辑|处理|改)/i,
|
||||
/(?:合成|融合|拼接|对比|混合|组合|参考|编辑|处理)[\s\S]{0,28}(?:两|俩|二|三|四|五|六|七|八|2|3|4|5|6|7|8|多|几|第一|第二|第三|第四|图\s*1|图\s*2|图\s*3|图\s*4)[\s\S]{0,12}(?:图|图片|照片|参考|素材)?/i,
|
||||
/(?:合成|融合|拼接|对比|混合|组合|参考|编辑|增加|添加|放入|换成)[\s\S]{0,28}(?:两|俩|二|三|四|五|六|七|八|2|3|4|5|6|7|8|多|几|第二|第三|第四|图片\s*(?:2|3|4|二|三|四)|照片\s*(?:2|3|4|二|三|四)|图\s*(?:2|3|4|二|三|四))[\s\S]{0,12}(?:图|图片|照片|参考|素材)?/i,
|
||||
/(?:multi|multiple|two|several|many)[\s\S]{0,20}(?:reference|input|source)[\s\S]{0,16}(?:image|photo)s?/i,
|
||||
/(?:reference|use|combine|merge|blend|edit)[\s\S]{0,24}(?:first|1st)[\s\S]{0,80}(?:second|2nd)[\s\S]{0,32}(?:image|photo|reference)?/i,
|
||||
];
|
||||
@ -19,31 +19,31 @@ const MULTI_IMAGE_REFERENCE_PATTERNS = [
|
||||
const REQUESTED_COUNT_PATTERNS: Array<{ count: number; pattern: RegExp }> = [
|
||||
{
|
||||
count: 8,
|
||||
pattern: /(?:第\s*(?:八|8)\s*(?:张|个)?(?:图|图片|照片)|(?:图|图片|照片|image)\s*8\b|(?:八|8)\s*(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
pattern: /(?:第\s*(?:八|8)\s*(?:张|个)?(?:图|图片|照片)|(?:图片|照片|图|image)\s*(?:8|八)\b|(?:八|8)\s*(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
},
|
||||
{
|
||||
count: 7,
|
||||
pattern: /(?:第\s*(?:七|7)\s*(?:张|个)?(?:图|图片|照片)|(?:图|图片|照片|image)\s*7\b|(?:七|7)\s*(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
pattern: /(?:第\s*(?:七|7)\s*(?:张|个)?(?:图|图片|照片)|(?:图片|照片|图|image)\s*(?:7|七)\b|(?:七|7)\s*(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
},
|
||||
{
|
||||
count: 6,
|
||||
pattern: /(?:第\s*(?:六|6)\s*(?:张|个)?(?:图|图片|照片)|(?:图|图片|照片|image)\s*6\b|(?:六|6)\s*(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
pattern: /(?:第\s*(?:六|6)\s*(?:张|个)?(?:图|图片|照片)|(?:图片|照片|图|image)\s*(?:6|六)\b|(?:六|6)\s*(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
},
|
||||
{
|
||||
count: 5,
|
||||
pattern: /(?:第\s*(?:五|5)\s*(?:张|个)?(?:图|图片|照片)|(?:图|图片|照片|image)\s*5\b|(?:五|5)\s*(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
pattern: /(?:第\s*(?:五|5)\s*(?:张|个)?(?:图|图片|照片)|(?:图片|照片|图|image)\s*(?:5|五)\b|(?:五|5)\s*(?:张|个)?(?:参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
},
|
||||
{
|
||||
count: 4,
|
||||
pattern: /(?:第\s*(?:四|4)\s*(?:张|个)?(?:图|图片|照片)|(?:图|图片|照片|image)\s*4\b|(?:四|4)\s*(?:张|个)?(?:图|图片|照片|参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
pattern: /(?:第\s*(?:四|4)\s*(?:张|个)?(?:图|图片|照片)|(?:图片|照片|图|image)\s*(?:4|四)\b|(?:四|4)\s*(?:张|个)?(?:图|图片|照片|参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
},
|
||||
{
|
||||
count: 3,
|
||||
pattern: /(?:第\s*(?:三|3)\s*(?:张|个)?(?:图|图片|照片)|(?:图|图片|照片|image)\s*3\b|(?:三|3)\s*(?:张|个)?(?:图|图片|照片|参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
pattern: /(?:第\s*(?:三|3)\s*(?:张|个)?(?:图|图片|照片)|(?:图片|照片|图|image)\s*(?:3|三)\b|(?:三|3)\s*(?:张|个)?(?:图|图片|照片|参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
},
|
||||
{
|
||||
count: 2,
|
||||
pattern: /(?:第\s*(?:二|两|2)\s*(?:张|个)?(?:图|图片|照片)|(?:图|图片|照片|image)\s*2\b|(?:两|俩|二|2)\s*(?:张|个)?(?:图|图片|照片|参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
pattern: /(?:第\s*(?:二|两|2)\s*(?:张|个)?(?:图|图片|照片)|(?:图片|照片|图|image)\s*(?:2|二|两)\b|(?:两|俩|二|2)\s*(?:张|个)?(?:图|图片|照片|参考图|素材图|输入图|源图|上传图|原图))/i,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user