Update app.py
Browse files
app.py
CHANGED
@@ -3,9 +3,8 @@ 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 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.",
|
@@ -17,11 +16,10 @@ step_details = {
|
|
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
|
25 |
<div id="tooltip" style="
|
26 |
display:none;
|
27 |
position:absolute;
|
@@ -36,17 +34,24 @@ html_content = f"""
|
|
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: '
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
50 |
}},
|
51 |
style: [
|
52 |
{{
|
@@ -60,10 +65,8 @@ const cy = cytoscape({{
|
|
60 |
'font-size': '14px',
|
61 |
'text-wrap': 'wrap',
|
62 |
'text-max-width': 100,
|
63 |
-
'
|
64 |
-
'
|
65 |
-
'padding': '10px',
|
66 |
-
'shape': 'roundrectangle'
|
67 |
}}
|
68 |
}},
|
69 |
{{
|
@@ -79,43 +82,4 @@ const cy = cytoscape({{
|
|
79 |
elements: [
|
80 |
{{ data: {{ id: 'lodged', label: '1. Claim Lodged' }} }},
|
81 |
{{ data: {{ id: 'fraud', label: '2. Fraud Check' }} }},
|
82 |
-
{{ data:
|
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)
|
|
|
3 |
import json
|
4 |
|
5 |
st.set_page_config(layout="wide")
|
6 |
+
st.title("ποΈ GenAI Claims Workflow (Horizontal + Popup)")
|
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.",
|
|
|
16 |
}
|
17 |
node_data = json.dumps(step_details)
|
18 |
|
|
|
19 |
html_content = f"""
|
20 |
<div id="cy" style="width: 100%; height: 500px; border:1px solid #ccc;"></div>
|
21 |
|
22 |
+
<!-- Tooltip -->
|
23 |
<div id="tooltip" style="
|
24 |
display:none;
|
25 |
position:absolute;
|
|
|
34 |
z-index: 10;
|
35 |
"></div>
|
36 |
|
37 |
+
<!-- Load Cytoscape and dagre extension -->
|
38 |
<script src="https://unpkg.com/[email protected]/dist/cytoscape.min.js"></script>
|
39 |
+
<script src="https://unpkg.com/[email protected]/dist/dagre.min.js"></script>
|
40 |
+
<script src="https://unpkg.com/[email protected]/cytoscape-dagre.js"></script>
|
41 |
+
|
42 |
<script>
|
43 |
const stepDetails = {node_data};
|
44 |
|
45 |
+
cytoscape.use(window.cytoscapeDagre);
|
46 |
+
|
47 |
const cy = cytoscape({{
|
48 |
container: document.getElementById('cy'),
|
49 |
layout: {{
|
50 |
+
name: 'dagre',
|
51 |
+
rankDir: 'LR', // Left to Right
|
52 |
+
nodeSep: 50,
|
53 |
+
edgeSep: 30,
|
54 |
+
rankSep: 100
|
55 |
}},
|
56 |
style: [
|
57 |
{{
|
|
|
65 |
'font-size': '14px',
|
66 |
'text-wrap': 'wrap',
|
67 |
'text-max-width': 100,
|
68 |
+
'shape': 'roundrectangle',
|
69 |
+
'padding': '10px'
|
|
|
|
|
70 |
}}
|
71 |
}},
|
72 |
{{
|
|
|
82 |
elements: [
|
83 |
{{ data: {{ id: 'lodged', label: '1. Claim Lodged' }} }},
|
84 |
{{ data: {{ id: 'fraud', label: '2. Fraud Check' }} }},
|
85 |
+
{{ data:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|