Skip to content

Commit 63c5baa

Browse files
authored
Merge pull request #6010 from code-october/fix-visionModels
修复 VISION_MDOELS 在 docker 运行阶段不生效的问题
2 parents defefba + 266e9ef commit 63c5baa

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

app/api/config/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const DANGER_CONFIG = {
1414
disableFastLink: serverConfig.disableFastLink,
1515
customModels: serverConfig.customModels,
1616
defaultModel: serverConfig.defaultModel,
17+
visionModels: serverConfig.visionModels,
1718
};
1819

1920
declare global {

app/config/build.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export const getBuildConfig = () => {
4040
buildMode,
4141
isApp,
4242
template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
43-
visionModels: process.env.VISION_MODELS || "",
4443
};
4544
};
4645

app/config/server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ declare global {
2323
DISABLE_FAST_LINK?: string; // disallow parse settings from url or not
2424
CUSTOM_MODELS?: string; // to control custom models
2525
DEFAULT_MODEL?: string; // to control default model in every new chat window
26+
VISION_MODELS?: string; // to control vision models
2627

2728
// stability only
2829
STABILITY_URL?: string;
@@ -128,6 +129,7 @@ export const getServerSideConfig = () => {
128129
const disableGPT4 = !!process.env.DISABLE_GPT4;
129130
let customModels = process.env.CUSTOM_MODELS ?? "";
130131
let defaultModel = process.env.DEFAULT_MODEL ?? "";
132+
let visionModels = process.env.VISION_MODELS ?? "";
131133

132134
if (disableGPT4) {
133135
if (customModels) customModels += ",";
@@ -249,6 +251,7 @@ export const getServerSideConfig = () => {
249251
disableFastLink: !!process.env.DISABLE_FAST_LINK,
250252
customModels,
251253
defaultModel,
254+
visionModels,
252255
allowedWebDavEndpoints,
253256
};
254257
};

app/store/access.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const DEFAULT_ACCESS_STATE = {
131131
disableFastLink: false,
132132
customModels: "",
133133
defaultModel: "",
134+
visionModels: "",
134135

135136
// tts config
136137
edgeTTSVoiceName: "zh-CN-YunxiNeural",
@@ -145,7 +146,10 @@ export const useAccessStore = createPersistStore(
145146

146147
return get().needCode;
147148
},
148-
149+
getVisionModels() {
150+
this.fetch();
151+
return get().visionModels;
152+
},
149153
edgeVoiceName() {
150154
this.fetch();
151155

app/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ServiceProvider } from "./constant";
66
// import { fetch as tauriFetch, ResponseType } from "@tauri-apps/api/http";
77
import { fetch as tauriStreamFetch } from "./utils/stream";
88
import { VISION_MODEL_REGEXES, EXCLUDE_VISION_MODEL_REGEXES } from "./constant";
9-
import { getClientConfig } from "./config/client";
9+
import { useAccessStore } from "./store";
1010
import { ModelSize } from "./typing";
1111

1212
export function trimTopic(topic: string) {
@@ -255,8 +255,8 @@ export function getMessageImages(message: RequestMessage): string[] {
255255
}
256256

257257
export function isVisionModel(model: string) {
258-
const clientConfig = getClientConfig();
259-
const envVisionModels = clientConfig?.visionModels
258+
const visionModels = useAccessStore.getState().visionModels;
259+
const envVisionModels = visionModels
260260
?.split(",")
261261
.map((m) => m.trim());
262262
if (envVisionModels?.includes(model)) {

0 commit comments

Comments
 (0)