From 89dd63a0ee9a040d25fbc917bf177f6d55139fce Mon Sep 17 00:00:00 2001 From: pangshikang Date: Sat, 12 Oct 2024 16:03:29 +0800 Subject: [PATCH 1/2] fix: Refactor openAICompatible initialization in sendLLMMessage.ts --- extensions/void/src/common/sendLLMMessage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/void/src/common/sendLLMMessage.ts b/extensions/void/src/common/sendLLMMessage.ts index 7ab49ab5..6d083979 100644 --- a/extensions/void/src/common/sendLLMMessage.ts +++ b/extensions/void/src/common/sendLLMMessage.ts @@ -119,13 +119,14 @@ const sendOpenAIMsg: SendLLMMessageFnTypeInternal = ({ messages, onText, onFinal didAbort = true; }; - const openai = new OpenAI({ apiKey: apiConfig.openAI.apikey, dangerouslyAllowBrowser: true }); + let openai = new OpenAI({ apiKey: apiConfig.openAI.apikey, dangerouslyAllowBrowser: true }); let options: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming if (apiConfig.whichApi === 'openAI') { options = { model: apiConfig.openAI.model, messages: messages, stream: true, } } else if (apiConfig.whichApi === 'openAICompatible') { + openai = new OpenAI({ baseURL:apiConfig.openAICompatible.endpoint,apiKey: apiConfig.openAICompatible.apikey, dangerouslyAllowBrowser: true }); options = { model: apiConfig.openAICompatible.model, messages: messages, stream: true, } } else { From 767c45080f057669c01e41ff4c43fdcbc63d4c3f Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 14 Oct 2024 16:44:57 -0700 Subject: [PATCH 2/2] update openai --- extensions/void/src/common/sendLLMMessage.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extensions/void/src/common/sendLLMMessage.ts b/extensions/void/src/common/sendLLMMessage.ts index 6d083979..39c38fee 100644 --- a/extensions/void/src/common/sendLLMMessage.ts +++ b/extensions/void/src/common/sendLLMMessage.ts @@ -119,14 +119,15 @@ const sendOpenAIMsg: SendLLMMessageFnTypeInternal = ({ messages, onText, onFinal didAbort = true; }; - let openai = new OpenAI({ apiKey: apiConfig.openAI.apikey, dangerouslyAllowBrowser: true }); - + let openai: OpenAI let options: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming + if (apiConfig.whichApi === 'openAI') { + openai = new OpenAI({ baseURL: apiConfig.openAICompatible.endpoint, apiKey: apiConfig.openAICompatible.apikey, dangerouslyAllowBrowser: true }) options = { model: apiConfig.openAI.model, messages: messages, stream: true, } } else if (apiConfig.whichApi === 'openAICompatible') { - openai = new OpenAI({ baseURL:apiConfig.openAICompatible.endpoint,apiKey: apiConfig.openAICompatible.apikey, dangerouslyAllowBrowser: true }); + openai = new OpenAI({ apiKey: apiConfig.openAI.apikey, dangerouslyAllowBrowser: true }); options = { model: apiConfig.openAICompatible.model, messages: messages, stream: true, } } else {