feat: The judge supports `startsWith` and `endsWith` (#4217)

This commit is contained in:
shaohuzhang1 2025-10-20 10:48:03 +08:00 committed by GitHub
parent c0c15d8983
commit 6f1c83d287
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 2 deletions

View File

@ -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()]

View File

@ -0,0 +1,22 @@
# coding=utf-8
"""
@project: MaxKB
@Author虎虎
@file start_with.py
@date2025/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))

View File

@ -0,0 +1,22 @@
# coding=utf-8
"""
@project: MaxKB
@Author虎虎
@file start_with.py
@date2025/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))

View File

@ -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 = {