mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 20:48:01 +08:00
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 = {
|
type BadgeProps = {
|
||||||
className?: string
|
className?: string
|
||||||
text: string
|
text?: string
|
||||||
|
children?: React.ReactNode
|
||||||
uppercase?: boolean
|
uppercase?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const Badge = ({
|
const Badge = ({
|
||||||
className,
|
className,
|
||||||
text,
|
text,
|
||||||
|
children,
|
||||||
uppercase = true,
|
uppercase = true,
|
||||||
}: BadgeProps) => {
|
}: BadgeProps) => {
|
||||||
return (
|
return (
|
||||||
@ -20,7 +22,7 @@ const Badge = ({
|
|||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{text}
|
{children || text}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
29
web/app/components/datasets/common/chunking-mode-label.tsx
Normal file
29
web/app/components/datasets/common/chunking-mode-label.tsx
Normal file
@ -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 React, { useState } from 'react'
|
||||||
import { useBoolean } from 'ahooks'
|
import { useBoolean } from 'ahooks'
|
||||||
import { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react'
|
import { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import FileIcon from '../document-file-icon'
|
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 {
|
import {
|
||||||
PortalToFollowElem,
|
PortalToFollowElem,
|
||||||
PortalToFollowElemContent,
|
PortalToFollowElemContent,
|
||||||
@ -32,6 +34,7 @@ const DocumentPicker: FC<Props> = ({
|
|||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
extension,
|
extension,
|
||||||
@ -49,7 +52,7 @@ const DocumentPicker: FC<Props> = ({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const documentsList = data?.data
|
const documentsList = data?.data
|
||||||
const isParentChild = processMode === 'hierarchical'
|
const isParentChild = processMode === ProcessMode.parentChild
|
||||||
const TypeIcon = isParentChild ? ParentChildType : GeneralType
|
const TypeIcon = isParentChild ? ParentChildType : GeneralType
|
||||||
|
|
||||||
const [open, {
|
const [open, {
|
||||||
@ -75,7 +78,7 @@ const DocumentPicker: FC<Props> = ({
|
|||||||
<div className='flex items-center h-3 text-text-tertiary space-x-0.5'>
|
<div className='flex items-center h-3 text-text-tertiary space-x-0.5'>
|
||||||
<TypeIcon className='w-3 h-3' />
|
<TypeIcon className='w-3 h-3' />
|
||||||
<span className={cn('system-2xs-medium-uppercase', isParentChild && 'mt-0.5' /* to icon problem cause not ver align */)}>
|
<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 || '--'}`}
|
{isParentChild && ` · ${parentMode || '--'}`}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import { useTranslation } from 'react-i18next'
|
|||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { Edit03 } from '../../base/icons/src/vender/solid/general'
|
import { Edit03 } from '../../base/icons/src/vender/solid/general'
|
||||||
import { Globe01 } from '../../base/icons/src/vender/line/mapsAndTravel'
|
import { Globe01 } from '../../base/icons/src/vender/line/mapsAndTravel'
|
||||||
|
import ChunkingModeLabel from '../common/chunking-mode-label'
|
||||||
import s from './style.module.css'
|
import s from './style.module.css'
|
||||||
import RenameModal from './rename-modal'
|
import RenameModal from './rename-modal'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
@ -436,7 +437,7 @@ const DocumentList: FC<IDocumentListProps> = ({ embeddingAvailable, documents =
|
|||||||
{t('datasetDocuments.list.table.header.fileName')}
|
{t('datasetDocuments.list.table.header.fileName')}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</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-24'>{t('datasetDocuments.list.table.header.words')}</td>
|
||||||
<td className='w-44'>{t('datasetDocuments.list.table.header.hitCount')}</td>
|
<td className='w-44'>{t('datasetDocuments.list.table.header.hitCount')}</td>
|
||||||
<td className='w-44'>
|
<td className='w-44'>
|
||||||
@ -489,7 +490,12 @@ const DocumentList: FC<IDocumentListProps> = ({ embeddingAvailable, documents =
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{isGeneralMode ? `general ${isQAMode ? '. QA' : ''}` : 'ParentChilde'}</td>
|
<td>
|
||||||
|
<ChunkingModeLabel
|
||||||
|
isGeneralMode={isGeneralMode}
|
||||||
|
isQAMode={isQAMode}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
<td>{renderCount(doc.word_count)}</td>
|
<td>{renderCount(doc.word_count)}</td>
|
||||||
<td>{renderCount(doc.hit_count)}</td>
|
<td>{renderCount(doc.hit_count)}</td>
|
||||||
<td className='text-text-secondary text-[13px]'>
|
<td className='text-text-secondary text-[13px]'>
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
const translation = {
|
const translation = {
|
||||||
knowledge: 'Knowledge',
|
knowledge: 'Knowledge',
|
||||||
|
chunkingMode: {
|
||||||
|
general: 'General',
|
||||||
|
parentChild: 'Parent-child',
|
||||||
|
},
|
||||||
externalTag: 'External',
|
externalTag: 'External',
|
||||||
externalAPI: 'External API',
|
externalAPI: 'External API',
|
||||||
externalAPIPanelTitle: 'External Knowledge API',
|
externalAPIPanelTitle: 'External Knowledge API',
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
const translation = {
|
const translation = {
|
||||||
knowledge: '知识库',
|
knowledge: '知识库',
|
||||||
|
chunkingMode: {
|
||||||
|
general: '通用',
|
||||||
|
parentChild: '父子',
|
||||||
|
},
|
||||||
externalTag: '外部',
|
externalTag: '外部',
|
||||||
externalAPI: '外部 API',
|
externalAPI: '外部 API',
|
||||||
externalAPIPanelTitle: '外部知识库 API',
|
externalAPIPanelTitle: '外部知识库 API',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user