From c82b6413573479ff6a165a5ff71d986e5fab4e2e Mon Sep 17 00:00:00 2001 From: JzoNg Date: Fri, 1 Nov 2024 11:59:45 +0800 Subject: [PATCH] Revert "get credentials of provider" This reverts commit 72ef04d3e43e8acebf127daf06a837bc3500412b. --- .../header/account-setting/model-provider-page/hooks.ts | 7 +++---- .../model-provider-page/model-modal/index.tsx | 2 +- .../provider-added-card/model-load-balancing-modal.tsx | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) 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 36aba3bc39..95bbd24f4a 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 @@ -11,7 +11,6 @@ import type { DefaultModel, DefaultModelResponse, Model, - ModelProvider, ModelTypeEnum, } from './declarations' import { @@ -64,20 +63,20 @@ export const useLanguage = () => { } export const useProviderCredentialsAndLoadBalancing = ( - provider: ModelProvider, + provider: string, configurationMethod: ConfigurationMethodEnum, configured?: boolean, currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields, ) => { const { data: predefinedFormSchemasValue, mutate: mutatePredefined } = useSWR( (configurationMethod === ConfigurationMethodEnum.predefinedModel && configured) - ? `/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/credentials` + ? `/workspaces/current/model-providers/${provider}/credentials` : null, fetchModelProviderCredentials, ) const { data: customFormSchemasValue, mutate: mutateCustomized } = useSWR( (configurationMethod === ConfigurationMethodEnum.customizableModel && currentCustomConfigurationModelFixedFields) - ? `/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/models/credentials?model=${currentCustomConfigurationModelFixedFields?.__model_name}&model_type=${currentCustomConfigurationModelFixedFields?.__model_type}` + ? `/workspaces/current/model-providers/${provider}/models/credentials?model=${currentCustomConfigurationModelFixedFields?.__model_name}&model_type=${currentCustomConfigurationModelFixedFields?.__model_type}` : null, fetchModelProviderCredentials, ) diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx index 0bb6942428..967bcccdca 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx @@ -72,7 +72,7 @@ const ModelModal: FC = ({ loadBalancing: originalConfig, mutate, } = useProviderCredentialsAndLoadBalancing( - provider, + provider.provider, configurateMethod, providerFormSchemaPredefined && provider.custom_configuration.status === CustomConfigurationStatusEnum.active, currentCustomConfigurationModelFixedFields, 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 a58d6e13e7..84af503af4 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 @@ -30,7 +30,7 @@ const ModelLoadBalancingModal = ({ provider, model, open = false, onClose, onSav const [loading, setLoading] = useState(false) const { data, mutate } = useSWR( - `/workspaces/current/model-providers/${provider.plugin_id}/${provider.provider}/models/credentials?model=${model.model}&model_type=${model.model_type}`, + `/workspaces/current/model-providers/${provider.provider}/models/credentials?model=${model.model}&model_type=${model.model_type}`, fetchModelLoadBalancingConfig, )