retrieval-node.tsx

Overview

The retrieval-node.tsx file defines a React component named RetrievalNode designed to represent a "Retrieval" node within a visual flow or graph editor interface, likely part of a larger workflow or knowledge graph system. This node visually displays linked knowledge bases, provides connection handles for graph edges, and integrates toolbar controls for node interaction.

Functionally, the component:

This component is tightly integrated into a React-based flow framework (@xyflow/react) and hooks into application-specific state and utilities for fetching knowledge data and labeling variables.


Detailed Explanation

Imports


Component: InnerRetrievalNode

function InnerRetrievalNode({
  id,
  data,
  isConnectable = true,
  selected,
}: NodeProps<IRetrievalNode>)

Description

InnerRetrievalNode is the core functional component rendering the retrieval node UI. It receives props describing the node state and data.

Parameters

Internal Logic

Returns

JSX element representing the fully rendered node.

Usage Example

import { RetrievalNode } from './retrieval-node';

<RetrievalNode 
  id="node-123"
  data={{
    name: 'Retrieve Documents',
    label: 'Document Retrieval',
    form: { kb_ids: ['kb1', 'kb2'] },
  }}
  isConnectable={true}
  selected={false}
/>

Exported Component: RetrievalNode

export const RetrievalNode = memo(InnerRetrievalNode);

Important Implementation Details


Interaction with Other System Parts


Visual Diagram

componentDiagram
    component RetrievalNode {
      +id: string
      +data: IRetrievalNode
      +isConnectable?: boolean
      +selected?: boolean
    }

    component ToolBar
    component NodeWrapper
    component CommonHandle
    component NodeHeader
    component RAGFlowAvatar

    RetrievalNode --> ToolBar : wraps node content
    RetrievalNode --> NodeWrapper : main container
    RetrievalNode --> CommonHandle : left handle (target)
    RetrievalNode --> CommonHandle : right handle (source)
    RetrievalNode --> NodeHeader : displays node title
    RetrievalNode --> RAGFlowAvatar : displays knowledge base avatars

Summary

The retrieval-node.tsx file implements a React component tailored for rendering a "retrieval" node in a visual workflow/graph editor. It integrates knowledge base data, connection handles for graph linking, and user interface elements such as avatars and toolbars. The component is optimized with memoization and leverages several custom hooks and shared UI components, making it a modular, reusable part of a larger flow-based application.