|
49 | 49 | /** @param {Drawflow} editor*/ |
50 | 50 | function renderRoutingFlow(editor){ |
51 | 51 | let posX = 0; |
52 | | - let nodeSpace = 250; |
53 | | - let posY = 100 * agents.length / 2 + 50; |
| 52 | + const nodeSpaceX = 300, nodeSpaceY = 120; |
| 53 | +
|
| 54 | + let posY = nodeSpaceY * (agents.length + 1) / 2; |
54 | 55 |
|
55 | 56 | // add end-user node |
56 | 57 | let userNodeId = editor.addNode('user', 0, 1, posX, posY, 'user', |
|
61 | 62 | }, `<i class="mdi mdi-account font-size-16 text-info me-2"></i><span class="h6">User Request</span>`, false); |
62 | 63 |
|
63 | 64 | // add router node |
64 | | - posX += nodeSpace; |
| 65 | + posX += nodeSpaceX; |
65 | 66 | let hostNodeId = 0; |
66 | | - let routerPosY = posY; |
| 67 | + let routerPosY = nodeSpaceY * (routers.length + 1) / 2; |
67 | 68 | routers.forEach(router => { |
68 | 69 | let profiles = []; |
69 | | - let html = `<span class="h6">${router.name}</span>`; |
| 70 | + const chatTestLinkHtml = `<a href= "/chat/${router.id}" class="btn btn-primary float-end" target="_blank"><i class="bx bx-chat"></i></a>`; |
| 71 | + let html = `<span class="h5">${router.name} ${chatTestLinkHtml}</span><span class="text-info">Routing Agent</span>`; |
70 | 72 | if (router.profiles.length > 0) { |
71 | 73 | profiles = router.profiles; |
72 | | - html += `<br/><i class="mdi mdi-folder font-size-16 text-info me-2"></i>${profiles.join(', ')}`; |
| 74 | + html += `<br/><i class="mdi mdi-folder font-size-16 text-info me-2"></i><span>${profiles.join(', ')}</span>`; |
73 | 75 | } |
74 | 76 | |
75 | 77 | const data = { |
|
88 | 90 | } |
89 | 91 | // connect user and router |
90 | 92 | editor.addConnection(userNodeId, nodeId, `output_1`, `input_1`); |
91 | | - routerPosY += 100; |
| 93 | + routerPosY += nodeSpaceY * (agents.length - 1) / 2; |
92 | 94 | }); |
93 | 95 |
|
94 | 96 | posY = 100; |
95 | | - posX += nodeSpace; |
| 97 | + posX += nodeSpaceX; |
96 | 98 | agents.forEach(agent => { |
97 | 99 | let profiles = []; |
98 | | - let html = `<span class="h6">${agent.name}</span>`; |
| 100 | + const chatTestLinkHtml = `<a href= "/chat/${agent.id}" class="btn btn-primary float-end" target="_blank"><i class="bx bx-chat"></i></a>`; |
| 101 | + let html = `<span class="h6">${agent.name}</span>${chatTestLinkHtml}`; |
99 | 102 | if (agent.profiles.length > 0) { |
100 | 103 | profiles = agent.profiles; |
101 | 104 | html += `<br/><i class="mdi mdi-folder font-size-16 text-info me-2"></i>` + profiles.join(', '); |
|
118 | 121 | editor.addConnection(r.nid, nid, `output_1`, `input_1`); |
119 | 122 | } else { |
120 | 123 | // editor.removeNodeInput(nid, "input_2"); |
| 124 | + editor.addConnection(userNodeId, nid, `output_1`, `input_1`); |
121 | 125 | } |
122 | 126 | }); |
123 | 127 | }); |
|
130 | 134 | }); |
131 | 135 | } |
132 | 136 |
|
133 | | - posY += 100; |
| 137 | + posY += nodeSpaceY; |
134 | 138 | }); |
135 | 139 | } |
136 | 140 | |
|
0 commit comments