diff --git a/web/app/components/header/account-setting/model-provider-page/declarations.ts b/web/app/components/header/account-setting/model-provider-page/declarations.ts index 6d9cbf0195..afb1cbce48 100644 --- a/web/app/components/header/account-setting/model-provider-page/declarations.ts +++ b/web/app/components/header/account-setting/model-provider-page/declarations.ts @@ -153,6 +153,7 @@ export type ModelItem = { model_properties: Record load_balancing_enabled: boolean deprecated?: boolean + has_invalid_load_balancing_configs?: boolean } export enum PreferredProviderTypeEnum { diff --git a/web/app/components/header/account-setting/model-provider-page/hooks.ts b/web/app/components/header/account-setting/model-provider-page/hooks.ts index 87117161e3..fa5130137a 100644 --- a/web/app/components/header/account-setting/model-provider-page/hooks.ts +++ b/web/app/components/header/account-setting/model-provider-page/hooks.ts @@ -357,6 +357,7 @@ export const useModelModalHandler = () => { isModelCredential?: boolean, credential?: Credential, model?: CustomModel, + onUpdate?: () => void, ) => { setShowModelModal({ payload: { @@ -369,6 +370,7 @@ export const useModelModalHandler = () => { }, onSaveCallback: () => { handleRefreshModel(provider, configurationMethod, CustomConfigurationModelFixedFields) + onUpdate?.() }, }) } diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/add-credential-in-load-balancing.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/add-credential-in-load-balancing.tsx index 52adebd262..829ef25795 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/add-credential-in-load-balancing.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/add-credential-in-load-balancing.tsx @@ -58,11 +58,15 @@ const AddCredentialInLoadBalancing = ({ items={[ { title: customModel ? t('common.modelProvider.auth.modelCredentials') : t('common.modelProvider.auth.apiKeys'), - model, + model: customModel ? model : undefined, credentials: available_credentials ?? [], }, ]} configurationMethod={configurationMethod} + currentCustomConfigurationModelFixedFields={customModel ? { + __model_name: model.model, + __model_type: model.model_type, + } : undefined} onItemClick={onSelectCredential} placement='bottom-start' onUpdate={onUpdate} diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx index b45653bbff..8d526e3bda 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/authorized/index.tsx @@ -161,7 +161,15 @@ const Authorized = ({ { isModelCredential && (
handleEdit()} + onClick={() => handleEdit( + undefined, + currentCustomConfigurationModelFixedFields + ? { + model: currentCustomConfigurationModelFixedFields.__model_name, + model_type: currentCustomConfigurationModelFixedFields.__model_type, + } + : undefined, + )} className='system-xs-medium flex h-[30px] cursor-pointer items-center px-3 text-text-accent-light-mode-only' > diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/config-model.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/config-model.tsx index 5693dac45b..c9f1744cdb 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/config-model.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/config-model.tsx @@ -1,5 +1,8 @@ import { memo } from 'react' -import { RiEqualizer2Line } from '@remixicon/react' +import { + RiEqualizer2Line, + RiScales3Line, +} from '@remixicon/react' import { useTranslation } from 'react-i18next' import Button from '@/app/components/base/button' import cn from '@/utils/classnames' @@ -7,12 +10,29 @@ import cn from '@/utils/classnames' type ConfigModelProps = { className?: string onClick?: () => void + loadBalancingEnabled?: boolean + loadBalancingInvalid?: boolean } const ConfigModel = ({ className, onClick, + loadBalancingEnabled, + loadBalancingInvalid, }: ConfigModelProps) => { const { t } = useTranslation() + + if (loadBalancingEnabled && loadBalancingInvalid) { + return ( +
+ + {t('common.modelProvider.auth.authorizationError')} +
+ ) + } + return ( ) } diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.ts b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.ts index a5723b4046..d4a0417a44 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.ts +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-auth.ts @@ -138,8 +138,9 @@ export const useAuth = ( isModelCredential, credential, model, + onUpdate, ) - }, [handleOpenModelModal, provider, configurationMethod, currentCustomConfigurationModelFixedFields, isModelCredential]) + }, [handleOpenModelModal, provider, configurationMethod, currentCustomConfigurationModelFixedFields, isModelCredential, onUpdate]) return { pendingOperationCredentialId, diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-model-form-schemas.ts b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-model-form-schemas.ts index 1769d8217d..eafbedfddf 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-model-form-schemas.ts +++ b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-model-form-schemas.ts @@ -66,10 +66,11 @@ export const useModelFormSchemas = ( const formValues = useMemo(() => { let result = {} - if (credentials) - result = { ...credentials } - if (credential) + if (credential) { result = { ...result, __authorization_name__: credential?.credential_name } + if (credentials) + result = { ...result, ...credentials } + } if (model) result = { ...result, __model_name: model?.model, __model_type: model?.model_type } return result diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx index 72ccb30cec..5093904b2f 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx @@ -76,6 +76,8 @@ const ModelListItem = ({ model, provider, isConfigurable, onModifyLoadBalancing onModifyLoadBalancing?.(model)} + loadBalancingEnabled={model.load_balancing_enabled} + loadBalancingInvalid={model.has_invalid_load_balancing_configs} /> ) } diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx index dd1ab5bcb0..28fc5d39b7 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx @@ -165,7 +165,15 @@ const ModelLoadBalancingConfigs = ({
{draftConfig.enabled && (
- {draftConfig.configs.map((config, index) => { + {draftConfig.configs.filter((config) => { + if (config.name === '__inherit__') + return true + + if (config.credential_id) + return true + + return false + }).map((config, index) => { const isProviderManaged = config.name === '__inherit__' return (
diff --git a/web/i18n/en-US/common.ts b/web/i18n/en-US/common.ts index da8308cbf3..7226c9850f 100644 --- a/web/i18n/en-US/common.ts +++ b/web/i18n/en-US/common.ts @@ -498,6 +498,7 @@ const translation = { modelCredentials: 'Model credentials', configModel: 'Config model', configLoadBalancing: 'Config Load Balancing', + authorizationError: 'Authorization error', }, }, dataSource: { diff --git a/web/i18n/zh-Hans/common.ts b/web/i18n/zh-Hans/common.ts index 26680fbaa3..e91407872a 100644 --- a/web/i18n/zh-Hans/common.ts +++ b/web/i18n/zh-Hans/common.ts @@ -498,6 +498,7 @@ const translation = { modelCredentials: '模型凭据', configModel: '配置模型', configLoadBalancing: '配置负载均衡', + authorizationError: '授权错误', }, }, dataSource: { diff --git a/web/service/use-models.ts b/web/service/use-models.ts index 1f6e101ec0..75321d2706 100644 --- a/web/service/use-models.ts +++ b/web/service/use-models.ts @@ -85,6 +85,7 @@ export const useGetModelCredential = ( queryKey: [NAME_SPACE, 'model-list', provider, model, modelType, credentialId], queryFn: () => get(`/workspaces/current/model-providers/${provider}/models/credentials?model=${model}&model_type=${modelType}&config_from=${configFrom}${credentialId ? `&credential_id=${credentialId}` : ''}`), staleTime: 0, + gcTime: 0, }) }