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