ai-chatbot/lib/ai/providers/snapgen-reference-order.ts

15 lines
730 B
TypeScript

export function buildSnapgenReferenceOrderPrompt(prompt: string, imageUrls: string[]) {
const normalizedPrompt = String(prompt || "").trim();
const referenceCount = imageUrls.filter((url) => String(url || "").trim()).length;
if (referenceCount < 2) return normalizedPrompt;
return [
`参考图顺序说明:本次请求包含 ${referenceCount} 张参考图,顺序与上传/选中顺序一致。`,
"第 1 张参考图优先作为主参考;如果用户提到“第一张图/图1/主图/原图”,对应第 1 张参考图,除非用户明确另行指定。",
"第 2 张及后续参考图仅作为辅助参考,按用户提示使用。",
normalizedPrompt,
]
.filter(Boolean)
.join("\n");
}