diff --git a/api/core/workflow/workflow_entry.py b/api/core/workflow/workflow_entry.py index 84b251223f..099d54158b 100644 --- a/api/core/workflow/workflow_entry.py +++ b/api/core/workflow/workflow_entry.py @@ -289,5 +289,22 @@ class WorkflowEntry: if new_value: input_value = new_value + if node_type == NodeType.TOOL and isinstance(input_value, dict) and "transferMethod" in input_value: + if input_value.get("supportFileType"): + type = FileType.value_of(input_value.get("supportFileType")) + else: + type = FileType.CUSTOM + transfer_method = FileTransferMethod.value_of(input_value.get("transferMethod")) + file = File( + tenant_id=tenant_id, + type=type, + transfer_method=transfer_method, + remote_url=input_value.get("url") if transfer_method == FileTransferMethod.REMOTE_URL else None, + related_id=input_value.get("uploadedId") + if transfer_method == FileTransferMethod.LOCAL_FILE + else None, + ) + input_value = file + # append variable and value to variable pool variable_pool.add([variable_node_id] + variable_key_list, input_value) diff --git a/api/services/workflow_service.py b/api/services/workflow_service.py index 7187d40517..3b64a6c21b 100644 --- a/api/services/workflow_service.py +++ b/api/services/workflow_service.py @@ -6,6 +6,7 @@ from typing import Optional from core.app.apps.advanced_chat.app_config_manager import AdvancedChatAppConfigManager from core.app.apps.workflow.app_config_manager import WorkflowAppConfigManager +from core.file.models import File from core.model_runtime.utils.encoders import jsonable_encoder from core.variables import Variable from core.workflow.entities.node_entities import NodeRunResult @@ -262,6 +263,9 @@ class WorkflowService: if run_succeeded and node_run_result: # create workflow node execution + for key, value in node_run_result.inputs.items(): + if isinstance(value, File): + node_run_result.inputs[key] = value.to_dict() workflow_node_execution.inputs = json.dumps(node_run_result.inputs) if node_run_result.inputs else None workflow_node_execution.process_data = ( json.dumps(node_run_result.process_data) if node_run_result.process_data else None