fix(ui): prompt template preset preview out of order

This commit is contained in:
psychedelicious 2024-08-18 23:45:59 +10:00
parent 584e07182b
commit 6c404ce5f8

View File

@ -5,11 +5,13 @@ export const getViewModeChunks = (currentPrompt: string, presetPrompt?: string):
return ['', currentPrompt, '']; return ['', currentPrompt, ''];
} }
const [before, after] = presetPrompt.split(PRESET_PLACEHOLDER, 2); // When preset prompt does not contain the placeholder, we append the preset to the current prompt
if (!presetPrompt.includes(PRESET_PLACEHOLDER)) {
if (!before || !after) { return ['', `${currentPrompt} `, presetPrompt];
return ['', `${currentPrompt} `, before || after || ''];
} }
return [before ?? '', currentPrompt, after ?? '']; // Otherwise, we split the preset prompt into 3 parts: before, current, and after the placeholder
const [before, after] = presetPrompt.split(PRESET_PLACEHOLDER, 2);
return [before || '', currentPrompt, after || ''];
}; };