mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-03 02:59:07 +08:00
feat: update-t2i-image (#12236)
* chore: comment * chore: comment 2 * fix: comment * chore: var name
This commit is contained in:
parent
77e024027c
commit
48a582820f
@ -75,12 +75,37 @@ const VISION_REGEX = new RegExp(
|
||||
'i'
|
||||
)
|
||||
|
||||
// For middleware to identify models that must use the dedicated Image API
|
||||
// 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_MODELS = [
|
||||
'grok-2-image(?:-[\\w-]+)?',
|
||||
// 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-]+)?',
|
||||
// zhipu
|
||||
'cogview(?:-[\\w-]+)?',
|
||||
// Alibaba
|
||||
'qwen-image(?:-[\\w-]+)?',
|
||||
// Others
|
||||
'janus(?:-[\\w-]+)?',
|
||||
'midjourney(?:-[\\w-]+)?',
|
||||
'mj-[\\w-]+',
|
||||
'z-image(?:-[\\w-]+)?',
|
||||
'longcat-image(?:-[\\w-]+)?',
|
||||
'hunyuanimage(?:-[\\w-]+)?',
|
||||
'seedream(?:-[\\w-]+)?',
|
||||
'kandinsky(?:-[\\w-]+)?'
|
||||
]
|
||||
|
||||
const IMAGE_ENHANCEMENT_MODELS = [
|
||||
@ -133,13 +158,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)
|
||||
}
|
||||
|
||||
// Backward compatible aliases
|
||||
export const isDedicatedImageGenerationModel = isDedicatedImageModel
|
||||
|
||||
export const isAutoEnableImageGenerationModel = (model: Model): boolean => {
|
||||
if (!model) return false
|
||||
|
||||
@ -195,14 +230,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
|
||||
|
||||
/**
|
||||
* 判断模型是否支持图片增强(包括编辑、增强、修复等)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user