forked from GithubProxy/ChatGPT-Next-Web
refactor: remove NEXT_PUBLIC_ prefix from VISION_MODELS env var
This commit is contained in:
parent
ed8c3580c8
commit
210b29bfbe
@ -40,6 +40,7 @@ export const getBuildConfig = () => {
|
|||||||
buildMode,
|
buildMode,
|
||||||
isApp,
|
isApp,
|
||||||
template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
|
template: process.env.DEFAULT_INPUT_TEMPLATE ?? DEFAULT_INPUT_TEMPLATE,
|
||||||
|
visionModels: process.env.VISION_MODELS || "",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import { ServiceProvider } from "./constant";
|
|||||||
// import { fetch as tauriFetch, ResponseType } from "@tauri-apps/api/http";
|
// import { fetch as tauriFetch, ResponseType } from "@tauri-apps/api/http";
|
||||||
import { fetch as tauriStreamFetch } from "./utils/stream";
|
import { fetch as tauriStreamFetch } from "./utils/stream";
|
||||||
import { VISION_MODEL_REGEXES, EXCLUDE_VISION_MODEL_REGEXES } from "./constant";
|
import { VISION_MODEL_REGEXES, EXCLUDE_VISION_MODEL_REGEXES } from "./constant";
|
||||||
|
import { getClientConfig } from "./config/client";
|
||||||
|
|
||||||
export function trimTopic(topic: string) {
|
export function trimTopic(topic: string) {
|
||||||
// Fix an issue where double quotes still show in the Indonesian language
|
// Fix an issue where double quotes still show in the Indonesian language
|
||||||
@ -253,9 +254,10 @@ export function getMessageImages(message: RequestMessage): string[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isVisionModel(model: string) {
|
export function isVisionModel(model: string) {
|
||||||
const envVisionModels = process.env.NEXT_PUBLIC_VISION_MODELS?.split(",").map(
|
const clientConfig = getClientConfig();
|
||||||
(m) => m.trim(),
|
const envVisionModels = clientConfig.visionModels
|
||||||
);
|
?.split(",")
|
||||||
|
.map((m) => m.trim());
|
||||||
if (envVisionModels?.includes(model)) {
|
if (envVisionModels?.includes(model)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -48,19 +48,19 @@ describe("isVisionModel", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should identify models from NEXT_PUBLIC_VISION_MODELS env var", () => {
|
test("should identify models from VISION_MODELS env var", () => {
|
||||||
process.env.NEXT_PUBLIC_VISION_MODELS = "custom-vision-model,another-vision-model";
|
process.env.VISION_MODELS = "custom-vision-model,another-vision-model";
|
||||||
|
|
||||||
expect(isVisionModel("custom-vision-model")).toBe(true);
|
expect(isVisionModel("custom-vision-model")).toBe(true);
|
||||||
expect(isVisionModel("another-vision-model")).toBe(true);
|
expect(isVisionModel("another-vision-model")).toBe(true);
|
||||||
expect(isVisionModel("unrelated-model")).toBe(false);
|
expect(isVisionModel("unrelated-model")).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should handle empty or missing NEXT_PUBLIC_VISION_MODELS", () => {
|
test("should handle empty or missing VISION_MODELS", () => {
|
||||||
process.env.NEXT_PUBLIC_VISION_MODELS = "";
|
process.env.VISION_MODELS = "";
|
||||||
expect(isVisionModel("unrelated-model")).toBe(false);
|
expect(isVisionModel("unrelated-model")).toBe(false);
|
||||||
|
|
||||||
delete process.env.NEXT_PUBLIC_VISION_MODELS;
|
delete process.env.VISION_MODELS;
|
||||||
expect(isVisionModel("unrelated-model")).toBe(false);
|
expect(isVisionModel("unrelated-model")).toBe(false);
|
||||||
expect(isVisionModel("gpt-4-vision")).toBe(true);
|
expect(isVisionModel("gpt-4-vision")).toBe(true);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user