added error notification for empty model or apikey using the ChatGPT API

This commit is contained in:
mic 2024-07-29 22:47:17 +02:00
parent 679e2bf057
commit 1ba49b64f3
2 changed files with 26 additions and 0 deletions

View file

@ -418,5 +418,17 @@
"ChatGPT_Models_Loading": {
"message": "Loading...",
"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": ""
}
}

View file

@ -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
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';
}
@ -255,6 +260,15 @@ function checkScreenDimensions(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
const menus = new mzta_Menus(openChatGPT);
menus.loadMenus();