| 
									
										
										
										
											2025-04-25 17:24:47 +08:00
										 |  |  | import type { FC } from 'react' | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  | import { | 
					
						
							|  |  |  |   memo, | 
					
						
							|  |  |  | } from 'react' | 
					
						
							| 
									
										
										
										
											2025-04-25 17:24:47 +08:00
										 |  |  | import type { KnowledgeBaseNodeType } from './types' | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  | import { | 
					
						
							|  |  |  |   IndexMethodEnum, | 
					
						
							|  |  |  | } from './types' | 
					
						
							| 
									
										
										
										
											2025-04-28 18:36:55 +08:00
										 |  |  | import InputVariable from './components/input-variable' | 
					
						
							|  |  |  | import ChunkStructure from './components/chunk-structure' | 
					
						
							| 
									
										
										
										
											2025-04-28 12:12:33 +08:00
										 |  |  | import IndexMethod from './components/index-method' | 
					
						
							| 
									
										
										
										
											2025-04-28 18:36:55 +08:00
										 |  |  | import RetrievalSetting from './components/retrieval-setting' | 
					
						
							|  |  |  | import EmbeddingModel from './components/embedding-model' | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  | import { useConfig } from './hooks/use-config' | 
					
						
							| 
									
										
										
										
											2025-04-25 17:24:47 +08:00
										 |  |  | import type { NodePanelProps } from '@/app/components/workflow/types' | 
					
						
							| 
									
										
										
										
											2025-04-28 18:36:55 +08:00
										 |  |  | import { | 
					
						
							|  |  |  |   Group, | 
					
						
							|  |  |  |   GroupWithBox, | 
					
						
							|  |  |  | } from '@/app/components/workflow/nodes/_base/components/layout' | 
					
						
							|  |  |  | import Split from '../_base/components/split' | 
					
						
							| 
									
										
										
										
											2025-04-25 17:24:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  | const Panel: FC<NodePanelProps<KnowledgeBaseNodeType>> = ({ | 
					
						
							|  |  |  |   id, | 
					
						
							|  |  |  |   data, | 
					
						
							|  |  |  | }) => { | 
					
						
							|  |  |  |   const { | 
					
						
							|  |  |  |     handleChunkStructureChange, | 
					
						
							|  |  |  |     handleIndexMethodChange, | 
					
						
							|  |  |  |     handleKeywordNumberChange, | 
					
						
							| 
									
										
										
										
											2025-05-07 15:08:13 +08:00
										 |  |  |     handleEmbeddingModelChange, | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  |     handleRetrievalSearchMethodChange, | 
					
						
							|  |  |  |     handleHybridSearchModeChange, | 
					
						
							|  |  |  |     handleWeighedScoreChange, | 
					
						
							|  |  |  |     handleRerankingModelChange, | 
					
						
							| 
									
										
										
										
											2025-05-07 15:08:13 +08:00
										 |  |  |     handleTopKChange, | 
					
						
							|  |  |  |     handleScoreThresholdChange, | 
					
						
							|  |  |  |     handleScoreThresholdEnabledChange, | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  |   } = useConfig(id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-25 17:24:47 +08:00
										 |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2025-04-28 12:12:33 +08:00
										 |  |  |     <div> | 
					
						
							| 
									
										
										
										
											2025-04-28 18:36:55 +08:00
										 |  |  |       <GroupWithBox boxProps={{ withBorderBottom: true }}> | 
					
						
							|  |  |  |         <InputVariable /> | 
					
						
							|  |  |  |       </GroupWithBox> | 
					
						
							|  |  |  |       <Group | 
					
						
							|  |  |  |         className='py-3' | 
					
						
							|  |  |  |         withBorderBottom | 
					
						
							|  |  |  |       > | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  |         <ChunkStructure | 
					
						
							|  |  |  |           chunkStructure={data.chunk_structure} | 
					
						
							|  |  |  |           onChunkStructureChange={handleChunkStructureChange} | 
					
						
							|  |  |  |         /> | 
					
						
							| 
									
										
										
										
											2025-04-28 18:36:55 +08:00
										 |  |  |       </Group> | 
					
						
							|  |  |  |       <GroupWithBox> | 
					
						
							|  |  |  |         <div className='space-y-3'> | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  |           <IndexMethod | 
					
						
							|  |  |  |             indexMethod={data.indexing_technique} | 
					
						
							|  |  |  |             onIndexMethodChange={handleIndexMethodChange} | 
					
						
							|  |  |  |             keywordNumber={data.keyword_number} | 
					
						
							|  |  |  |             onKeywordNumberChange={handleKeywordNumberChange} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             data.indexing_technique === IndexMethodEnum.QUALIFIED && ( | 
					
						
							| 
									
										
										
										
											2025-05-07 15:08:13 +08:00
										 |  |  |               <EmbeddingModel | 
					
						
							|  |  |  |                 embeddingModel={data.embedding_model} | 
					
						
							|  |  |  |                 embeddingModelProvider={data.embedding_model_provider} | 
					
						
							|  |  |  |                 onEmbeddingModelChange={handleEmbeddingModelChange} | 
					
						
							|  |  |  |               /> | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  |             ) | 
					
						
							|  |  |  |           } | 
					
						
							| 
									
										
										
										
											2025-04-28 18:36:55 +08:00
										 |  |  |           <div className='pt-1'> | 
					
						
							|  |  |  |             <Split className='h-[1px]' /> | 
					
						
							|  |  |  |           </div> | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  |           <RetrievalSetting | 
					
						
							|  |  |  |             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} | 
					
						
							| 
									
										
										
										
											2025-05-07 15:08:13 +08:00
										 |  |  |             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} | 
					
						
							| 
									
										
										
										
											2025-05-06 17:24:30 +08:00
										 |  |  |           /> | 
					
						
							| 
									
										
										
										
											2025-04-28 12:12:33 +08:00
										 |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2025-04-28 18:36:55 +08:00
										 |  |  |       </GroupWithBox> | 
					
						
							| 
									
										
										
										
											2025-04-25 17:24:47 +08:00
										 |  |  |     </div> | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default memo(Panel) |