Skip to content

Commit

Permalink
feat: The form node supports obtaining data from other nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
shaohuzhang1 committed Dec 27, 2024
1 parent 74edbd0 commit 9ef61b4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/application/flow/step_node/form_node/impl/base_form_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ def execute(self, form_field_list, form_content_format, form_data, **kwargs) ->
"chat_record_id": self.flow_params_serializer.data.get("chat_record_id"),
"is_submit": self.context.get("is_submit", False)}
form = f'<form_rander>{json.dumps(form_setting)}</form_rander>'
context = self.workflow_manage.get_workflow_content()
form_content_format = self.workflow_manage.reset_prompt(form_content_format)
prompt_template = PromptTemplate.from_template(form_content_format, template_format='jinja2')
value = prompt_template.format(form=form)
value = prompt_template.format(form=form, context=context)
return NodeResult(
{'result': value, 'form_field_list': form_field_list, 'form_content_format': form_content_format}, {},
_write_context=write_context)
Expand All @@ -69,8 +71,10 @@ def get_answer_list(self) -> List[Answer] | None:
'form_data': self.context.get('form_data', {}),
"is_submit": self.context.get("is_submit", False)}
form = f'<form_rander>{json.dumps(form_setting)}</form_rander>'
context = self.workflow_manage.get_workflow_content()
form_content_format = self.workflow_manage.reset_prompt(form_content_format)
prompt_template = PromptTemplate.from_template(form_content_format, template_format='jinja2')
value = prompt_template.format(form=form)
value = prompt_template.format(form=form, context=context)
return [Answer(value, self.view_type, self.runtime_node_id, self.workflow_params['chat_record_id'], None)]

def get_details(self, index: int, **kwargs):
Expand All @@ -81,8 +85,10 @@ def get_details(self, index: int, **kwargs):
'form_data': self.context.get('form_data', {}),
"is_submit": self.context.get("is_submit", False)}
form = f'<form_rander>{json.dumps(form_setting)}</form_rander>'
context = self.workflow_manage.get_workflow_content()
form_content_format = self.workflow_manage.reset_prompt(form_content_format)
prompt_template = PromptTemplate.from_template(form_content_format, template_format='jinja2')
value = prompt_template.format(form=form)
value = prompt_template.format(form=form, context=context)
return {
'name': self.node.properties.get('stepName'),
"index": index,
Expand Down

0 comments on commit 9ef61b4

Please sign in to comment.