optimize fallback image prompts in auto mode
This commit is contained in:
parent
54a971e3b1
commit
641827031f
@ -3372,6 +3372,35 @@ export async function POST(request: Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!smartAutoOptimizedPrompt &&
|
||||
smartAutoExecution?.shouldOptimizePrompt &&
|
||||
(smartAutoDetectedIntent === "image_edit" || smartAutoDetectedIntent === "image_gen")
|
||||
) {
|
||||
try {
|
||||
const { optimizePrompt } = await import("@/lib/ai/prompt-optimizer");
|
||||
const optimizedFallback = optimizePrompt({
|
||||
originalPrompt: autoTextForFallback,
|
||||
intent: smartAutoDetectedIntent,
|
||||
subIntent: smartAutoExecution.routeSubIntent,
|
||||
});
|
||||
if (optimizedFallback.optimizedPrompt?.trim()) {
|
||||
smartAutoOptimizedPrompt = optimizedFallback.optimizedPrompt.trim();
|
||||
console.log("[Smart Auto Mode] ✨ Prompt optimized (fallback heuristic):", {
|
||||
original: autoTextForFallback.substring(0, 80),
|
||||
optimized: smartAutoOptimizedPrompt.substring(0, 140),
|
||||
intent: smartAutoDetectedIntent,
|
||||
subIntent: smartAutoExecution.routeSubIntent || null,
|
||||
});
|
||||
}
|
||||
if (!smartAutoRecommendedImageParams && optimizedFallback.recommendedImageParams) {
|
||||
smartAutoRecommendedImageParams = optimizedFallback.recommendedImageParams;
|
||||
}
|
||||
} catch (fallbackOptimizeError) {
|
||||
console.warn("[Smart Auto Mode] Fallback prompt optimization failed:", fallbackOptimizeError);
|
||||
}
|
||||
}
|
||||
|
||||
const allModels = await getEnabledAiModelsWithProvider();
|
||||
const hasImage =
|
||||
autoCurrentImageUrlsForFallback.length > 0 || smartAutoHistoryImages.length > 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user