import { RAGFlowAvatar } from '@/components/ragflow-avatar'; import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; import { IRetrievalNode } from '@/interfaces/database/flow'; import { NodeProps, Position } from '@xyflow/react'; import classNames from 'classnames'; import { get } from 'lodash'; import { memo, useMemo } from 'react'; import { NodeHandleId } from '../../constant'; import { useGetVariableLabelByValue } from '../../hooks/use-get-begin-query'; import { CommonHandle } from './handle'; import { LeftHandleStyle, RightHandleStyle } from './handle-icon'; import styles from './index.less'; import NodeHeader from './node-header'; import { NodeWrapper } from './node-wrapper'; import { ToolBar } from './toolbar'; function InnerRetrievalNode({ id, data, isConnectable = true, selected, }: NodeProps) { const knowledgeBaseIds: string[] = get(data, 'form.kb_ids', []); console.log('🚀 ~ InnerRetrievalNode ~ knowledgeBaseIds:', knowledgeBaseIds); const { list: knowledgeList } = useFetchKnowledgeList(true); const knowledgeBases = useMemo(() => { return knowledgeBaseIds.map((x) => { const item = knowledgeList.find((y) => x === y.id); return { name: item?.name, avatar: item?.avatar, id: x, }; }); }, [knowledgeList, knowledgeBaseIds]); const getLabel = useGetVariableLabelByValue(id); return ( 0, })} >
{knowledgeBaseIds.map((id) => { const item = knowledgeList.find((y) => id === y.id); const label = getLabel(id); return (
{label || item?.name}
); })}
); } export const RetrievalNode = memo(InnerRetrievalNode);