Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复 VISION_MDOELS 在 docker 运行阶段不生效的问题 #6010

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/api/config/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const DANGER_CONFIG = {
disableFastLink: serverConfig.disableFastLink,
customModels: serverConfig.customModels,
defaultModel: serverConfig.defaultModel,
visionModels: serverConfig.visionModels,
};

declare global {
Expand Down
1 change: 0 additions & 1 deletion app/config/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const getBuildConfig = () => {
buildMode,
isApp,
template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
visionModels: process.env.VISION_MODELS || "",
};
};

Expand Down
3 changes: 3 additions & 0 deletions app/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 += ",";
Expand Down Expand Up @@ -249,6 +251,7 @@ export const getServerSideConfig = () => {
disableFastLink: !!process.env.DISABLE_FAST_LINK,
customModels,
defaultModel,
visionModels,
allowedWebDavEndpoints,
};
};
6 changes: 5 additions & 1 deletion app/store/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const DEFAULT_ACCESS_STATE = {
disableFastLink: false,
customModels: "",
defaultModel: "",
visionModels: "",

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

return get().needCode;
},

setVisionModels() {
this.fetch();
return get().visionModels;
},
code-october marked this conversation as resolved.
Show resolved Hide resolved
edgeVoiceName() {
this.fetch();

Expand Down
6 changes: 3 additions & 3 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down