对生图优化提示词补充原始需求避免偏差
This commit is contained in:
parent
419712f1bf
commit
dcd5853808
@ -146,7 +146,17 @@ function applyOptimizedPromptToLatestUserMessage(
|
|||||||
const textPart = msg.parts.find(
|
const textPart = msg.parts.find(
|
||||||
(part): part is { type: "text"; text: string } => part.type === "text",
|
(part): part is { type: "text"; text: string } => part.type === "text",
|
||||||
);
|
);
|
||||||
const finalPrompt = `${hiddenPromptPrefix}${prompt}`.trim();
|
const originalText = textPart?.text?.trim() || "";
|
||||||
|
const normalizedOriginal = hiddenPromptPrefix && originalText.startsWith(hiddenPromptPrefix)
|
||||||
|
? originalText.slice(hiddenPromptPrefix.length).trim()
|
||||||
|
: originalText;
|
||||||
|
const shouldAppendOriginal =
|
||||||
|
normalizedOriginal &&
|
||||||
|
normalizedOriginal !== prompt &&
|
||||||
|
!prompt.includes(normalizedOriginal);
|
||||||
|
const finalPrompt = shouldAppendOriginal
|
||||||
|
? `${hiddenPromptPrefix}${prompt}\n\n用户原始需求:${normalizedOriginal}`.trim()
|
||||||
|
: `${hiddenPromptPrefix}${prompt}`.trim();
|
||||||
|
|
||||||
if (textPart) {
|
if (textPart) {
|
||||||
textPart.text = finalPrompt;
|
textPart.text = finalPrompt;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user