mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-16 20:57:21 +08:00
### What problem does this PR solve? Feat: Constructing query parameter options for the Retrieval operator #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import { useTheme } from '@/components/theme-provider';
|
|
import { IAgentNode } from '@/interfaces/database/flow';
|
|
import { Handle, NodeProps, Position } from '@xyflow/react';
|
|
import classNames from 'classnames';
|
|
import { memo, useMemo } from 'react';
|
|
import { Operator } from '../../constant';
|
|
import useGraphStore from '../../store';
|
|
import { LeftHandleStyle, RightHandleStyle } from './handle-icon';
|
|
import styles from './index.less';
|
|
import NodeHeader from './node-header';
|
|
|
|
function InnerAgentNode({
|
|
id,
|
|
data,
|
|
isConnectable = true,
|
|
selected,
|
|
}: NodeProps<IAgentNode>) {
|
|
const { theme } = useTheme();
|
|
const getNode = useGraphStore((state) => state.getNode);
|
|
const edges = useGraphStore((state) => state.edges);
|
|
|
|
const isNotParentAgent = useMemo(() => {
|
|
const edge = edges.find((x) => x.target === id);
|
|
const label = getNode(edge?.source)?.data.label;
|
|
return label !== Operator.Agent;
|
|
}, [edges, getNode, id]);
|
|
|
|
return (
|
|
<section
|
|
className={classNames(
|
|
styles.ragNode,
|
|
theme === 'dark' ? styles.dark : '',
|
|
{
|
|
[styles.selectedNode]: selected,
|
|
},
|
|
)}
|
|
>
|
|
{isNotParentAgent && (
|
|
<>
|
|
<Handle
|
|
id="c"
|
|
type="source"
|
|
position={Position.Left}
|
|
isConnectable={isConnectable}
|
|
className={styles.handle}
|
|
style={LeftHandleStyle}
|
|
></Handle>
|
|
<Handle
|
|
type="source"
|
|
position={Position.Right}
|
|
isConnectable={isConnectable}
|
|
className={styles.handle}
|
|
id="b"
|
|
style={RightHandleStyle}
|
|
></Handle>
|
|
</>
|
|
)}
|
|
<Handle
|
|
type="target"
|
|
position={Position.Top}
|
|
isConnectable={false}
|
|
id="f"
|
|
></Handle>
|
|
<Handle
|
|
type="source"
|
|
position={Position.Bottom}
|
|
isConnectable={false}
|
|
id="e"
|
|
style={{ left: 180 }}
|
|
></Handle>
|
|
<NodeHeader id={id} name={data.name} label={data.label}></NodeHeader>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
export const AgentNode = memo(InnerAgentNode);
|