Skip to content

Commit b840c97

Browse files
authored
Merge pull request #32 from hchen2020/main
Add chat test in routing-flow.
2 parents 683819f + 7aab191 commit b840c97

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/lib/drawflow/drawflow.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
.drawflow .drawflow-node {
22
background: var(--bs-primary);
33
color: white;
4+
width: 200px;
5+
border: 2px solid var(--bs-primary);
46
}
57

68
.drawflow .drawflow-node.selected {
7-
background: var(--bs-success);
9+
background: var(--bs-primary);
10+
border: 2px solid black;
811
}
912

1013
.drawflow .new-node {
1114
background: var(--bs-info);
1215
color: white;
16+
}
17+
18+
.drawflow-delete {
19+
background-color: var(--bs-danger);
20+
line-height: 25px;
1321
}

src/routes/page/agent/router/routing-flow.svelte

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
/** @param {Drawflow} editor*/
5050
function renderRoutingFlow(editor){
5151
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;
5455
5556
// add end-user node
5657
let userNodeId = editor.addNode('user', 0, 1, posX, posY, 'user',
@@ -61,15 +62,16 @@
6162
}, `<i class="mdi mdi-account font-size-16 text-info me-2"></i><span class="h6">User Request</span>`, false);
6263
6364
// add router node
64-
posX += nodeSpace;
65+
posX += nodeSpaceX;
6566
let hostNodeId = 0;
66-
let routerPosY = posY;
67+
let routerPosY = nodeSpaceY * (routers.length + 1) / 2;
6768
routers.forEach(router => {
6869
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>`;
7072
if (router.profiles.length > 0) {
7173
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>`;
7375
}
7476
7577
const data = {
@@ -88,14 +90,15 @@
8890
}
8991
// connect user and router
9092
editor.addConnection(userNodeId, nodeId, `output_1`, `input_1`);
91-
routerPosY += 100;
93+
routerPosY += nodeSpaceY * (agents.length - 1) / 2;
9294
});
9395
9496
posY = 100;
95-
posX += nodeSpace;
97+
posX += nodeSpaceX;
9698
agents.forEach(agent => {
9799
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}`;
99102
if (agent.profiles.length > 0) {
100103
profiles = agent.profiles;
101104
html += `<br/><i class="mdi mdi-folder font-size-16 text-info me-2"></i>` + profiles.join(', ');
@@ -118,6 +121,7 @@
118121
editor.addConnection(r.nid, nid, `output_1`, `input_1`);
119122
} else {
120123
// editor.removeNodeInput(nid, "input_2");
124+
editor.addConnection(userNodeId, nid, `output_1`, `input_1`);
121125
}
122126
});
123127
});
@@ -130,7 +134,7 @@
130134
});
131135
}
132136
133-
posY += 100;
137+
posY += nodeSpaceY;
134138
});
135139
}
136140

0 commit comments

Comments
 (0)