import type { FC } from 'react' import { memo, useCallback, } from 'react' import { useTranslation } from 'react-i18next' import type { KnowledgeBaseNodeType } from './types' import { ChunkStructureEnum, IndexMethodEnum, } from './types' import ChunkStructure from './components/chunk-structure' import IndexMethod from './components/index-method' import RetrievalSetting from './components/retrieval-setting' import EmbeddingModel from './components/embedding-model' import { useConfig } from './hooks/use-config' import type { NodePanelProps } from '@/app/components/workflow/types' import { BoxGroup, BoxGroupField, Group, } from '@/app/components/workflow/nodes/_base/components/layout' import Split from '../_base/components/split' import { useNodesReadOnly } from '@/app/components/workflow/hooks' import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' import type { Var } from '@/app/components/workflow/types' import { CHUNK_TYPE_MAP } from '@/app/components/workflow/utils/tool' const Panel: FC> = ({ id, data, }) => { const { t } = useTranslation() const { nodesReadOnly } = useNodesReadOnly() const { handleChunkStructureChange, handleIndexMethodChange, handleKeywordNumberChange, handleEmbeddingModelChange, handleRetrievalSearchMethodChange, handleHybridSearchModeChange, handleWeighedScoreChange, handleRerankingModelChange, handleTopKChange, handleScoreThresholdChange, handleScoreThresholdEnabledChange, handleInputVariableChange, } = useConfig(id) const filterVar = useCallback((variable: Var) => { if (data.chunk_structure === ChunkStructureEnum.general && variable.alias === CHUNK_TYPE_MAP.general_chunks) return true if (data.chunk_structure === ChunkStructureEnum.parent_child && variable.alias === CHUNK_TYPE_MAP.parent_child_chunks) return true if (data.chunk_structure === ChunkStructureEnum.question_answer && variable.alias === CHUNK_TYPE_MAP.qa_chunks) return true return false }, [data.chunk_structure]) return (
{ data.chunk_structure && ( <> { data.indexing_technique === IndexMethodEnum.QUALIFIED && ( ) }
) }
) } export default memo(Panel)