[Ollama API] It's now possible to use a local LMM using Ollama [#79].
+
[ChatGPT API][Ollama API] Added a "Stop" button to stop the current elaboration [#113].
+
[ChatGPT API] If the configuration is missing the model or the API key, an error message is now provided, and there is no more fallback to the ChatGPT web interface [#111].
+
[ChatGPT API][Ollama API] Improved chat colors scheme for darkmode.
+
[ChatGPT API][Ollama API] Added a status message to give feedback to the user about the current operation [#119].
+
Improved the internal messaging system between the background script and the chat windows [#117].
+
...
Version 2.0.7 - 21/08/2024
[ChatGPT Web] Fixed an issue with automatically sending the prompt.
diff --git a/README.md b/README.md
index aedf5d52..c335f23f 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
#  ThunderAI
-ThunderAI is a Thunderbird Addon that uses the capabilities of ChatGPT to enhance email management.
+ThunderAI is a Thunderbird Addon that uses the capabilities of ChatGPT or Ollama to enhance email management.
It enables users to analyse, write, correct, and optimize their emails, facilitating more effective and professional communication.
@@ -11,10 +11,20 @@ Find out how [here](https://micz.it/thunderbird-addon-thunderai/custom-prompts/)
> [!TIP]
-> There is no need for an API key and is possibile to use this extension even with a free account!
+> **Using ChatGPT**
+>
+> There is no need for an API key and is possibile to use this extension even with a free account, using the web interface!
>
> Starting from version 2.0.0, if you want to connect with the OpenAI API integration, now you can use an API Key!
+
+
+> [!TIP]
+> **Using Ollama**
+>
+> From version 2.1.0 is possible to use a local Ollama server!
+>
+> Just remember to add `OLLAMA_ORIGINS = moz-extension://*` to the Ollama server environment variables.
diff --git a/_locales/de/messages.json b/_locales/de/messages.json
index 7f63734c..83223218 100644
--- a/_locales/de/messages.json
+++ b/_locales/de/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Verwenden Sie ChatGPT, um Ihre E-Mails zu verbessern!",
+ "message": "Verwende ChatGPT oder Ollama, um deine E-Mails zu verbessern!",
"description": "Beschreibung der Erweiterung."
},
"menu_title": {
@@ -284,7 +284,7 @@
"description": ""
},
"prefs_OptionText_default_chatgpt_lang": {
- "message": "Standardsprache für ChatGPT-Antworten",
+ "message": "Standardsprache für die Antworten",
"description": ""
},
"prefs_OptionText_reply_all": {
@@ -320,11 +320,11 @@
"description": ""
},
"prefsInfoDesc_2": {
- "message": "Um die ChatGPT-API zu verwenden, benötigen Sie einen OpenAI ChatGPT-API-Schlüssel und müssen ein Modell auswählen. Falls Sie dies nicht tun, wird ThunderAI auf die Verwendung der ChatGPT-Webschnittstelle zurückgreifen.",
+ "message": "Um die ChatGPT-API zu verwenden, benötigen Sie einen OpenAI ChatGPT-API-Schlüssel und müssen ein Modell auswählen.",
"description": ""
},
"prefsInfoDesc_3": {
- "message": " ",
+ "message": "Um die Integration mit Ollama zu nutzen, müssen Sie einen lokalen Ollama-Server einrichten. Sobald der Server läuft, geben Sie dessen Adresse in das dafür vorgesehene Feld in der Anwendung ein. Um eine ordnungsgemäße Kommunikation zwischen der App und dem Ollama-Server sicherzustellen, denken Sie daran, OLLAMA_ORIGINS=moz-extension://* festzulegen.",
"description": ""
},
"prefsDonation_1": {
@@ -399,7 +399,7 @@
"message": "ChatGPT API-Schlüssel",
"description": ""
},
- "ChatGPT_Models": {
+ "ChatGPT_Models": {
"message": "ChatGPT-Modelle",
"description": ""
},
@@ -411,7 +411,7 @@
"message": "Fehler beim Abrufen der ChatGPT-Modelle",
"description": ""
},
- "ChatGPT_Models_Loading": {
+ "Loading": {
"message": "Laden...",
"description": ""
},
@@ -431,8 +431,72 @@
"message": "Modell wird verwendet",
"description": ""
},
- "chagtp_api_connecting": {
- "message": "Versucht, eine Verbindung zu OpenAI ChatGPT mit dem angegebenen API-Schlüssel herzustellen...",
+ "chagpt_api_connecting": {
+ "message": "Versuch, eine Verbindung zu OpenAI ChatGPT mit dem bereitgestellten API-Schlüssel herzustellen",
+ "description": ""
+ },
+ "Debug": {
+ "message": "Debuggen",
+ "description": ""
+ },
+ "prefs_OptionText_do_debug_info": {
+ "message": "Aktiviere das Debug-System",
+ "description": ""
+ },
+ "prefs_Connection_type_Ollama_API": {
+ "message": "Ollama API (Lokales LLM)",
+ "description": ""
+ },
+ "prefs_Ollama_Host": {
+ "message": "Host-Adresse",
+ "description": ""
+ },
+ "Ollama_Models": {
+ "message": "Ollama-Modelle",
+ "description": ""
+ },
+ "Ollama_Models_Fetch": {
+ "message": "Liste der Ollama-Modelle aktualisieren",
+ "description": ""
+ },
+ "Ollama_Models_Error_fetching": {
+ "message": "Fehler beim Abrufen der Ollama-Modelle",
+ "description": ""
+ },
+ "Ollama_Models_Error_NoModels": {
+ "message": "Keine Modelle gefunden",
+ "description": ""
+ },
+ "ollama_empty_host": {
+ "message": "Sie haben keine Host-Adresse für die Ollama API hinzugefügt. Bitte fügen Sie eine auf der Optionsseite ein.",
+ "description": ""
+ },
+ "ollama_empty_model": {
+ "message": "Sie haben kein Modell für die Ollama API ausgewählt. Bitte wählen Sie eines auf der Optionsseite aus.",
+ "description": ""
+ },
+ "ollama_api_connecting": {
+ "message": "Versuch, eine Verbindung zum Ollama-Lokalserver über den Host herzustellen",
+ "description": ""
+ },
+ "andModel": {
+ "message": "und Modell",
+ "description": ""
+ },
+ "error_connection_interrupted": {
+ "message": "Die Verbindung zum Server wurde unerwartet unterbrochen.",
+ "description": ""
+ },
+ "ollama_api_request_failed": {
+ "message": "Anfrage an die Ollama API fehlgeschlagen.",
+ "description": ""
+ },
+ "WaitingServerReponse": {
+ "message": "Warten auf die Serverantwort.",
+ "description": ""
+ },
+ "prefs_Ollama_Host_Info": {
+ "message": "Etwas wie",
"description": ""
}
}
\ No newline at end of file
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 09f84521..020f9da9 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Use ChatGPT to enhance you emails!",
+ "message": "Use ChatGPT or Ollama to enhance you emails!",
"description": "Description of the extension."
},
"menu_title": {
@@ -284,7 +284,7 @@
"description": ""
},
"prefs_OptionText_default_chatgpt_lang": {
- "message": "Default language for ChatGPT responses",
+ "message": "Default language for the responses",
"description": ""
},
"prefs_OptionText_reply_all": {
@@ -320,11 +320,11 @@
"description": ""
},
"prefsInfoDesc_2": {
- "message": "To use the ChatGPT API, you need an OpenAI ChatGPT API Key and must choose a model. If you fail to do so, ThunderAI will fall back to using the ChatGPT web interface.",
+ "message": "To use the ChatGPT API, you need an OpenAI ChatGPT API Key and must choose a model.",
"description": ""
},
"prefsInfoDesc_3": {
- "message": " ",
+ "message": "To use the integration with Ollama, you need to set up a local Ollama server. Once the server is running, enter its address in the designated field within the application. To ensure proper communication between the app and the Ollama server remember to set OLLAMA_ORIGINS=moz-extension://*.",
"description": ""
},
"prefsDonation_1": {
@@ -411,7 +411,7 @@
"message": "Error trying to fetch ChatGPT models",
"description": ""
},
- "ChatGPT_Models_Loading": {
+ "Loading": {
"message": "Loading...",
"description": ""
},
@@ -431,8 +431,72 @@
"message": "Using model",
"description": ""
},
- "chagtp_api_connecting": {
- "message": "Will attempt to connect to OpenAI ChatGPT using the API key provided...",
+ "chagpt_api_connecting": {
+ "message": "Attempting to connect to OpenAI ChatGPT using the API key provided",
+ "description": ""
+ },
+ "Debug": {
+ "message": "Debug",
+ "description": ""
+ },
+ "prefs_OptionText_do_debug_info": {
+ "message": "Activate the debug system",
+ "description": ""
+ },
+ "prefs_Connection_type_Ollama_API": {
+ "message": "Ollama API (Local LLM)",
+ "description": ""
+ },
+ "prefs_Ollama_Host": {
+ "message": "Host Address",
+ "description": ""
+ },
+ "Ollama_Models": {
+ "message": "Ollama Models",
+ "description": ""
+ },
+ "Ollama_Models_Fetch": {
+ "message": "Update Ollama Models list",
+ "description": ""
+ },
+ "Ollama_Models_Error_fetching": {
+ "message": "Error trying to fetch Ollama models",
+ "description": ""
+ },
+ "Ollama_Models_Error_NoModels": {
+ "message": "No models found",
+ "description": ""
+ },
+ "ollama_empty_host": {
+ "message": "You've not added an Host Address for the Ollama API. Please insert one in the options page.",
+ "description": ""
+ },
+ "ollama_empty_model": {
+ "message": "You've not choosen a model for the Ollama API. Please choose one in the options page.",
+ "description": ""
+ },
+ "ollama_api_connecting": {
+ "message": "Attempting to connect to the Ollama Local Server using the host",
+ "description": ""
+ },
+ "andModel": {
+ "message": "and model",
+ "description": ""
+ },
+ "error_connection_interrupted": {
+ "message": "The connection to the server was unexpectedly interrupted",
+ "description": ""
+ },
+ "ollama_api_request_failed": {
+ "message": "Ollama API request failed",
+ "description": ""
+ },
+ "WaitingServerReponse": {
+ "message": "Waiting for the server response",
+ "description": ""
+ },
+ "prefs_Ollama_Host_Info": {
+ "message": "Something like",
"description": ""
}
}
\ No newline at end of file
diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json
index 31b811b7..0cfdaa7b 100644
--- a/_locales/fr/messages.json
+++ b/_locales/fr/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Utilisez ChatGPT pour améliorer vos emails !",
+ "message": "Utilise ChatGPT ou Ollama pour améliorer tes e-mails !",
"description": "Description de l'extension."
},
"menu_title": {
@@ -284,7 +284,7 @@
"description": ""
},
"prefs_OptionText_default_chatgpt_lang": {
- "message": "Langue par défaut pour les réponses de ChatGPT",
+ "message": "Langue par défaut pour les réponses",
"description": ""
},
"prefs_OptionText_reply_all": {
@@ -320,11 +320,11 @@
"description": ""
},
"prefsInfoDesc_2": {
- "message": "Pour utiliser l'API ChatGPT, vous avez besoin d'une clé API OpenAI ChatGPT et devez choisir un modèle. Si vous ne le faites pas, ThunderAI utilisera l'interface web de ChatGPT par défaut.",
+ "message": "Pour utiliser l'API ChatGPT, vous avez besoin d'une clé API OpenAI ChatGPT et devez choisir un modèle.",
"description": ""
},
"prefsInfoDesc_3": {
- "message": " ",
+ "message": "Pour utiliser l'intégration avec Ollama, vous devez configurer un serveur Ollama local. Une fois que le serveur est en marche, entrez son adresse dans le champ prévu à cet effet dans l'application. Pour garantir une communication adéquate entre l'application et le serveur Ollama, n'oubliez pas de définir OLLAMA_ORIGINS=moz-extension://*.",
"description": ""
},
"prefsDonation_1": {
@@ -399,7 +399,7 @@
"message": "Clé API ChatGPT",
"description": ""
},
- "ChatGPT_Models": {
+ "ChatGPT_Models": {
"message": "Modèles ChatGPT",
"description": ""
},
@@ -411,7 +411,7 @@
"message": "Erreur lors de la récupération des modèles ChatGPT",
"description": ""
},
- "ChatGPT_Models_Loading": {
+ "Loading": {
"message": "Chargement...",
"description": ""
},
@@ -431,8 +431,72 @@
"message": "Utilisation du modèle",
"description": ""
},
- "chagtp_api_connecting": {
- "message": "Tentative de connexion à OpenAI ChatGPT en utilisant la clé API fournie...",
+ "chagpt_api_connecting": {
+ "message": "Tentative de connexion à OpenAI ChatGPT en utilisant la clé API fournie",
+ "description": ""
+ },
+ "Debug": {
+ "message": "Debug",
+ "description": ""
+ },
+ "prefs_OptionText_do_debug_info": {
+ "message": "Activer le système de débogage",
+ "description": ""
+ },
+ "prefs_Connection_type_Ollama_API": {
+ "message": "API Ollama (LLM local)",
+ "description": ""
+ },
+ "prefs_Ollama_Host": {
+ "message": "Adresse de l'hôte",
+ "description": ""
+ },
+ "Ollama_Models": {
+ "message": "Modèles Ollama",
+ "description": ""
+ },
+ "Ollama_Models_Fetch": {
+ "message": "Mettre à jour la liste des modèles Ollama",
+ "description": ""
+ },
+ "Ollama_Models_Error_fetching": {
+ "message": "Erreur lors de la tentative de récupération des modèles Ollama",
+ "description": ""
+ },
+ "Ollama_Models_Error_NoModels": {
+ "message": "Aucun modèle trouvé",
+ "description": ""
+ },
+ "ollama_empty_host": {
+ "message": "Vous n'avez pas ajouté d'adresse d'hôte pour l'API Ollama. Veuillez en insérer une sur la page des options.",
+ "description": ""
+ },
+ "ollama_empty_model": {
+ "message": "Vous n'avez pas choisi de modèle pour l'API Ollama. Veuillez en choisir un sur la page des options.",
+ "description": ""
+ },
+ "ollama_api_connecting": {
+ "message": "Tentative de connexion au serveur local Ollama en utilisant l'hôte",
+ "description": ""
+ },
+ "andModel": {
+ "message": "et le modèle",
+ "description": ""
+ },
+ "error_connection_interrupted": {
+ "message": "La connexion au serveur a été interrompue de manière inattendue",
+ "description": ""
+ },
+ "ollama_api_request_failed": {
+ "message": "La demande d'API Ollama a échoué",
+ "description": ""
+ },
+ "WaitingServerReponse": {
+ "message": "En attente de la réponse du serveur",
+ "description": ""
+ },
+ "prefs_Ollama_Host_Info": {
+ "message": "Quelque chose comme",
"description": ""
}
}
\ No newline at end of file
diff --git a/_locales/it/messages.json b/_locales/it/messages.json
index c1c362b4..66ae3769 100644
--- a/_locales/it/messages.json
+++ b/_locales/it/messages.json
@@ -1,6 +1,6 @@
{
"extensionDescription": {
- "message": "Usa ChatGPT per migliorare le tue email!",
+ "message": "Usa ChatGPT o Ollama per migliorare le tue email!",
"description": "Description of the extension."
},
"menu_title": {
@@ -284,7 +284,7 @@
"description": ""
},
"prefs_OptionText_default_chatgpt_lang": {
- "message": "Lingua predefinita per le risposte di ChatGPT",
+ "message": "Lingua predefinita per le risposte",
"description": ""
},
"prefs_OptionText_reply_all": {
@@ -320,11 +320,11 @@
"description": ""
},
"prefsInfoDesc_2": {
- "message": "Per utilizzare l'API di ChatGPT, è necessaria una OpenAI ChatGPT API Key e devi scegliere un modello. Se non lo fai, ThunderAI utilizzerà l'interfaccia web di ChatGPT.",
+ "message": "Per utilizzare l'API di ChatGPT, è necessaria una OpenAI ChatGPT API Key e devi scegliere un modello.",
"description": ""
},
"prefsInfoDesc_3": {
- "message": " ",
+ "message": "Per utilizzare l'integrazione con Ollama, è necessario configurare un server Ollama locale. Una volta che il server è attivo, inserisci il suo indirizzo nel campo designato all'interno dell'applicazione. Per garantire una corretta comunicazione tra l'app e il server Ollama, ricorda di impostare OLLAMA_ORIGINS=moz-extension://*.",
"description": ""
},
"prefsDonation_1": {
@@ -384,8 +384,8 @@
"description": ""
},
"prefs_Connection_type": {
- "message": "Tipo di connessione",
- "description": ""
+ "message": "Tipo di connessione",
+ "description": ""
},
"prefs_Connection_type_ChatGTP_Web": {
"message": "Interfaccia Web ChatGTP",
@@ -399,7 +399,7 @@
"message": "Chiave API ChatGPT",
"description": ""
},
- "ChatGPT_Models": {
+ "ChatGPT_Models": {
"message": "Modelli ChatGPT",
"description": ""
},
@@ -408,10 +408,10 @@
"description": ""
},
"ChatGPT_Models_Error_fetching": {
- "message": "Errore durante il recupero dei modelli di ChatGPT",
- "description": ""
+ "message": "Errore durante il recupero dei modelli di ChatGPT",
+ "description": ""
},
- "ChatGPT_Models_Loading": {
+ "Loading": {
"message": "Caricamento in corso...",
"description": ""
},
@@ -431,8 +431,72 @@
"message": "Modello utilizzato",
"description": ""
},
- "chagtp_api_connecting": {
- "message": "Tentativo di connessione a OpenAI ChatGPT utilizzando la chiave API fornita...",
+ "chagpt_api_connecting": {
+ "message": "Tentativo di connessione a OpenAI ChatGPT utilizzando la chiave API fornita",
+ "description": ""
+ },
+ "Debug": {
+ "message": "Debug",
+ "description": ""
+ },
+ "prefs_OptionText_do_debug_info": {
+ "message": "Attiva il sistema di debug",
+ "description": ""
+ },
+ "prefs_Connection_type_Ollama_API": {
+ "message": "API Ollama (LLM Locale)",
+ "description": ""
+ },
+ "prefs_Ollama_Host": {
+ "message": "Indirizzo dell'host",
+ "description": ""
+ },
+ "Ollama_Models": {
+ "message": "Modelli Ollama",
+ "description": ""
+ },
+ "Ollama_Models_Fetch": {
+ "message": "Aggiorna la lista dei modelli Ollama",
+ "description": ""
+ },
+ "Ollama_Models_Error_fetching": {
+ "message": "Errore nel tentativo di recuperare i modelli Ollama",
+ "description": ""
+ },
+ "Ollama_Models_Error_NoModels": {
+ "message": "Nessun modello trovato",
+ "description": ""
+ },
+ "ollama_empty_host": {
+ "message": "Non hai aggiunto un indirizzo host per l'API Ollama. Per favore, inseriscine uno nella pagina delle opzioni.",
+ "description": ""
+ },
+ "ollama_empty_model": {
+ "message": "Non hai scelto un modello per l'API Ollama. Per favore, scegline uno nella pagina delle opzioni.",
+ "description": ""
+ },
+ "ollama_api_connecting": {
+ "message": "Tentativo di connettersi al server locale Ollama usando l'host",
+ "description": ""
+ },
+ "andModel": {
+ "message": "e il modello",
+ "description": ""
+ },
+ "error_connection_interrupted": {
+ "message": "La connessione al server è stata interrotta inaspettatamente",
+ "description": ""
+ },
+ "ollama_api_request_failed": {
+ "message": "La richiesta all'API Ollama è fallita",
+ "description": ""
+ },
+ "WaitingServerReponse": {
+ "message": "In attesa della risposta del server",
+ "description": ""
+ },
+ "prefs_Ollama_Host_Info": {
+ "message": "Qualcosa come",
"description": ""
}
}
\ No newline at end of file
diff --git a/api_webchat/controller.js b/api_webchat/controller.js
index ad07b97c..1fdd237f 100644
--- a/api_webchat/controller.js
+++ b/api_webchat/controller.js
@@ -20,11 +20,28 @@
* The original code has been released under the Apache License, Version 2.0.
*/
+// Get the LLM to be used
+const urlParams = new URLSearchParams(window.location.search);
+const llm = urlParams.get('llm');
+const call_id = urlParams.get('call_id');
+//console.log(">>>>>>>>>>> llm: " + llm);
// The controller wires up all the components and workers together,
// managing the dependencies. A kind of "DI" class.
-const worker = new Worker('model-worker.js', { type: 'module' });
+let worker = null;
+
+switch (llm) {
+ case "chatgpt_api":
+ browser.runtime.sendMessage({command: "openai_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
+ worker = new Worker('model-worker-openai.js', { type: 'module' });
+ break;
+ case "ollama_api": {
+ browser.runtime.sendMessage({command: "ollama_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
+ worker = new Worker('model-worker-ollama.js', { type: 'module' });
+ break;
+ }
+}
const messagesArea = document.querySelector('messages-area');
messagesArea.init(worker);
@@ -54,15 +71,31 @@ let promptData = null;
// }
// ============================== TESTING - END
-const params = new URLSearchParams(window.location.search);
-let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: ''});
-// const openaiApiKey = params.get('openapi-key');
-//console.log(">>>>>>>>>>> chatgpt_api_key: " + prefs_api_key.chatgpt_api_key);
-worker.postMessage({ type: 'init', chatgpt_api_key: prefs_api.chatgpt_api_key, chatgpt_model: prefs_api.chatgpt_model});
-messagesArea.appendUserMessage(browser.i18n.getMessage("chagtp_api_connecting"), "info");
+switch (llm) {
+ case "chatgpt_api":
+ let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: ''});
+ //console.log(">>>>>>>>>>> chatgpt_api_key: " + prefs_api_key.chatgpt_api_key);
+ messageInput.setModel(prefs_api.chatgpt_model);
+ messagesArea.setLLMName("ChatGPT");
+ worker.postMessage({ type: 'init', chatgpt_api_key: prefs_api.chatgpt_api_key, chatgpt_model: prefs_api.chatgpt_model});
+ messagesArea.appendUserMessage(browser.i18n.getMessage("chagpt_api_connecting") + " " +browser.i18n.getMessage("AndModel") + " " + prefs_api.chatgpt_model + " ...", "info");
+ break;
+ case "ollama_api": {
+ let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: ''});
+ let i18nStrings = {};
+ i18nStrings["ollama_api_request_failed"] = browser.i18n.getMessage('ollama_api_request_failed');
+ i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
+ //console.log(">>>>>>>>>>> ollama_host: " + prefs_api_key.ollama_host);
+ messageInput.setModel(prefs_api.ollama_model);
+ messagesArea.setLLMName("Ollama Local");
+ worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, i18nStrings: i18nStrings});
+ messagesArea.appendUserMessage(browser.i18n.getMessage("ollama_api_connecting") + " " + prefs_api.ollama_host + " " +browser.i18n.getMessage("AndModel") + " " + prefs_api.ollama_model + " ...", "info");
+ break;
+ }
+}
+
// Event listeners for worker messages
-// TODO I'm sure there's a better way to do this
worker.onmessage = function(event) {
const { type, payload } = event.data;
switch (type) {
@@ -71,6 +104,7 @@ worker.onmessage = function(event) {
break;
case 'newToken':
messagesArea.handleNewToken(payload.token);
+ messageInput.setStatusMessage('Receiving data...');
break;
case 'tokensDone':
messagesArea.handleTokensDone(promptData);
@@ -78,6 +112,7 @@ worker.onmessage = function(event) {
break;
case 'error':
messagesArea.appendBotMessage(payload,'error');
+ messageInput.enableInput();
break;
default:
console.error('[ThunderAI] Unknown event type from API worker:', type);
@@ -87,16 +122,22 @@ worker.onmessage = function(event) {
// handling commands from the backgound page
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
//console.log(">>>>>>>>>>>>> controller.js onMessage: " + JSON.stringify(message));
- if (message.command === "chatgpt_send") {
- //send the received prompt to the chatgpt api
- if(message.do_custom_text=="1") {
- let userInput = prompt(browser.i18n.getMessage("chatgpt_win_custom_text"));
- if(userInput !== null) {
- message.prompt += " " + userInput;
+ switch (message.command) {
+ case "api_send":
+ //send the received prompt to the llm api
+ if(message.do_custom_text=="1") {
+ let userInput = prompt(browser.i18n.getMessage("chatgpt_win_custom_text"));
+ if(userInput !== null) {
+ message.prompt += " " + userInput;
+ }
}
- }
- promptData = message;
- messageInput._setMessageInputValue(message.prompt);
- messageInput._handleNewChatMessage();
+ promptData = message;
+ messageInput._setMessageInputValue(message.prompt);
+ messageInput._handleNewChatMessage();
+ break;
+ case "api_error":
+ messagesArea.appendBotMessage(message.error,'error');
+ messageInput.enableInput();
+ break;
}
});
\ No newline at end of file
diff --git a/api_webchat/index.html b/api_webchat/index.html
index cdad673c..7989868d 100644
--- a/api_webchat/index.html
+++ b/api_webchat/index.html
@@ -1,3 +1,5 @@
+
+
@@ -7,7 +9,7 @@
[Ollama API] It's now possible to use a local LMM using Ollama [#79].
+
[ChatGPT API][Ollama API] Added a "Stop" button to stop the current elaboration [#113].
+
[ChatGPT API] If the configuration is missing the model or the API key, an error message is now provided, and there is no more fallback to the ChatGPT web interface [#111].
+
[ChatGPT API][Ollama API] Improved chat colors scheme for darkmode.
+
[ChatGPT API][Ollama API] Added a status message to give feedback to the user about the current operation [#119].
+
Improved the internal messaging system between the background script and the chat windows [#117].
+
...
Version 2.0.7 - 21/08/2024
[ChatGPT Web] Fixed an issue with automatically sending the prompt.