If the prompt is more than 30.000 characters, do not procede and give a warning. Fixes #26
This commit is contained in:
parent
c00b0b5f97
commit
a30810cbee
4 changed files with 21 additions and 1 deletions
|
|
@ -79,6 +79,11 @@
|
|||
"description": ""
|
||||
},
|
||||
|
||||
"msg_prompt_too_long": {
|
||||
"message": "The text you provided is too long. You need to reduce it to use ChatGPT.",
|
||||
"description": ""
|
||||
},
|
||||
|
||||
"prefs_OptionText_release_notes": {
|
||||
"message": "Release Notes",
|
||||
"description": ""
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@
|
|||
"description": ""
|
||||
},
|
||||
|
||||
"msg_prompt_too_long": {
|
||||
"message": "Il testo che vuoi inviare a ChatGPT è troppo lungo. Devi ridurlo per poter procedere.",
|
||||
"description": ""
|
||||
},
|
||||
|
||||
"prefs_OptionText_release_notes": {
|
||||
"message": "Note di rilascio",
|
||||
"description": ""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Modified version derived from https://github.com/ali-raheem/Aify/blob/13ff87583bc520fb80f555ab90a90c5c9df797a7/plugin/content_scripts/compose.js
|
||||
|
||||
console.log('mzta-compose-script.js');
|
||||
//console.log('mzta-compose-script.js');
|
||||
|
||||
const makeParagraphs = (text, func) => {
|
||||
const chunks = text.split(/\n{2,}/);
|
||||
|
|
@ -86,6 +86,10 @@ switch (message.command) {
|
|||
insertReply(message.text);
|
||||
break;
|
||||
|
||||
case 'promptTooLong':
|
||||
alert(browser.i18n.getMessage('msg_prompt_too_long'));
|
||||
break;
|
||||
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -96,6 +96,12 @@ messenger.runtime.onMessage.addListener(async (message, sender, sendResponse) =>
|
|||
async function openChatGPT(promptText, action, curr_tabId) {
|
||||
let prefs = await browser.storage.sync.get(prefs_default);
|
||||
prefs = checkScreenDimensions(prefs);
|
||||
console.log('Prompt length: ' + promptText.length);
|
||||
if(promptText.length > 30000 ){
|
||||
// Prompt too long for ChatGPT
|
||||
browser.tabs.sendMessage(curr_tabId, { command: "promptTooLong" });
|
||||
return;
|
||||
}
|
||||
let newWindow = await browser.windows.create({
|
||||
url: "https://chat.openai.com",
|
||||
type: "popup",
|
||||
|
|
|
|||
Loading…
Reference in a new issue