| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | 
							- 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'
 - 
 - const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = ({
 -   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) return false
 -     switch (data.chunk_structure) {
 -       case ChunkStructureEnum.general:
 -         return variable.schemaType === 'general_structure'
 -       case ChunkStructureEnum.parent_child:
 -         return variable.schemaType === 'parent_child_structure'
 -       case ChunkStructureEnum.question_answer:
 -         return variable.schemaType === 'qa_structure'
 -       default:
 -         return false
 -     }
 -   }, [data.chunk_structure])
 - 
 -   return (
 -     <div>
 -       <Group
 -         className='py-3'
 -         withBorderBottom={!!data.chunk_structure}
 -       >
 -         <ChunkStructure
 -           chunkStructure={data.chunk_structure}
 -           onChunkStructureChange={handleChunkStructureChange}
 -           readonly={nodesReadOnly}
 -         />
 -       </Group>
 -       {
 -         data.chunk_structure && (
 -           <>
 -             <BoxGroupField
 -               boxGroupProps={{
 -                 boxProps: { withBorderBottom: true },
 -               }}
 -               fieldProps={{
 -                 fieldTitleProps: {
 -                   title: t('workflow.nodes.common.inputVars'),
 -                 },
 -               }}
 -             >
 -               <VarReferencePicker
 -                 nodeId={id}
 -                 isShowNodeName
 -                 value={data.index_chunk_variable_selector}
 -                 onChange={handleInputVariableChange}
 -                 readonly={nodesReadOnly}
 -                 filterVar={filterVar}
 -                 isFilterFileVar
 -                 isSupportFileVar={false}
 -                 preferSchemaType
 -               />
 -             </BoxGroupField>
 -             <BoxGroup>
 -               <div className='space-y-3'>
 -                 <IndexMethod
 -                   chunkStructure={data.chunk_structure}
 -                   indexMethod={data.indexing_technique}
 -                   onIndexMethodChange={handleIndexMethodChange}
 -                   keywordNumber={data.keyword_number}
 -                   onKeywordNumberChange={handleKeywordNumberChange}
 -                   readonly={nodesReadOnly}
 -                 />
 -                 {
 -                   data.indexing_technique === IndexMethodEnum.QUALIFIED && (
 -                     <EmbeddingModel
 -                       embeddingModel={data.embedding_model}
 -                       embeddingModelProvider={data.embedding_model_provider}
 -                       onEmbeddingModelChange={handleEmbeddingModelChange}
 -                       readonly={nodesReadOnly}
 -                     />
 -                   )
 -                 }
 -                 <div className='pt-1'>
 -                   <Split className='h-[1px]' />
 -                 </div>
 -                 <RetrievalSetting
 -                   indexMethod={data.indexing_technique}
 -                   searchMethod={data.retrieval_model.search_method}
 -                   onRetrievalSearchMethodChange={handleRetrievalSearchMethodChange}
 -                   hybridSearchMode={data.retrieval_model.hybridSearchMode}
 -                   onHybridSearchModeChange={handleHybridSearchModeChange}
 -                   weightedScore={data.retrieval_model.weights}
 -                   onWeightedScoreChange={handleWeighedScoreChange}
 -                   rerankingModel={data.retrieval_model.reranking_model}
 -                   onRerankingModelChange={handleRerankingModelChange}
 -                   topK={data.retrieval_model.top_k}
 -                   onTopKChange={handleTopKChange}
 -                   scoreThreshold={data.retrieval_model.score_threshold}
 -                   onScoreThresholdChange={handleScoreThresholdChange}
 -                   isScoreThresholdEnabled={data.retrieval_model.score_threshold_enabled}
 -                   onScoreThresholdEnabledChange={handleScoreThresholdEnabledChange}
 -                   readonly={nodesReadOnly}
 -                 />
 -               </div>
 -             </BoxGroup>
 -           </>
 -         )
 -       }
 -     </div>
 -   )
 - }
 - 
 - export default memo(Panel)
 
 
  |