mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-01 01:30:51 +08:00
Support API models with provider_name field in getModelName
- Add ApiModel type import and update function signature to accept ApiModel - Return formatted name using provider_name field for API models - Maintain backward compatibility for legacy models by looking up provider in store
This commit is contained in:
parent
34b05a138b
commit
117e390cf1
@ -1,5 +1,6 @@
|
||||
import store from '@renderer/store'
|
||||
import { Model } from '@renderer/types'
|
||||
import { ApiModel } from '@renderer/types/apiModels'
|
||||
import { pick } from 'lodash'
|
||||
|
||||
import { getProviderName } from './ProviderService'
|
||||
@ -18,12 +19,19 @@ export const hasModel = (m?: Model) => {
|
||||
return allModels.find((model) => model.id === m?.id)
|
||||
}
|
||||
|
||||
export function getModelName(model?: Model) {
|
||||
const provider = store.getState().llm.providers.find((p) => p.id === model?.provider)
|
||||
export function getModelName(model?: Model | ApiModel) {
|
||||
const modelName = model?.name || model?.id || ''
|
||||
|
||||
// For API models that have provider_name field, use it directly
|
||||
const apiModel = model as ApiModel
|
||||
if (apiModel?.provider_name) {
|
||||
return `${modelName} | ${apiModel.provider_name}`
|
||||
}
|
||||
|
||||
// For legacy models, look up the provider in the store
|
||||
const provider = store.getState().llm.providers.find((p) => p.id === model?.provider)
|
||||
if (provider) {
|
||||
const providerName = getProviderName(model)
|
||||
const providerName = getProviderName(model as Model)
|
||||
return `${modelName} | ${providerName}`
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user