import { Input } from '@/components/ui/input'; import { Sheet, SheetContent, SheetHeader, SheetTitle, } from '@/components/ui/sheet'; import { IModalProps } from '@/interfaces/common'; import { RAGFlowNodeType } from '@/interfaces/database/flow'; import { cn } from '@/lib/utils'; import { lowerFirst } from 'lodash'; import { Play, X } from 'lucide-react'; import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { BeginId, Operator } from '../constant'; import { AgentFormContext } from '../context'; import { RunTooltip } from '../flow-tooltip'; import { useHandleNodeNameChange } from '../hooks/use-change-node-name'; import OperatorIcon from '../operator-icon'; import useGraphStore from '../store'; import { needsSingleStepDebugging } from '../utils'; import { FormConfigMap } from './form-config-map'; import SingleDebugSheet from './single-debug-sheet'; interface IProps { node?: RAGFlowNodeType; singleDebugDrawerVisible: IModalProps['visible']; hideSingleDebugDrawer: IModalProps['hideModal']; showSingleDebugDrawer: IModalProps['showModal']; chatVisible: boolean; } const EmptyContent = () =>
; const FormSheet = ({ visible, hideModal, node, singleDebugDrawerVisible, chatVisible, hideSingleDebugDrawer, showSingleDebugDrawer, }: IModalProps & IProps) => { const operatorName: Operator = node?.data.label as Operator; const clickedToolId = useGraphStore((state) => state.clickedToolId); const currentFormMap = FormConfigMap[operatorName]; const OperatorForm = currentFormMap?.component ?? EmptyContent; const { name, handleNameBlur, handleNameChange } = useHandleNodeNameChange({ id: node?.id, data: node?.data, }); const isMcp = useMemo(() => { return ( operatorName === Operator.Tool && Object.values(Operator).every((x) => x !== clickedToolId) ); }, [clickedToolId, operatorName]); const { t } = useTranslation(); return (
{isMcp ? (
MCP Config
) : (
{node?.id === BeginId ? ( {t(BeginId)} ) : ( )}
)} {needsSingleStepDebugging(operatorName) && ( )}
{isMcp || ( {t( `dataflow.${lowerFirst(operatorName === Operator.Tool ? clickedToolId : operatorName)}Description`, )} )}
{visible && ( )}
{singleDebugDrawerVisible && ( )}
); }; export default FormSheet;