mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: New condition for determining whether the discriminator is true or not (#2809)
This commit is contained in:
parent
add9d1bab8
commit
76d050bea4
|
|
@ -9,20 +9,22 @@
|
|||
|
||||
from .contain_compare import *
|
||||
from .equal_compare import *
|
||||
from .gt_compare import *
|
||||
from .ge_compare import *
|
||||
from .gt_compare import *
|
||||
from .is_not_null_compare import *
|
||||
from .is_not_true import IsNotTrueCompare
|
||||
from .is_null_compare import *
|
||||
from .is_true import IsTrueCompare
|
||||
from .le_compare import *
|
||||
from .lt_compare import *
|
||||
from .len_equal_compare import *
|
||||
from .len_ge_compare import *
|
||||
from .len_gt_compare import *
|
||||
from .len_le_compare import *
|
||||
from .len_lt_compare import *
|
||||
from .len_equal_compare import *
|
||||
from .is_not_null_compare import *
|
||||
from .is_null_compare import *
|
||||
from .lt_compare import *
|
||||
from .not_contain_compare import *
|
||||
|
||||
compare_handle_list = [GECompare(), GTCompare(), ContainCompare(), EqualCompare(), LTCompare(), LECompare(),
|
||||
LenLECompare(), LenGECompare(), LenEqualCompare(), LenGTCompare(), LenLTCompare(),
|
||||
IsNullCompare(),
|
||||
IsNotNullCompare(), NotContainCompare()]
|
||||
IsNotNullCompare(), NotContainCompare(), IsTrueCompare(), IsNotTrueCompare()]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
# coding=utf-8
|
||||
"""
|
||||
@project: MaxKB
|
||||
@Author:虎
|
||||
@file: is_not_true.py
|
||||
@date:2025/4/7 13:44
|
||||
@desc:
|
||||
"""
|
||||
from typing import List
|
||||
|
||||
from application.flow.step_node.condition_node.compare import Compare
|
||||
|
||||
|
||||
class IsNotTrueCompare(Compare):
|
||||
|
||||
def support(self, node_id, fields: List[str], source_value, compare, target_value):
|
||||
if compare == 'is_not_true':
|
||||
return True
|
||||
|
||||
def compare(self, source_value, compare, target_value):
|
||||
try:
|
||||
return source_value is False
|
||||
except Exception as e:
|
||||
return False
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# coding=utf-8
|
||||
"""
|
||||
@project: MaxKB
|
||||
@Author:虎
|
||||
@file: IsTrue.py
|
||||
@date:2025/4/7 13:38
|
||||
@desc:
|
||||
"""
|
||||
from typing import List
|
||||
|
||||
from application.flow.step_node.condition_node.compare import Compare
|
||||
|
||||
|
||||
class IsTrueCompare(Compare):
|
||||
|
||||
def support(self, node_id, fields: List[str], source_value, compare, target_value):
|
||||
if compare == 'is_true':
|
||||
return True
|
||||
|
||||
def compare(self, source_value, compare, target_value):
|
||||
try:
|
||||
return source_value is True
|
||||
except Exception as e:
|
||||
return False
|
||||
|
|
@ -40,7 +40,11 @@ class BaseConditionNode(IConditionNode):
|
|||
value = self.workflow_manage.generate_prompt(value)
|
||||
except Exception as e:
|
||||
pass
|
||||
field_value = self.workflow_manage.get_reference_field(field_list[0], field_list[1:])
|
||||
field_value = None
|
||||
try:
|
||||
field_value = self.workflow_manage.get_reference_field(field_list[0], field_list[1:])
|
||||
except Exception as e:
|
||||
pass
|
||||
for compare_handler in compare_handle_list:
|
||||
if compare_handler.support(field_list[0], field_list[1:], field_value, compare, value):
|
||||
return compare_handler.compare(field_value, compare, value)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default {
|
|||
copyParam: 'Copy Parameters',
|
||||
debug: 'Run',
|
||||
exit: 'Exit',
|
||||
exitSave: 'Save & Exit',
|
||||
exitSave: 'Save & Exit'
|
||||
},
|
||||
tip: {
|
||||
publicSuccess: 'Published successfully',
|
||||
|
|
@ -37,7 +37,7 @@ export default {
|
|||
cannotCopy: 'Cannot be copied',
|
||||
copyError: 'Node already copied',
|
||||
paramErrorMessage: 'Parameter already exists: ',
|
||||
saveMessage: 'Current changes have not been saved. Save before exiting?',
|
||||
saveMessage: 'Current changes have not been saved. Save before exiting?'
|
||||
},
|
||||
delete: {
|
||||
confirmTitle: 'Confirm to delete this node?',
|
||||
|
|
@ -229,7 +229,7 @@ export default {
|
|||
toolParam: 'Tool Params',
|
||||
mcpServerTip: 'Please enter the JSON format of the MCP server config',
|
||||
mcpToolTip: 'Please select a tool',
|
||||
configLabel: 'MCP Server Config (Only supports SSE call method)',
|
||||
configLabel: 'MCP Server Config (Only supports SSE call method)'
|
||||
},
|
||||
imageGenerateNode: {
|
||||
label: 'Image Generation',
|
||||
|
|
@ -293,7 +293,9 @@ export default {
|
|||
len_ge: 'Length greater than or equal to',
|
||||
len_gt: 'Length greater than',
|
||||
len_le: 'Length less than or equal to',
|
||||
len_lt: 'Length less than'
|
||||
len_lt: 'Length less than',
|
||||
is_true: 'Is true',
|
||||
is_not_true: 'Is not true'
|
||||
},
|
||||
FileUploadSetting: {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default {
|
|||
copyParam: '复制参数',
|
||||
debug: '调试',
|
||||
exit: '直接退出',
|
||||
exitSave: '保存并退出',
|
||||
exitSave: '保存并退出'
|
||||
},
|
||||
tip: {
|
||||
publicSuccess: '发布成功',
|
||||
|
|
@ -37,7 +37,7 @@ export default {
|
|||
cannotCopy: '不能被复制',
|
||||
copyError: '已复制节点',
|
||||
paramErrorMessage: '参数已存在: ',
|
||||
saveMessage: '当前的更改尚未保存,是否保存后退出?',
|
||||
saveMessage: '当前的更改尚未保存,是否保存后退出?'
|
||||
},
|
||||
delete: {
|
||||
confirmTitle: '确定删除该节点?',
|
||||
|
|
@ -292,7 +292,9 @@ export default {
|
|||
len_ge: '长度大于等于',
|
||||
len_gt: '长度大于',
|
||||
len_le: '长度小于等于',
|
||||
len_lt: '长度小于'
|
||||
len_lt: '长度小于',
|
||||
is_true: '为真',
|
||||
is_not_true: '不为真'
|
||||
},
|
||||
FileUploadSetting: {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export default {
|
|||
copyParam: '複製參數',
|
||||
debug: '調試',
|
||||
exit: '直接退出',
|
||||
exitSave: '保存並退出',
|
||||
exitSave: '保存並退出'
|
||||
},
|
||||
tip: {
|
||||
publicSuccess: '發布成功',
|
||||
|
|
@ -37,7 +37,7 @@ export default {
|
|||
cannotCopy: '不能被複製',
|
||||
copyError: '已複製節點',
|
||||
paramErrorMessage: '參數已存在: ',
|
||||
saveMessage: '當前修改未保存,是否保存後退出?',
|
||||
saveMessage: '當前修改未保存,是否保存後退出?'
|
||||
},
|
||||
delete: {
|
||||
confirmTitle: '確定刪除該節點?',
|
||||
|
|
@ -229,7 +229,7 @@ export default {
|
|||
toolParam: '工具變數',
|
||||
mcpServerTip: '請輸入JSON格式的MCP服務器配置',
|
||||
mcpToolTip: '請選擇工具',
|
||||
configLabel: 'MCP Server Config (僅支持SSE調用方式)',
|
||||
configLabel: 'MCP Server Config (僅支持SSE調用方式)'
|
||||
},
|
||||
imageGenerateNode: {
|
||||
label: '圖片生成',
|
||||
|
|
@ -292,7 +292,9 @@ export default {
|
|||
len_ge: '長度大於等於',
|
||||
len_gt: '長度大於',
|
||||
len_le: '長度小於等於',
|
||||
len_lt: '長度小於'
|
||||
len_lt: '長度小於',
|
||||
is_true: '為真',
|
||||
is_not_true: '不為真'
|
||||
},
|
||||
FileUploadSetting: {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ export const mcpNode = {
|
|||
properties: {
|
||||
stepName: t('views.applicationWorkflow.nodes.mcpNode.label'),
|
||||
config: {
|
||||
fields:[
|
||||
fields: [
|
||||
{
|
||||
label: t('common.result'),
|
||||
value: 'result'
|
||||
|
|
@ -424,7 +424,9 @@ export const compareList = [
|
|||
{ value: 'len_ge', label: t('views.applicationWorkflow.compare.len_ge') },
|
||||
{ value: 'len_gt', label: t('views.applicationWorkflow.compare.len_gt') },
|
||||
{ value: 'len_le', label: t('views.applicationWorkflow.compare.len_le') },
|
||||
{ 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_not_true', label: t('views.applicationWorkflow.compare.is_not_true') }
|
||||
]
|
||||
|
||||
export const nodeDict: any = {
|
||||
|
|
@ -446,7 +448,7 @@ export const nodeDict: any = {
|
|||
[WorkflowType.SpeechToTextNode]: speechToTextNode,
|
||||
[WorkflowType.ImageGenerateNode]: imageGenerateNode,
|
||||
[WorkflowType.VariableAssignNode]: variableAssignNode,
|
||||
[WorkflowType.McpNode]: mcpNode,
|
||||
[WorkflowType.McpNode]: mcpNode
|
||||
}
|
||||
export function isWorkFlow(type: string | undefined) {
|
||||
return type === 'WORK_FLOW'
|
||||
|
|
|
|||
|
|
@ -25,14 +25,8 @@
|
|||
size="small"
|
||||
style="width: 60px; margin: 0 8px"
|
||||
>
|
||||
<el-option
|
||||
:label="$t('views.applicationWorkflow.condition.AND')"
|
||||
value="and"
|
||||
/>
|
||||
<el-option
|
||||
:label="$t('views.applicationWorkflow.condition.OR')"
|
||||
value="or"
|
||||
/>
|
||||
<el-option :label="$t('views.applicationWorkflow.condition.AND')" value="and" />
|
||||
<el-option :label="$t('views.applicationWorkflow.condition.OR')" value="or" />
|
||||
</el-select>
|
||||
<span>{{
|
||||
$t('views.applicationWorkflow.nodes.conditionNode.conditions.label')
|
||||
|
|
@ -56,9 +50,7 @@
|
|||
ref="nodeCascaderRef"
|
||||
:nodeModel="nodeModel"
|
||||
class="w-full"
|
||||
:placeholder="
|
||||
$t('views.applicationWorkflow.variable.placeholder')
|
||||
"
|
||||
:placeholder="$t('views.applicationWorkflow.variable.placeholder')"
|
||||
v-model="condition.field"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
|
@ -94,7 +86,11 @@
|
|||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item
|
||||
v-if="condition.compare !== 'is_null' && condition.compare !== 'is_not_null'"
|
||||
v-if="
|
||||
!['is_null', 'is_not_null', 'is_true', 'is_not_true'].includes(
|
||||
condition.compare
|
||||
)
|
||||
"
|
||||
:prop="'branch.' + index + '.conditions.' + cIndex + '.value'"
|
||||
:rules="{
|
||||
required: true,
|
||||
|
|
@ -137,7 +133,8 @@
|
|||
</el-card>
|
||||
</template>
|
||||
<el-button link type="primary" @click="addBranch">
|
||||
<el-icon class="mr-4"><Plus /></el-icon> {{ $t('views.applicationWorkflow.nodes.conditionNode.addBranch') }}
|
||||
<el-icon class="mr-4"><Plus /></el-icon>
|
||||
{{ $t('views.applicationWorkflow.nodes.conditionNode.addBranch') }}
|
||||
</el-button>
|
||||
</el-form>
|
||||
</NodeContainer>
|
||||
|
|
|
|||
Loading…
Reference in New Issue