Update app.py
Browse files
app.py
CHANGED
@@ -3,85 +3,119 @@ import streamlit.components.v1 as components
|
|
3 |
import json
|
4 |
|
5 |
st.set_page_config(layout="wide")
|
6 |
-
st.title("GenAI Claims Workflow
|
7 |
|
8 |
-
# Define
|
9 |
step_details = {
|
10 |
-
"lodged": "
|
11 |
-
"fraud": "LLM
|
12 |
-
"coverage": "
|
13 |
-
"builder": "
|
14 |
-
"schedule": "
|
15 |
-
"payment": "
|
16 |
-
"settle": "
|
17 |
}
|
18 |
-
|
19 |
node_data = json.dumps(step_details)
|
20 |
|
|
|
21 |
html_content = f"""
|
22 |
<div id="cy" style="width: 100%; height: 500px; border:1px solid #ccc;"></div>
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
<script src="https://unpkg.com/[email protected]/dist/cytoscape.min.js"></script>
|
25 |
<script>
|
26 |
-
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
}},
|
62 |
-
{{
|
63 |
-
selector: 'edge',
|
64 |
-
style: {{
|
65 |
-
'width': 2,
|
66 |
-
'line-color': '#aaa',
|
67 |
-
'target-arrow-color': '#aaa',
|
68 |
-
'target-arrow-shape': 'triangle'
|
69 |
-
}}
|
70 |
}}
|
71 |
-
],
|
72 |
-
layout: {{
|
73 |
-
name: 'breadthfirst',
|
74 |
-
directed: true,
|
75 |
-
padding: 10
|
76 |
}}
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
</script>
|
85 |
"""
|
86 |
|
87 |
-
|
|
|
|
3 |
import json
|
4 |
|
5 |
st.set_page_config(layout="wide")
|
6 |
+
st.title("ποΈ GenAI Claims Workflow (Interactive & Horizontal)")
|
7 |
|
8 |
+
# Define step descriptions
|
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.",
|
12 |
+
"coverage": "π Policy coverage is evaluated for eligibility using claim metadata.",
|
13 |
+
"builder": "π· Based on location and damage type, a builder is assigned.",
|
14 |
+
"schedule": "π
Repairs are scheduled between the customer and the builder.",
|
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 |
node_data = json.dumps(step_details)
|
19 |
|
20 |
+
# Cytoscape HTML + JS
|
21 |
html_content = f"""
|
22 |
<div id="cy" style="width: 100%; height: 500px; border:1px solid #ccc;"></div>
|
23 |
+
|
24 |
+
<!-- Tooltip box -->
|
25 |
+
<div id="tooltip" style="
|
26 |
+
display:none;
|
27 |
+
position:absolute;
|
28 |
+
background-color:white;
|
29 |
+
color:black;
|
30 |
+
border:1px solid #999;
|
31 |
+
padding:10px;
|
32 |
+
border-radius:5px;
|
33 |
+
font-size:14px;
|
34 |
+
box-shadow:2px 2px 10px rgba(0,0,0,0.2);
|
35 |
+
max-width: 300px;
|
36 |
+
z-index: 10;
|
37 |
+
"></div>
|
38 |
+
|
39 |
<script src="https://unpkg.com/[email protected]/dist/cytoscape.min.js"></script>
|
40 |
<script>
|
41 |
+
const stepDetails = {node_data};
|
42 |
|
43 |
+
const cy = cytoscape({{
|
44 |
+
container: document.getElementById('cy'),
|
45 |
+
layout: {{
|
46 |
+
name: 'breadthfirst',
|
47 |
+
directed: true,
|
48 |
+
padding: 10,
|
49 |
+
orientation: 'horizontal'
|
50 |
+
}},
|
51 |
+
style: [
|
52 |
+
{{
|
53 |
+
selector: 'node',
|
54 |
+
style: {{
|
55 |
+
'label': 'data(label)',
|
56 |
+
'text-valign': 'center',
|
57 |
+
'text-halign': 'center',
|
58 |
+
'background-color': '#0077B6',
|
59 |
+
'color': 'white',
|
60 |
+
'font-size': '14px',
|
61 |
+
'text-wrap': 'wrap',
|
62 |
+
'text-max-width': 100,
|
63 |
+
'width': 'label',
|
64 |
+
'height': 'label',
|
65 |
+
'padding': '10px',
|
66 |
+
'shape': 'roundrectangle'
|
67 |
+
}}
|
68 |
+
}},
|
69 |
+
{{
|
70 |
+
selector: 'edge',
|
71 |
+
style: {{
|
72 |
+
'width': 3,
|
73 |
+
'line-color': '#aaa',
|
74 |
+
'target-arrow-color': '#aaa',
|
75 |
+
'target-arrow-shape': 'triangle'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}}
|
|
|
|
|
|
|
|
|
|
|
77 |
}}
|
78 |
+
],
|
79 |
+
elements: [
|
80 |
+
{{ data: {{ id: 'lodged', label: '1. Claim Lodged' }} }},
|
81 |
+
{{ data: {{ id: 'fraud', label: '2. Fraud Check' }} }},
|
82 |
+
{{ data: {{ id: 'coverage', label: '3. Coverage Check' }} }},
|
83 |
+
{{ data: {{ id: 'builder', label: '4. Builder Assignment' }} }},
|
84 |
+
{{ data: {{ id: 'schedule', label: '5. Schedule Repairs' }} }},
|
85 |
+
{{ data: {{ id: 'payment', label: '6. Authorise Payment' }} }},
|
86 |
+
{{ data: {{ id: 'settle', label: '7. Settle Claim' }} }},
|
87 |
+
{{ data: {{ source: 'lodged', target: 'fraud' }} }},
|
88 |
+
{{ data: {{ source: 'fraud', target: 'coverage' }} }},
|
89 |
+
{{ data: {{ source: 'coverage', target: 'builder' }} }},
|
90 |
+
{{ data: {{ source: 'builder', target: 'schedule' }} }},
|
91 |
+
{{ data: {{ source: 'schedule', target: 'payment' }} }},
|
92 |
+
{{ data: {{ source: 'payment', target: 'settle' }} }},
|
93 |
+
]
|
94 |
+
}});
|
95 |
+
|
96 |
+
const tooltip = document.getElementById('tooltip');
|
97 |
+
|
98 |
+
// Show tooltip on node click
|
99 |
+
cy.on('tap', 'node', function(evt){{
|
100 |
+
const nodeId = evt.target.id();
|
101 |
+
const description = stepDetails[nodeId] || "No info available.";
|
102 |
+
|
103 |
+
const rect = document.getElementById('cy').getBoundingClientRect();
|
104 |
+
const pos = evt.originalEvent;
|
105 |
+
|
106 |
+
tooltip.style.left = (pos.clientX - rect.left + 10) + 'px';
|
107 |
+
tooltip.style.top = (pos.clientY - rect.top + 10) + 'px';
|
108 |
+
tooltip.innerHTML = '<strong>' + evt.target.data('label') + '</strong><br>' + description;
|
109 |
+
tooltip.style.display = 'block';
|
110 |
+
}});
|
111 |
|
112 |
+
cy.on('tap', function(event) {{
|
113 |
+
if (event.target === cy) {{
|
114 |
+
tooltip.style.display = 'none';
|
115 |
+
}}
|
116 |
+
}});
|
117 |
</script>
|
118 |
"""
|
119 |
|
120 |
+
# Inject HTML into Streamlit app
|
121 |
+
components.html(html_content, height=550, scrolling=False)
|