added error notification for empty model or apikey using the ChatGPT API
This commit is contained in:
parent
679e2bf057
commit
1ba49b64f3
2 changed files with 26 additions and 0 deletions
|
|
@ -418,5 +418,17 @@
|
||||||
"ChatGPT_Models_Loading": {
|
"ChatGPT_Models_Loading": {
|
||||||
"message": "Loading...",
|
"message": "Loading...",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"message": "ThunderAI Error!",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"chatgpt_empty_apikey": {
|
||||||
|
"message": "You've not added an API Key a model for the ChatGPT API. Please insert one in the options page.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"chatgpt_empty_model": {
|
||||||
|
"message": "You've not choosen a model for the ChatGPT API. Please choose one in the options page.",
|
||||||
|
"description": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,6 +149,11 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
|
|
||||||
// check if the API is present, otherwise open the web interface
|
// check if the API is present, otherwise open the web interface
|
||||||
if (prefs.api_key_chatgpt == '') {
|
if (prefs.api_key_chatgpt == '') {
|
||||||
|
showNotification(browser.i18n.getMessage('error'),browser.i18n.getMessage('chatgpt_empty_apikey'));
|
||||||
|
prefs.connection_type = 'chatgpt_web';
|
||||||
|
}
|
||||||
|
if (prefs.model_chatgpt == '') {
|
||||||
|
showNotification(browser.i18n.getMessage('error'),browser.i18n.getMessage('chatgpt_empty_model'));
|
||||||
prefs.connection_type = 'chatgpt_web';
|
prefs.connection_type = 'chatgpt_web';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,6 +260,15 @@ function checkScreenDimensions(prefs){
|
||||||
return prefs;
|
return prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showNotification(title, message) {
|
||||||
|
browser.notifications.create({
|
||||||
|
"type": "basic",
|
||||||
|
"title": title,
|
||||||
|
"iconUrl": browser.extension.getURL("images/icon.png"),
|
||||||
|
"message": message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Menus handling
|
// Menus handling
|
||||||
const menus = new mzta_Menus(openChatGPT);
|
const menus = new mzta_Menus(openChatGPT);
|
||||||
menus.loadMenus();
|
menus.loadMenus();
|
||||||
Loading…
Reference in a new issue