fix: require prompt pack for detail scene replacement

This commit is contained in:
Your Name 2026-06-04 13:15:35 +08:00
parent 9da001e3ee
commit faa70a315c
2 changed files with 34 additions and 1 deletions

View File

@ -573,6 +573,8 @@ const SMART_AUTO_FALLBACK_TIMEOUT_MS = 20_000;
const SMART_AUTO_IMAGE_SUMMARY_TIMEOUT_MS = 18_000;
const DEFAULT_STREAM_KEEPALIVE_INTERVAL_MS = 12_000;
const CHAT_CREATION_LOOKUP_RETRY_DELAYS_MS = [60, 180, 360] as const;
const DETAIL_REPLACEMENT_PROMPT_PACK_REQUIRED_MESSAGE =
"请先在「风格化提示词配置」里选择提示词组合,再执行详情场景替换;缺少提示词组时系统不会处理。";
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
@ -3118,6 +3120,15 @@ export async function POST(request: Request) {
const replacementReferences = normalizeAgentModeReferences(agentModePayload);
const detailReplacementStrategy =
normalizeAgentModeDetailReplacementStrategy(agentModePayload);
if (detailReplacementStrategy !== "product_only" && !hiddenPromptText) {
return NextResponse.json(
{
code: "bad_request:api",
message: DETAIL_REPLACEMENT_PROMPT_PACK_REQUIRED_MESSAGE,
},
{ status: 400 },
);
}
if (replacementReferences.length === 0) {
return NextResponse.json(
{
@ -3720,6 +3731,19 @@ export async function POST(request: Request) {
{ status: 400 },
);
}
if (
isDetailReplacementPreset &&
detailReplacementStrategy !== "product_only" &&
!hiddenPromptText
) {
return NextResponse.json(
{
code: "bad_request:api",
message: DETAIL_REPLACEMENT_PROMPT_PACK_REQUIRED_MESSAGE,
},
{ status: 400 },
);
}
const uploadedImageParts = extractCurrentMessageImageParts(message.parts as any[]);
const requiredUploadCount = getAgentRequiredUploadCount({

View File

@ -3941,6 +3941,15 @@ export function AgentGenerationWorkspaceDarkV2({
toast.error(`请先查询并选择${skuReferenceSourceLabel}参考图`);
return;
}
const resolvedWorkflowContext = getLatestWorkflowContext?.() ?? workflowContext;
if (
isDetailReplacementPreset &&
detailReplacementStrategy !== "product_only" &&
!String(resolvedWorkflowContext?.promptText || "").trim()
) {
toast.error("请先在「风格化提示词配置」里选择提示词组合,再执行详情场景替换");
return;
}
const replacementModeType =
options?.replacementModeType ||
(isDetailReplacementPreset
@ -4034,7 +4043,6 @@ export function AgentGenerationWorkspaceDarkV2({
assetId: isValidChatUuid(attachment.assetId) ? attachment.assetId : undefined,
});
});
const resolvedWorkflowContext = getLatestWorkflowContext?.() ?? workflowContext;
let textContent = String(options?.promptText || "").trim() || input.trim();
if (!textContent && replacementModeType && replacementExecutionCards.length === 1) {
textContent = "请重新生成当前这张替换结果,保持版式和主体一致。";
@ -4124,6 +4132,7 @@ export function AgentGenerationWorkspaceDarkV2({
activeBusinessModeKey,
detailResultCards,
detailReplacementReferenceCards.length,
detailReplacementStrategy,
handleRunAiDetailGeneration,
currentResultModeType,
getReplacementExecutionCards,