Elffuss BraidHub

kikocis/continue public

Merge pull request #7721 from fbricon/refactor-vision-support-detection

fix: improve modelSupportsImages logic
Changeset9fb47873748c7c5974da6471831ed792c8fd5d58b27f96f4ae604729ebae55e8
AuthorDallin Romney <dallinromney@gmail.com> · 2025-09-15 13:16 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-15 13:16 -07:00
Parentsbe967b5bd8c5, b63d495e4ad4

Browse the files at this changeset

3 files changed

modified core/llm/autodetect.ts +24 −22
@@ -85,26 +85,24 @@
8585 "watsonx",
8686 ];
8787
88-const MODEL_SUPPORTS_IMAGES: string[] = [
89- "llava",
90- "gpt-4-turbo",
91- "gpt-4o",
92- "gpt-4o-mini",
93- "gpt-4-vision",
94- "claude-3",
95- "c4ai-aya-vision-8b",
96- "c4ai-aya-vision-32b",
97- "gemini-ultra",
98- "gemini-1.5-pro",
99- "gemini-1.5-flash",
100- "sonnet",
101- "opus",
102- "haiku",
103- "pixtral",
104- "llama3.2",
105- "llama-3.2",
106- "llama4",
107- "granite-vision",
88+const MODEL_SUPPORTS_IMAGES: RegExp[] = [
89+ /llava/,
90+ /gpt-4-turbo/,
91+ /gpt-4o/,
92+ /gpt-4o-mini/,
93+ /claude-3/,
94+ /gemini-ultra/,
95+ /gemini-1\.5-pro/,
96+ /gemini-1\.5-flash/,
97+ /sonnet/,
98+ /opus/,
99+ /haiku/,
100+ /pixtral/,
101+ /llama-?3\.2/,
102+ /llama-?4/, // might use something like /llama-?(?:[4-9](?:\.\d+)?|\d{2,}(?:\.\d+)?)/ for forward compat, if needed
103+ /\bgemma-?3(?!n)/, // gemma3 supports vision, but gemma3n doesn't!
104+ /\b(pali|med)gemma/,
105+ /qwen(.*)vl/,
108106 ];
109107
110108 function modelSupportsImages(
@@ -120,10 +118,14 @@
120118 return false;
121119 }
122120
123- const lower = model.toLowerCase();
121+ const lowerModel = model.toLowerCase();
122+ const lowerTitle = title?.toLowerCase() ?? "";
123+
124124 if (
125+ lowerModel.includes("vision") ||
126+ lowerTitle.includes("vision") ||
125127 MODEL_SUPPORTS_IMAGES.some(
126- (modelName) => lower.includes(modelName) || title?.includes(modelName),
128+ (modelrx) => modelrx.test(lowerModel) || modelrx.test(lowerTitle),
127129 )
128130 ) {
129131 return true;
modified core/llm/index.test.ts +21 −0
@@ -95,10 +95,31 @@
9595 test("should return true when modelSupportsImages returns true", () => {
9696 baseLLM.model = "gpt-4-vision";
9797 expect(baseLLM.supportsImages()).toBe(true);
98+
99+ baseLLM.model = "fancy-vision-model";
100+ expect(baseLLM.supportsImages()).toBe(true);
101+
102+ baseLLM.model = "gemma3:4b";
103+ expect(baseLLM.supportsImages()).toBe(true);
104+
105+ baseLLM.model = "google/gemma-3-270m";
106+ expect(baseLLM.supportsImages()).toBe(true);
107+
108+ baseLLM.model = "foo/paligemma-custom-100";
109+ expect(baseLLM.supportsImages()).toBe(true);
110+
111+ baseLLM.model = "foo/medgemma_4b_it_16Q";
112+ expect(baseLLM.supportsImages()).toBe(true);
113+
114+ baseLLM.model = "qwen2.5vl";
115+ expect(baseLLM.supportsImages()).toBe(true);
98116 });
99117
100118 test("should return false when modelSupportsImages returns false", () => {
101119 expect(baseLLM.supportsImages()).toBe(false);
120+
121+ baseLLM.model = "gemma3n";
122+ expect(baseLLM.supportsImages()).toBe(false);
102123 });
103124 });
104125
modified docs/customize/deep-dives/model-capabilities.mdx +2 −1
@@ -231,12 +231,13 @@
231231 | Model | Tool Use | Image Input | Context Window |
232232 | :------------- | -------- | ----------- | -------------- |
233233 | Qwen 3 Coder | Yes | No | 32k |
234+| Qwen 2.5 VL | No | Yes | 128k |
234235 | Devstral Small | Yes | No | 32k |
235236 | Llama 3.1 | Yes | No | 128k |
236237 | Llama 3 | Yes | No | 8k |
237238 | Mistral | Yes | No | 32k |
238239 | Codestral | Yes | No | 32k |
239-| Gemma 3 4B | Yes | No | 8k |
240+| Gemma 3 4B | Yes | Yes | 128k |
240241
241242 ### Notes
242243