From 1d382b83c82362c99b279392420c4f1d0d50dfe1 Mon Sep 17 00:00:00 2001 From: Zayd Krunz <70227235+ShrootBuck@users.noreply.github.com> Date: Fri, 23 May 2025 01:16:47 +0000 Subject: [PATCH] refac: improve prompt formatting for selected text in FloatingButtons --- .../chat/ContentRenderer/FloatingButtons.svelte | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/ContentRenderer/FloatingButtons.svelte b/src/lib/components/chat/ContentRenderer/FloatingButtons.svelte index 9286aaed0..de3752157 100644 --- a/src/lib/components/chat/ContentRenderer/FloatingButtons.svelte +++ b/src/lib/components/chat/ContentRenderer/FloatingButtons.svelte @@ -44,7 +44,13 @@ toast.error('Model not selected'); return; } - prompt = `${floatingInputValue}\n\`\`\`\n${selectedText}\n\`\`\``; + prompt = [ + // Blockquote each line of the selected text + ...selectedText.split('\n').map(line => `> ${line}`), + '', + // Then your question + floatingInputValue + ].join('\n'); floatingInputValue = ''; responseContent = ''; @@ -121,8 +127,11 @@ toast.error('Model not selected'); return; } - const explainText = $i18n.t('Explain this section to me in more detail'); - prompt = `${explainText}\n\n\`\`\`\n${selectedText}\n\`\`\``; + const quotedText = selectedText + .split('\n') + .map(line => `> ${line}`) + .join('\n'); + prompt = `${quotedText}\n\nExplain`; responseContent = ''; const [res, controller] = await chatCompletion(localStorage.token, {