giving error to user and console on model fetch if needed. see #92

This commit is contained in:
mic 2024-07-26 22:30:58 +02:00
parent acb1dd8629
commit 9787db321d
2 changed files with 10 additions and 2 deletions

View file

@ -406,10 +406,13 @@
"ChatGPT_Models": {
"message": "ChatGPT Models",
"description": ""
}
,
},
"ChatGPT_Models_Fetch": {
"message": "Update ChatGPT Models list",
"description": ""
},
"ChatGPT_Models_Error_fetching": {
"message": "Error trying to fetch ChatGPT models",
"description": ""
}
}

View file

@ -164,6 +164,11 @@ document.addEventListener('DOMContentLoaded', async () => {
document.getElementById('btnUpdateChatGPTModels').addEventListener('click', () => {
openai.fetchModels().then((data) => {
if(!data){
console.error("[ThunderAI] " + browser.i18n.getMessage("ChatGPT_Models_Error_fetching"));
alert(browser.i18n.getMessage("ChatGPT_Models_Error_fetching"));
return;
}
console.log(">>>>>>>>> ChatGPT models: " + JSON.stringify(data));
data.forEach(model => {
if (!Array.from(select_model_chatgpt.options).some(option => option.value === model.id)) {