Browse Source

refac: prompt command behaviour

Timothy Jaeryang Baek 3 months ago
parent
commit
effa87638d

+ 0 - 1
src/lib/components/chat/MessageInput.svelte

@@ -855,7 +855,6 @@
 											on:keydown={async (e) => {
 											on:keydown={async (e) => {
 												const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac
 												const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac
 
 
-												console.log('keydown', e);
 												const commandsContainerElement =
 												const commandsContainerElement =
 													document.getElementById('commands-container');
 													document.getElementById('commands-container');
 
 

+ 7 - 3
src/lib/components/chat/MessageInput/Commands/Prompts.svelte

@@ -1,5 +1,5 @@
 <script lang="ts">
 <script lang="ts">
-	import { prompts, user } from '$lib/stores';
+	import { prompts, settings, user } from '$lib/stores';
 	import {
 	import {
 		findWordIndices,
 		findWordIndices,
 		getUserPosition,
 		getUserPosition,
@@ -120,12 +120,16 @@
 			text = text.replaceAll('{{CURRENT_WEEKDAY}}', weekday);
 			text = text.replaceAll('{{CURRENT_WEEKDAY}}', weekday);
 		}
 		}
 
 
-		const promptWords = prompt.split(' ');
+		const paragraphs = prompt.split('\n');
+
+		let lastParagraph = paragraphs.pop();
+		const promptWords = lastParagraph.split(' ');
 
 
 		promptWords.pop();
 		promptWords.pop();
 		promptWords.push(`${text}`);
 		promptWords.push(`${text}`);
 
 
-		prompt = promptWords.join(' ');
+		lastParagraph = promptWords.join(' ');
+		prompt = $settings?.richTextInput ? paragraphs.join('<br/>') : paragraphs.join('\n');
 
 
 		const chatInputContainerElement = document.getElementById('chat-input-container');
 		const chatInputContainerElement = document.getElementById('chat-input-container');
 		const chatInputElement = document.getElementById('chat-input');
 		const chatInputElement = document.getElementById('chat-input');