Skip to content

Commit de47084

Browse files
authored
fix: Tool Workflow AI Node Add Add Function Call Error (#4989)
1 parent 6935322 commit de47084

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,19 @@ def _handle_mcp_request(self, mcp_source, mcp_servers, mcp_tool_id, mcp_tool_ids
428428
if len(mcp_servers_config) > 0 or len(tools) > 0:
429429
# 安全获取 application
430430
application_id = None
431-
if (self.workflow_manage and
432-
self.workflow_manage.work_flow_post_handler and
433-
self.workflow_manage.work_flow_post_handler.chat_info):
431+
tool_id = None
432+
knowledge_id = None
433+
if [WorkflowMode.KNOWLEDGE, WorkflowMode.KNOWLEDGE_LOOP].__contains__(
434+
self.workflow_manage.flow.workflow_mode):
435+
knowledge_id = self.workflow_params.get('knowledge_id')
436+
elif [WorkflowMode.APPLICATION, WorkflowMode.APPLICATION_LOOP].__contains__(
437+
self.workflow_manage.flow.workflow_mode):
434438
application_id = self.workflow_manage.work_flow_post_handler.chat_info.application.id
435-
knowledge_id = self.workflow_params.get('knowledge_id')
436-
source_id = application_id or knowledge_id
437-
source_type = 'APPLICATION' if application_id else 'KNOWLEDGE'
439+
elif [WorkflowMode.TOOL, WorkflowMode.TOOL_LOOP].__contains__(self.workflow_manage.flow.workflow_mode):
440+
tool_id = self.workflow_params.get('tool_id')
441+
442+
source_id = application_id or knowledge_id or tool_id
443+
source_type = 'APPLICATION' if application_id else 'KNOWLEDGE' if knowledge_id else 'TOOL'
438444
r = mcp_response_generator(chat_model, message_list, json.dumps(mcp_servers_config), mcp_output_enable,
439445
tool_init_params, source_id, source_type, chat_id, tools)
440446
return NodeResult(

0 commit comments

Comments
 (0)