feat: The judge supports `startsWith` and `endsWith` (#4217)
parent
c0c15d8983
commit
6f1c83d287
|
|
@ -8,6 +8,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .contain_compare import *
|
from .contain_compare import *
|
||||||
|
from .end_with import EndWithCompare
|
||||||
from .equal_compare import *
|
from .equal_compare import *
|
||||||
from .ge_compare import *
|
from .ge_compare import *
|
||||||
from .gt_compare import *
|
from .gt_compare import *
|
||||||
|
|
@ -23,8 +24,10 @@ from .len_le_compare import *
|
||||||
from .len_lt_compare import *
|
from .len_lt_compare import *
|
||||||
from .lt_compare import *
|
from .lt_compare import *
|
||||||
from .not_contain_compare import *
|
from .not_contain_compare import *
|
||||||
|
from .start_with import StartWithCompare
|
||||||
|
|
||||||
compare_handle_list = [GECompare(), GTCompare(), ContainCompare(), EqualCompare(), LTCompare(), LECompare(),
|
compare_handle_list = [GECompare(), GTCompare(), ContainCompare(), EqualCompare(), LTCompare(), LECompare(),
|
||||||
LenLECompare(), LenGECompare(), LenEqualCompare(), LenGTCompare(), LenLTCompare(),
|
LenLECompare(), LenGECompare(), LenEqualCompare(), LenGTCompare(), LenLTCompare(),
|
||||||
IsNullCompare(),
|
IsNullCompare(),
|
||||||
IsNotNullCompare(), NotContainCompare(), IsTrueCompare(), IsNotTrueCompare()]
|
IsNotNullCompare(), NotContainCompare(), IsTrueCompare(), IsNotTrueCompare(), StartWithCompare(),
|
||||||
|
EndWithCompare()]
|
||||||
|
|
|
||||||
|
|
@ -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))
|
||||||
|
|
@ -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))
|
||||||
|
|
@ -344,7 +344,6 @@ export const variableAggregationNode = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const variableAssignNode = {
|
export const variableAssignNode = {
|
||||||
type: WorkflowType.VariableAssignNode,
|
type: WorkflowType.VariableAssignNode,
|
||||||
text: t('views.applicationWorkflow.nodes.variableAssignNode.text'),
|
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: 'len_lt', label: t('views.applicationWorkflow.compare.len_lt') },
|
||||||
{ value: 'is_true', label: t('views.applicationWorkflow.compare.is_true') },
|
{ value: 'is_true', label: t('views.applicationWorkflow.compare.is_true') },
|
||||||
{ value: 'is_not_true', label: t('views.applicationWorkflow.compare.is_not_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 = {
|
export const nodeDict: any = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue