From 79412640e08b244fe9c2872695b01c6bbe984ceb Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Mon, 9 Sep 2024 15:32:02 +0800 Subject: [PATCH] chore: offline n to 1 retrieval (#8134) --- .../params-config/config-content.tsx | 93 ++++--------------- web/i18n/en-US/dataset.ts | 1 + web/i18n/zh-Hans/dataset.ts | 1 + 3 files changed, 22 insertions(+), 73 deletions(-) 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 7f55649dab89cd..91cae54bb8e7ea 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 @@ -1,20 +1,12 @@ 'use client' -import { memo, useMemo } from 'react' +import { memo, useEffect, useMemo } from 'react' import type { FC } from 'react' import { useTranslation } from 'react-i18next' -import { - RiAlertFill, -} from '@remixicon/react' import WeightedScore from './weighted-score' import TopKItem from '@/app/components/base/param-item/top-k-item' import ScoreThresholdItem from '@/app/components/base/param-item/score-threshold-item' -import RadioCard from '@/app/components/base/radio-card/simple' import { RETRIEVE_TYPE } from '@/types/app' -import { - MultiPathRetrieval, - NTo1Retrieval, -} from '@/app/components/base/icons/src/public/common' import type { DatasetConfigs, } from '@/models/debug' @@ -31,7 +23,6 @@ import { RerankingModeEnum } from '@/models/datasets' import cn from '@/utils/classnames' import { useSelectedDatasetsMode } from '@/app/components/workflow/nodes/knowledge-retrieval/hooks' import Switch from '@/app/components/base/switch' -import { useGetLanguage } from '@/context/i18n' type Props = { datasetConfigs: DatasetConfigs @@ -43,11 +34,6 @@ type Props = { selectedDatasets?: DataSet[] } -const LEGACY_LINK_MAP = { - en_US: 'https://docs.dify.ai/guides/knowledge-base/integrate-knowledge-within-application', - zh_Hans: 'https://docs.dify.ai/v/zh-hans/guides/knowledge-base/integrate_knowledge_within_application', -} as Record - const ConfigContent: FC = ({ datasetConfigs, onChange, @@ -58,15 +44,18 @@ const ConfigContent: FC = ({ selectedDatasets = [], }) => { const { t } = useTranslation() - const language = useGetLanguage() const selectedDatasetsMode = useSelectedDatasetsMode(selectedDatasets) const type = datasetConfigs.retrieval_model - const setType = (value: RETRIEVE_TYPE) => { - onChange({ - ...datasetConfigs, - retrieval_model: value, - }, true) - } + + useEffect(() => { + if (type === RETRIEVE_TYPE.oneWay) { + onChange({ + ...datasetConfigs, + retrieval_model: RETRIEVE_TYPE.multiWay, + }, isInWorkflow) + } + }, [type]) + const { modelList: rerankModelList, defaultModel: rerankDefaultModel, @@ -166,63 +155,21 @@ const ConfigContent: FC = ({ return (
{t('dataset.retrievalSettings')}
-
- } - title={( -
- {t('appDebug.datasetConfig.retrieveOneWay.title')} - - {t('dataset.nTo1RetrievalLegacy')} -
- )} - > -
legacy
- -
- )} - description={t('appDebug.datasetConfig.retrieveOneWay.description')} - isChosen={type === RETRIEVE_TYPE.oneWay} - onChosen={() => { setType(RETRIEVE_TYPE.oneWay) }} - extra={( -
- -
- {t('dataset.nTo1RetrievalLegacyLinkText')} - - {t('dataset.nTo1RetrievalLegacyLink')} - -
-
- )} - /> - } - title={t('appDebug.datasetConfig.retrieveMultiWay.title')} - description={t('appDebug.datasetConfig.retrieveMultiWay.description')} - isChosen={type === RETRIEVE_TYPE.multiWay} - onChosen={() => { setType(RETRIEVE_TYPE.multiWay) }} - /> +
+ {t('dataset.defaultRetrievalTip')}
{type === RETRIEVE_TYPE.multiWay && ( <> -
-
- {t('dataset.rerankSettings')} +
+
+ {t('dataset.rerankSettings')} +
+
{ selectedDatasetsMode.inconsistentEmbeddingModel && ( -
+
{t('dataset.inconsistentEmbeddingModelTip')}
) @@ -230,7 +177,7 @@ const ConfigContent: FC = ({ { selectedDatasetsMode.mixtureHighQualityAndEconomic && ( -
+
{t('dataset.mixtureHighQualityAndEconomicTip')}
) diff --git a/web/i18n/en-US/dataset.ts b/web/i18n/en-US/dataset.ts index e6914b4a00beee..a15efe5dc0753d 100644 --- a/web/i18n/en-US/dataset.ts +++ b/web/i18n/en-US/dataset.ts @@ -55,6 +55,7 @@ const translation = { hybrid_search: 'HYBRID', invertedIndex: 'INVERTED', }, + defaultRetrievalTip: 'Multi-path retrieval is used by default. Knowledge is retrieved from multiple knowledge bases and then re-ranked.', mixtureHighQualityAndEconomicTip: 'The Rerank model is required for mixture of high quality and economical knowledge bases.', inconsistentEmbeddingModelTip: 'The Rerank model is required if the Embedding models of the selected knowledge bases are inconsistent.', retrievalSettings: 'Retrieval Setting', diff --git a/web/i18n/zh-Hans/dataset.ts b/web/i18n/zh-Hans/dataset.ts index f76be97818da9f..013830af6fce6d 100644 --- a/web/i18n/zh-Hans/dataset.ts +++ b/web/i18n/zh-Hans/dataset.ts @@ -55,6 +55,7 @@ const translation = { hybrid_search: '混合检索', invertedIndex: '倒排索引', }, + defaultRetrievalTip: '默认情况下使用多路召回。从多个知识库中检索知识,然后重新排序。', mixtureHighQualityAndEconomicTip: '混合使用高质量和经济型知识库需要配置 Rerank 模型。', inconsistentEmbeddingModelTip: '当所选知识库配置的 Embedding 模型不一致时,需要配置 Rerank 模型。', retrievalSettings: '召回设置',