From c3eaa4762d10dbdb4b34262b6dadb709572c32aa Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Fri, 12 Jul 2024 21:27:30 +0800 Subject: [PATCH] hotfix: custom comfig for Gemini api. #4944 --- app/client/platforms/google.ts | 15 ++++++--------- app/constant.ts | 1 + app/store/access.ts | 10 +++++----- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts index 828b28a0d4d..6054c7a476e 100644 --- a/app/client/platforms/google.ts +++ b/app/client/platforms/google.ts @@ -122,16 +122,13 @@ export class GeminiProApi implements LLMApi { const controller = new AbortController(); options.onController?.(controller); try { - // let baseUrl = accessStore.googleUrl; - - if (!baseUrl) { - baseUrl = isApp - ? DEFAULT_API_HOST + - "/api/proxy/google/" + - Google.ChatPath(modelConfig.model) - : this.path(Google.ChatPath(modelConfig.model)); + if (!baseUrl && isApp) { + baseUrl = DEFAULT_API_HOST + "/api/proxy/google/"; } - + baseUrl = `${baseUrl}/${Google.ChatPath(modelConfig.model)}`.replaceAll( + "//", + "/", + ); if (isApp) { baseUrl += `?key=${accessStore.googleApiKey}`; } diff --git a/app/constant.ts b/app/constant.ts index 14ac36999e9..5cdd1fe4be3 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -36,6 +36,7 @@ export enum ApiPath { Azure = "/api/azure", OpenAI = "/api/openai", Anthropic = "/api/anthropic", + Google = "/api/google", Baidu = "/api/baidu", ByteDance = "/api/bytedance", Alibaba = "/api/alibaba", diff --git a/app/store/access.ts b/app/store/access.ts index 61d154b4bda..57a98fcdd0e 100644 --- a/app/store/access.ts +++ b/app/store/access.ts @@ -17,10 +17,10 @@ const DEFAULT_OPENAI_URL = ? DEFAULT_API_HOST + "/api/proxy/openai" : ApiPath.OpenAI; -const DEFAULT_AZURE_URL = +const DEFAULT_GOOGLE_URL = getClientConfig()?.buildMode === "export" - ? DEFAULT_API_HOST + "/api/proxy/azure/{resource_name}" - : ApiPath.Azure; + ? DEFAULT_API_HOST + "/api/proxy/google" + : ApiPath.Google; const DEFAULT_ACCESS_STATE = { accessCode: "", @@ -33,13 +33,13 @@ const DEFAULT_ACCESS_STATE = { openaiApiKey: "", // azure - azureUrl: DEFAULT_AZURE_URL, + azureUrl: "", azureApiKey: "", azureApiVersion: "2023-05-15", azureVoiceKey: "", // google ai studio - googleUrl: "", + googleUrl: DEFAULT_GOOGLE_URL, googleApiKey: "", googleApiVersion: "v1",