diff --git a/apps/application/flow/compare/__init__.py b/apps/application/flow/compare/__init__.py index c015f6fea..f18845014 100644 --- a/apps/application/flow/compare/__init__.py +++ b/apps/application/flow/compare/__init__.py @@ -8,6 +8,7 @@ """ from .contain_compare import * +from .end_with import EndWithCompare from .equal_compare import * from .ge_compare import * from .gt_compare import * @@ -23,8 +24,10 @@ from .len_le_compare import * from .len_lt_compare import * from .lt_compare import * from .not_contain_compare import * +from .start_with import StartWithCompare compare_handle_list = [GECompare(), GTCompare(), ContainCompare(), EqualCompare(), LTCompare(), LECompare(), LenLECompare(), LenGECompare(), LenEqualCompare(), LenGTCompare(), LenLTCompare(), IsNullCompare(), - IsNotNullCompare(), NotContainCompare(), IsTrueCompare(), IsNotTrueCompare()] + IsNotNullCompare(), NotContainCompare(), IsTrueCompare(), IsNotTrueCompare(), StartWithCompare(), + EndWithCompare()] diff --git a/apps/application/flow/compare/end_with.py b/apps/application/flow/compare/end_with.py new file mode 100644 index 000000000..a0fe17989 --- /dev/null +++ b/apps/application/flow/compare/end_with.py @@ -0,0 +1,22 @@ +# coding=utf-8 +""" + @project: MaxKB + @Author:虎虎 + @file: start_with.py + @date:2025/10/20 10:37 + @desc: +""" +from typing import List + +from application.flow.compare import Compare + + +class EndWithCompare(Compare): + + def support(self, node_id, fields: List[str], source_value, compare, target_value): + if compare == 'end_with': + return True + + def compare(self, source_value, compare, target_value): + source_value = str(source_value) + return source_value.endswith(str(target_value)) diff --git a/apps/application/flow/compare/start_with.py b/apps/application/flow/compare/start_with.py new file mode 100644 index 000000000..ccf0ae45b --- /dev/null +++ b/apps/application/flow/compare/start_with.py @@ -0,0 +1,22 @@ +# coding=utf-8 +""" + @project: MaxKB + @Author:虎虎 + @file: start_with.py + @date:2025/10/20 10:37 + @desc: +""" +from typing import List + +from application.flow.compare import Compare + + +class StartWithCompare(Compare): + + def support(self, node_id, fields: List[str], source_value, compare, target_value): + if compare == 'start_with': + return True + + def compare(self, source_value, compare, target_value): + source_value = str(source_value) + return source_value.startswith(str(target_value)) diff --git a/ui/src/workflow/common/data.ts b/ui/src/workflow/common/data.ts index 54636e62a..a8595e14c 100644 --- a/ui/src/workflow/common/data.ts +++ b/ui/src/workflow/common/data.ts @@ -344,7 +344,6 @@ export const variableAggregationNode = { }, } - export const variableAssignNode = { type: WorkflowType.VariableAssignNode, text: t('views.applicationWorkflow.nodes.variableAssignNode.text'), @@ -744,6 +743,8 @@ export const compareList = [ { value: 'len_lt', label: t('views.applicationWorkflow.compare.len_lt') }, { value: 'is_true', label: t('views.applicationWorkflow.compare.is_true') }, { value: 'is_not_true', label: t('views.applicationWorkflow.compare.is_not_true') }, + { value: 'start_with', label: 'startWith' }, + { value: 'end_with', label: 'endWith' }, ] export const nodeDict: any = {