Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
ifEsle node add regex match (#8007)
Charlie.Wei01858e1cafd0
diff --git a/api/core/workflow/nodes/if_else/entities.py b/api/core/workflow/nodes/if_else/entities.pyindex bc6dce0d3bd..7eb69b80dfe 100644--- a/api/core/workflow/nodes/if_else/entities.py+++ b/api/core/workflow/nodes/if_else/entities.py@@ -12,7 +12,7 @@ class Condition(BaseModel):variable_selector: list[str]comparison_operator: Literal[# for string or array- "contains", "not contains", "start with", "end with", "is", "is not", "empty", "not empty",+ "contains", "not contains", "start with", "end with", "is", "is not", "empty", "not empty", "regex match",# for number"=", "≠", ">", "<", "≥", "≤", "null", "not null"]diff --git a/api/core/workflow/nodes/if_else/if_else_node.py b/api/core/workflow/nodes/if_else/if_else_node.pyindex c6d235627f0..5f240df6b07 100644--- a/api/core/workflow/nodes/if_else/if_else_node.py+++ b/api/core/workflow/nodes/if_else/if_else_node.py@@ -1,3 +1,4 @@+import refrom collections.abc import Sequencefrom typing import Optional, cast@@ -136,6 +137,8 @@ class IfElseNode(BaseNode):return self._assert_null(actual_value)elif comparison_operator == "not null":return self._assert_not_null(actual_value)+ elif comparison_operator == "regex match":+ return self._assert_regex_match(actual_value, expected_value)else:raise ValueError(f"Invalid comparison operator: {comparison_operator}")@@ -285,6 +288,21 @@ class IfElseNode(BaseNode):return Truereturn False+ def _assert_regex_match(self, actual_value: Optional[str], expected_value: str) -> bool:+ """+ Assert empty+ :param actual_value: actual value+ :return:+ """+ if actual_value is None:+ return False++ pattern = re.compile(expected_value)+ regex_result = pattern.findall(actual_value)+ if len(regex_result) > 0:+ return True+ return False+def _assert_not_empty(self, actual_value: Optional[str]) -> bool:"""Assert not emptydiff --git a/web/app/components/app/configuration/config-var/index.tsx b/web/app/components/app/configuration/config-var/index.tsxindex 802528e0af7..fc165571c4a 100644--- a/web/app/components/app/configuration/config-var/index.tsx+++ b/web/app/components/app/configuration/config-var/index.tsx@@ -88,7 +88,6 @@ const ConfigVar: FC<IConfigVarProps> = ({ promptVariables, readonly, onPromptVar} as InputVar})()const updatePromptVariableItem = (payload: InputVar) => {- console.log(payload)const newPromptVariables = produce(promptVariables, (draft) => {const { variable, label, type, ...rest } = payloaddraft[currIndex] = {diff --git a/web/app/components/workflow/nodes/if-else/types.ts b/web/app/components/workflow/nodes/if-else/types.tsindex 693dce1784e..e67bee2fdcc 100644--- a/web/app/components/workflow/nodes/if-else/types.ts+++ b/web/app/components/workflow/nodes/if-else/types.ts@@ -28,6 +28,7 @@ export enum ComparisonOperator {lessThanOrEqual = '≤',isNull = 'is null',isNotNull = 'is not null',+ regexMatch = 'regex match',}export type Condition = {diff --git a/web/app/components/workflow/nodes/if-else/utils.ts b/web/app/components/workflow/nodes/if-else/utils.tsindex ffb6758bba5..b71a3a57ca7 100644--- a/web/app/components/workflow/nodes/if-else/utils.ts+++ b/web/app/components/workflow/nodes/if-else/utils.ts@@ -30,6 +30,7 @@ export const getOperators = (type?: VarType) => {ComparisonOperator.isNot,ComparisonOperator.empty,ComparisonOperator.notEmpty,+ ComparisonOperator.regexMatch,]case VarType.number:return [diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.tsindex e0613a110fa..033049f0f45 100644--- a/web/i18n/en-US/workflow.ts+++ b/web/i18n/en-US/workflow.ts@@ -412,6 +412,7 @@ const translation = {'not empty': 'is not empty','null': 'is null','not null': 'is not null',+ 'regex match': 'regex match',},enterValue: 'Enter value',addCondition: 'Add Condition',diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.tsindex 56d1de6ceb6..34cfb6380ec 100644--- a/web/i18n/zh-Hans/workflow.ts+++ b/web/i18n/zh-Hans/workflow.ts@@ -412,6 +412,7 @@ const translation = {'not empty': '不为空','null': '空','not null': '不为空',+ 'regex match': '正则匹配',},enterValue: '输入值',addCondition: '添加条件',