Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: model list refresh when change credential (#26421)

zxhlyh595df172a852
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 b10aeeb47eb..48dc6097953 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
@@ -323,15 +323,18 @@ export const useRefreshModel = () => {
const { eventEmitter } = useEventEmitterContextContext()
const updateModelProviders = useUpdateModelProviders()
const updateModelList = useUpdateModelList()
- const handleRefreshModel = useCallback((provider: ModelProvider, configurationMethod: ConfigurationMethodEnum, CustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields) => {
+ const handleRefreshModel = useCallback((
+ provider: ModelProvider,
+ CustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields,
+ refreshModelList?: boolean,
+ ) => {
updateModelProviders()
provider.supported_model_types.forEach((type) => {
updateModelList(type)
})
- if (configurationMethod === ConfigurationMethodEnum.customizableModel
- && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
+ if (refreshModelList && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
eventEmitter?.emit({
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
payload: provider.provider,
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 14b21be7f77..3136a70563d 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
@@ -90,7 +90,7 @@ export const useAuth = (
type: 'success',
message: t('common.api.actionSuccess'),
})
- handleRefreshModel(provider, configurationMethod, undefined)
+ handleRefreshModel(provider, undefined, true)
}
finally {
handleSetDoingAction(false)
@@ -125,7 +125,7 @@ export const useAuth = (
type: 'success',
message: t('common.api.actionSuccess'),
})
- handleRefreshModel(provider, configurationMethod, undefined)
+ handleRefreshModel(provider, undefined, true)
onRemove?.(pendingOperationCredentialId.current ?? '')
closeConfirmDelete()
}
@@ -147,7 +147,7 @@ export const useAuth = (
if (res.result === 'success') {
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
- handleRefreshModel(provider, configurationMethod, undefined)
+ handleRefreshModel(provider, undefined, !payload.credential_id)
}
}
finally {
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx
index 070c2ee90f0..090147897b5 100644
--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx
@@ -159,7 +159,7 @@ const ModelLoadBalancingModal = ({
)
if (res.result === 'success') {
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
- handleRefreshModel(provider, configurateMethod, currentCustomConfigurationModelFixedFields)
+ handleRefreshModel(provider, currentCustomConfigurationModelFixedFields, false)
onSave?.(provider.provider)
onClose?.()
}