diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index c8103b6313..4c908c8fe6 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -58,6 +58,7 @@ import { getNotionInfo, getWebsiteInfo, useCreateDocument, useCreateFirstDocumen import Loading from '@/app/components/base/loading' import Badge from '@/app/components/base/badge' import { SkeletonContanier, SkeletonPoint, SkeletonRectangle, SkeletonRow } from '@/app/components/base/skeleton' +import Tooltip from '@/app/components/base/tooltip' const TextLabel: FC = (props) => { return @@ -166,15 +167,17 @@ const StepTwo = ({ ? IndexingType.QUALIFIED : IndexingType.ECONOMICAL, ) + + // QA Related const [isLanguageSelectDisabled, setIsLanguageSelectDisabled] = useState(false) const [docForm, setDocForm] = useState( (datasetId && documentDetail) ? documentDetail.doc_form : DocForm.TEXT, ) + const [docLanguage, setDocLanguage] = useState( (datasetId && documentDetail) ? documentDetail.doc_language : (locale !== LanguagesSupported[1] ? 'English' : 'Chinese'), ) const [QATipHide, setQATipHide] = useState(false) - const [qaPreviewSwitched, setQAPreviewSwitched] = useState(false) const [parentChildConfig, setParentChildConfig] = useState(defaultParentChildConfig) @@ -255,22 +258,6 @@ const StepTwo = ({ ? notionIndexingEstimateQuery.data : websiteIndexingEstimateQuery.data - // const getIsEstimateReady = useCallback(() => { - // if (dataSourceType === DataSourceType.FILE) - // return fileIndexingEstimateQuery.isSuccess - - // if (dataSourceType === DataSourceType.NOTION) - // return notionIndexingEstimateQuery.isSuccess - - // if (dataSourceType === DataSourceType.WEB) - // return websiteIndexingEstimateQuery.isSuccess - // }, [dataSourceType, fileIndexingEstimateQuery.isSuccess, notionIndexingEstimateQuery.isSuccess, websiteIndexingEstimateQuery.isSuccess]) - - // const getFileName = (name: string) => { - // const arr = name.split('.') - // return arr.slice(0, -1).join('.') - // } - const getRuleName = (key: string) => { if (key === 'remove_extra_spaces') return t('datasetCreation.stepTwo.removeExtraSpaces') @@ -309,7 +296,6 @@ const StepTwo = ({ return } fetchEstimate() - setQAPreviewSwitched(false) } const { @@ -503,7 +489,6 @@ const StepTwo = ({ } const previewSwitch = () => { - setQAPreviewSwitched(true) setIsLanguageSelectDisabled(true) fetchEstimate() } @@ -511,7 +496,7 @@ const StepTwo = ({ const handleSelect = (language: string) => { setDocLanguage(language) // Switch language, re-cutter - if (docForm === DocForm.QA && qaPreviewSwitched) + if (docForm === DocForm.QA) previewSwitch() } @@ -618,6 +603,31 @@ const StepTwo = ({ + {IS_CE_EDITION &&
+ { + if (docForm === DocForm.QA) + setDocForm(DocForm.TEXT) + else + setDocForm(DocForm.QA) + }} + className='mr-2' + /> +
+ + Chunk using Q&A format in + +
+ +
+ +
+
} } className={cn(s.previewWrap, isMobile && s.isMobile, 'relative h-full overflow-y-scroll space-y-4')} > - {qaPreviewSwitched && docForm === DocForm.QA && estimate?.qa_preview && ( + {docForm === DocForm.QA && estimate?.qa_preview && ( estimate?.qa_preview.map(item => ( )) )} - {(docForm === DocForm.TEXT || !qaPreviewSwitched) && estimate?.preview && ( + {docForm === DocForm.TEXT && estimate?.preview && ( estimate?.preview.map((item, index) => ( )) )} - {qaPreviewSwitched && docForm === DocForm.QA && !estimate?.qa_preview && ( + {docForm === DocForm.QA && !estimate?.qa_preview && (
)} - {/* {!qaPreviewSwitched && !estimate?.preview && ( -
- -
- )} */} {currentEstimateMutation.isIdle && (
diff --git a/web/app/components/datasets/create/step-two/language-select/index.tsx b/web/app/components/datasets/create/step-two/language-select/index.tsx index 41f3e0abb5..1e0f2db030 100644 --- a/web/app/components/datasets/create/step-two/language-select/index.tsx +++ b/web/app/components/datasets/create/step-two/language-select/index.tsx @@ -22,6 +22,7 @@ const LanguageSelect: FC = ({ manualClose trigger='click' disabled={disabled} + popupClassName='z-20' htmlContent={
{languages.filter(language => language.supported).map(({ prompt_name }) => (