|
|
|
|
@ -1,13 +1,15 @@
|
|
|
|
|
import { memo } from 'react'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
import { RiAddLine } from '@remixicon/react'
|
|
|
|
|
import { Field } from '@/app/components/workflow/nodes/_base/components/layout'
|
|
|
|
|
import type { ChunkStructureEnum } from '../../types'
|
|
|
|
|
import OptionCard from '../option-card'
|
|
|
|
|
import Selector from './selector'
|
|
|
|
|
import { useChunkStructure } from './hooks'
|
|
|
|
|
import Button from '@/app/components/base/button'
|
|
|
|
|
|
|
|
|
|
type ChunkStructureProps = {
|
|
|
|
|
chunkStructure: ChunkStructureEnum
|
|
|
|
|
chunkStructure?: ChunkStructureEnum
|
|
|
|
|
onChunkStructureChange: (value: ChunkStructureEnum) => void
|
|
|
|
|
readonly?: boolean
|
|
|
|
|
}
|
|
|
|
|
@ -27,7 +29,7 @@ const ChunkStructure = ({
|
|
|
|
|
fieldTitleProps={{
|
|
|
|
|
title: t('workflow.nodes.knowledgeBase.chunkStructure'),
|
|
|
|
|
tooltip: t('workflow.nodes.knowledgeBase.chunkStructure'),
|
|
|
|
|
operation: (
|
|
|
|
|
operation: chunkStructure && (
|
|
|
|
|
<Selector
|
|
|
|
|
options={options}
|
|
|
|
|
value={chunkStructure}
|
|
|
|
|
@ -37,12 +39,34 @@ const ChunkStructure = ({
|
|
|
|
|
),
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<OptionCard
|
|
|
|
|
{...optionMap[chunkStructure]}
|
|
|
|
|
selectedId={chunkStructure}
|
|
|
|
|
enableSelect={false}
|
|
|
|
|
enableHighlightBorder={false}
|
|
|
|
|
/>
|
|
|
|
|
{
|
|
|
|
|
chunkStructure && (
|
|
|
|
|
<OptionCard
|
|
|
|
|
{...optionMap[chunkStructure]}
|
|
|
|
|
selectedId={chunkStructure}
|
|
|
|
|
enableSelect={false}
|
|
|
|
|
enableHighlightBorder={false}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
!chunkStructure && (
|
|
|
|
|
<Selector
|
|
|
|
|
options={options}
|
|
|
|
|
onChange={onChunkStructureChange}
|
|
|
|
|
readonly={readonly}
|
|
|
|
|
trigger={(
|
|
|
|
|
<Button
|
|
|
|
|
className='w-full'
|
|
|
|
|
variant='secondary-accent'
|
|
|
|
|
>
|
|
|
|
|
<RiAddLine className='mr-1 h-4 w-4' />
|
|
|
|
|
{t('workflow.nodes.knowledgeBase.chooseChunkStructure')}
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</Field>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|