Skip to content

Commit c255b25

Browse files
authored
fix: [Tool] The workflow tool references a regular tool, and the return value after calling the regular tool is empty (#5014)
1 parent 23f792d commit c255b25

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

apps/application/flow/step_node/tool_lib_node/impl/base_tool_lib_node.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from django.db.models import QuerySet
2121
from django.utils.translation import gettext as _
2222

23+
from application.flow.common import WorkflowMode
2324
from application.flow.i_step_node import NodeResult
2425
from application.flow.step_node.tool_lib_node.i_tool_lib_node import IToolLibNode
2526
from common.database_model_manage.database_model_manage import DatabaseModelManage
@@ -260,14 +261,23 @@ def tool_exec_record(self, tool_lib, all_params):
260261
}
261262
else:
262263
filtered_args = all_params
264+
if [WorkflowMode.KNOWLEDGE, WorkflowMode.KNOWLEDGE_LOOP].__contains__(
265+
self.workflow_manage.flow.workflow_mode):
266+
source_id = self.workflow_manage.params.get('knowledge_id')
267+
source_type = ToolTaskTypeChoices.KNOWLEDGE.value
268+
elif [WorkflowMode.TOOL, WorkflowMode.TOOL_LOOP].__contains__(self.workflow_manage.flow.workflow_mode):
269+
source_id = self.workflow_manage.params.get('application_id')
270+
source_type = ToolTaskTypeChoices.APPLICATION.value
271+
else:
272+
source_id = self.workflow_manage.params.get('tool_id')
273+
source_type = ToolTaskTypeChoices.TOOL.value
274+
263275
ToolRecord(
264276
id=task_record_id,
265277
workspace_id=tool_lib.workspace_id,
266278
tool_id=tool_lib.id,
267-
source_type=ToolTaskTypeChoices.KNOWLEDGE.value if self.workflow_manage.params.get(
268-
'knowledge_id') else ToolTaskTypeChoices.APPLICATION.value,
269-
source_id=self.workflow_manage.params.get('knowledge_id') or self.workflow_manage.params.get(
270-
'application_id'),
279+
source_type=source_type,
280+
source_id=source_id,
271281
meta={'input': filtered_args, 'output': {}},
272282
state=State.STARTED
273283
).save()

0 commit comments

Comments
 (0)