From 57c88c0717bf21f29395642f32a306dc2388018d Mon Sep 17 00:00:00 2001 From: code-october <148516338+code-october@users.noreply.github.com> Date: Mon, 30 Dec 2024 08:58:41 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20VISION=5FMDOELS=20?= =?UTF-8?q?=E5=9C=A8=20docker=20=E8=BF=90=E8=A1=8C=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/config/route.ts | 1 + app/config/build.ts | 1 - app/config/server.ts | 3 +++ app/store/access.ts | 6 +++++- app/utils.ts | 6 +++--- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/api/config/route.ts b/app/api/config/route.ts index b0d9da03103..855a5db017e 100644 --- a/app/api/config/route.ts +++ b/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 { diff --git a/app/config/build.ts b/app/config/build.ts index aa7c10729b6..b2b1ad49da1 100644 --- a/app/config/build.ts +++ b/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 || "", }; }; diff --git a/app/config/server.ts b/app/config/server.ts index d5ffaab5467..73faa881527 100644 --- a/app/config/server.ts +++ b/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, }; }; diff --git a/app/store/access.ts b/app/store/access.ts index 3c7f84adac0..f0352ad549f 100644 --- a/app/store/access.ts +++ b/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; }, - + setVisionModels() { + this.fetch(); + return get().visionModels; + }, edgeVoiceName() { this.fetch(); diff --git a/app/utils.ts b/app/utils.ts index 810dc7842b1..4f5b7b0b7de 100644 --- a/app/utils.ts +++ b/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)) { From 266e9efd2e004664d73f0aa7f93a8684c0e5c55e Mon Sep 17 00:00:00 2001 From: code-october <148516338+code-october@users.noreply.github.com> Date: Mon, 30 Dec 2024 09:13:12 +0000 Subject: [PATCH 2/2] rename the function --- app/store/access.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/access.ts b/app/store/access.ts index f0352ad549f..1fed5dfeda7 100644 --- a/app/store/access.ts +++ b/app/store/access.ts @@ -146,7 +146,7 @@ export const useAccessStore = createPersistStore( return get().needCode; }, - setVisionModels() { + getVisionModels() { this.fetch(); return get().visionModels; },