|
@@ -5,6 +5,7 @@ import { RequestMessage } from "./client/api";
|
|
|
import { ServiceProvider } from "./constant";
|
|
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";
|
|
|
|
|
|
|
|
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
|
|
@@ -252,27 +253,15 @@ export function getMessageImages(message: RequestMessage): string[] {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function isVisionModel(model: string) {
|
|
export function isVisionModel(model: string) {
|
|
|
- // Note: This is a better way using the TypeScript feature instead of `&&` or `||` (ts v5.5.0-dev.20240314 I've been using)
|
|
|
|
|
-
|
|
|
|
|
- const excludeKeywords = ["claude-3-5-haiku-20241022"];
|
|
|
|
|
- const visionKeywords = [
|
|
|
|
|
- "vision",
|
|
|
|
|
- "gpt-4o",
|
|
|
|
|
- "claude-3",
|
|
|
|
|
- "gemini-1.5",
|
|
|
|
|
- "gemini-exp",
|
|
|
|
|
- "learnlm",
|
|
|
|
|
- "qwen-vl",
|
|
|
|
|
- "qwen2-vl",
|
|
|
|
|
- ];
|
|
|
|
|
- const isGpt4Turbo =
|
|
|
|
|
- model.includes("gpt-4-turbo") && !model.includes("preview");
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const envVisionModels = process.env.NEXT_PUBLIC_VISION_MODELS?.split(",").map(
|
|
|
|
|
+ (m) => m.trim(),
|
|
|
|
|
+ );
|
|
|
|
|
+ if (envVisionModels?.includes(model)) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
return (
|
|
return (
|
|
|
- !excludeKeywords.some((keyword) => model.includes(keyword)) &&
|
|
|
|
|
- (visionKeywords.some((keyword) => model.includes(keyword)) ||
|
|
|
|
|
- isGpt4Turbo ||
|
|
|
|
|
- isDalle3(model))
|
|
|
|
|
|
|
+ !EXCLUDE_VISION_MODEL_REGEXES.some((regex) => regex.test(model)) &&
|
|
|
|
|
+ VISION_MODEL_REGEXES.some((regex) => regex.test(model))
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|