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": ""
|
"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": {
|
"prefs_OptionText_release_notes": {
|
||||||
"message": "Release Notes",
|
"message": "Release Notes",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,11 @@
|
||||||
"description": ""
|
"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": {
|
"prefs_OptionText_release_notes": {
|
||||||
"message": "Note di rilascio",
|
"message": "Note di rilascio",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// Modified version derived from https://github.com/ali-raheem/Aify/blob/13ff87583bc520fb80f555ab90a90c5c9df797a7/plugin/content_scripts/compose.js
|
// 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 makeParagraphs = (text, func) => {
|
||||||
const chunks = text.split(/\n{2,}/);
|
const chunks = text.split(/\n{2,}/);
|
||||||
|
|
@ -86,6 +86,10 @@ switch (message.command) {
|
||||||
insertReply(message.text);
|
insertReply(message.text);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'promptTooLong':
|
||||||
|
alert(browser.i18n.getMessage('msg_prompt_too_long'));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// do nothing
|
// do nothing
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,12 @@ messenger.runtime.onMessage.addListener(async (message, sender, sendResponse) =>
|
||||||
async function openChatGPT(promptText, action, curr_tabId) {
|
async function openChatGPT(promptText, action, curr_tabId) {
|
||||||
let prefs = await browser.storage.sync.get(prefs_default);
|
let prefs = await browser.storage.sync.get(prefs_default);
|
||||||
prefs = checkScreenDimensions(prefs);
|
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({
|
let newWindow = await browser.windows.create({
|
||||||
url: "https://chat.openai.com",
|
url: "https://chat.openai.com",
|
||||||
type: "popup",
|
type: "popup",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue