From bc9679335d7bf1755ac3671a56b1c3593495d15c Mon Sep 17 00:00:00 2001 From: Hk-Gosuto Date: Fri, 7 Jun 2024 23:29:24 +0800 Subject: [PATCH] fix: USE_OPENAI_ENDPOINT_FOR_ALL_MODELS --- app/client/api.ts | 2 +- app/components/exporter.tsx | 8 +++++++- app/store/chat.ts | 5 ++--- app/utils.ts | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/client/api.ts b/app/client/api.ts index cf3edb575..9d14d31d2 100644 --- a/app/client/api.ts +++ b/app/client/api.ts @@ -218,7 +218,7 @@ export function getHeaders(ignoreHeaders?: boolean) { const modelConfig = useChatStore.getState().currentSession().mask.modelConfig; const isGoogle = modelConfig.model.startsWith("gemini") && - !accessStore.useOpenAIEndpointForAllModels(); + !accessStore.isUseOpenAIEndpointForAllModels; if (!ignoreHeaders && !isGoogle) { headers = { "Content-Type": "application/json", diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx index 940322a73..e4f6ccc1d 100644 --- a/app/components/exporter.tsx +++ b/app/components/exporter.tsx @@ -1,5 +1,11 @@ /* eslint-disable @next/next/no-img-element */ -import { ChatMessage, ModelType, useAppConfig, useChatStore } from "../store"; +import { + ChatMessage, + ModelType, + useAccessStore, + useAppConfig, + useChatStore, +} from "../store"; import Locale from "../locales"; import styles from "./exporter.module.scss"; import { diff --git a/app/store/chat.ts b/app/store/chat.ts index aa8193d43..ae3b596c8 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -392,8 +392,7 @@ export const useChatStore = createPersistStore( session.messages.push(botMessage); }); const isEnableRAG = attachFiles && attachFiles?.length > 0; - var api: ClientApi; - api = new ClientApi(ModelProvider.GPT); + var api: ClientApi = getClientApi(modelConfig.model); if ( config.pluginConfig.enable && session.mask.usePlugins && @@ -660,7 +659,7 @@ export const useChatStore = createPersistStore( const session = get().currentSession(); const modelConfig = session.mask.modelConfig; - var api: ClientApi = getClientApi(config.modelConfig.model); + var api: ClientApi = getClientApi(modelConfig.model); // remove error messages if any const messages = session.messages; diff --git a/app/utils.ts b/app/utils.ts index 6cac9cfbd..4e2835690 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -284,8 +284,9 @@ export function isSupportRAGModel(modelName: string) { export function getClientApi(modelName: string): ClientApi { const accessStore = useAccessStore.getState(); - if (accessStore.useOpenAIEndpointForAllModels()) + if (accessStore.isUseOpenAIEndpointForAllModels) { return new ClientApi(ModelProvider.GPT); + } var api: ClientApi; if (modelName.startsWith("gemini")) { api = new ClientApi(ModelProvider.GeminiPro);