Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

721 B
Raw Blame
import { Edge } from '@xyflow/react';
import { filterAllDownstreamAgentAndToolNodeIds } from './filter-downstream-nodes';

// Delete all downstream agent and tool operators of the current agent operator
export function deleteAllDownstreamAgentsAndTool(
  nodeId: string,
  edges: Edge[],
) {
  const downstreamAgentAndToolNodeIds = filterAllDownstreamAgentAndToolNodeIds(
    edges,
    [nodeId],
  );

  const downstreamNodeIdSet = new Set(downstreamAgentAndToolNodeIds);
  const downstreamAgentAndToolEdges = edges.filter(
    (edge) =>
      downstreamNodeIdSet.has(edge.source) ||
      downstreamNodeIdSet.has(edge.target),
  );

  return {
    downstreamAgentAndToolNodeIds,
    downstreamAgentAndToolEdges,
  };
}