diff --git a/web/app/components/base/badge.tsx b/web/app/components/base/badge.tsx index 722fde3237..787b005a8f 100644 --- a/web/app/components/base/badge.tsx +++ b/web/app/components/base/badge.tsx @@ -3,13 +3,15 @@ import cn from '@/utils/classnames' type BadgeProps = { className?: string - text: string + text?: string + children?: React.ReactNode uppercase?: boolean } const Badge = ({ className, text, + children, uppercase = true, }: BadgeProps) => { return ( @@ -20,7 +22,7 @@ const Badge = ({ className, )} > - {text} + {children || text} ) } diff --git a/web/app/components/datasets/common/chunking-mode-label.tsx b/web/app/components/datasets/common/chunking-mode-label.tsx new file mode 100644 index 0000000000..7c6e924009 --- /dev/null +++ b/web/app/components/datasets/common/chunking-mode-label.tsx @@ -0,0 +1,29 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import { useTranslation } from 'react-i18next' +import Badge from '@/app/components/base/badge' +import { GeneralType, ParentChildType } from '@/app/components/base/icons/src/public/knowledge' + +type Props = { + isGeneralMode: boolean + isQAMode: boolean +} + +const ChunkingModeLabel: FC = ({ + isGeneralMode, + isQAMode, +}) => { + const { t } = useTranslation() + const TypeIcon = isGeneralMode ? GeneralType : ParentChildType + + return ( + +
+ + {isGeneralMode ? `${t('dataset.chunkingMode.general')}${isQAMode ? ' · QA' : ''}` : t('dataset.chunkingMode.parentChild')} +
+
+ ) +} +export default React.memo(ChunkingModeLabel) diff --git a/web/app/components/datasets/common/document-picker/index.tsx b/web/app/components/datasets/common/document-picker/index.tsx index a78a004f3b..0f7f0aa69a 100644 --- a/web/app/components/datasets/common/document-picker/index.tsx +++ b/web/app/components/datasets/common/document-picker/index.tsx @@ -3,8 +3,10 @@ import type { FC } from 'react' import React, { useState } from 'react' import { useBoolean } from 'ahooks' import { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react' +import { useTranslation } from 'react-i18next' import FileIcon from '../document-file-icon' -import type { ParentMode, ProcessMode, SimpleDocumentDetail } from '@/models/datasets' +import type { ParentMode, SimpleDocumentDetail } from '@/models/datasets' +import { ProcessMode } from '@/models/datasets' import { PortalToFollowElem, PortalToFollowElemContent, @@ -32,6 +34,7 @@ const DocumentPicker: FC = ({ value, onChange, }) => { + const { t } = useTranslation() const { name, extension, @@ -49,7 +52,7 @@ const DocumentPicker: FC = ({ }, }) const documentsList = data?.data - const isParentChild = processMode === 'hierarchical' + const isParentChild = processMode === ProcessMode.parentChild const TypeIcon = isParentChild ? ParentChildType : GeneralType const [open, { @@ -75,7 +78,7 @@ const DocumentPicker: FC = ({
- {isParentChild ? 'Parent-Child' : 'General'} + {isParentChild ? t('dataset.chunkingMode.parentChild') : t('dataset.chunkingMode.general')} {isParentChild && ` · ${parentMode || '--'}`}
diff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsx index 83c260c4eb..62da976e5e 100644 --- a/web/app/components/datasets/documents/list.tsx +++ b/web/app/components/datasets/documents/list.tsx @@ -18,6 +18,7 @@ import { useTranslation } from 'react-i18next' import dayjs from 'dayjs' import { Edit03 } from '../../base/icons/src/vender/solid/general' import { Globe01 } from '../../base/icons/src/vender/line/mapsAndTravel' +import ChunkingModeLabel from '../common/chunking-mode-label' import s from './style.module.css' import RenameModal from './rename-modal' import cn from '@/utils/classnames' @@ -436,7 +437,7 @@ const DocumentList: FC = ({ embeddingAvailable, documents = {t('datasetDocuments.list.table.header.fileName')} - {t('datasetDocuments.list.table.header.chunkingMode')} + {t('datasetDocuments.list.table.header.chunkingMode')} {t('datasetDocuments.list.table.header.words')} {t('datasetDocuments.list.table.header.hitCount')} @@ -489,7 +490,12 @@ const DocumentList: FC = ({ embeddingAvailable, documents = - {isGeneralMode ? `general ${isQAMode ? '. QA' : ''}` : 'ParentChilde'} + + + {renderCount(doc.word_count)} {renderCount(doc.hit_count)} diff --git a/web/i18n/en-US/dataset.ts b/web/i18n/en-US/dataset.ts index e89ea47c26..59f105adca 100644 --- a/web/i18n/en-US/dataset.ts +++ b/web/i18n/en-US/dataset.ts @@ -1,5 +1,9 @@ const translation = { knowledge: 'Knowledge', + chunkingMode: { + general: 'General', + parentChild: 'Parent-child', + }, externalTag: 'External', externalAPI: 'External API', externalAPIPanelTitle: 'External Knowledge API', diff --git a/web/i18n/zh-Hans/dataset.ts b/web/i18n/zh-Hans/dataset.ts index d057af0c16..801a974cbc 100644 --- a/web/i18n/zh-Hans/dataset.ts +++ b/web/i18n/zh-Hans/dataset.ts @@ -1,5 +1,9 @@ const translation = { knowledge: '知识库', + chunkingMode: { + general: '通用', + parentChild: '父子', + }, externalTag: '外部', externalAPI: '外部 API', externalAPIPanelTitle: '外部知识库 API',