diff --git a/web/app/components/datasets/create/step-two/index.module.css b/web/app/components/datasets/create/step-two/index.module.css index d7864d9667..178cbeba85 100644 --- a/web/app/components/datasets/create/step-two/index.module.css +++ b/web/app/components/datasets/create/step-two/index.module.css @@ -13,17 +13,6 @@ z-index: 10; } -.form { - @apply px-16 py-8; -} - -.form .label { - @apply pb-2 flex items-center text-text-secondary; - font-weight: 500; - font-size: 16px; - line-height: 24px; -} - .segmentationItem { min-height: 68px; } @@ -249,7 +238,7 @@ } .ruleItem { - @apply flex items-center; + @apply flex items-center py-1.5; } .formFooter { diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index 81fe80f67d..1ae566177b 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -63,7 +63,7 @@ import CustomDialog from '@/app/components/base/dialog' import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem' const TextLabel: FC = (props) => { - return + return } type StepTwoProps = { @@ -550,7 +550,7 @@ const StepTwo = ({ getRulesFromDetail() getDefaultMode() } - // eslint-disable-next-line react-hooks/exhaustive-deps + // eslint-disable-next-line react-hooks/exhaustive-deps }, []) useEffect(() => { @@ -578,407 +578,403 @@ const StepTwo = ({ const isHoveringEconomy = useHover(economyDomRef) return ( -
-
-
-
{t('datasetCreation.stepTwo.segmentation')}
-
-
- {(!datasetId || [ChuckingMode.text, ChuckingMode.qa].includes(currentDataset!.doc_form)) - && } - activeHeaderClassName='bg-dataset-option-card-blue-gradient' - description={t('datasetCreation.stepTwo.generalTip')} - isActive={ - [ChuckingMode.text, ChuckingMode.qa].includes( - datasetId ? currentDataset!.doc_form : docForm, - ) - } - onSwitched={() => - handleChangeDocform(ChuckingMode.text) - } - actions={ - <> - - - - } - noHighlight={Boolean(datasetId)} - > -
-
- setSegmentIdentifier(e.target.value)} - /> - - -
-
-
- {t('datasetCreation.stepTwo.rules')} -
- {rules.map(rule => ( -
{ - ruleChangeHandle(rule.id) - }}> - - -
- ))} -
-
-
- {IS_CE_EDITION && <> -
- { - if (docForm === ChuckingMode.qa) - handleChangeDocform(ChuckingMode.text) - else - handleChangeDocform(ChuckingMode.qa) - }} - className='mr-2' - /> -
- - {t('datasetCreation.stepTwo.QALanguage')} - -
- -
- -
-
- {docForm === ChuckingMode.qa && ( -
- - - {t('datasetCreation.stepTwo.QATip')} - -
- )} - } -
-
} - { - (!datasetId || currentDataset!.doc_form === ChuckingMode.parentChild) - && } - effectImg={OrangeEffect.src} - activeHeaderClassName='bg-dataset-option-card-orange-gradient' - description={t('datasetCreation.stepTwo.parentChildTip')} - isActive={ - datasetId ? currentDataset!.doc_form === ChuckingMode.parentChild : docForm === ChuckingMode.parentChild - } - onSwitched={() => handleChangeDocform(ChuckingMode.parentChild)} - actions={ - <> - - - - } - noHighlight={Boolean(datasetId)} - > -
-
- - {t('datasetCreation.stepTwo.parentChunkForContext')} - - } - title={t('datasetCreation.stepTwo.paragraph')} - description={t('datasetCreation.stepTwo.paragraphTip')} - isChosen={parentChildConfig.chunkForContext === 'paragraph'} - onChosen={() => setParentChildConfig( - { - ...parentChildConfig, - chunkForContext: 'paragraph', - }, - )} - chosenConfig={ -
- setParentChildConfig({ - ...parentChildConfig, - parent: { - ...parentChildConfig.parent, - delimiter: e.target.value, - }, - })} - /> - setParentChildConfig({ - ...parentChildConfig, - parent: { - ...parentChildConfig.parent, - maxLength: value, - }, - })} - /> -
- } - /> - } - title={t('datasetCreation.stepTwo.fullDoc')} - description={t('datasetCreation.stepTwo.fullDocTip')} - onChosen={() => setParentChildConfig( - { - ...parentChildConfig, - chunkForContext: 'full-doc', - }, - )} - isChosen={parentChildConfig.chunkForContext === 'full-doc'} - /> -
- -
- - {t('datasetCreation.stepTwo.childChunkForRetrieval')} - -
- setParentChildConfig({ - ...parentChildConfig, - child: { - ...parentChildConfig.child, - delimiter: e.target.value, - }, - })} - /> - setParentChildConfig({ - ...parentChildConfig, - child: { - ...parentChildConfig.child, - maxLength: value, - }, - })} - /> -
- -
- - {t('datasetCreation.stepTwo.rules')} - -
- {rules.map(rule => ( -
{ - ruleChangeHandle(rule.id) - }}> - - -
- ))} -
-
-
-
-
} -
-
- -
{t('datasetCreation.stepTwo.indexMode')}
-
-
- {(!hasSetIndexType || (hasSetIndexType && indexingType === IndexingType.QUALIFIED)) && ( - - {t('datasetCreation.stepTwo.qualified')} - {!hasSetIndexType && {t('datasetCreation.stepTwo.recommend')}} - - {!hasSetIndexType && } - -

} - description={t('datasetCreation.stepTwo.qualifiedTip')} - icon={} - isActive={!hasSetIndexType && indexType === IndexingType.QUALIFIED} - disabled={!isAPIKeySet || hasSetIndexType} - onSwitched={() => { - if (isAPIKeySet) - setIndexType(IndexingType.QUALIFIED) - }} +
+
+
{t('datasetCreation.stepTwo.segmentation')}
+ {(!datasetId || [ChuckingMode.text, ChuckingMode.qa].includes(currentDataset!.doc_form)) + && } + activeHeaderClassName='bg-dataset-option-card-blue-gradient' + description={t('datasetCreation.stepTwo.generalTip')} + isActive={ + [ChuckingMode.text, ChuckingMode.qa].includes( + datasetId ? currentDataset!.doc_form : docForm, + ) + } + onSwitched={() => + handleChangeDocform(ChuckingMode.text) + } + actions={ + <> + + + + } + noHighlight={Boolean(datasetId)} + > +
+
+ setSegmentIdentifier(e.target.value)} /> - )} - - {(!hasSetIndexType || (hasSetIndexType && indexingType === IndexingType.ECONOMICAL)) && ( - <> - setIsQAConfirmDialogOpen(false)} className='w-[432px]'> -
-

- {t('datasetCreation.stepTwo.qaSwitchHighQualityTipTitle')} -

-

- {t('datasetCreation.stepTwo.qaSwitchHighQualityTipContent')} -

-
-
- - + + +
+
+
+
+ {t('datasetCreation.stepTwo.rules')} +
+ +
+
+ {rules.map(rule => ( +
{ + ruleChangeHandle(rule.id) + }}> + +
- - - - } - isActive={!hasSetIndexType && indexType === IndexingType.ECONOMICAL} - disabled={!isAPIKeySet || hasSetIndexType || docForm !== ChuckingMode.text} - ref={economyDomRef} - onSwitched={() => { - if (isAPIKeySet && docForm === ChuckingMode.text) - setIndexType(IndexingType.ECONOMICAL) + ))} + {IS_CE_EDITION && <> +
+ { + if (docForm === ChuckingMode.qa) + handleChangeDocform(ChuckingMode.text) + else + handleChangeDocform(ChuckingMode.qa) }} /> - - -
- { - docForm === ChuckingMode.qa - ? t('datasetCreation.stepTwo.notAvailableForQA') - : t('datasetCreation.stepTwo.notAvailableForParentChild') - } +
+ +
+ +
+
- - - )} +
+ {docForm === ChuckingMode.qa && ( +
+ + + {t('datasetCreation.stepTwo.QATip')} + +
+ )} + } +
+
- {hasSetIndexType && indexType === IndexingType.ECONOMICAL && ( + } + { + (!datasetId || currentDataset!.doc_form === ChuckingMode.parentChild) + && } + effectImg={OrangeEffect.src} + activeHeaderClassName='bg-dataset-option-card-orange-gradient' + description={t('datasetCreation.stepTwo.parentChildTip')} + isActive={ + datasetId ? currentDataset!.doc_form === ChuckingMode.parentChild : docForm === ChuckingMode.parentChild + } + onSwitched={() => handleChangeDocform(ChuckingMode.parentChild)} + actions={ + <> + + + + } + noHighlight={Boolean(datasetId)} + > +
+
+ + {t('datasetCreation.stepTwo.parentChunkForContext')} + + } + title={t('datasetCreation.stepTwo.paragraph')} + description={t('datasetCreation.stepTwo.paragraphTip')} + isChosen={parentChildConfig.chunkForContext === 'paragraph'} + onChosen={() => setParentChildConfig( + { + ...parentChildConfig, + chunkForContext: 'paragraph', + }, + )} + chosenConfig={ +
+ setParentChildConfig({ + ...parentChildConfig, + parent: { + ...parentChildConfig.parent, + delimiter: e.target.value, + }, + })} + /> + setParentChildConfig({ + ...parentChildConfig, + parent: { + ...parentChildConfig.parent, + maxLength: value, + }, + })} + /> +
+ } + /> + } + title={t('datasetCreation.stepTwo.fullDoc')} + description={t('datasetCreation.stepTwo.fullDocTip')} + onChosen={() => setParentChildConfig( + { + ...parentChildConfig, + chunkForContext: 'full-doc', + }, + )} + isChosen={parentChildConfig.chunkForContext === 'full-doc'} + /> +
+ +
+ + {t('datasetCreation.stepTwo.childChunkForRetrieval')} + +
+ setParentChildConfig({ + ...parentChildConfig, + child: { + ...parentChildConfig.child, + delimiter: e.target.value, + }, + })} + /> + setParentChildConfig({ + ...parentChildConfig, + child: { + ...parentChildConfig.child, + maxLength: value, + }, + })} + /> +
+ +
+ + {t('datasetCreation.stepTwo.rules')} + +
+ {rules.map(rule => ( +
{ + ruleChangeHandle(rule.id) + }}> + + +
+ ))} +
+
+
+
+
} + +
{t('datasetCreation.stepTwo.indexMode')}
+
+ {(!hasSetIndexType || (hasSetIndexType && indexingType === IndexingType.QUALIFIED)) && ( + + {t('datasetCreation.stepTwo.qualified')} + {!hasSetIndexType + && {t('datasetCreation.stepTwo.recommend')}} + + {!hasSetIndexType && } + +

} + description={t('datasetCreation.stepTwo.qualifiedTip')} + icon={} + isActive={!hasSetIndexType && indexType === IndexingType.QUALIFIED} + disabled={!isAPIKeySet || hasSetIndexType} + onSwitched={() => { + if (isAPIKeySet) + setIndexType(IndexingType.QUALIFIED) + }} + /> + )} + + {(!hasSetIndexType || (hasSetIndexType && indexingType === IndexingType.ECONOMICAL)) && ( + <> + setIsQAConfirmDialogOpen(false)} className='w-[432px]'> +
+

+ {t('datasetCreation.stepTwo.qaSwitchHighQualityTipTitle')} +

+

+ {t('datasetCreation.stepTwo.qaSwitchHighQualityTipContent')} +

+
+
+ + +
+
+ + + } + isActive={!hasSetIndexType && indexType === IndexingType.ECONOMICAL} + disabled={!isAPIKeySet || hasSetIndexType || docForm !== ChuckingMode.text} + ref={economyDomRef} + onSwitched={() => { + if (isAPIKeySet && docForm === ChuckingMode.text) + setIndexType(IndexingType.ECONOMICAL) + }} + /> + + +
+ { + docForm === ChuckingMode.qa + ? t('datasetCreation.stepTwo.notAvailableForQA') + : t('datasetCreation.stepTwo.notAvailableForParentChild') + } +
+
+
+ )} +
+ {hasSetIndexType && indexType === IndexingType.ECONOMICAL && ( +
+ {t('datasetCreation.stepTwo.indexSettingTip')} + {t('datasetCreation.stepTwo.datasetSettingLink')} +
+ )} + {/* Embedding model */} + {indexType === IndexingType.QUALIFIED && ( +
+
{t('datasetSettings.form.embeddingModel')}
+ { + setEmbeddingModel(model) + }} + /> + {!!datasetId && (
{t('datasetCreation.stepTwo.indexSettingTip')} {t('datasetCreation.stepTwo.datasetSettingLink')}
)} - {/* Embedding model */} - {indexType === IndexingType.QUALIFIED && ( -
-
{t('datasetSettings.form.embeddingModel')}
- { - setEmbeddingModel(model) - }} - /> - {!!datasetId && ( -
- {t('datasetCreation.stepTwo.indexSettingTip')} - {t('datasetCreation.stepTwo.datasetSettingLink')} -
- )} +
+ )} + + {/* Retrieval Method Config */} +
+ {!datasetId + ? ( +
+
{t('datasetSettings.form.retrievalSetting.title')}
+
+ {t('datasetSettings.form.retrievalSetting.learnMore')} + {t('datasetSettings.form.retrievalSetting.longDescription')} +
+
+ ) + : ( +
+
{t('datasetSettings.form.retrievalSetting.title')}
)} - - {/* Retrieval Method Config */} -
- {!datasetId + +
+ { + getIndexing_technique() === IndexingType.QUALIFIED ? ( -
-
{t('datasetSettings.form.retrievalSetting.title')}
-
- {t('datasetSettings.form.retrievalSetting.learnMore')} - {t('datasetSettings.form.retrievalSetting.longDescription')} -
-
+ ) : ( -
-
{t('datasetSettings.form.retrievalSetting.title')}
-
- )} - -
- { - getIndexing_technique() === IndexingType.QUALIFIED - ? ( - - ) - : ( - - ) - } -
-
- - {!isSetting - ? ( -
- - -
- ) - : ( -
- - -
- )} + + ) + }
+ + {!isSetting + ? ( +
+ + +
+ ) + : ( +
+ + +
+ )}
{ }} footer={null}>
} - className={cn(s.previewWrap, isMobile && s.isMobile, 'relative h-full overflow-y-scroll')} + className={cn('flex shrink-0 w-1/2 relative h-full overflow-y-scroll', isMobile && 'w-full max-w-[524px]')} mainClassName='space-y-6' > {docForm === ChuckingMode.qa && estimate?.qa_preview && ( diff --git a/web/app/components/datasets/create/step-two/inputs.tsx b/web/app/components/datasets/create/step-two/inputs.tsx index ab62003da8..3d38a256f1 100644 --- a/web/app/components/datasets/create/step-two/inputs.tsx +++ b/web/app/components/datasets/create/step-two/inputs.tsx @@ -19,8 +19,8 @@ const FormField: FC> = (props) => { export const DelimiterInput: FC = (props) => { const { t } = useTranslation() - return - {t('datasetCreation.stepTwo.separator')} + return + {t('datasetCreation.stepTwo.separator')} @@ -40,7 +40,7 @@ export const DelimiterInput: FC = (props) => { export const MaxLengthInput: FC = (props) => { const { t } = useTranslation() - return + return {t('datasetCreation.stepTwo.maxLength')}
}> = (props) => { export const OverlapInput: FC = (props) => { const { t } = useTranslation() - return - {t('datasetCreation.stepTwo.overlap')} + return + {t('datasetCreation.stepTwo.overlap')} diff --git a/web/app/components/datasets/create/step-two/option-card.tsx b/web/app/components/datasets/create/step-two/option-card.tsx index 80bdce9c07..9d745fa946 100644 --- a/web/app/components/datasets/create/step-two/option-card.tsx +++ b/web/app/components/datasets/create/step-two/option-card.tsx @@ -25,16 +25,16 @@ export const OptionCardHeader: FC = (props) => { )}>
{isActive && effectImg && } -
+
{icon}
-
-
{title}
-
{description}
+
+
{title}
+
{description}
} @@ -57,16 +57,15 @@ export const OptionCard: FC = forwardRef((props, ref) => { const { icon, className, title, description, isActive, children, actions, activeHeaderClassName, style, effectImg, onSwitched, onClick, noHighlight, disabled, ...rest } = props return
{ if (!isActive) @@ -85,7 +84,7 @@ export const OptionCard: FC = forwardRef((props, ref) => { effectImg={effectImg} /> {/** Body */} - {isActive && (children || actions) &&
+ {isActive && (children || actions) &&
{children} {actions &&
{actions} diff --git a/web/app/components/datasets/create/top-bar/index.tsx b/web/app/components/datasets/create/top-bar/index.tsx index 1488d57b8d..c1782f1174 100644 --- a/web/app/components/datasets/create/top-bar/index.tsx +++ b/web/app/components/datasets/create/top-bar/index.tsx @@ -20,7 +20,9 @@ export const Topbar: FC = (props) => { const { t } = useTranslation() return
- +
+ +

{t('datasetCreation.steps.header.creation')}