the controller is using the new model worker. see #126

This commit is contained in:
mic 2024-09-12 21:44:22 +02:00
parent be550e9f7c
commit f34c3ef788
2 changed files with 20 additions and 2 deletions

View file

@ -530,5 +530,9 @@
"OpenAIComp_api_connecting": {
"message": "Attempting to connect to the OpenAI Compatible API Local Server using the host",
"description": ""
},
"OpenAIComp_api_request_failed": {
"message": "OpenAI Comp API request failed",
"description": ""
}
}

View file

@ -36,11 +36,14 @@ switch (llm) {
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": {
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;
}
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' });
break;
}
const messagesArea = document.querySelector('messages-area');
@ -92,6 +95,17 @@ switch (llm) {
messagesArea.appendUserMessage(browser.i18n.getMessage("ollama_api_connecting") + " \"" + prefs_api.ollama_host + "\" " +browser.i18n.getMessage("AndModel") + " \"" + prefs_api.ollama_model + "\"...", "info");
break;
}
case "openai_comp_api": {
let prefs_api = await browser.storage.sync.get({openai_comp_host: '', openai_comp_model: '', openai_chat_name: ''});
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_chat_name);
worker.postMessage({ type: 'init', ollama_host: prefs_api.openai_comp_host, openai_comp_model: prefs_api.openai_comp_model, 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");
break;
}
}