| 97 | |
| 98 | |
| 99 | def hand_node(node, update_tool_map): |
| 100 | if node.get("type") == "tool-lib-node": |
| 101 | tool_lib_id = node.get("properties", {}).get("node_data", {}).get("tool_lib_id") or "" |
| 102 | node.get("properties", {}).get("node_data", {})["tool_lib_id"] = update_tool_map.get(tool_lib_id, tool_lib_id) |
| 103 | |
| 104 | if node.get("type") == "search-knowledge-node": |
| 105 | node.get("properties", {}).get("node_data", {})["knowledge_id_list"] = [] |
| 106 | if node.get("type") == "ai-chat-node": |
| 107 | node_data = node.get("properties", {}).get("node_data", {}) |
| 108 | mcp_tool_ids = node_data.get("mcp_tool_ids") or [] |
| 109 | node_data["mcp_tool_ids"] = [update_tool_map.get(tool_id, tool_id) for tool_id in mcp_tool_ids] |
| 110 | tool_ids = node_data.get("tool_ids") or [] |
| 111 | node_data["tool_ids"] = [update_tool_map.get(tool_id, tool_id) for tool_id in tool_ids] |
| 112 | if node.get("type") == "mcp-node": |
| 113 | mcp_tool_id = node.get("properties", {}).get("node_data", {}).get("mcp_tool_id") or "" |
| 114 | node.get("properties", {}).get("node_data", {})["mcp_tool_id"] = update_tool_map.get(mcp_tool_id, mcp_tool_id) |
| 115 | |
| 116 | |
| 117 | class ToolWorkflowModelSerializer(serializers.ModelSerializer): |