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, ''];
}
const [before, after] = presetPrompt.split(PRESET_PLACEHOLDER, 2);
if (!before || !after) {
return ['', `${currentPrompt} `, before || after || ''];
// When preset prompt does not contain the placeholder, we append the preset to the current prompt
if (!presetPrompt.includes(PRESET_PLACEHOLDER)) {
return ['', `${currentPrompt} `, presetPrompt];
}
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 || ''];
};