Revert "Stable Diffusion: never re-run reference image selection on swipe" This reverts commit 6d112755c32328608e0aa05943d069b69f5221e1.
| @@ -1145,13 +1145,6 @@ const REFERENCE_IMAGE_PLACEHOLDER = /"%reference[-_]image%"/i; | |||
| 1145 | let pendingReferenceImage = null; | 1145 | let pendingReferenceImage = null; |
| 1146 | 1146 | ||
| 1147 | /** | 1147 | /** |
| 1148 | * Whether the current generation may run an LLM reference-image selection. | ||
| 1149 | * Swipes reuse the prompt, so they must also reuse the reference selection | ||
| 1150 | * instead of asking the LLM again. | ||
| 1151 | */ | ||
| 1152 | let referenceSelectionAllowed = true; | ||
| 1153 | |||
| 1154 | /** | ||
| 1155 | * Returns library entries that have an uploaded image. | 1148 | * Returns library entries that have an uploaded image. |
| 1156 | * @returns {{tag: string, description: string, path: string}[]} Valid reference images. | 1149 | * @returns {{tag: string, description: string, path: string}[]} Valid reference images. |
| 1157 | */ | 1150 | */ |
| @@ -1421,13 +1414,6 @@ async function resolveReferenceImageForGeneration(prompt) { | |||
| 1421 | pendingReferenceImage = images[0]; | 1414 | pendingReferenceImage = images[0]; |
| 1422 | return pendingReferenceImage; | 1415 | return pendingReferenceImage; |
| 1423 | } | 1416 | } |
| 1424 | if (!referenceSelectionAllowed) { | ||
| 1425 | // Swipe without a stored selection (e.g. after a page reload): don't ask | ||
| 1426 | // the LLM again, just fall back to the first library image. | ||
| 1427 | console.log('SD: swipe regeneration - reusing the reference image without a new LLM selection'); | ||
| 1428 | pendingReferenceImage = images[0]; | ||
| 1429 | return pendingReferenceImage; | ||
| 1430 | } | ||
| 1431 | try { | 1417 | try { |
| 1432 | pendingReferenceImage = await selectReferenceImageWithLlm(prompt, images) ?? images[0]; | 1418 | pendingReferenceImage = await selectReferenceImageWithLlm(prompt, images) ?? images[0]; |
| 1433 | } catch (error) { | 1419 | } catch (error) { |
| @@ -4255,10 +4241,6 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP | |||
| 4255 | const isCharChat = this_chid !== undefined && !selected_group; | 4241 | const isCharChat = this_chid !== undefined && !selected_group; |
| 4256 | const ignoreNoCharForSwipe = initiator === initiators.swipe && isCharChat; | 4242 | const ignoreNoCharForSwipe = initiator === initiators.swipe && isCharChat; |
| 4257 | 4243 | ||
| 4258 | // Swipes reuse the existing prompt, so the reference-image selection must be | ||
| 4259 | // reused as well - never re-run the LLM selection for a swipe. | ||
| 4260 | referenceSelectionAllowed = initiator !== initiators.swipe; | ||
| 4261 | |||
| 4262 | const skipCharPrefix = !ignoreNoCharForSwipe && noCharPrefix.includes(generationType); | 4244 | const skipCharPrefix = !ignoreNoCharForSwipe && noCharPrefix.includes(generationType); |
| 4263 | 4245 | ||
| 4264 | /** | 4246 | /** |