Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/application/flow/compare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from .not_equal_compare import NotEqualCompare
from .regex_compare import RegexCompare
from .start_with import StartWithCompare
from .type_is_compare import TypeIsCompare
from .type_not_compare import TypeNotCompare
from .wildcard_compare import WildcardCompare

_compare_handler_dict = {
Expand All @@ -50,6 +52,8 @@
'is_not_true': IsNotTrueCompare(),
'start_with': StartWithCompare(),
'end_with': EndWithCompare(),
'type_is': TypeIsCompare(),
'type_not': TypeNotCompare(),
'regex': RegexCompare(),
'wildcard': WildcardCompare(),
}
Expand Down
23 changes: 23 additions & 0 deletions apps/application/flow/compare/type_is_compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# coding=utf-8
"""
@project: MaxKB
@Author:wangliang181230
@file:type_is_compare.py
@date:2026/5/25 10:01
@desc: “数据类型是” 比较器
"""
from .compare import Compare


class TypeIsCompare(Compare):

def compare(self, source_value, compare, target_value):
try:
if target_value == "json":
return isinstance(source_value, (list, dict))
elif target_value == "num":
return isinstance(source_value, (int, float))
else:
return type(source_value).__name__ == target_value
except Exception:
return False
23 changes: 23 additions & 0 deletions apps/application/flow/compare/type_not_compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# coding=utf-8
"""
@project: MaxKB
@Author:wangliang181230
@file:type_not_compare.py
@date:2026/5/25 10:01
@desc: “数据类型不是” 比较器
"""
from .compare import Compare


class TypeNotCompare(Compare):

def compare(self, source_value, compare, target_value):
try:
if target_value == "json":
return not isinstance(source_value, (list, dict))
elif target_value == "num":
return not isinstance(source_value, (int, float))
else:
return type(source_value).__name__ != target_value
except Exception:
return False
5 changes: 5 additions & 0 deletions ui/src/locales/lang/en-US/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ You are a master of problem optimization, adept at accurately inferring user int
requiredMessage: 'Please select conditions',
},
valueMessage: 'Please enter a value',
verify_type_compare: {
requiredMessage: 'Please select a type',
},
addCondition: 'Add Condition',
addBranch: 'Add Branch',
},
Expand Down Expand Up @@ -547,6 +550,8 @@ You are a master of problem optimization, adept at accurately inferring user int
len_lt: 'Length less than',
is_true: 'Is true',
is_not_true: 'Is not true',
type_is: 'Type is',
type_not: 'Type not',
regex: 'Regex matching',
wildcard: 'Wildcard matching',
},
Expand Down
5 changes: 5 additions & 0 deletions ui/src/locales/lang/zh-CN/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ export default {
requiredMessage: '请选择条件',
},
valueMessage: '请输入值',
verify_type_compare: {
requiredMessage: '请选择类型',
},
addCondition: '添加条件',
addBranch: '添加分支',
},
Expand Down Expand Up @@ -538,6 +541,8 @@ export default {
len_lt: '长度小于',
is_true: '为真',
is_not_true: '不为真',
type_is: '类型是',
type_not: '类型不是',
regex: '正则匹配',
wildcard: '通配符匹配',
},
Expand Down
5 changes: 5 additions & 0 deletions ui/src/locales/lang/zh-Hant/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ export default {
requiredMessage: '請選擇條件',
},
valueMessage: '請輸入值',
verify_type_compare: {
requiredMessage: '請選擇類型',
},
addCondition: '添加條件',
addBranch: '添加分支',
},
Expand Down Expand Up @@ -532,6 +535,8 @@ export default {
len_lt: '長度小於',
is_true: '為真',
is_not_true: '不為真',
type_is: '類型是',
type_not: '類型不是',
regex: '正則匹配',
wildcard: '通配符匹配',
},
Expand Down
2 changes: 2 additions & 0 deletions ui/src/workflow/common/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,8 @@ export const compareList = [
{value: 'is_not_true', label: t('workflow.compare.is_not_true')},
{value: 'start_with', label: 'startWith'},
{value: 'end_with', label: 'endWith'},
{value: 'type_is', label: t('workflow.compare.type_is')},
{value: 'type_not', label: t('workflow.compare.type_not')},
{value: 'regex', label: t('workflow.compare.regex')},
{value: 'wildcard', label: t('workflow.compare.wildcard')},
]
Expand Down
20 changes: 17 additions & 3 deletions ui/src/workflow/nodes/condition-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,25 @@
trigger: 'blur',
}"
>
<el-select
v-if="['type_is', 'type_not'].includes(condition.compare)"
v-model="condition.value"
:placeholder="$t('workflow.nodes.conditionNode.verify_type_compare.requiredMessage')"
>
<el-option label="json" value="json" />
<el-option label="dict" value="dict" />
<el-option label="array" value="list" />
<el-option label="string" value="str" />
<el-option label="num" value="num" />
<el-option label="int" value="int" />
<el-option label="float" value="float" />
<el-option label="boolean" value="bool" />
<el-option label="null" value="NoneType" />
</el-select>
<el-input
v-else
v-model="condition.value"
:placeholder="
$t('workflow.nodes.conditionNode.valueMessage')
"
:placeholder="$t('workflow.nodes.conditionNode.valueMessage')"
/>
</el-form-item>
</el-col>
Expand Down
16 changes: 16 additions & 0 deletions ui/src/workflow/nodes/loop-break-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,23 @@
trigger: 'blur',
}"
>
<el-select
v-if="['type_is', 'type_not'].includes(condition.compare)"
v-model="condition.value"
:placeholder="$t('workflow.nodes.conditionNode.verify_type_compare.requiredMessage')"
>
<el-option label="json" value="json" />
<el-option label="dict" value="dict" />
<el-option label="array" value="list" />
<el-option label="string" value="str" />
<el-option label="num" value="num" />
<el-option label="int" value="int" />
<el-option label="float" value="float" />
<el-option label="boolean" value="bool" />
<el-option label="null" value="NoneType" />
</el-select>
<el-input
v-else
v-model="condition.value"
:placeholder="$t('workflow.nodes.conditionNode.valueMessage')"
/>
Expand Down
16 changes: 16 additions & 0 deletions ui/src/workflow/nodes/loop-continue-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,23 @@
trigger: 'blur',
}"
>
<el-select
v-if="['type_is', 'type_not'].includes(condition.compare)"
v-model="condition.value"
:placeholder="$t('workflow.nodes.conditionNode.verify_type_compare.requiredMessage')"
>
<el-option label="json" value="json" />
<el-option label="dict" value="dict" />
<el-option label="array" value="list" />
<el-option label="string" value="str" />
<el-option label="num" value="num" />
<el-option label="int" value="int" />
<el-option label="float" value="float" />
<el-option label="boolean" value="bool" />
<el-option label="null" value="NoneType" />
</el-select>
<el-input
v-else
v-model="condition.value"
:placeholder="$t('workflow.nodes.conditionNode.valueMessage')"
/>
Expand Down
Loading