Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,9 @@ import streamlit.components.v1 as components
|
|
3 |
import json
|
4 |
|
5 |
st.set_page_config(layout="wide")
|
6 |
-
st.title("ποΈ GenAI Claims Workflow (Horizontal +
|
7 |
|
|
|
8 |
step_details = {
|
9 |
"lodged": "π© Claim is received via the customer portal. If more info is needed, an email is sent.",
|
10 |
"fraud": "π LLM performs a fraud check using historical claims and language cues.",
|
@@ -14,34 +15,22 @@ step_details = {
|
|
14 |
"payment": "π³ Payment is authorised after validation of repair progress.",
|
15 |
"settle": "β
Final review is done and the claim is marked as settled."
|
16 |
}
|
17 |
-
|
18 |
|
19 |
-
|
|
|
20 |
<div id="cy" style="width: 100%; height: 500px; border:1px solid #ccc;"></div>
|
21 |
-
|
22 |
-
<div id="tooltip" style="
|
23 |
-
display:none;
|
24 |
-
position:absolute;
|
25 |
-
background-color:white;
|
26 |
-
color:black;
|
27 |
-
border:1px solid #999;
|
28 |
-
padding:10px;
|
29 |
-
border-radius:5px;
|
30 |
-
font-size:14px;
|
31 |
-
box-shadow:2px 2px 10px rgba(0,0,0,0.2);
|
32 |
-
max-width: 300px;
|
33 |
-
z-index: 10;
|
34 |
-
"></div>
|
35 |
|
36 |
<script src="https://unpkg.com/[email protected]/dist/cytoscape.min.js"></script>
|
37 |
<script src="https://unpkg.com/[email protected]/dist/dagre.min.js"></script>
|
38 |
<script src="https://unpkg.com/[email protected]/cytoscape-dagre.min.js"></script>
|
39 |
|
40 |
<script>
|
41 |
-
const stepDetails = {node_data};
|
42 |
-
|
43 |
cytoscape.use(window.cytoscapeDagre);
|
44 |
|
|
|
|
|
45 |
const cy = cytoscape({{
|
46 |
container: document.getElementById('cy'),
|
47 |
layout: {{
|
@@ -49,7 +38,7 @@ const cy = cytoscape({{
|
|
49 |
rankDir: 'LR',
|
50 |
nodeSep: 50,
|
51 |
edgeSep: 30,
|
52 |
-
rankSep:
|
53 |
}},
|
54 |
style: [
|
55 |
{{
|
@@ -59,10 +48,10 @@ const cy = cytoscape({{
|
|
59 |
'text-valign': 'center',
|
60 |
'text-halign': 'center',
|
61 |
'background-color': '#0077B6',
|
62 |
-
'color': '
|
63 |
'font-size': '14px',
|
64 |
'text-wrap': 'wrap',
|
65 |
-
'text-max-width':
|
66 |
'shape': 'roundrectangle',
|
67 |
'padding': '10px'
|
68 |
}}
|
@@ -70,7 +59,7 @@ const cy = cytoscape({{
|
|
70 |
{{
|
71 |
selector: 'edge',
|
72 |
style: {{
|
73 |
-
'width':
|
74 |
'line-color': '#aaa',
|
75 |
'target-arrow-color': '#aaa',
|
76 |
'target-arrow-shape': 'triangle'
|
@@ -102,18 +91,19 @@ cy.on('tap', 'node', function(evt) {{
|
|
102 |
const rect = document.getElementById('cy').getBoundingClientRect();
|
103 |
const pos = evt.originalEvent;
|
104 |
|
105 |
-
tooltip.style.left = (pos.clientX - rect.left + 10) + 'px';
|
106 |
-
tooltip.style.top = (pos.clientY - rect.top + 10) + 'px';
|
107 |
tooltip.innerHTML = '<strong>' + evt.target.data('label') + '</strong><br>' + description;
|
|
|
|
|
108 |
tooltip.style.display = 'block';
|
109 |
}});
|
110 |
|
111 |
-
cy.on('tap', function(
|
112 |
-
if (
|
113 |
tooltip.style.display = 'none';
|
114 |
}}
|
115 |
}});
|
116 |
</script>
|
117 |
"""
|
118 |
|
119 |
-
|
|
|
|
3 |
import json
|
4 |
|
5 |
st.set_page_config(layout="wide")
|
6 |
+
st.title("ποΈ GenAI Claims Workflow (Horizontal + Tooltip)")
|
7 |
|
8 |
+
# Tooltip content
|
9 |
step_details = {
|
10 |
"lodged": "π© Claim is received via the customer portal. If more info is needed, an email is sent.",
|
11 |
"fraud": "π LLM performs a fraud check using historical claims and language cues.",
|
|
|
15 |
"payment": "π³ Payment is authorised after validation of repair progress.",
|
16 |
"settle": "β
Final review is done and the claim is marked as settled."
|
17 |
}
|
18 |
+
step_json = json.dumps(step_details)
|
19 |
|
20 |
+
# Safe HTML/JS with escaped braces
|
21 |
+
html = f"""
|
22 |
<div id="cy" style="width: 100%; height: 500px; border:1px solid #ccc;"></div>
|
23 |
+
<div id="tooltip" style="display:none; position:absolute; background:white; color:black; padding:10px; border-radius:5px; border:1px solid #666; box-shadow:2px 2px 8px rgba(0,0,0,0.2); z-index:10; max-width:300px;"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
<script src="https://unpkg.com/[email protected]/dist/cytoscape.min.js"></script>
|
26 |
<script src="https://unpkg.com/[email protected]/dist/dagre.min.js"></script>
|
27 |
<script src="https://unpkg.com/[email protected]/cytoscape-dagre.min.js"></script>
|
28 |
|
29 |
<script>
|
|
|
|
|
30 |
cytoscape.use(window.cytoscapeDagre);
|
31 |
|
32 |
+
const stepDetails = {step_json};
|
33 |
+
|
34 |
const cy = cytoscape({{
|
35 |
container: document.getElementById('cy'),
|
36 |
layout: {{
|
|
|
38 |
rankDir: 'LR',
|
39 |
nodeSep: 50,
|
40 |
edgeSep: 30,
|
41 |
+
rankSep: 120
|
42 |
}},
|
43 |
style: [
|
44 |
{{
|
|
|
48 |
'text-valign': 'center',
|
49 |
'text-halign': 'center',
|
50 |
'background-color': '#0077B6',
|
51 |
+
'color': '#fff',
|
52 |
'font-size': '14px',
|
53 |
'text-wrap': 'wrap',
|
54 |
+
'text-max-width': 80,
|
55 |
'shape': 'roundrectangle',
|
56 |
'padding': '10px'
|
57 |
}}
|
|
|
59 |
{{
|
60 |
selector: 'edge',
|
61 |
style: {{
|
62 |
+
'width': 2,
|
63 |
'line-color': '#aaa',
|
64 |
'target-arrow-color': '#aaa',
|
65 |
'target-arrow-shape': 'triangle'
|
|
|
91 |
const rect = document.getElementById('cy').getBoundingClientRect();
|
92 |
const pos = evt.originalEvent;
|
93 |
|
|
|
|
|
94 |
tooltip.innerHTML = '<strong>' + evt.target.data('label') + '</strong><br>' + description;
|
95 |
+
tooltip.style.left = (pos.clientX - rect.left + 20) + 'px';
|
96 |
+
tooltip.style.top = (pos.clientY - rect.top + 20) + 'px';
|
97 |
tooltip.style.display = 'block';
|
98 |
}});
|
99 |
|
100 |
+
cy.on('tap', function(evt) {{
|
101 |
+
if (evt.target === cy) {{
|
102 |
tooltip.style.display = 'none';
|
103 |
}}
|
104 |
}});
|
105 |
</script>
|
106 |
"""
|
107 |
|
108 |
+
# Inject into Streamlit
|
109 |
+
components.html(html, height=550, scrolling=False)
|