diff --git a/src/lib/components/chat/MessageInput/Commands/Prompts.svelte b/src/lib/components/chat/MessageInput/Commands/Prompts.svelte index 9e85c023b..d7dcd25f5 100644 --- a/src/lib/components/chat/MessageInput/Commands/Prompts.svelte +++ b/src/lib/components/chat/MessageInput/Commands/Prompts.svelte @@ -120,16 +120,16 @@ text = text.replaceAll('{{CURRENT_WEEKDAY}}', weekday); } - const paragraphs = prompt.split('\n'); + const lines = prompt.split('\n'); + const lastLine = lines.pop(); - let lastParagraph = paragraphs.pop(); - const promptWords = lastParagraph.split(' '); + const lastLineWords = lastLine.split(' '); + const lastWord = lastLineWords.pop(); - promptWords.pop(); - promptWords.push(`${text}`); + lastLineWords.push(text); + lines.push(lastLineWords.join(' ')); - lastParagraph = promptWords.join(' '); - prompt = $settings?.richTextInput ? paragraphs.join('
') : paragraphs.join('\n'); + prompt = lines.join('\n'); const chatInputContainerElement = document.getElementById('chat-input-container'); const chatInputElement = document.getElementById('chat-input');