commit
4925c81e6e
19 changed files with 286 additions and 92 deletions
|
|
@ -5,6 +5,11 @@
|
|||
|
||||
|
||||
|
||||
<h2>Version 2.2.2 - 15/10/2024</h2>
|
||||
<ul>
|
||||
<li>APIs error handling improved.</li>
|
||||
<li><i>[OpenAI Comp API]</i> Added an option to remove the <i>v1</i> segment in the API calls path [<a href="https://github.com/micz/ThunderAI/issues/161">#161</a>].</li>
|
||||
</ul>
|
||||
<h2>Version 2.2.1 - 11/10/2024</h2>
|
||||
<ul>
|
||||
<li><i>[ChatGPT Web]</i> Added a workaround to login in ChatGPT. See the new button in the options page.</li>
|
||||
|
|
|
|||
|
|
@ -503,6 +503,10 @@
|
|||
"message": "Anfrage an die Ollama API fehlgeschlagen.",
|
||||
"description": ""
|
||||
},
|
||||
"chatgpt_api_request_failed": {
|
||||
"message": "Anfrage an die OpenAI ChatGPT API fehlgeschlagen",
|
||||
"description": ""
|
||||
},
|
||||
"WaitingServerReponse": {
|
||||
"message": "Warten auf die Serverantwort.",
|
||||
"description": ""
|
||||
|
|
@ -586,5 +590,17 @@
|
|||
"OpenChatGPTTab_Info": {
|
||||
"message": "Bei Anmeldeproblemen im ThunderAI-Fenster öffnen Sie ChatGPT in einem neuen Tab über die Schaltfläche rechts, melden Sie sich an, schließen Sie dann den Tab und fahren Sie fort, ThunderAI zu verwenden.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1": {
|
||||
"message": "\"v1\"-Kompatibilität beibehalten",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1_info": {
|
||||
"message": "Wenn aktiviert, wird das \"v1\"-Segment im Pfad der API-Aufrufe beibehalten, z.B. \"http://localhost:1234/v1/chat/completions\".",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_owl_warning": {
|
||||
"message": "Es scheint, dass mindestens eines Ihrer Konten das Add-on Eule für Exchange verwendet. Es gibt ein bekanntes Problem zwischen Thunderbird und Eule, das derzeit behoben wird. Derzeit können Sie ThunderAI beim Verfassen von E-Mails verwenden, jedoch nicht beim Lesen.",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -503,6 +503,10 @@
|
|||
"message": "Ollama API request failed",
|
||||
"description": ""
|
||||
},
|
||||
"chatgpt_api_request_failed": {
|
||||
"message": "OpenAI ChatGPT API request failed",
|
||||
"description": ""
|
||||
},
|
||||
"WaitingServerReponse": {
|
||||
"message": "Waiting for the server response",
|
||||
"description": ""
|
||||
|
|
@ -590,5 +594,17 @@
|
|||
"OpenChatGPTTab_Info": {
|
||||
"message": "In case of login issues in the ThunderAI window, open ChatGPT in a new tab using the button on the right, log in, then close the tab and continue using ThunderAI.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1" : {
|
||||
"message": "Keep the \"v1\" compatibility",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1_info": {
|
||||
"message": "If checked, the \"v1\" segment in the path of API calls will be kept, like \"http://localhost:1234/v1/chat/completions\".",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_owl_warning": {
|
||||
"message": "It appears that at least one of your accounts is using the Owl for Exchange add-on. There is a known issue between Thunderbird and Owl, which is currently being addressed. At this time, you can use ThunderAI while composing emails, but not when reading them.",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -503,6 +503,10 @@
|
|||
"message": "La demande d'API Ollama a échoué",
|
||||
"description": ""
|
||||
},
|
||||
"chatgpt_api_request_failed": {
|
||||
"message": "La demande d'API OpenAI ChatGPT a échoué",
|
||||
"description": ""
|
||||
},
|
||||
"WaitingServerReponse": {
|
||||
"message": "En attente de la réponse du serveur",
|
||||
"description": ""
|
||||
|
|
@ -586,5 +590,17 @@
|
|||
"OpenChatGPTTab_Info": {
|
||||
"message": "En cas de problèmes de connexion dans la fenêtre ThunderAI, ouvrez ChatGPT dans un nouvel onglet à l'aide du bouton à droite, connectez-vous, puis fermez l'onglet et continuez à utiliser ThunderAI.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1": {
|
||||
"message": "Conserver la compatibilité \"v1\"",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1_info": {
|
||||
"message": "Si coché, le segment \"v1\" dans le chemin des appels API sera conservé, comme \"http://localhost:1234/v1/chat/completions\".",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_owl_warning": {
|
||||
"message": "Il semble qu'au moins un de vos comptes utilise le module complémentaire Chouette pour Exchange. Il existe un problème connu entre Thunderbird et Chouette, qui est en cours de résolution. Pour le moment, vous pouvez utiliser ThunderAI lors de la rédaction d'e-mails, mais pas lors de leur lecture.",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -539,6 +539,10 @@
|
|||
"message": "Richiesta all'API compatibile con OpenAI fallita",
|
||||
"description": ""
|
||||
},
|
||||
"chatgpt_api_request_failed": {
|
||||
"message": "Richiesta all'API compatibile con OpenAI ChatGPT fallita",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OpenAIComp_ChatName": {
|
||||
"message": "Nome della chat",
|
||||
"description": ""
|
||||
|
|
@ -586,5 +590,17 @@
|
|||
"OpenChatGPTTab_Info": {
|
||||
"message": "In caso di problemi di accesso nella finestra di ThunderAI, apri ChatGPT in un nuovo tab utilizzando il pulsante a destra, accedi, quindi chiudi la scheda e continua a usare ThunderAI.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1": {
|
||||
"message": "Mantieni la compatibilità con \"v1\"",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1_info": {
|
||||
"message": "Se selezionato, il segmento \"v1\" nel percorso delle chiamate API verrà mantenuto, ad esempio \"http://localhost:1234/v1/chat/completions\".",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_owl_warning": {
|
||||
"message": "Sembra che almeno uno dei tuoi account stia utilizzando il componente aggiuntivo Gufo per Exchange. Esiste un problema noto tra Thunderbird e Gufo, che è attualmente in fase di risoluzione. Al momento, puoi utilizzare ThunderAI durante la composizione delle email, ma non durante la loro lettura.",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -503,6 +503,10 @@
|
|||
"message": "A solicitação da API do Ollama falhou",
|
||||
"description": ""
|
||||
},
|
||||
"chatgpt_api_request_failed": {
|
||||
"message": "A solicitação da API do OpenAI ChatGPT falhou",
|
||||
"description": ""
|
||||
},
|
||||
"WaitingServerReponse": {
|
||||
"message": "Aguardando a resposta do servidor",
|
||||
"description": ""
|
||||
|
|
@ -590,5 +594,17 @@
|
|||
"OpenChatGPTTab_Info": {
|
||||
"message": "Em caso de problemas de login na janela do ThunderAI, abra o ChatGPT em uma nova aba usando o botão à direita, faça o login, depois feche a aba e continue usando o ThunderAI.",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1": {
|
||||
"message": "Manter a compatibilidade com \"v1\"",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_openai_comp_use_v1_info": {
|
||||
"message": "Se marcado, o segmento \"v1\" no caminho das chamadas de API será mantido, como em \"http://localhost:1234/v1/chat/completions\".",
|
||||
"description": ""
|
||||
},
|
||||
"prefs_OptionText_owl_warning": {
|
||||
"message": "Parece que pelo menos uma das suas contas está usando o complemento Coruja para Exchange. Existe um problema conhecido entre Thunderbird e Coruja, que está sendo resolvido no momento. Por enquanto, você pode usar o ThunderAI ao redigir e-mails, mas não ao lê-los.",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -80,13 +80,13 @@ switch (llm) {
|
|||
break;
|
||||
}
|
||||
case "openai_comp_api": {
|
||||
let prefs_api = await browser.storage.sync.get({openai_comp_host: '', openai_comp_model: '', openai_comp_api_key: '', openai_comp_chat_name: '', do_debug: false});
|
||||
let prefs_api = await browser.storage.sync.get({openai_comp_host: '', openai_comp_model: '', openai_comp_api_key: '', openai_comp_use_v1: true, openai_comp_chat_name: '', do_debug: false});
|
||||
let i18nStrings = {};
|
||||
i18nStrings["OpenAIComp_api_request_failed"] = browser.i18n.getMessage('OpenAIComp_api_request_failed');
|
||||
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
|
||||
messageInput.setModel(prefs_api.openai_comp_model);
|
||||
messagesArea.setLLMName(prefs_api.openai_comp_chat_name);
|
||||
worker.postMessage({ type: 'init', openai_comp_host: prefs_api.openai_comp_host, openai_comp_model: prefs_api.openai_comp_model, openai_comp_api_key: prefs_api.openai_comp_api_key, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
worker.postMessage({ type: 'init', openai_comp_host: prefs_api.openai_comp_host, openai_comp_model: prefs_api.openai_comp_model, openai_comp_api_key: prefs_api.openai_comp_api_key, openai_comp_use_v1: prefs_api.openai_comp_use_v1, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
messagesArea.appendUserMessage(browser.i18n.getMessage("OpenAIComp_api_connecting") + " \"" + prefs_api.openai_comp_host + "\" " +browser.i18n.getMessage("AndModel") + " \"" + prefs_api.openai_comp_model + "\"...", "info");
|
||||
browser.runtime.sendMessage({command: "openai_comp_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -57,13 +57,17 @@ self.onmessage = async function(event) {
|
|||
if(response.is_exception === true){
|
||||
error_message = response.error;
|
||||
}else{
|
||||
const errorJSON = await response.json();
|
||||
errorDetail = JSON.stringify(errorJSON);
|
||||
error_message = errorJSON.error;
|
||||
taLog.log("errorJSON.error.message: " + JSON.stringify(errorJSON.error.message));
|
||||
try{
|
||||
const errorJSON = await response.json();
|
||||
errorDetail = JSON.stringify(errorJSON);
|
||||
error_message = errorJSON.error.message;
|
||||
}catch(e){
|
||||
error_message = response.statusText;
|
||||
}
|
||||
taLog.log("error_message: " + JSON.stringify(error_message));
|
||||
}
|
||||
postMessage({ type: 'error', payload: i18nStrings["ollama_api_request_failed"] + ": " + error_message });
|
||||
throw new Error("[ThunderAI] Ollama API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail);
|
||||
postMessage({ type: 'error', payload: i18nStrings["ollama_api_request_failed"] + ": " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail });
|
||||
throw new Error("[ThunderAI] Ollama API request failed: " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail);
|
||||
}
|
||||
|
||||
const reader = response.body.getReader();
|
||||
|
|
|
|||
|
|
@ -52,13 +52,17 @@ self.onmessage = async function(event) {
|
|||
if(response.is_exception === true){
|
||||
error_message = response.error;
|
||||
}else{
|
||||
const errorJSON = await response.json();
|
||||
errorDetail = JSON.stringify(errorJSON);
|
||||
error_message = errorJSON.error.message;
|
||||
taLog.error("errorJSON.error.message: " + JSON.stringify(errorJSON.error.message));
|
||||
try{
|
||||
const errorJSON = await response.json();
|
||||
errorDetail = JSON.stringify(errorJSON);
|
||||
error_message = errorJSON.error.message;
|
||||
}catch(e){
|
||||
error_message = response.statusText;
|
||||
}
|
||||
taLog.log("error_message: " + JSON.stringify(error_message));
|
||||
}
|
||||
postMessage({ type: 'error', payload: error_message });
|
||||
throw new Error("[ThunderAI] OpenAI API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail);
|
||||
postMessage({ type: 'error', payload: i18nStrings["chatgpt_api_request_failed"] + ": " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail });
|
||||
throw new Error("[ThunderAI] OpenAI ChatGPT API request failed: " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail);
|
||||
}
|
||||
|
||||
const reader = response.body.getReader();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import { taLogger } from '../js/mzta-logger.js';
|
|||
let openai_comp_host = null;
|
||||
let openai_comp_model = '';
|
||||
let openai_comp_api_key = '';
|
||||
let openai_comp_use_v1 = true;
|
||||
let openai_comp = null;
|
||||
let stopStreaming = false;
|
||||
let i18nStrings = null;
|
||||
|
|
@ -40,7 +41,8 @@ self.onmessage = async function(event) {
|
|||
openai_comp_host = event.data.openai_comp_host;
|
||||
openai_comp_model = event.data.openai_comp_model;
|
||||
openai_comp_api_key = event.data.openai_comp_api_key;
|
||||
openai_comp = new OpenAIComp(openai_comp_host, openai_comp_model, openai_comp_api_key, true);
|
||||
openai_comp_use_v1 = event.data.openai_comp_use_v1;
|
||||
openai_comp = new OpenAIComp(openai_comp_host, openai_comp_model, openai_comp_api_key, true, openai_comp_use_v1);
|
||||
do_debug = event.data.do_debug;
|
||||
i18nStrings = event.data.i18nStrings;
|
||||
taLog = new taLogger('model-worker-openai_comp', do_debug);
|
||||
|
|
@ -56,13 +58,17 @@ self.onmessage = async function(event) {
|
|||
if(response.is_exception === true){
|
||||
error_message = response.error;
|
||||
}else{
|
||||
const errorJSON = await response.json();
|
||||
errorDetail = JSON.stringify(errorJSON);
|
||||
error_message = errorJSON.error.message;
|
||||
taLog.log("errorJSON.error.message: " + JSON.stringify(errorJSON.error.message));
|
||||
try{
|
||||
const errorJSON = await response.json();
|
||||
errorDetail = JSON.stringify(errorJSON);
|
||||
error_message = errorJSON.error.message;
|
||||
}catch(e){
|
||||
error_message = response.statusText;
|
||||
}
|
||||
taLog.log("error_message: " + JSON.stringify(error_message));
|
||||
}
|
||||
postMessage({ type: 'error', payload: i18nStrings["OpenAIComp_api_request_failed"] + ": " + error_message });
|
||||
throw new Error("[ThunderAI] OpenAI Comp API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail);
|
||||
postMessage({ type: 'error', payload: i18nStrings["OpenAIComp_api_request_failed"] + ": " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail });
|
||||
throw new Error("[ThunderAI] OpenAI Comp API request failed: " + response.status + " " + response.statusText + ", Detail: " + error_message + " " + errorDetail);
|
||||
}
|
||||
|
||||
const reader = response.body.getReader();
|
||||
|
|
|
|||
|
|
@ -29,31 +29,40 @@ export class Ollama {
|
|||
}
|
||||
|
||||
fetchModels = async () => {
|
||||
const response = await fetch(this.host + "/api/tags", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
});
|
||||
try{
|
||||
const response = await fetch(this.host + "/api/tags", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorDetail = await response.text();
|
||||
let err_msg = "[ThunderAI] Ollama API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail;
|
||||
console.error(err_msg);
|
||||
let output = {};
|
||||
output.ok = false;
|
||||
output.error = errorDetail;
|
||||
return output;
|
||||
if (!response.ok) {
|
||||
const errorDetail = await response.text();
|
||||
let err_msg = "[ThunderAI] Ollama API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail;
|
||||
console.error(err_msg);
|
||||
let output = {};
|
||||
output.ok = false;
|
||||
output.error = errorDetail;
|
||||
return output;
|
||||
}
|
||||
|
||||
let output = {};
|
||||
output.ok = true;
|
||||
let output_response = await response.json();
|
||||
output.response = output_response;
|
||||
|
||||
//console.log(">>>>>>>>>> output_response: " + JSON.stringify(output_response));
|
||||
|
||||
return output;
|
||||
}catch (error) {
|
||||
console.error("[ThunderAI] Ollama API request failed: " + error);
|
||||
let output = {};
|
||||
output.is_exception = true;
|
||||
output.ok = false;
|
||||
output.error = "Ollama API request failed: " + error;
|
||||
return output;
|
||||
}
|
||||
|
||||
let output = {};
|
||||
output.ok = true;
|
||||
let output_response = await response.json();
|
||||
output.response = output_response;
|
||||
|
||||
//console.log(">>>>>>>>>> output_response: " + JSON.stringify(output_response));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,30 +33,39 @@ export class OpenAI {
|
|||
|
||||
|
||||
fetchModels = async () => {
|
||||
const response = await fetch("https://api.openai.com/v1/models", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer "+ this.apiKey
|
||||
},
|
||||
});
|
||||
try{
|
||||
const response = await fetch("https://api.openai.com/v1/models", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer "+ this.apiKey
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorDetail = await response.text();
|
||||
let err_msg = "[ThunderAI] OpenAI API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail;
|
||||
console.error(err_msg);
|
||||
let output = {};
|
||||
output.ok = false;
|
||||
output.error = errorDetail;
|
||||
return output;
|
||||
if (!response.ok) {
|
||||
const errorDetail = await response.text();
|
||||
let err_msg = "[ThunderAI] OpenAI API request failed: " + response.status + " " + response.statusText + ", Detail: " + errorDetail;
|
||||
console.error(err_msg);
|
||||
let output = {};
|
||||
output.ok = false;
|
||||
output.error = errorDetail;
|
||||
return output;
|
||||
}
|
||||
|
||||
let output = {};
|
||||
output.ok = true;
|
||||
let output_response = await response.json();
|
||||
output.response = output_response.data.filter(item => item.id.startsWith('gpt-')).sort((a, b) => b.id.localeCompare(a.id));
|
||||
|
||||
return output;
|
||||
}catch (error) {
|
||||
console.error("[ThunderAI] OpenAI API request failed: " + error);
|
||||
let output = {};
|
||||
output.is_exception = true;
|
||||
output.ok = false;
|
||||
output.error = "OpenAI API request failed: " + error;
|
||||
return output;
|
||||
}
|
||||
|
||||
let output = {};
|
||||
output.ok = true;
|
||||
let output_response = await response.json();
|
||||
output.response = output_response.data.filter(item => item.id.startsWith('gpt-')).sort((a, b) => b.id.localeCompare(a.id));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
fetchResponse = async (messages, maxTokens = 0) => {
|
||||
|
|
|
|||
|
|
@ -24,13 +24,15 @@ export class OpenAIComp {
|
|||
host = '';
|
||||
model = '';
|
||||
apiKey = '';
|
||||
use_v1 = true;
|
||||
stream = false;
|
||||
|
||||
constructor(host, model, apiKey = '', stream = false) {
|
||||
constructor(host, model, apiKey = '', stream = false, use_v1 = true) {
|
||||
this.host = host.trim().replace(/\/+$/, "");
|
||||
this.model = model;
|
||||
this.stream = stream;
|
||||
this.apiKey = apiKey;
|
||||
this.use_v1 = use_v1;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -40,7 +42,7 @@ export class OpenAIComp {
|
|||
};
|
||||
if(this.apiKey !== '') curr_headers["Authorization"] = "Bearer "+ this.apiKey;
|
||||
|
||||
const response = await fetch(this.host + "/v1/models", {
|
||||
const response = await fetch(this.host + (this.use_v1 ? "/v1" : "") + "/models", {
|
||||
method: "GET",
|
||||
headers: curr_headers,
|
||||
});
|
||||
|
|
@ -64,23 +66,32 @@ export class OpenAIComp {
|
|||
}
|
||||
|
||||
fetchResponse = async (messages, maxTokens = 0) => {
|
||||
const curr_headers = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
if(this.apiKey !== '') curr_headers["Authorization"] = "Bearer "+ this.apiKey;
|
||||
try{
|
||||
const curr_headers = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
if(this.apiKey !== '') curr_headers["Authorization"] = "Bearer "+ this.apiKey;
|
||||
|
||||
try {
|
||||
const response = await fetch(this.host + "/v1/chat/completions", {
|
||||
method: "POST",
|
||||
headers: curr_headers,
|
||||
body: JSON.stringify({
|
||||
model: this.model,
|
||||
messages: messages,
|
||||
stream: this.stream,
|
||||
...(maxTokens > 0 ? { 'max_tokens': parseInt(maxTokens) } : {})
|
||||
}),
|
||||
});
|
||||
return response;
|
||||
try {
|
||||
const response = await fetch(this.host + (this.use_v1 ? "/v1" : "") + "/chat/completions", {
|
||||
method: "POST",
|
||||
headers: curr_headers,
|
||||
body: JSON.stringify({
|
||||
model: this.model,
|
||||
messages: messages,
|
||||
stream: this.stream,
|
||||
...(maxTokens > 0 ? { 'max_tokens': parseInt(maxTokens) } : {})
|
||||
}),
|
||||
});
|
||||
return response;
|
||||
}catch (error) {
|
||||
console.error("[ThunderAI] OpenAI API Comp request failed: " + error);
|
||||
let output = {};
|
||||
output.is_exception = true;
|
||||
output.ok = false;
|
||||
output.error = "OpenAI API Comp request failed: " + error;
|
||||
return output;
|
||||
}
|
||||
}catch (error) {
|
||||
console.error("[ThunderAI] OpenAI API Comp request failed: " + error);
|
||||
let output = {};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"manifest_version": 2,
|
||||
"name": "ThunderAI",
|
||||
"description": "__MSG_extensionDescription__",
|
||||
"version": "2.2.1",
|
||||
"version": "2.2.2",
|
||||
"author": "Mic (m@micz.it)",
|
||||
"homepage_url": "https://micz.it/thunderbird-addon-thunderai/",
|
||||
"browser_specific_settings": {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export const prefs_default = {
|
|||
openai_comp_host: '', // For OpenAI Compatible API as LM-Studio
|
||||
openai_comp_model: '',
|
||||
openai_comp_api_key: '',
|
||||
openai_comp_use_v1: true,
|
||||
openai_comp_chat_name: 'OpenAI Comp',
|
||||
dynamic_menu_force_enter: false,
|
||||
dynamic_menu_order_alphabet: true,
|
||||
|
|
|
|||
|
|
@ -146,6 +146,26 @@ input.option-input[type="text"]{
|
|||
font-style: italic;
|
||||
}
|
||||
|
||||
#owl_warning{
|
||||
display: none;
|
||||
}
|
||||
|
||||
#owl_warning div{
|
||||
color: white;
|
||||
font-style: italic;
|
||||
background-color: red;
|
||||
border-radius: 4px;
|
||||
padding: 3px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
#owl_warning div a{
|
||||
background-color: white;
|
||||
padding:0px 3px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body {
|
||||
background-color: rgb(35, 34, 43);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
<div id="miczRelNotes"><a href="mzta-release-notes.html">__MSG_prefs_OptionText_release_notes__</a></div>
|
||||
<div id="miczStatusPage" class="conntype_chatgpt_web"><a href="https://micz.it/thunderbird-addon-thunderai/status/">__MSG_prefs_status_page__</a></div>
|
||||
<table id="miczPrefs">
|
||||
<tr id="owl_warning">
|
||||
<td colspan="2"><div>__MSG_prefs_OptionText_owl_warning__ <a href="https://micz.it/thunderbird-addon-thunderai/owl/">__MSG_customPrompts_managePrompts_help__</a></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span>__MSG_prefs_OptionText_chatgpt_win_text__</span></td>
|
||||
<td>
|
||||
|
|
@ -170,6 +173,17 @@
|
|||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OptionText_openai_comp_use_v1__</span>
|
||||
</label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" id="openai_comp_use_v1" name="openai_comp_use_v1" class="option-input" />
|
||||
<span>__MSG_prefs_OptionText_openai_comp_use_v1_info__</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="conntype_openai_comp_api">
|
||||
<td><label>
|
||||
<span>__MSG_prefs_OpenAIComp_API_Key__</span>
|
||||
|
|
|
|||
|
|
@ -205,6 +205,14 @@ function warn_OpenAIComp_HostEmpty() {
|
|||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
await restoreOptions();
|
||||
|
||||
// show Owl warning
|
||||
const accountList = await messenger.accounts.list(false);
|
||||
if(accountList.some(account => account.type.toLowerCase().includes('owl'))) {
|
||||
taLog.log('OWL detected, displaying the warning.');
|
||||
document.getElementById('owl_warning').style.display = 'table-row';
|
||||
}
|
||||
|
||||
i18n.updateDocument();
|
||||
document.querySelectorAll(".option-input").forEach(element => {
|
||||
element.addEventListener("change", saveOptions);
|
||||
|
|
@ -247,10 +255,16 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
let openai = new OpenAI(document.getElementById("chatgpt_api_key").value, '', true);
|
||||
openai.fetchModels().then((data) => {
|
||||
if(!data.ok){
|
||||
let errorDetail = JSON.parse(data.error);
|
||||
let errorDetail;
|
||||
try {
|
||||
errorDetail = JSON.parse(data.error);
|
||||
errorDetail = errorDetail.error.message;
|
||||
} catch (e) {
|
||||
errorDetail = data.error;
|
||||
}
|
||||
document.getElementById('chatgpt_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("ChatGPT_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("ChatGPT_Models_Error_fetching")+": " + errorDetail.error.message);
|
||||
alert(browser.i18n.getMessage("ChatGPT_Models_Error_fetching")+": " + errorDetail);
|
||||
return;
|
||||
}
|
||||
taLog.log("ChatGPT models: " + JSON.stringify(data));
|
||||
|
|
@ -288,10 +302,16 @@ select_ollama_model.addEventListener("change", warn_Ollama_HostEmpty);
|
|||
return;
|
||||
}
|
||||
if(!data.ok){
|
||||
let errorDetail = JSON.parse(data.error);
|
||||
let errorDetail;
|
||||
try {
|
||||
errorDetail = JSON.parse(data.error);
|
||||
errorDetail = errorDetail.error.message;
|
||||
} catch (e) {
|
||||
errorDetail = data.error;
|
||||
}
|
||||
document.getElementById('ollama_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("Ollama_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("Ollama_Models_Error_fetching")+": " + errorDetail.error.message);
|
||||
alert(browser.i18n.getMessage("Ollama_Models_Error_fetching")+": " + errorDetail);
|
||||
return;
|
||||
}
|
||||
if(data.response.models.length == 0){
|
||||
|
|
@ -330,13 +350,19 @@ select_openai_comp_model.addEventListener("change", warn_OpenAIComp_HostEmpty);
|
|||
|
||||
document.getElementById('btnUpdateOpenAICompModels').addEventListener('click', async () => {
|
||||
document.getElementById('openai_comp_model_fetch_loading').style.display = 'inline';
|
||||
let openai_comp = new OpenAIComp(document.getElementById("openai_comp_host").value , null, document.getElementById("openai_comp_api_key").value, true);
|
||||
let openai_comp = new OpenAIComp(document.getElementById("openai_comp_host").value , null, document.getElementById("openai_comp_api_key").value, true, document.getElementById("openai_comp_use_v1").checked);
|
||||
openai_comp.fetchModels().then((data) => {
|
||||
if(!data.ok){
|
||||
let errorDetail = JSON.parse(data.error);
|
||||
let errorDetail;
|
||||
try {
|
||||
errorDetail = JSON.parse(data.error);
|
||||
errorDetail = errorDetail.error.message;
|
||||
} catch (e) {
|
||||
errorDetail = data.error;
|
||||
}
|
||||
document.getElementById('openai_comp_model_fetch_loading').style.display = 'none';
|
||||
console.error("[ThunderAI] " + browser.i18n.getMessage("OpenAIComp_Models_Error_fetching"));
|
||||
alert(browser.i18n.getMessage("OpenAIComp_Models_Error_fetching")+": " + errorDetail.error.message);
|
||||
alert(browser.i18n.getMessage("OpenAIComp_Models_Error_fetching")+": " + errorDetail);
|
||||
return;
|
||||
}
|
||||
taLog.log("OpenAIComp models: " + JSON.stringify(data));
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@
|
|||
<body>
|
||||
<div id="miczBackPrefs"><a href="mzta-options.html">__MSG_backToOptionsText__</a></div>
|
||||
<div id="miczRelNotes"><h1>ThunderAI Release Notes</h1>
|
||||
<h2>Version 2.2.2 - 15/10/2024</h2>
|
||||
<ul>
|
||||
<li>APIs error handling improved.</li>
|
||||
<li><i>[OpenAI Comp API]</i> Added an option to remove the <i>v1</i> segment in the API calls path [<a href="https://github.com/micz/ThunderAI/issues/161">#161</a>].</li>
|
||||
</ul>
|
||||
<h2>Version 2.2.1 - 11/10/2024</h2>
|
||||
<ul>
|
||||
<li><i>[ChatGPT Web]</i> Added a workaround to login in ChatGPT. See the new button in the options page.</li>
|
||||
|
|
|
|||
Loading…
Reference in a new issue