diff --git a/web/src/pages/flow/constant.tsx b/web/src/pages/flow/constant.tsx index 4da80de48c..60f1887b1f 100644 --- a/web/src/pages/flow/constant.tsx +++ b/web/src/pages/flow/constant.tsx @@ -254,6 +254,9 @@ export const RestrictedUpstreamMap = { Operator.Categorize, Operator.Relevant, ], + [Operator.KeywordExtract]: [Operator.Begin], + [Operator.Baidu]: [Operator.Begin], + [Operator.DuckDuckGo]: [Operator.Begin], }; export const NodeMap = { diff --git a/web/src/pages/flow/hooks.ts b/web/src/pages/flow/hooks.ts index 3d3b103652..e052fb773e 100644 --- a/web/src/pages/flow/hooks.ts +++ b/web/src/pages/flow/hooks.ts @@ -297,12 +297,16 @@ export const useValidateConnection = () => { // restricted lines cannot be connected successfully. const isValidConnection = useCallback( (connection: Connection) => { + // node cannot connect to itself + const isSelfConnected = connection.target === connection.source; + // limit the connection between two nodes to only one connection line in one direction const hasLine = edges.some( (x) => x.source === connection.source && x.target === connection.target, ); const ret = + !isSelfConnected && !hasLine && RestrictedUpstreamMap[ getOperatorTypeFromId(connection.source) as Operator