ソースを参照

hotfix: custom comfig for Gemini api. #4944

lloydzhou 1 年間 前
コミット
9b97dca601
3 ファイル変更12 行追加14 行削除
  1. 6 9
      app/client/platforms/google.ts
  2. 1 0
      app/constant.ts
  3. 5 5
      app/store/access.ts

+ 6 - 9
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}`;
       }

+ 1 - 0
app/constant.ts

@@ -35,6 +35,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",

+ 5 - 5
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,12 +33,12 @@ const DEFAULT_ACCESS_STATE = {
   openaiApiKey: "",
 
   // azure
-  azureUrl: DEFAULT_AZURE_URL,
+  azureUrl: "",
   azureApiKey: "",
   azureApiVersion: "2023-08-01-preview",
 
   // google ai studio
-  googleUrl: "",
+  googleUrl: DEFAULT_GOOGLE_URL,
   googleApiKey: "",
   googleApiVersion: "v1",