From 0a891e5392a646bc31a76f8714775a47fa60a820 Mon Sep 17 00:00:00 2001 From: twwu Date: Tue, 13 May 2025 16:17:59 +0800 Subject: [PATCH] feat: Update retrieval method configuration to use new OptionCard component and improve layout --- .../index.tsx | 39 ++-- .../common/retrieval-method-config/index.tsx | 73 ++++--- .../datasets/settings/form/index.tsx | 189 ++++++++++-------- 3 files changed, 172 insertions(+), 129 deletions(-) diff --git a/web/app/components/datasets/common/economical-retrieval-method-config/index.tsx b/web/app/components/datasets/common/economical-retrieval-method-config/index.tsx index 17cb3ef123..024ba075b6 100644 --- a/web/app/components/datasets/common/economical-retrieval-method-config/index.tsx +++ b/web/app/components/datasets/common/economical-retrieval-method-config/index.tsx @@ -2,12 +2,12 @@ import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' -import Image from 'next/image' import RetrievalParamConfig from '../retrieval-param-config' -import { OptionCard } from '../../create/step-two/option-card' -import { retrievalIcon } from '../../create/icons' import { RETRIEVE_METHOD } from '@/types/app' import type { RetrievalConfig } from '@/types/app' +import OptionCard from '../../settings/option-card' +import { VectorSearch } from '@/app/components/base/icons/src/vender/knowledge' +import { EffectColor } from '../../settings/chunk-structure/types' type Props = { disabled?: boolean @@ -23,20 +23,25 @@ const EconomicalRetrievalMethodConfig: FC = ({ const { t } = useTranslation() return ( -
- } - title={t('dataset.retrieval.invertedIndex.title')} - description={t('dataset.retrieval.invertedIndex.description')} isActive - activeHeaderClassName='bg-dataset-option-card-purple-gradient' - > - - -
+ } + iconActiveColor='text-util-colors-purple-purple-600' + title={t('dataset.retrieval.invertedIndex.title')} + description={t('dataset.retrieval.invertedIndex.description')} + isActive + effectColor={EffectColor.purple} + showEffectColor + showChildren + className='gap-x-2' + > + + ) } export default React.memo(EconomicalRetrievalMethodConfig) diff --git a/web/app/components/datasets/common/retrieval-method-config/index.tsx b/web/app/components/datasets/common/retrieval-method-config/index.tsx index f979447857..57d357442f 100644 --- a/web/app/components/datasets/common/retrieval-method-config/index.tsx +++ b/web/app/components/datasets/common/retrieval-method-config/index.tsx @@ -2,11 +2,7 @@ import type { FC } from 'react' import React, { useCallback } from 'react' import { useTranslation } from 'react-i18next' -import Image from 'next/image' import RetrievalParamConfig from '../retrieval-param-config' -import { OptionCard } from '../../create/step-two/option-card' -import Effect from '../../create/assets/option-card-effect-purple.svg' -import { retrievalIcon } from '../../create/icons' import type { RetrievalConfig } from '@/types/app' import { RETRIEVE_METHOD } from '@/types/app' import { useProviderContext } from '@/context/provider-context' @@ -17,7 +13,9 @@ import { RerankingModeEnum, WeightedScoreEnum, } from '@/models/datasets' -import Badge from '@/app/components/base/badge' +import OptionCard from '../../settings/option-card' +import { FullTextSearch, HybridSearch, VectorSearch } from '@/app/components/base/icons/src/vender/knowledge' +import { EffectColor } from '../../settings/chunk-structure/types' type Props = { disabled?: boolean @@ -92,17 +90,21 @@ const RetrievalMethodConfig: FC = ({ }, [value, rerankDefaultModel, isRerankDefaultModelValid, onChange]) return ( -
+
{supportRetrievalMethods.includes(RETRIEVE_METHOD.semantic) && ( - } + } + iconActiveColor='text-util-colors-purple-purple-600' title={t('dataset.retrieval.semantic_search.title')} description={t('dataset.retrieval.semantic_search.description')} - isActive={ - value.search_method === RETRIEVE_METHOD.semantic - } - onSwitched={() => onSwitch(RETRIEVE_METHOD.semantic)} - effectImg={Effect.src} - activeHeaderClassName='bg-dataset-option-card-purple-gradient' + isActive={value.search_method === RETRIEVE_METHOD.semantic} + onClick={onSwitch} + effectColor={EffectColor.purple} + showEffectColor + showChildren={value.search_method === RETRIEVE_METHOD.semantic} + className='gap-x-2' > = ({ )} {supportRetrievalMethods.includes(RETRIEVE_METHOD.fullText) && ( - } + } + iconActiveColor='text-util-colors-purple-purple-600' title={t('dataset.retrieval.full_text_search.title')} description={t('dataset.retrieval.full_text_search.description')} - isActive={ - value.search_method === RETRIEVE_METHOD.fullText - } - onSwitched={() => onSwitch(RETRIEVE_METHOD.fullText)} - effectImg={Effect.src} - activeHeaderClassName='bg-dataset-option-card-purple-gradient' + isActive={value.search_method === RETRIEVE_METHOD.fullText} + onClick={onSwitch} + effectColor={EffectColor.purple} + showEffectColor + showChildren={value.search_method === RETRIEVE_METHOD.fullText} + className='gap-x-2' > = ({ )} {supportRetrievalMethods.includes(RETRIEVE_METHOD.hybrid) && ( - } - title={ -
-
{t('dataset.retrieval.hybrid_search.title')}
- -
- } - description={t('dataset.retrieval.hybrid_search.description')} isActive={ - value.search_method === RETRIEVE_METHOD.hybrid - } - onSwitched={() => onSwitch(RETRIEVE_METHOD.hybrid)} - effectImg={Effect.src} - activeHeaderClassName='bg-dataset-option-card-purple-gradient' + } + iconActiveColor='text-util-colors-purple-purple-600' + title={t('dataset.retrieval.hybrid_search.title')} + description={t('dataset.retrieval.hybrid_search.description')} + isActive={value.search_method === RETRIEVE_METHOD.hybrid} + onClick={onSwitch} + effectColor={EffectColor.purple} + showEffectColor + isRecommended + showChildren={value.search_method === RETRIEVE_METHOD.hybrid} + className='gap-x-2' > { } = useModelListAndDefaultModelAndCurrentProviderAndModel(ModelTypeEnum.rerank) const { data: embeddingModelList } = useModelList(ModelTypeEnum.textEmbedding) const previousAppIcon = useRef(DEFAULT_APP_ICON) + const docLanguage = useGetDocLanguage() const getMembers = async () => { const { accounts } = await fetchMembers({ url: '/workspaces/current/members', params: {} }) @@ -181,6 +183,7 @@ const Form = () => { score_threshold_enabled: scoreThresholdEnabled, }, }), + keyword_number: keywordNumber, }, } as any if (permission === DatasetPermission.partialMembers) { @@ -273,22 +276,20 @@ const Form = () => { /> {/* Chunk Structure */}
-
-
-
- {t('datasetSettings.form.chunkStructure.title')} -
-
- - {t('datasetSettings.form.chunkStructure.learnMore')} - - {t('datasetSettings.form.chunkStructure.description')} -
+
+
+ {t('datasetSettings.form.chunkStructure.title')} +
+
+ + {t('datasetSettings.form.chunkStructure.learnMore')} + + {t('datasetSettings.form.chunkStructure.description')}
@@ -353,80 +354,110 @@ const Form = () => { )} {/* Retrieval Method Config */} {currentDataset?.provider === 'external' - ? <> -
-
-
-
{t('datasetSettings.form.retrievalSetting.title')}
-
- + -
-
-
-
-
{t('datasetSettings.form.externalKnowledgeAPI')}
-
-
-
- -
- {currentDataset?.external_knowledge_info.external_knowledge_api_name} -
-
·
-
{currentDataset?.external_knowledge_info.external_knowledge_api_endpoint}
-
-
-
-
-
-
{t('datasetSettings.form.externalKnowledgeID')}
-
-
-
-
{currentDataset?.external_knowledge_info.external_knowledge_id}
-
-
-
- - : indexMethod - ? <> -
-
-
{t('datasetSettings.form.retrievalSetting.title')}
-
- {t('datasetSettings.form.retrievalSetting.learnMore')} - {t('datasetSettings.form.retrievalSetting.description')} +
{t('datasetSettings.form.retrievalSetting.title')}
+
+ +
+ +
+
+
{t('datasetSettings.form.externalKnowledgeAPI')}
+
+
+
+ +
+ {currentDataset?.external_knowledge_info.external_knowledge_api_name} +
+
·
+
+ {currentDataset?.external_knowledge_info.external_knowledge_api_endpoint}
-
- {indexMethod === IndexingType.QUALIFIED - ? ( - - ) - : ( - - )} +
+
+
+
{t('datasetSettings.form.externalKnowledgeID')}
+
+
+
+
+ {currentDataset?.external_knowledge_info.external_knowledge_id} +
+
+ ) + // eslint-disable-next-line sonarjs/no-nested-conditional + : indexMethod + ? ( + <> + +
+
+
+
+ {t('datasetSettings.form.retrievalSetting.title')} +
+
+ + {t('datasetSettings.form.retrievalSetting.learnMore')} + + {t('datasetSettings.form.retrievalSetting.description')} +
+
+
+
+ {indexMethod === IndexingType.QUALIFIED + ? ( + + ) + : ( + + )} +
+
+ + ) : null } -
+