Sasidhar commited on
Commit
8479d9f
Β·
verified Β·
1 Parent(s): 6c18cec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -55
app.py CHANGED
@@ -1,26 +1,39 @@
1
  import streamlit as st
2
  import streamlit.components.v1 as components
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.",
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
- 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>
@@ -29,21 +42,29 @@ html = f"""
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: {{
37
  name: 'dagre',
38
  rankDir: 'LR',
39
  nodeSep: 50,
40
  edgeSep: 30,
41
  rankSep: 120
42
- }},
43
  style: [
44
- {{
45
  selector: 'node',
46
- style: {{
47
  'label': 'data(label)',
48
  'text-valign': 'center',
49
  'text-halign': 'center',
@@ -51,41 +72,41 @@ const cy = cytoscape({{
51
  'color': '#fff',
52
  'font-size': '14px',
53
  'text-wrap': 'wrap',
54
- 'text-max-width': 80,
55
  'shape': 'roundrectangle',
56
  'padding': '10px'
57
- }}
58
- }},
59
- {{
60
  selector: 'edge',
61
- style: {{
62
  'width': 2,
63
  'line-color': '#aaa',
64
  'target-arrow-color': '#aaa',
65
  'target-arrow-shape': 'triangle'
66
- }}
67
- }}
68
  ],
69
  elements: [
70
- {{ data: {{ id: 'lodged', label: '1. Claim Lodged' }} }},
71
- {{ data: {{ id: 'fraud', label: '2. Fraud Check' }} }},
72
- {{ data: {{ id: 'coverage', label: '3. Coverage Check' }} }},
73
- {{ data: {{ id: 'builder', label: '4. Builder Assignment' }} }},
74
- {{ data: {{ id: 'schedule', label: '5. Schedule Repairs' }} }},
75
- {{ data: {{ id: 'payment', label: '6. Authorise Payment' }} }},
76
- {{ data: {{ id: 'settle', label: '7. Settle Claim' }} }},
77
- {{ data: {{ source: 'lodged', target: 'fraud' }} }},
78
- {{ data: {{ source: 'fraud', target: 'coverage' }} }},
79
- {{ data: {{ source: 'coverage', target: 'builder' }} }},
80
- {{ data: {{ source: 'builder', target: 'schedule' }} }},
81
- {{ data: {{ source: 'schedule', target: 'payment' }} }},
82
- {{ data: {{ source: 'payment', target: 'settle' }} }}
83
  ]
84
- }});
85
 
86
  const tooltip = document.getElementById('tooltip');
87
 
88
- cy.on('tap', 'node', function(evt) {{
89
  const nodeId = evt.target.id();
90
  const description = stepDetails[nodeId] || "No info available.";
91
  const rect = document.getElementById('cy').getBoundingClientRect();
@@ -95,15 +116,17 @@ cy.on('tap', 'node', function(evt) {{
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)
 
 
 
1
  import streamlit as st
2
  import streamlit.components.v1 as components
 
3
 
4
  st.set_page_config(layout="wide")
5
+ st.title("πŸ—οΈ GenAI Claims Workflow (Horizontal with Tooltips)")
6
 
7
+ # Inline the full HTML, JS, and CSS
8
+ components.html(
9
+ """
10
+ <!DOCTYPE html>
11
+ <html>
12
+ <head>
13
+ <meta charset="utf-8">
14
+ <style>
15
+ #cy {
16
+ width: 100%;
17
+ height: 500px;
18
+ border: 1px solid #ccc;
19
+ }
20
+ #tooltip {
21
+ display: none;
22
+ position: absolute;
23
+ background: white;
24
+ color: black;
25
+ padding: 10px;
26
+ border-radius: 5px;
27
+ border: 1px solid #666;
28
+ box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
29
+ z-index: 10;
30
+ max-width: 300px;
31
+ }
32
+ </style>
33
+ </head>
34
+ <body>
35
+ <div id="cy"></div>
36
+ <div id="tooltip"></div>
37
 
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>
 
42
  <script>
43
  cytoscape.use(window.cytoscapeDagre);
44
 
45
+ const stepDetails = {
46
+ lodged: "πŸ“© Claim is received via the customer portal. If more info is needed, an email is sent.",
47
+ fraud: "πŸ” LLM performs a fraud check using historical claims and language cues.",
48
+ coverage: "πŸ“œ Policy coverage is evaluated for eligibility using claim metadata.",
49
+ builder: "πŸ‘· Based on location and damage type, a builder is assigned.",
50
+ schedule: "πŸ“… Repairs are scheduled between the customer and the builder.",
51
+ payment: "πŸ’³ Payment is authorised after validation of repair progress.",
52
+ settle: "βœ… Final review is done and the claim is marked as settled."
53
+ };
54
 
55
+ const cy = cytoscape({
56
  container: document.getElementById('cy'),
57
+ layout: {
58
  name: 'dagre',
59
  rankDir: 'LR',
60
  nodeSep: 50,
61
  edgeSep: 30,
62
  rankSep: 120
63
+ },
64
  style: [
65
+ {
66
  selector: 'node',
67
+ style: {
68
  'label': 'data(label)',
69
  'text-valign': 'center',
70
  'text-halign': 'center',
 
72
  'color': '#fff',
73
  'font-size': '14px',
74
  'text-wrap': 'wrap',
75
+ 'text-max-width': 100,
76
  'shape': 'roundrectangle',
77
  'padding': '10px'
78
+ }
79
+ },
80
+ {
81
  selector: 'edge',
82
+ style: {
83
  'width': 2,
84
  'line-color': '#aaa',
85
  'target-arrow-color': '#aaa',
86
  'target-arrow-shape': 'triangle'
87
+ }
88
+ }
89
  ],
90
  elements: [
91
+ { data: { id: 'lodged', label: '1. Claim Lodged' }},
92
+ { data: { id: 'fraud', label: '2. Fraud Check' }},
93
+ { data: { id: 'coverage', label: '3. Coverage Check' }},
94
+ { data: { id: 'builder', label: '4. Builder Assignment' }},
95
+ { data: { id: 'schedule', label: '5. Schedule Repairs' }},
96
+ { data: { id: 'payment', label: '6. Authorise Payment' }},
97
+ { data: { id: 'settle', label: '7. Settle Claim' }},
98
+ { data: { source: 'lodged', target: 'fraud' }},
99
+ { data: { source: 'fraud', target: 'coverage' }},
100
+ { data: { source: 'coverage', target: 'builder' }},
101
+ { data: { source: 'builder', target: 'schedule' }},
102
+ { data: { source: 'schedule', target: 'payment' }},
103
+ { data: { source: 'payment', target: 'settle' }}
104
  ]
105
+ });
106
 
107
  const tooltip = document.getElementById('tooltip');
108
 
109
+ cy.on('tap', 'node', function(evt) {
110
  const nodeId = evt.target.id();
111
  const description = stepDetails[nodeId] || "No info available.";
112
  const rect = document.getElementById('cy').getBoundingClientRect();
 
116
  tooltip.style.left = (pos.clientX - rect.left + 20) + 'px';
117
  tooltip.style.top = (pos.clientY - rect.top + 20) + 'px';
118
  tooltip.style.display = 'block';
119
+ });
120
 
121
+ cy.on('tap', function(evt) {
122
+ if (evt.target === cy) {
123
  tooltip.style.display = 'none';
124
+ }
125
+ });
126
  </script>
127
+ </body>
128
+ </html>
129
+ """,
130
+ height=550,
131
+ scrolling=False
132
+ )