Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(workflow_tool): enable File parameter support after workflow is published as a tool (#13175)

胡春东cf3674577073
diff --git a/api/core/tools/tool/workflow_tool.py b/api/core/tools/tool/workflow_tool.py
index eea66ee4ed7..9d13e2c49a5 100644
--- a/api/core/tools/tool/workflow_tool.py
+++ b/api/core/tools/tool/workflow_tool.py
@@ -195,14 +195,14 @@ class WorkflowTool(Tool):
if isinstance(value, list):
for item in value:
if isinstance(item, dict) and item.get("dify_model_identity") == FILE_MODEL_IDENTITY:
- item["tool_file_id"] = item.get("related_id")
+ item = self._update_file_mapping(item)
file = build_from_mapping(
mapping=item,
tenant_id=str(cast(Tool.Runtime, self.runtime).tenant_id),
)
files.append(file)
elif isinstance(value, dict) and value.get("dify_model_identity") == FILE_MODEL_IDENTITY:
- value["tool_file_id"] = value.get("related_id")
+ value = self._update_file_mapping(value)
file = build_from_mapping(
mapping=value,
tenant_id=str(cast(Tool.Runtime, self.runtime).tenant_id),
@@ -211,3 +211,11 @@ class WorkflowTool(Tool):
result[key] = value
return result, files
+
+ def _update_file_mapping(self, file_dict: dict) -> dict:
+ transfer_method = FileTransferMethod.value_of(file_dict.get("transfer_method"))
+ if transfer_method == FileTransferMethod.TOOL_FILE:
+ file_dict["tool_file_id"] = file_dict.get("related_id")
+ elif transfer_method == FileTransferMethod.LOCAL_FILE:
+ file_dict["upload_file_id"] = file_dict.get("related_id")
+ return file_dict