From 22766c27c78249a4c5bd1ce25d5d1468929d7cd7 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Fri, 1 Nov 2024 11:59:48 +0800 Subject: [PATCH] Revert "model list of provider" This reverts commit 766ac3e255147cea3219df1f1c718ecbdeb529ce. --- .../account-setting/model-provider-page/index.tsx | 2 +- .../provider-added-card/credential-panel.tsx | 2 +- .../provider-added-card/index.tsx | 12 ++++++------ .../provider-added-card/model-list.tsx | 2 +- .../model-load-balancing-modal.tsx | 4 ++-- web/context/modal-context.tsx | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/index.tsx b/web/app/components/header/account-setting/model-provider-page/index.tsx index 3a45424a8a..6d508f0de1 100644 --- a/web/app/components/header/account-setting/model-provider-page/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/index.tsx @@ -110,7 +110,7 @@ const ModelProviderPage = ({ searchText }: Props) => { if (configurationMethod === ConfigurationMethodEnum.customizableModel && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) { eventEmitter?.emit({ type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST, - payload: provider, + payload: provider.provider, } as any) if (CustomConfigurationModelFixedFields?.__model_type) diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx index ac82dce3bf..e7f865f198 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx @@ -57,7 +57,7 @@ const CredentialPanel: FC = ({ eventEmitter?.emit({ type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST, - payload: provider, + payload: provider.provider, } as any) } } diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx index 7b7702d6b8..46ef6add24 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx @@ -52,12 +52,12 @@ const ProviderAddedCard: FC = ({ const showQuota = systemConfig.enabled && [...MODEL_PROVIDER_QUOTA_GET_PAID].includes(provider.provider) && !IS_CE_EDITION const showCredential = configurationMethods.includes(ConfigurationMethodEnum.predefinedModel) && isCurrentWorkspaceManager - const getModelList = async (pluginID: string, providerName: string) => { + const getModelList = async (providerName: string) => { if (loading) return try { setLoading(true) - const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${pluginID}/${providerName}/models`) + const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${providerName}/models`) setModelList(modelsData.data) setCollapsed(false) setFetched(true) @@ -72,12 +72,12 @@ const ProviderAddedCard: FC = ({ return } - getModelList(provider.plugin_id, provider.provider) + getModelList(provider.provider) } eventEmitter?.useSubscription((v: any) => { - if (v?.type === UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST && v.payload.provider === provider.provider) - getModelList(v.payload.plugin_id, v.payload.provider) + if (v?.type === UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST && v.payload === provider.provider) + getModelList(v.payload) }) return ( @@ -172,7 +172,7 @@ const ProviderAddedCard: FC = ({ models={modelList} onCollapse={() => setCollapsed(true)} onConfig={currentCustomConfigurationModelFixedFields => onOpenModal(ConfigurationMethodEnum.customizableModel, currentCustomConfigurationModelFixedFields)} - onChange={(provider: ModelProvider) => getModelList(provider.plugin_id, provider.provider)} + onChange={(provider: string) => getModelList(provider)} /> ) } diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx index 3b6a4ccbe5..5e70a0def1 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list.tsx @@ -23,7 +23,7 @@ type ModelListProps = { models: ModelItem[] onCollapse: () => void onConfig: (currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields) => void - onChange?: (provider: ModelProvider) => void + onChange?: (provider: string) => void } const ModelList: FC = ({ provider, 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 84af503af4..edbb4665e9 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 @@ -19,7 +19,7 @@ export type ModelLoadBalancingModalProps = { model: ModelItem open?: boolean onClose?: () => void - onSave?: (provider: ModelProvider) => void + onSave?: (provider: string) => void } // model balancing config modal @@ -94,7 +94,7 @@ const ModelLoadBalancingModal = ({ provider, model, open = false, onClose, onSav if (res.result === 'success') { notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) mutate() - onSave?.(provider) + onSave?.(provider.provider) onClose?.() } } diff --git a/web/context/modal-context.tsx b/web/context/modal-context.tsx index c8383ae336..60d53f1e98 100644 --- a/web/context/modal-context.tsx +++ b/web/context/modal-context.tsx @@ -32,7 +32,7 @@ import OpeningSettingModal from '@/app/components/base/features/new-feature-pane import type { OpeningStatement } from '@/app/components/base/features/types' import type { InputVar } from '@/app/components/workflow/types' -export type ModalState = { +export interface ModalState { payload: T onCancelCallback?: () => void onSaveCallback?: (newPayload: T) => void @@ -43,7 +43,7 @@ export type ModalState = { datasetBindings?: { id: string; name: string }[] } -export type ModelModalType = { +export interface ModelModalType { currentProvider: ModelProvider currentConfigurationMethod: ConfigurationMethodEnum currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields @@ -52,7 +52,7 @@ export type LoadBalancingEntryModalType = ModelModalType & { entry?: ModelLoadBalancingConfigEntry index?: number } -export type ModalContextState = { +export interface ModalContextState { setShowAccountSettingModal: Dispatch | null>> setShowApiBasedExtensionModal: Dispatch | null>> setShowModerationSettingModal: Dispatch | null>> @@ -90,7 +90,7 @@ export const useModalContext = () => useContext(ModalContext) export const useModalContextSelector = (selector: (state: ModalContextState) => T): T => useContextSelector(ModalContext, selector) -type ModalContextProviderProps = { +interface ModalContextProviderProps { children: React.ReactNode } export const ModalContextProvider = ({