mirror of https://github.com/langgenius/dify.git
feat: finish add chunk mode
This commit is contained in:
parent
1578dc50ef
commit
8a8fc7ab50
|
|
@ -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}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Props> = ({
|
||||
isGeneralMode,
|
||||
isQAMode,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const TypeIcon = isGeneralMode ? GeneralType : ParentChildType
|
||||
|
||||
return (
|
||||
<Badge>
|
||||
<div className='flex items-center h-full space-x-0.5 text-text-tertiary'>
|
||||
<TypeIcon className='w-3 h-3' />
|
||||
<span className='system-2xs-medium-uppercase'>{isGeneralMode ? `${t('dataset.chunkingMode.general')}${isQAMode ? ' · QA' : ''}` : t('dataset.chunkingMode.parentChild')}</span>
|
||||
</div>
|
||||
</Badge>
|
||||
)
|
||||
}
|
||||
export default React.memo(ChunkingModeLabel)
|
||||
|
|
@ -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<Props> = ({
|
|||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const {
|
||||
name,
|
||||
extension,
|
||||
|
|
@ -49,7 +52,7 @@ const DocumentPicker: FC<Props> = ({
|
|||
},
|
||||
})
|
||||
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<Props> = ({
|
|||
<div className='flex items-center h-3 text-text-tertiary space-x-0.5'>
|
||||
<TypeIcon className='w-3 h-3' />
|
||||
<span className={cn('system-2xs-medium-uppercase', isParentChild && 'mt-0.5' /* to icon problem cause not ver align */)}>
|
||||
{isParentChild ? 'Parent-Child' : 'General'}
|
||||
{isParentChild ? t('dataset.chunkingMode.parentChild') : t('dataset.chunkingMode.general')}
|
||||
{isParentChild && ` · ${parentMode || '--'}`}
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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<IDocumentListProps> = ({ embeddingAvailable, documents =
|
|||
{t('datasetDocuments.list.table.header.fileName')}
|
||||
</div>
|
||||
</td>
|
||||
<td className='w-[120px]'>{t('datasetDocuments.list.table.header.chunkingMode')}</td>
|
||||
<td className='w-[130px]'>{t('datasetDocuments.list.table.header.chunkingMode')}</td>
|
||||
<td className='w-24'>{t('datasetDocuments.list.table.header.words')}</td>
|
||||
<td className='w-44'>{t('datasetDocuments.list.table.header.hitCount')}</td>
|
||||
<td className='w-44'>
|
||||
|
|
@ -489,7 +490,12 @@ const DocumentList: FC<IDocumentListProps> = ({ embeddingAvailable, documents =
|
|||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>{isGeneralMode ? `general ${isQAMode ? '. QA' : ''}` : 'ParentChilde'}</td>
|
||||
<td>
|
||||
<ChunkingModeLabel
|
||||
isGeneralMode={isGeneralMode}
|
||||
isQAMode={isQAMode}
|
||||
/>
|
||||
</td>
|
||||
<td>{renderCount(doc.word_count)}</td>
|
||||
<td>{renderCount(doc.hit_count)}</td>
|
||||
<td className='text-text-secondary text-[13px]'>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
const translation = {
|
||||
knowledge: 'Knowledge',
|
||||
chunkingMode: {
|
||||
general: 'General',
|
||||
parentChild: 'Parent-child',
|
||||
},
|
||||
externalTag: 'External',
|
||||
externalAPI: 'External API',
|
||||
externalAPIPanelTitle: 'External Knowledge API',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
const translation = {
|
||||
knowledge: '知识库',
|
||||
chunkingMode: {
|
||||
general: '通用',
|
||||
parentChild: '父子',
|
||||
},
|
||||
externalTag: '外部',
|
||||
externalAPI: '外部 API',
|
||||
externalAPIPanelTitle: '外部知识库 API',
|
||||
|
|
|
|||
Loading…
Reference in New Issue