Merge pull request #14210 from ShrootBuck/main

refac: improve prompt formatting for selected text in FloatingButtons
This commit is contained in:
Tim Jaeryang Baek 2025-05-23 13:14:27 +04:00 committed by GitHub
commit 55a6fae9db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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, {