From f2029f82b393044404f16ed74ed408938f176a49 Mon Sep 17 00:00:00 2001 From: suyao Date: Fri, 2 Jan 2026 15:07:07 +0800 Subject: [PATCH 1/3] chore: comment --- src/renderer/src/config/models/vision.ts | 64 +++++++++++++++++------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/src/renderer/src/config/models/vision.ts b/src/renderer/src/config/models/vision.ts index fe4bc9912c..ec0fa38737 100644 --- a/src/renderer/src/config/models/vision.ts +++ b/src/renderer/src/config/models/vision.ts @@ -75,14 +75,40 @@ const VISION_REGEX = new RegExp( 'i' ) -// For middleware to identify models that must use the dedicated Image API -const DEDICATED_IMAGE_MODELS = [ - 'grok-2-image(?:-[\\w-]+)?', +// All dedicated image generation models (only generate images, no text chat capability) +// These models need: +// 1. Route to dedicated image generation API +// 2. Exclude from reasoning/websearch/tooluse selection +const DEDICATED_IMAGE_MODEL_PATTERNS = [ + // OpenAI series 'dall-e(?:-[\\w-]+)?', - 'gpt-image-1(?:-[\\w-]+)?', - 'imagen(?:-[\\w-]+)?' + 'gpt-image(?:-[\\w-]+)?', + // xAI + 'grok-2-image(?:-[\\w-]+)?', + // Google + 'imagen(?:-[\\w-]+)?', + // Stable Diffusion series + 'flux(?:-[\\w-]+)?', + 'stable-?diffusion(?:-[\\w-]+)?', + 'stabilityai(?:-[\\w-]+)?', + 'sd-[\\w-]+', + 'sdxl(?:-[\\w-]+)?', + // Alibaba + 'cogview(?:-[\\w-]+)?', + 'qwen-image(?:-[\\w-]+)?', + // Others + 'janus(?:-[\\w-]+)?', + 'midjourney(?:-[\\w-]+)?', + 'mj-[\\w-]+', + 'z-image(?:-[\\w-]+)?', + 'longcat-image(?:-[\\w-]+)?', + 'seedream(?:-[\\w-]+)?', + 'kandinsky(?:-[\\w-]+)?' ] +// Legacy alias for backward compatibility with GENERATE_IMAGE_MODELS +const DEDICATED_IMAGE_MODELS = DEDICATED_IMAGE_MODEL_PATTERNS + const IMAGE_ENHANCEMENT_MODELS = [ 'grok-2-image(?:-[\\w-]+)?', 'qwen-image-edit', @@ -94,7 +120,7 @@ const IMAGE_ENHANCEMENT_MODELS = [ const IMAGE_ENHANCEMENT_MODELS_REGEX = new RegExp(IMAGE_ENHANCEMENT_MODELS.join('|'), 'i') -const DEDICATED_IMAGE_MODELS_REGEX = new RegExp(DEDICATED_IMAGE_MODELS.join('|'), 'i') +const DEDICATED_IMAGE_MODEL_REGEX = new RegExp(DEDICATED_IMAGE_MODEL_PATTERNS.join('|'), 'i') // Models that should auto-enable image generation button when selected const AUTO_ENABLE_IMAGE_MODELS = [ @@ -133,13 +159,23 @@ const GENERATE_IMAGE_MODELS_REGEX = new RegExp(GENERATE_IMAGE_MODELS.join('|'), const MODERN_GENERATE_IMAGE_MODELS_REGEX = new RegExp(MODERN_IMAGE_MODELS.join('|'), 'i') -export const isDedicatedImageGenerationModel = (model: Model): boolean => { +/** + * Check if the model is a dedicated image generation model + * Dedicated image generation models can only generate images, no text chat capability + * + * These models need: + * 1. Route to dedicated image generation API + * 2. Exclude from reasoning/websearch/tooluse selection + */ +export function isDedicatedImageModel(model: Model): boolean { if (!model) return false - const modelId = getLowerBaseModelName(model.id) - return DEDICATED_IMAGE_MODELS_REGEX.test(modelId) + return DEDICATED_IMAGE_MODEL_REGEX.test(modelId) } +// Backward compatible aliases +export const isDedicatedImageGenerationModel = isDedicatedImageModel + export const isAutoEnableImageGenerationModel = (model: Model): boolean => { if (!model) return false @@ -195,14 +231,8 @@ export function isPureGenerateImageModel(model: Model): boolean { return !OPENAI_TOOL_USE_IMAGE_GENERATION_MODELS.some((m) => modelId.includes(m)) } -// TODO: refine the regex -// Text to image models -const TEXT_TO_IMAGE_REGEX = /flux|diffusion|stabilityai|sd-|dall|cogview|janus|midjourney|mj-|imagen|gpt-image/i - -export function isTextToImageModel(model: Model): boolean { - const modelId = getLowerBaseModelName(model.id) - return TEXT_TO_IMAGE_REGEX.test(modelId) -} +// Backward compatible alias - now uses unified dedicated image model detection +export const isTextToImageModel = isDedicatedImageModel /** * 判断模型是否支持图片增强(包括编辑、增强、修复等) From f3975b1b08350fc7188d1e1764e0b3832b7341f1 Mon Sep 17 00:00:00 2001 From: suyao Date: Fri, 2 Jan 2026 15:07:31 +0800 Subject: [PATCH 2/3] chore: comment 2 --- src/renderer/src/config/models/vision.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/config/models/vision.ts b/src/renderer/src/config/models/vision.ts index ec0fa38737..eed0b44915 100644 --- a/src/renderer/src/config/models/vision.ts +++ b/src/renderer/src/config/models/vision.ts @@ -93,8 +93,9 @@ const DEDICATED_IMAGE_MODEL_PATTERNS = [ 'stabilityai(?:-[\\w-]+)?', 'sd-[\\w-]+', 'sdxl(?:-[\\w-]+)?', - // Alibaba + // zhipu 'cogview(?:-[\\w-]+)?', + // Alibaba 'qwen-image(?:-[\\w-]+)?', // Others 'janus(?:-[\\w-]+)?', From 025d4a678f818e38239b22aca6751e01bdafa6fc Mon Sep 17 00:00:00 2001 From: suyao Date: Fri, 2 Jan 2026 15:36:01 +0800 Subject: [PATCH 3/3] fix: comment --- src/renderer/src/config/models/vision.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/config/models/vision.ts b/src/renderer/src/config/models/vision.ts index eed0b44915..c16c83e2ed 100644 --- a/src/renderer/src/config/models/vision.ts +++ b/src/renderer/src/config/models/vision.ts @@ -79,7 +79,7 @@ const VISION_REGEX = new RegExp( // These models need: // 1. Route to dedicated image generation API // 2. Exclude from reasoning/websearch/tooluse selection -const DEDICATED_IMAGE_MODEL_PATTERNS = [ +const DEDICATED_IMAGE_MODELS = [ // OpenAI series 'dall-e(?:-[\\w-]+)?', 'gpt-image(?:-[\\w-]+)?', @@ -103,13 +103,11 @@ const DEDICATED_IMAGE_MODEL_PATTERNS = [ 'mj-[\\w-]+', 'z-image(?:-[\\w-]+)?', 'longcat-image(?:-[\\w-]+)?', + 'hunyuanimage(?:-[\\w-]+)?', 'seedream(?:-[\\w-]+)?', 'kandinsky(?:-[\\w-]+)?' ] -// Legacy alias for backward compatibility with GENERATE_IMAGE_MODELS -const DEDICATED_IMAGE_MODELS = DEDICATED_IMAGE_MODEL_PATTERNS - const IMAGE_ENHANCEMENT_MODELS = [ 'grok-2-image(?:-[\\w-]+)?', 'qwen-image-edit', @@ -121,7 +119,7 @@ const IMAGE_ENHANCEMENT_MODELS = [ const IMAGE_ENHANCEMENT_MODELS_REGEX = new RegExp(IMAGE_ENHANCEMENT_MODELS.join('|'), 'i') -const DEDICATED_IMAGE_MODEL_REGEX = new RegExp(DEDICATED_IMAGE_MODEL_PATTERNS.join('|'), 'i') +const DEDICATED_IMAGE_MODEL_REGEX = new RegExp(DEDICATED_IMAGE_MODELS.join('|'), 'i') // Models that should auto-enable image generation button when selected const AUTO_ENABLE_IMAGE_MODELS = [