mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-19 04:00:16 +09:00
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,
|
||||
isApp,
|
||||
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 tauriStreamFetch } from "./utils/stream";
|
||||
import { VISION_MODEL_REGEXES, EXCLUDE_VISION_MODEL_REGEXES } from "./constant";
|
||||
import { getClientConfig } from "./config/client";
|
||||
|
||||
export function trimTopic(topic: string) {
|
||||
// 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) {
|
||||
const envVisionModels = process.env.NEXT_PUBLIC_VISION_MODELS?.split(",").map(
|
||||
(m) => m.trim(),
|
||||
);
|
||||
const clientConfig = getClientConfig();
|
||||
const envVisionModels = clientConfig.visionModels
|
||||
?.split(",")
|
||||
.map((m) => m.trim());
|
||||
if (envVisionModels?.includes(model)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -48,19 +48,19 @@ describe("isVisionModel", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("should identify models from NEXT_PUBLIC_VISION_MODELS env var", () => {
|
||||
process.env.NEXT_PUBLIC_VISION_MODELS = "custom-vision-model,another-vision-model";
|
||||
test("should identify models from VISION_MODELS env var", () => {
|
||||
process.env.VISION_MODELS = "custom-vision-model,another-vision-model";
|
||||
|
||||
expect(isVisionModel("custom-vision-model")).toBe(true);
|
||||
expect(isVisionModel("another-vision-model")).toBe(true);
|
||||
expect(isVisionModel("unrelated-model")).toBe(false);
|
||||
});
|
||||
|
||||
test("should handle empty or missing NEXT_PUBLIC_VISION_MODELS", () => {
|
||||
process.env.NEXT_PUBLIC_VISION_MODELS = "";
|
||||
test("should handle empty or missing VISION_MODELS", () => {
|
||||
process.env.VISION_MODELS = "";
|
||||
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("gpt-4-vision")).toBe(true);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user