mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
Merge pull request #14210 from ShrootBuck/main
refac: improve prompt formatting for selected text in FloatingButtons
This commit is contained in:
commit
55a6fae9db
@ -44,7 +44,13 @@
|
|||||||
toast.error('Model not selected');
|
toast.error('Model not selected');
|
||||||
return;
|
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 = '';
|
floatingInputValue = '';
|
||||||
|
|
||||||
responseContent = '';
|
responseContent = '';
|
||||||
@ -121,8 +127,11 @@
|
|||||||
toast.error('Model not selected');
|
toast.error('Model not selected');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const explainText = $i18n.t('Explain this section to me in more detail');
|
const quotedText = selectedText
|
||||||
prompt = `${explainText}\n\n\`\`\`\n${selectedText}\n\`\`\``;
|
.split('\n')
|
||||||
|
.map(line => `> ${line}`)
|
||||||
|
.join('\n');
|
||||||
|
prompt = `${quotedText}\n\nExplain`;
|
||||||
|
|
||||||
responseContent = '';
|
responseContent = '';
|
||||||
const [res, controller] = await chatCompletion(localStorage.token, {
|
const [res, controller] = await chatCompletion(localStorage.token, {
|
||||||
|
Loading…
Reference in New Issue
Block a user