diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx index 10262342e1..43282d3300 100644 --- a/web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx +++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.tsx @@ -78,8 +78,8 @@ const ModelParameterTrigger: FC = ({ credentialState, ) const iconProvider = currentProvider || providerMeta - const statusLabelKey = DERIVED_MODEL_STATUS_BADGE_I18N[status] - const statusTooltipKey = DERIVED_MODEL_STATUS_TOOLTIP_I18N[status] + const statusLabelKey = DERIVED_MODEL_STATUS_BADGE_I18N[status as keyof typeof DERIVED_MODEL_STATUS_BADGE_I18N] + const statusTooltipKey = DERIVED_MODEL_STATUS_TOOLTIP_I18N[status as keyof typeof DERIVED_MODEL_STATUS_TOOLTIP_I18N] const isEmpty = status === 'empty' const isActive = status === 'active' diff --git a/web/app/components/header/account-setting/model-provider-page/derive-model-status.ts b/web/app/components/header/account-setting/model-provider-page/derive-model-status.ts index ce4b15de07..f9eb93536e 100644 --- a/web/app/components/header/account-setting/model-provider-page/derive-model-status.ts +++ b/web/app/components/header/account-setting/model-provider-page/derive-model-status.ts @@ -11,19 +11,19 @@ export type DerivedModelStatus | 'disabled' | 'incompatible' -export const DERIVED_MODEL_STATUS_BADGE_I18N: Partial> = { +export const DERIVED_MODEL_STATUS_BADGE_I18N = { 'configure-required': 'modelProvider.selector.configureRequired', 'credits-exhausted': 'modelProvider.selector.creditsExhausted', 'api-key-unavailable': 'modelProvider.selector.apiKeyUnavailable', 'disabled': 'modelProvider.selector.disabled', 'incompatible': 'modelProvider.selector.incompatible', -} +} as const satisfies Partial> -export const DERIVED_MODEL_STATUS_TOOLTIP_I18N: Partial> = { +export const DERIVED_MODEL_STATUS_TOOLTIP_I18N = { 'credits-exhausted': 'modelProvider.selector.creditsExhaustedTip', 'api-key-unavailable': 'modelProvider.selector.apiKeyUnavailableTip', 'incompatible': 'modelProvider.selector.incompatibleTip', -} +} as const satisfies Partial> export const deriveModelStatus = ( modelId: string | undefined, diff --git a/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/trigger.tsx b/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/trigger.tsx index fecd22f5ff..289a08e89e 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/trigger.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-parameter-modal/trigger.tsx @@ -40,10 +40,10 @@ const Trigger: FC = ({ const currentModelProvider = modelProviders.find(p => p.provider === providerName) const credentialState = useCredentialPanelState(currentModelProvider) const status = deriveTriggerStatus(modelId, providerName, currentModelProvider, currentModel, credentialState) - const badgeKey = TRIGGER_STATUS_BADGE_I18N[status] - const tooltipKey = TRIGGER_STATUS_TOOLTIP_I18N[status] - const badgeLabel = badgeKey ? t(badgeKey, { ns: 'common', defaultValue: badgeKey }) : null - const tooltipLabel = tooltipKey ? t(tooltipKey, { ns: 'common', defaultValue: tooltipKey }) : null + const badgeKey = TRIGGER_STATUS_BADGE_I18N[status as keyof typeof TRIGGER_STATUS_BADGE_I18N] + const tooltipKey = TRIGGER_STATUS_TOOLTIP_I18N[status as keyof typeof TRIGGER_STATUS_TOOLTIP_I18N] + const badgeLabel = badgeKey ? t(badgeKey, { ns: 'common' }) : null + const tooltipLabel = tooltipKey ? t(tooltipKey, { ns: 'common' }) : null const isActive = status === 'active' const iconProvider = currentProvider || modelProviders.find(item => item.provider === providerName) diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx index 045e0f7027..9db40714ef 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx @@ -62,10 +62,10 @@ const ModelSelectorTrigger: FC = ({ const isActive = status === 'active' const isDisabled = status !== 'active' && status !== 'empty' - const statusI18nKey = DERIVED_MODEL_STATUS_BADGE_I18N[status] - const tooltipI18nKey = DERIVED_MODEL_STATUS_TOOLTIP_I18N[status] - const statusLabel = statusI18nKey ? t(statusI18nKey, { ns: 'common', defaultValue: statusI18nKey }) : null - const tooltipLabel = tooltipI18nKey ? t(tooltipI18nKey, { ns: 'common', defaultValue: tooltipI18nKey }) : null + const statusI18nKey = DERIVED_MODEL_STATUS_BADGE_I18N[status as keyof typeof DERIVED_MODEL_STATUS_BADGE_I18N] + const tooltipI18nKey = DERIVED_MODEL_STATUS_TOOLTIP_I18N[status as keyof typeof DERIVED_MODEL_STATUS_TOOLTIP_I18N] + const statusLabel = statusI18nKey ? t(statusI18nKey, { ns: 'common' }) : null + const tooltipLabel = tooltipI18nKey ? t(tooltipI18nKey, { ns: 'common' }) : null const isCreditsExhausted = status === 'credits-exhausted' const shouldShowModelMeta = status === 'active' diff --git a/web/app/components/workflow/nodes/knowledge-base/node.tsx b/web/app/components/workflow/nodes/knowledge-base/node.tsx index 82adc13430..4aa10ad208 100644 --- a/web/app/components/workflow/nodes/knowledge-base/node.tsx +++ b/web/app/components/workflow/nodes/knowledge-base/node.tsx @@ -151,7 +151,7 @@ const Node: FC> = ({ data }) => { return t('detailPanel.configureModel', { ns: 'plugin' }) if (embeddingModelStatus !== 'active') { - const statusI18nKey = DERIVED_MODEL_STATUS_BADGE_I18N[embeddingModelStatus] + const statusI18nKey = DERIVED_MODEL_STATUS_BADGE_I18N[embeddingModelStatus as keyof typeof DERIVED_MODEL_STATUS_BADGE_I18N] if (statusI18nKey) return t(statusI18nKey as 'modelProvider.selector.incompatible', { ns: 'common' }) }