Skip to content

Commit f111ae1

Browse files
authored
feat: The form node supports obtaining data from other nodes (#1924)
1 parent 74edbd0 commit f111ae1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

apps/application/flow/step_node/form_node/impl/base_form_node.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ def execute(self, form_field_list, form_content_format, form_data, **kwargs) ->
5555
"chat_record_id": self.flow_params_serializer.data.get("chat_record_id"),
5656
"is_submit": self.context.get("is_submit", False)}
5757
form = f'<form_rander>{json.dumps(form_setting)}</form_rander>'
58+
context = self.workflow_manage.get_workflow_content()
59+
form_content_format = self.workflow_manage.reset_prompt(form_content_format)
5860
prompt_template = PromptTemplate.from_template(form_content_format, template_format='jinja2')
59-
value = prompt_template.format(form=form)
61+
value = prompt_template.format(form=form, context=context)
6062
return NodeResult(
6163
{'result': value, 'form_field_list': form_field_list, 'form_content_format': form_content_format}, {},
6264
_write_context=write_context)
@@ -69,8 +71,10 @@ def get_answer_list(self) -> List[Answer] | None:
6971
'form_data': self.context.get('form_data', {}),
7072
"is_submit": self.context.get("is_submit", False)}
7173
form = f'<form_rander>{json.dumps(form_setting)}</form_rander>'
74+
context = self.workflow_manage.get_workflow_content()
75+
form_content_format = self.workflow_manage.reset_prompt(form_content_format)
7276
prompt_template = PromptTemplate.from_template(form_content_format, template_format='jinja2')
73-
value = prompt_template.format(form=form)
77+
value = prompt_template.format(form=form, context=context)
7478
return [Answer(value, self.view_type, self.runtime_node_id, self.workflow_params['chat_record_id'], None)]
7579

7680
def get_details(self, index: int, **kwargs):
@@ -81,8 +85,10 @@ def get_details(self, index: int, **kwargs):
8185
'form_data': self.context.get('form_data', {}),
8286
"is_submit": self.context.get("is_submit", False)}
8387
form = f'<form_rander>{json.dumps(form_setting)}</form_rander>'
88+
context = self.workflow_manage.get_workflow_content()
89+
form_content_format = self.workflow_manage.reset_prompt(form_content_format)
8490
prompt_template = PromptTemplate.from_template(form_content_format, template_format='jinja2')
85-
value = prompt_template.format(form=form)
91+
value = prompt_template.format(form=form, context=context)
8692
return {
8793
'name': self.node.properties.get('stepName'),
8894
"index": index,

0 commit comments

Comments
 (0)