瀏覽代碼

Merge pull request #6010 from code-october/fix-visionModels

修复 VISION_MDOELS 在 docker 运行阶段不生效的问题
Dogtiti 11 月之前
父節點
當前提交
63c5baaa80
共有 5 個文件被更改,包括 12 次插入5 次删除
  1. 1 0
      app/api/config/route.ts
  2. 0 1
      app/config/build.ts
  3. 3 0
      app/config/server.ts
  4. 5 1
      app/store/access.ts
  5. 3 3
      app/utils.ts

+ 1 - 0
app/api/config/route.ts

@@ -14,6 +14,7 @@ const DANGER_CONFIG = {
   disableFastLink: serverConfig.disableFastLink,
   customModels: serverConfig.customModels,
   defaultModel: serverConfig.defaultModel,
+  visionModels: serverConfig.visionModels,
 };
 
 declare global {

+ 0 - 1
app/config/build.ts

@@ -40,7 +40,6 @@ export const getBuildConfig = () => {
     buildMode,
     isApp,
     template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
-    visionModels: process.env.VISION_MODELS || "",
   };
 };
 

+ 3 - 0
app/config/server.ts

@@ -23,6 +23,7 @@ declare global {
       DISABLE_FAST_LINK?: string; // disallow parse settings from url or not
       CUSTOM_MODELS?: string; // to control custom models
       DEFAULT_MODEL?: string; // to control default model in every new chat window
+      VISION_MODELS?: string; // to control vision models
 
       // stability only
       STABILITY_URL?: string;
@@ -128,6 +129,7 @@ export const getServerSideConfig = () => {
   const disableGPT4 = !!process.env.DISABLE_GPT4;
   let customModels = process.env.CUSTOM_MODELS ?? "";
   let defaultModel = process.env.DEFAULT_MODEL ?? "";
+  let visionModels = process.env.VISION_MODELS ?? "";
 
   if (disableGPT4) {
     if (customModels) customModels += ",";
@@ -249,6 +251,7 @@ export const getServerSideConfig = () => {
     disableFastLink: !!process.env.DISABLE_FAST_LINK,
     customModels,
     defaultModel,
+    visionModels,
     allowedWebDavEndpoints,
   };
 };

+ 5 - 1
app/store/access.ts

@@ -131,6 +131,7 @@ const DEFAULT_ACCESS_STATE = {
   disableFastLink: false,
   customModels: "",
   defaultModel: "",
+  visionModels: "",
 
   // tts config
   edgeTTSVoiceName: "zh-CN-YunxiNeural",
@@ -145,7 +146,10 @@ export const useAccessStore = createPersistStore(
 
       return get().needCode;
     },
-
+    getVisionModels() {
+      this.fetch();
+      return get().visionModels;
+    },
     edgeVoiceName() {
       this.fetch();
 

+ 3 - 3
app/utils.ts

@@ -6,7 +6,7 @@ import { ServiceProvider } from "./constant";
 // import { fetch as tauriFetch, ResponseType } from "@tauri-apps/api/http";
 import { fetch as tauriStreamFetch } from "./utils/stream";
 import { VISION_MODEL_REGEXES, EXCLUDE_VISION_MODEL_REGEXES } from "./constant";
-import { getClientConfig } from "./config/client";
+import { useAccessStore } from "./store";
 import { ModelSize } from "./typing";
 
 export function trimTopic(topic: string) {
@@ -255,8 +255,8 @@ export function getMessageImages(message: RequestMessage): string[] {
 }
 
 export function isVisionModel(model: string) {
-  const clientConfig = getClientConfig();
-  const envVisionModels = clientConfig?.visionModels
+  const visionModels = useAccessStore.getState().visionModels;
+  const envVisionModels = visionModels
     ?.split(",")
     .map((m) => m.trim());
   if (envVisionModels?.includes(model)) {