ported new chat window messaging code from branch issue_143. see #143
This commit is contained in:
parent
4f80aa888b
commit
66ba79833a
2 changed files with 89 additions and 100 deletions
|
|
@ -25,6 +25,14 @@ const urlParams = new URLSearchParams(window.location.search);
|
||||||
const llm = urlParams.get('llm');
|
const llm = urlParams.get('llm');
|
||||||
const call_id = urlParams.get('call_id');
|
const call_id = urlParams.get('call_id');
|
||||||
|
|
||||||
|
// Data received from the user
|
||||||
|
let promptData = null;
|
||||||
|
|
||||||
|
const messageInput = document.querySelector('message-input');
|
||||||
|
const messagesArea = document.querySelector('messages-area');
|
||||||
|
|
||||||
|
//console.log(">>>>>>>>>> controller.js DOMContentLoaded");
|
||||||
|
|
||||||
// console.log(">>>>>>>>>>> llm: " + llm);
|
// console.log(">>>>>>>>>>> llm: " + llm);
|
||||||
// console.log(">>>>>>>>>>> call_id: " + call_id);
|
// console.log(">>>>>>>>>>> call_id: " + call_id);
|
||||||
|
|
||||||
|
|
@ -34,65 +42,40 @@ let worker = null;
|
||||||
|
|
||||||
switch (llm) {
|
switch (llm) {
|
||||||
case "chatgpt_api":
|
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' });
|
worker = new Worker('model-worker-openai.js', { type: 'module' });
|
||||||
break;
|
break;
|
||||||
case "ollama_api":
|
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' });
|
worker = new Worker('model-worker-ollama.js', { type: 'module' });
|
||||||
break;
|
break;
|
||||||
case "openai_comp_api":
|
case "openai_comp_api":
|
||||||
browser.runtime.sendMessage({command: "openai_comp_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
|
||||||
worker = new Worker('model-worker-openai_comp.js', { type: 'module' });
|
worker = new Worker('model-worker-openai_comp.js', { type: 'module' });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const messagesArea = document.querySelector('messages-area');
|
|
||||||
messagesArea.init(worker);
|
messagesArea.init(worker);
|
||||||
|
|
||||||
// Initialize the messageInput component and pass the worker to it
|
// Initialize the messageInput component and pass the worker to it
|
||||||
const messageInput = document.querySelector('message-input');
|
|
||||||
messageInput.init(worker);
|
messageInput.init(worker);
|
||||||
messageInput.setMessagesArea(messagesArea);
|
messageInput.setMessagesArea(messagesArea);
|
||||||
|
|
||||||
// Data received from the user
|
|
||||||
let promptData = null;
|
|
||||||
|
|
||||||
// ============================== TESTING
|
|
||||||
// let browser = {
|
|
||||||
// i18n: {
|
|
||||||
// getMessage: async function(key) {
|
|
||||||
// return key;
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// storage: {
|
|
||||||
// sync: {
|
|
||||||
// get: async function(key) {
|
|
||||||
// return 'apitest';
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ============================== TESTING - END
|
|
||||||
|
|
||||||
switch (llm) {
|
switch (llm) {
|
||||||
case "chatgpt_api":
|
case "chatgpt_api":
|
||||||
let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: '', do_debug: false});
|
let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: '', do_debug: false});
|
||||||
//console.log(">>>>>>>>>>> chatgpt_api_key: " + prefs_api_key.chatgpt_api_key);
|
|
||||||
messageInput.setModel(prefs_api.chatgpt_model);
|
messageInput.setModel(prefs_api.chatgpt_model);
|
||||||
messagesArea.setLLMName("ChatGPT");
|
messagesArea.setLLMName("ChatGPT");
|
||||||
worker.postMessage({ type: 'init', chatgpt_api_key: prefs_api.chatgpt_api_key, chatgpt_model: prefs_api.chatgpt_model, do_debug: prefs_api.do_debug});
|
worker.postMessage({ type: 'init', chatgpt_api_key: prefs_api.chatgpt_api_key, chatgpt_model: prefs_api.chatgpt_model, do_debug: prefs_api.do_debug});
|
||||||
messagesArea.appendUserMessage(browser.i18n.getMessage("chagpt_api_connecting") + " " +browser.i18n.getMessage("AndModel") + " \"" + prefs_api.chatgpt_model + "\"...", "info");
|
messagesArea.appendUserMessage(browser.i18n.getMessage("chagpt_api_connecting") + " " +browser.i18n.getMessage("AndModel") + " \"" + prefs_api.chatgpt_model + "\"...", "info");
|
||||||
|
browser.runtime.sendMessage({command: "openai_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||||
break;
|
break;
|
||||||
case "ollama_api": {
|
case "ollama_api": {
|
||||||
let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: '', do_debug: false});
|
let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: '', do_debug: false});
|
||||||
let i18nStrings = {};
|
let i18nStrings = {};
|
||||||
i18nStrings["ollama_api_request_failed"] = browser.i18n.getMessage('ollama_api_request_failed');
|
i18nStrings["ollama_api_request_failed"] = browser.i18n.getMessage('ollama_api_request_failed');
|
||||||
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
|
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);
|
messageInput.setModel(prefs_api.ollama_model);
|
||||||
messagesArea.setLLMName("Ollama Local");
|
messagesArea.setLLMName("Ollama Local");
|
||||||
worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||||
|
browser.runtime.sendMessage({command: "ollama_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||||
messagesArea.appendUserMessage(browser.i18n.getMessage("ollama_api_connecting") + " \"" + prefs_api.ollama_host + "\" " +browser.i18n.getMessage("AndModel") + " \"" + prefs_api.ollama_model + "\"...", "info");
|
messagesArea.appendUserMessage(browser.i18n.getMessage("ollama_api_connecting") + " \"" + prefs_api.ollama_host + "\" " +browser.i18n.getMessage("AndModel") + " \"" + prefs_api.ollama_model + "\"...", "info");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -105,6 +88,7 @@ switch (llm) {
|
||||||
messagesArea.setLLMName(prefs_api.openai_comp_chat_name);
|
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, 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");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +120,6 @@ worker.onmessage = function(event) {
|
||||||
|
|
||||||
// handling commands from the backgound page
|
// handling commands from the backgound page
|
||||||
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||||
//console.log(">>>>>>>>>>>>> controller.js onMessage: " + JSON.stringify(message));
|
|
||||||
switch (message.command) {
|
switch (message.command) {
|
||||||
case "api_send":
|
case "api_send":
|
||||||
//send the received prompt to the llm api
|
//send the received prompt to the llm api
|
||||||
|
|
|
||||||
|
|
@ -239,6 +239,8 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mailMessage = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
||||||
|
|
||||||
switch(prefs.connection_type){
|
switch(prefs.connection_type){
|
||||||
case 'chatgpt_web':
|
case 'chatgpt_web':
|
||||||
// We are using the ChatGPT web interface
|
// We are using the ChatGPT web interface
|
||||||
|
|
@ -256,18 +258,12 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
win_options.width = prefs.chatgpt_win_width,
|
win_options.width = prefs.chatgpt_win_width,
|
||||||
win_options.height = prefs.chatgpt_win_height
|
win_options.height = prefs.chatgpt_win_height
|
||||||
}
|
}
|
||||||
let newWindow = await browser.windows.create(win_options);
|
|
||||||
|
|
||||||
let newWindowId = newWindow.id;
|
|
||||||
let createdTab = newWindow.tabs[0];
|
|
||||||
|
|
||||||
const listener = async (message, sender, sendResponse) => {
|
|
||||||
|
|
||||||
if (message.command === "chatgpt_web_ready_" + rand_call_id) {
|
|
||||||
|
|
||||||
|
const listener = (message, sender, sendResponse) => {
|
||||||
|
async function handleChatGptWeb(createdTab) {
|
||||||
taLog.log("[ThunderAI] ChatGPT web interface script started...");
|
taLog.log("[ThunderAI] ChatGPT web interface script started...");
|
||||||
|
|
||||||
let pre_script = `let mztaWinId = `+ newWindowId +`;
|
let pre_script = `let mztaWinId = `+ createdTab.windowId +`;
|
||||||
let mztaStatusPageDesc="`+ browser.i18n.getMessage("prefs_status_page") +`";
|
let mztaStatusPageDesc="`+ browser.i18n.getMessage("prefs_status_page") +`";
|
||||||
let mztaForceCompletionDesc="`+ browser.i18n.getMessage("chatgpt_force_completion") +`";
|
let mztaForceCompletionDesc="`+ browser.i18n.getMessage("chatgpt_force_completion") +`";
|
||||||
let mztaForceCompletionTitle="`+ browser.i18n.getMessage("chatgpt_force_completion_title") +`";
|
let mztaForceCompletionTitle="`+ browser.i18n.getMessage("chatgpt_force_completion_title") +`";
|
||||||
|
|
@ -280,7 +276,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
taLog.log("Waiting 1 sec done");
|
taLog.log("Waiting 1 sec done");
|
||||||
|
|
||||||
await browser.tabs.executeScript(createdTab.id, { code: pre_script + mzta_script, matchAboutBlank: false });
|
await browser.tabs.executeScript(createdTab.id, { code: pre_script + mzta_script, matchAboutBlank: false });
|
||||||
let mailMessage = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
// let mailMessage = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
||||||
let mailMessageId = -1;
|
let mailMessageId = -1;
|
||||||
if(mailMessage) mailMessageId = mailMessage.id;
|
if(mailMessage) mailMessageId = mailMessage.id;
|
||||||
browser.tabs.sendMessage(createdTab.id, { command: "chatgpt_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId});
|
browser.tabs.sendMessage(createdTab.id, { command: "chatgpt_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId});
|
||||||
|
|
@ -288,9 +284,15 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
taLog.log("[ThunderAI] ChatGPT Web script injected successfully");
|
taLog.log("[ThunderAI] ChatGPT Web script injected successfully");
|
||||||
browser.runtime.onMessage.removeListener(listener);
|
browser.runtime.onMessage.removeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message.command === "chatgpt_web_ready_" + rand_call_id) {
|
||||||
|
return handleChatGptWeb(sender.tab)
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener(listener);
|
browser.runtime.onMessage.addListener(listener);
|
||||||
|
await browser.windows.create(win_options);
|
||||||
break; // chatgpt_web - END
|
break; // chatgpt_web - END
|
||||||
|
|
||||||
case 'chatgpt_api':
|
case 'chatgpt_api':
|
||||||
|
|
@ -298,6 +300,35 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
|
|
||||||
let rand_call_id2 = '_openai_' + generateCallID();
|
let rand_call_id2 = '_openai_' + generateCallID();
|
||||||
|
|
||||||
|
const listener2 = (message, sender, sendResponse) => {
|
||||||
|
|
||||||
|
function handleChatGptApi(createdTab) {
|
||||||
|
let mailMessageId2 = -1;
|
||||||
|
if(mailMessage) mailMessageId2 = mailMessage.id;
|
||||||
|
|
||||||
|
// check if the config is present, or give a message error
|
||||||
|
if (prefs.chatgpt_api_key == '') {
|
||||||
|
browser.tabs.sendMessage(createdTab.id, { command: "api_error", error: browser.i18n.getMessage('chatgpt_empty_apikey')});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (prefs.chatgpt_model == '') {
|
||||||
|
browser.tabs.sendMessage(createdTab.id, { command: "api_error", error: browser.i18n.getMessage('chatgpt_empty_model')});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//console.log(">>>>>>>>>> sender: " + JSON.stringify(sender));
|
||||||
|
browser.tabs.sendMessage(createdTab.id, { command: "api_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId2, do_custom_text: do_custom_text});
|
||||||
|
taLog.log('[OpenAI ChatGPT] Connection succeded!');
|
||||||
|
browser.runtime.onMessage.removeListener(listener2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.command === "openai_api_ready_"+rand_call_id2) {
|
||||||
|
return handleChatGptApi(sender.tab);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
browser.runtime.onMessage.addListener(listener2);
|
||||||
|
|
||||||
let win_options2 = {
|
let win_options2 = {
|
||||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id2),
|
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id2),
|
||||||
type: "popup",
|
type: "popup",
|
||||||
|
|
@ -312,35 +343,6 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
|
|
||||||
await browser.windows.create(win_options2);
|
await browser.windows.create(win_options2);
|
||||||
|
|
||||||
const listener2 = async (message, sender, sendResponse) => {
|
|
||||||
|
|
||||||
if (message.command === "openai_api_ready_"+rand_call_id2) {
|
|
||||||
|
|
||||||
let newWindow2 = await browser.windows.get(message.window_id, {populate: true});
|
|
||||||
let createdTab2 = newWindow2.tabs[0];
|
|
||||||
|
|
||||||
let mailMessage = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
|
||||||
let mailMessageId2 = -1;
|
|
||||||
if(mailMessage) mailMessageId2 = mailMessage.id;
|
|
||||||
|
|
||||||
// check if the config is present, or give a message error
|
|
||||||
if (prefs.chatgpt_api_key == '') {
|
|
||||||
browser.tabs.sendMessage(createdTab2.id, { command: "api_error", error: browser.i18n.getMessage('chatgpt_empty_apikey')});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (prefs.chatgpt_model == '') {
|
|
||||||
browser.tabs.sendMessage(createdTab2.id, { command: "api_error", error: browser.i18n.getMessage('chatgpt_empty_model')});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
browser.tabs.sendMessage(createdTab2.id, { command: "api_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId2, do_custom_text: do_custom_text});
|
|
||||||
taLog.log('[OpenAI ChatGPT] Connection succeded!');
|
|
||||||
browser.runtime.onMessage.removeListener(listener2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener(listener2);
|
|
||||||
|
|
||||||
break; // chatgpt_api - END
|
break; // chatgpt_api - END
|
||||||
|
|
||||||
case 'ollama_api':
|
case 'ollama_api':
|
||||||
|
|
@ -350,6 +352,41 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
|
|
||||||
let rand_call_id3 = '_ollama_' + generateCallID();
|
let rand_call_id3 = '_ollama_' + generateCallID();
|
||||||
|
|
||||||
|
const listener3 = async (message, sender, sendResponse) => {
|
||||||
|
|
||||||
|
function handleOllamaApi(createdTab3) {
|
||||||
|
taLog.log("Ollama API window ready.");
|
||||||
|
taLog.log("message.window_id: " + message.window_id)
|
||||||
|
taLog.log(">>>>>> createdTab3.id: " + createdTab3.id)
|
||||||
|
// let mailMessage3 = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
||||||
|
let mailMessageId3 = -1;
|
||||||
|
if(mailMessage) mailMessageId3 = mailMessage.id;
|
||||||
|
taLog.log(">>>>>> mailMessageId3: " + mailMessageId3)
|
||||||
|
|
||||||
|
// check if the config is present, or give a message error
|
||||||
|
if (prefs.ollama_host == '') {
|
||||||
|
browser.tabs.sendMessage(createdTab3.id, { command: "api_error", error: browser.i18n.getMessage('ollama_empty_host')});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (prefs.ollama_model == '') {
|
||||||
|
browser.tabs.sendMessage(createdTab3.id, { command: "api_error", error: browser.i18n.getMessage('ollama_empty_model')});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(">>>>>> [ThunderAI] Ollama API about to send message to createdTab3.id: " + createdTab3.id);
|
||||||
|
browser.tabs.sendMessage(createdTab3.id, { command: "api_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId3, do_custom_text: do_custom_text});
|
||||||
|
taLog.log('[Ollama API] Connection succeded!');
|
||||||
|
browser.runtime.onMessage.removeListener(listener3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.command === "ollama_api_ready_"+rand_call_id3) {
|
||||||
|
return handleOllamaApi(sender.tab);
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
browser.runtime.onMessage.addListener(listener3);
|
||||||
|
|
||||||
let win_options3 = {
|
let win_options3 = {
|
||||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id3),
|
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id3),
|
||||||
type: "popup",
|
type: "popup",
|
||||||
|
|
@ -364,37 +401,6 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
|
|
||||||
await browser.windows.create(win_options3);
|
await browser.windows.create(win_options3);
|
||||||
|
|
||||||
const listener3 = async (message, sender, sendResponse) => {
|
|
||||||
|
|
||||||
if (message.command === "ollama_api_ready_"+rand_call_id3) {
|
|
||||||
taLog.log("Ollama API window ready.");
|
|
||||||
taLog.log("message.window_id: " + message.window_id)
|
|
||||||
let newWindow3 = await browser.windows.get(message.window_id, {populate: true});
|
|
||||||
let createdTab3 = newWindow3.tabs[0];
|
|
||||||
taLog.log(">>>>>> createdTab3.id: " + createdTab3.id)
|
|
||||||
let mailMessage3 = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
|
||||||
let mailMessageId3 = -1;
|
|
||||||
if(mailMessage3) mailMessageId3 = mailMessage3.id;
|
|
||||||
taLog.log(">>>>>> mailMessageId3: " + mailMessageId3)
|
|
||||||
|
|
||||||
// check if the config is present, or give a message error
|
|
||||||
if (prefs.ollama_host == '') {
|
|
||||||
await browser.tabs.sendMessage(createdTab3.id, { command: "api_error", error: browser.i18n.getMessage('ollama_empty_host')});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (prefs.ollama_model == '') {
|
|
||||||
await browser.tabs.sendMessage(createdTab3.id, { command: "api_error", error: browser.i18n.getMessage('ollama_empty_model')});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await browser.tabs.sendMessage(createdTab3.id, { command: "api_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId3, do_custom_text: do_custom_text});
|
|
||||||
taLog.log('[Ollama API] Connection succeded!');
|
|
||||||
browser.runtime.onMessage.removeListener(listener3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener(listener3);
|
|
||||||
|
|
||||||
break; // ollama_api - END
|
break; // ollama_api - END
|
||||||
|
|
||||||
case 'openai_comp_api':
|
case 'openai_comp_api':
|
||||||
|
|
@ -422,7 +428,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
let newWindow4 = await browser.windows.get(message.window_id, {populate: true});
|
let newWindow4 = await browser.windows.get(message.window_id, {populate: true});
|
||||||
let createdTab4 = newWindow4.tabs[0];
|
let createdTab4 = newWindow4.tabs[0];
|
||||||
|
|
||||||
let mailMessage = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
// let mailMessage = await browser.messageDisplay.getDisplayedMessage(curr_tabId);
|
||||||
let mailMessageId4 = -1;
|
let mailMessageId4 = -1;
|
||||||
if(mailMessage) mailMessageId4 = mailMessage.id;
|
if(mailMessage) mailMessageId4 = mailMessage.id;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue