From 2ecdc54b0b378c17b79cefee61c14a8fd8a37579 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Thu, 31 Oct 2024 20:20:46 +0800 Subject: [PATCH] Fix/rerank validation issue (#10131) Co-authored-by: Yi --- .../app/configuration/dataset-config/index.tsx | 16 ++++++++++++++++ .../params-config/config-content.tsx | 2 +- .../dataset-config/params-config/index.tsx | 10 ++++++++-- web/app/components/app/configuration/index.tsx | 10 ++++++++-- .../nodes/knowledge-retrieval/use-config.ts | 2 +- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/web/app/components/app/configuration/dataset-config/index.tsx b/web/app/components/app/configuration/dataset-config/index.tsx index 2c082d8815..0d9d575c1e 100644 --- a/web/app/components/app/configuration/dataset-config/index.tsx +++ b/web/app/components/app/configuration/dataset-config/index.tsx @@ -15,6 +15,7 @@ import { AppType } from '@/types/app' import type { DataSet } from '@/models/datasets' import { getMultipleRetrievalConfig, + getSelectedDatasetsMode, } from '@/app/components/workflow/nodes/knowledge-retrieval/utils' import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks' import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' @@ -38,6 +39,7 @@ const DatasetConfig: FC = () => { isAgent, datasetConfigs, setDatasetConfigs, + setRerankSettingModalOpen, } = useContext(ConfigContext) const formattingChangedDispatcher = useFormattingChangedDispatcher() @@ -55,6 +57,20 @@ const DatasetConfig: FC = () => { ...(datasetConfigs as any), ...retrievalConfig, }) + const { + allExternal, + allInternal, + mixtureInternalAndExternal, + mixtureHighQualityAndEconomic, + inconsistentEmbeddingModel, + } = getSelectedDatasetsMode(filteredDataSets) + + if ( + (allInternal && (mixtureHighQualityAndEconomic || inconsistentEmbeddingModel)) + || mixtureInternalAndExternal + || allExternal + ) + setRerankSettingModalOpen(true) formattingChangedDispatcher() } diff --git a/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx b/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx index f4c7c4ff19..5bd748382e 100644 --- a/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx +++ b/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx @@ -266,7 +266,7 @@ const ConfigContent: FC = ({
{ - selectedDatasetsMode.allEconomic && ( + selectedDatasetsMode.allEconomic && !selectedDatasetsMode.mixtureInternalAndExternal && (
{ let errMsg = '' if (tempDataSetConfigs.retrieval_model === RETRIEVE_TYPE.multiWay) { - if (!tempDataSetConfigs.reranking_model?.reranking_model_name && (rerankDefaultModel && !isRerankDefaultModelValid)) + if (tempDataSetConfigs.reranking_enable + && tempDataSetConfigs.reranking_mode === RerankingModeEnum.RerankingModel + && !isRerankDefaultModelValid + ) errMsg = t('appDebug.datasetConfig.rerankModelRequired') } if (errMsg) { @@ -62,7 +66,9 @@ const ParamsConfig = ({ if (!isValid()) return const config = { ...tempDataSetConfigs } - if (config.retrieval_model === RETRIEVE_TYPE.multiWay && !config.reranking_model) { + if (config.retrieval_model === RETRIEVE_TYPE.multiWay + && config.reranking_mode === RerankingModeEnum.RerankingModel + && !config.reranking_model) { config.reranking_model = { reranking_provider_name: rerankDefaultModel?.provider?.provider, reranking_model_name: rerankDefaultModel?.model, diff --git a/web/app/components/app/configuration/index.tsx b/web/app/components/app/configuration/index.tsx index 12ee7d75ad..639cb2fad1 100644 --- a/web/app/components/app/configuration/index.tsx +++ b/web/app/components/app/configuration/index.tsx @@ -253,12 +253,18 @@ const Configuration: FC = () => { } hideSelectDataSet() const { - allEconomic, + allExternal, + allInternal, + mixtureInternalAndExternal, mixtureHighQualityAndEconomic, inconsistentEmbeddingModel, } = getSelectedDatasetsMode(newDatasets) - if (allEconomic || mixtureHighQualityAndEconomic || inconsistentEmbeddingModel) + if ( + (allInternal && (mixtureHighQualityAndEconomic || inconsistentEmbeddingModel)) + || mixtureInternalAndExternal + || allExternal + ) setRerankSettingModalOpen(true) const { datasets, retrieval_model, score_threshold_enabled, ...restConfigs } = datasetConfigs diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/use-config.ts b/web/app/components/workflow/nodes/knowledge-retrieval/use-config.ts index d280a2d63e..288a718aa2 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/use-config.ts +++ b/web/app/components/workflow/nodes/knowledge-retrieval/use-config.ts @@ -240,7 +240,7 @@ const useConfig = (id: string, payload: KnowledgeRetrievalNodeType) => { if ( (allInternal && (mixtureHighQualityAndEconomic || inconsistentEmbeddingModel)) || mixtureInternalAndExternal - || (allExternal && newDatasets.length > 1) + || allExternal ) setRerankModelOpen(true) }, [inputs, setInputs, payload.retrieval_mode, selectedDatasets, currentRerankModel])