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_as_tool output files raise error (#12061)

非法操作b66c03dfe960
diff --git a/api/core/tools/tool/workflow_tool.py b/api/core/tools/tool/workflow_tool.py
index edff4a2d07c..eea66ee4ed7 100644
--- a/api/core/tools/tool/workflow_tool.py
+++ b/api/core/tools/tool/workflow_tool.py
@@ -1,12 +1,13 @@
import json
import logging
from copy import deepcopy
-from typing import Any, Optional, Union
+from typing import Any, Optional, Union, cast
from core.file import FILE_MODEL_IDENTITY, File, FileTransferMethod
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter, ToolProviderType
from core.tools.tool.tool import Tool
from extensions.ext_database import db
+from factories.file_factory import build_from_mapping
from models.account import Account
from models.model import App, EndUser
from models.workflow import Workflow
@@ -194,10 +195,18 @@ class WorkflowTool(Tool):
if isinstance(value, list):
for item in value:
if isinstance(item, dict) and item.get("dify_model_identity") == FILE_MODEL_IDENTITY:
- file = File.model_validate(item)
+ item["tool_file_id"] = item.get("related_id")
+ 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:
- file = File.model_validate(value)
+ value["tool_file_id"] = value.get("related_id")
+ file = build_from_mapping(
+ mapping=value,
+ tenant_id=str(cast(Tool.Runtime, self.runtime).tenant_id),
+ )
files.append(file)
result[key] = value