correctly showing error messages from the chatgpt api. fixes #191
This commit is contained in:
parent
8a96dccc19
commit
4d49d080cd
2 changed files with 6 additions and 1 deletions
|
|
@ -64,9 +64,12 @@ messageInput.setMessagesArea(messagesArea);
|
|||
switch (llm) {
|
||||
case "chatgpt_api":
|
||||
let prefs_api = await browser.storage.sync.get({chatgpt_api_key: '', chatgpt_model: '', do_debug: false});
|
||||
let i18nStrings = {};
|
||||
i18nStrings["chatgpt_api_request_failed"] = browser.i18n.getMessage('chatgpt_api_request_failed');
|
||||
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
|
||||
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, 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, i18nStrings: i18nStrings});
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ let chatgpt_api_key = null;
|
|||
let chatgpt_model = '';
|
||||
let openai = null;
|
||||
let stopStreaming = false;
|
||||
let i18nStrings = null;
|
||||
let do_debug = false;
|
||||
let taLog = null;
|
||||
|
||||
|
|
@ -39,6 +40,7 @@ self.onmessage = async function(event) {
|
|||
chatgpt_model = event.data.chatgpt_model;
|
||||
openai = new OpenAI(chatgpt_api_key, chatgpt_model, true);
|
||||
do_debug = event.data.do_debug;
|
||||
i18nStrings = event.data.i18nStrings;
|
||||
taLog = new taLogger('model-worker-openai', do_debug);
|
||||
} else if (event.data.type === 'chatMessage') {
|
||||
conversationHistory.push({ role: 'user', content: event.data.message });
|
||||
|
|
|
|||
Loading…
Reference in a new issue