mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-23 18:10:26 +08:00
Revert "fix: update selectedTypes logic in ModelEditContent for better handling" (#5858)
This commit is contained in:
parent
db6408f3b9
commit
8e1c10abd6
@ -237,10 +237,10 @@ export const CLAUDE_SUPPORTED_WEBSEARCH_REGEX = new RegExp(
|
||||
)
|
||||
|
||||
export function isFunctionCallingModel(model: Model): boolean {
|
||||
if (!model) return false
|
||||
if (model.type) {
|
||||
return model.type.includes('function_calling')
|
||||
} else {
|
||||
if (model.type?.includes('function_calling')) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (isEmbeddingModel(model)) {
|
||||
return false
|
||||
}
|
||||
@ -254,7 +254,6 @@ export function isFunctionCallingModel(model: Model): boolean {
|
||||
}
|
||||
|
||||
return FUNCTION_CALLING_REGEX.test(model.id)
|
||||
}
|
||||
}
|
||||
|
||||
export function getModelLogo(modelId: string) {
|
||||
@ -2189,9 +2188,7 @@ export function isEmbeddingModel(model: Model): boolean {
|
||||
if (!model) {
|
||||
return false
|
||||
}
|
||||
if (model.type) {
|
||||
return model.type.includes('embedding')
|
||||
} else {
|
||||
|
||||
if (['anthropic'].includes(model?.provider)) {
|
||||
return false
|
||||
}
|
||||
@ -2204,8 +2201,7 @@ export function isEmbeddingModel(model: Model): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
return EMBEDDING_REGEX.test(model.id)
|
||||
}
|
||||
return EMBEDDING_REGEX.test(model.id) || model.type?.includes('embedding') || false
|
||||
}
|
||||
|
||||
export function isRerankModel(model: Model): boolean {
|
||||
@ -2216,20 +2212,16 @@ export function isVisionModel(model: Model): boolean {
|
||||
if (!model) {
|
||||
return false
|
||||
}
|
||||
if (model.type) {
|
||||
return model.type.includes('vision')
|
||||
} else {
|
||||
// 新添字段 copilot-vision-request 后可使用 vision
|
||||
// if (model.provider === 'copilot') {
|
||||
// return false
|
||||
// }
|
||||
|
||||
if (model.provider === 'doubao') {
|
||||
return VISION_REGEX.test(model.name)
|
||||
return VISION_REGEX.test(model.name) || model.type?.includes('vision') || false
|
||||
}
|
||||
|
||||
return VISION_REGEX.test(model.id)
|
||||
}
|
||||
return VISION_REGEX.test(model.id) || model.type?.includes('vision') || false
|
||||
}
|
||||
|
||||
export function isOpenAIReasoningModel(model: Model): boolean {
|
||||
@ -2363,11 +2355,9 @@ export function isReasoningModel(model?: Model): boolean {
|
||||
if (!model) {
|
||||
return false
|
||||
}
|
||||
if (model.type) {
|
||||
return model.type.includes('reasoning')
|
||||
} else {
|
||||
|
||||
if (model.provider === 'doubao') {
|
||||
return REASONING_REGEX.test(model.name)
|
||||
return REASONING_REGEX.test(model.name) || model.type?.includes('reasoning') || false
|
||||
}
|
||||
|
||||
if (
|
||||
@ -2381,8 +2371,7 @@ export function isReasoningModel(model?: Model): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
return REASONING_REGEX.test(model.id)
|
||||
}
|
||||
return REASONING_REGEX.test(model.id) || model.type?.includes('reasoning') || false
|
||||
}
|
||||
|
||||
export function isSupportedModel(model: OpenAI.Models.Model): boolean {
|
||||
@ -2397,9 +2386,13 @@ export function isWebSearchModel(model: Model): boolean {
|
||||
if (!model) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (model.type) {
|
||||
return model.type.includes('web_search')
|
||||
} else {
|
||||
if (model.type.includes('web_search')) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
const provider = getProviderByModel(model)
|
||||
|
||||
if (!provider) {
|
||||
@ -2476,7 +2469,6 @@ export function isWebSearchModel(model: Model): boolean {
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function isGenerateImageModel(model: Model): boolean {
|
||||
|
||||
@ -132,7 +132,7 @@ const ModelEditContent: FC<ModelEditContentProps> = ({ model, onUpdateModel, ope
|
||||
] as ModelType[]
|
||||
|
||||
// 合并现有选择和默认类型
|
||||
const selectedTypes = model.type ? model.type : defaultTypes
|
||||
const selectedTypes = [...new Set([...(model.type || []), ...defaultTypes])]
|
||||
|
||||
const showTypeConfirmModal = (type: string) => {
|
||||
window.modal.confirm({
|
||||
@ -165,23 +165,28 @@ const ModelEditContent: FC<ModelEditContentProps> = ({ model, onUpdateModel, ope
|
||||
options={[
|
||||
{
|
||||
label: t('models.type.vision'),
|
||||
value: 'vision'
|
||||
value: 'vision',
|
||||
disabled: isVisionModel(model) && !selectedTypes.includes('vision')
|
||||
},
|
||||
{
|
||||
label: t('models.type.websearch'),
|
||||
value: 'web_search'
|
||||
value: 'web_search',
|
||||
disabled: isWebSearchModel(model) && !selectedTypes.includes('web_search')
|
||||
},
|
||||
{
|
||||
label: t('models.type.embedding'),
|
||||
value: 'embedding'
|
||||
value: 'embedding',
|
||||
disabled: isEmbeddingModel(model) && !selectedTypes.includes('embedding')
|
||||
},
|
||||
{
|
||||
label: t('models.type.reasoning'),
|
||||
value: 'reasoning'
|
||||
value: 'reasoning',
|
||||
disabled: isReasoningModel(model) && !selectedTypes.includes('reasoning')
|
||||
},
|
||||
{
|
||||
label: t('models.type.function_calling'),
|
||||
value: 'function_calling'
|
||||
value: 'function_calling',
|
||||
disabled: isFunctionCallingModel(model) && !selectedTypes.includes('function_calling')
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user