Skip to content

Commit a2c19ee

Browse files
feat: Variable assign supports set to null
1 parent fe7e42c commit a2c19ee

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

apps/application/flow/step_node/variable_assign_node/impl/base_variable_assign_node.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,38 @@ def handle(self, variable, evaluation):
6060
val = variable['value']
6161
evaluation(variable, val)
6262
result['output_value'] = val
63+
elif variable['source'] == 'null':
64+
val = None
65+
evaluation(variable, val)
66+
result['output_value'] = val
6367
else:
6468
reference = self.get_reference_content(variable['reference'])
6569
evaluation(variable, reference)
6670
result['output_value'] = reference
6771
return result
6872

6973
def execute(self, variable_list, **kwargs) -> NodeResult:
70-
#
7174
result_list = []
72-
is_chat = False
75+
contains_chat_variable = False
7376
for variable in variable_list:
7477
if 'fields' not in variable:
7578
continue
79+
7680
if 'global' == variable['fields'][0]:
7781
result = self.handle(variable, self.global_evaluation)
7882
result_list.append(result)
79-
if 'chat' == variable['fields'][0]:
83+
elif 'chat' == variable['fields'][0]:
8084
result = self.handle(variable, self.chat_evaluation)
8185
result_list.append(result)
82-
is_chat = True
83-
if 'loop' == variable['fields'][0]:
86+
contains_chat_variable = True
87+
elif 'loop' == variable['fields'][0]:
8488
result = self.handle(variable, self.loop_evaluation)
8589
result_list.append(result)
86-
if 'output' == variable['fields'][0]:
90+
elif 'output' == variable['fields'][0]:
8791
result = self.handle(variable, self.out_evaluation)
8892
result_list.append(result)
89-
if is_chat:
93+
94+
if contains_chat_variable:
9095
from application.flow.loop_workflow_manage import LoopWorkflowManage
9196
if isinstance(self.workflow_manage, LoopWorkflowManage):
9297
self.workflow_manage.parentWorkflowManage.get_chat_info().set_chat_variable(

ui/src/workflow/nodes/variable-assign-node/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<el-select :teleported="false" v-model="item.source" size="small" style="width: 85px">
4646
<el-option :label="$t('workflow.variable.Referencing')" value="referencing" />
4747
<el-option :label="$t('common.custom')" value="custom" />
48+
<el-option label="null" value="null" />
4849
</el-select>
4950
</div>
5051

@@ -142,7 +143,7 @@
142143
</el-select>
143144
</el-form-item>
144145
</div>
145-
<el-form-item v-else>
146+
<el-form-item v-else-if="item.source === 'referencing'">
146147
<NodeCascader
147148
ref="nodeCascaderRef2"
148149
:nodeModel="nodeModel"

0 commit comments

Comments
 (0)