Sasidhar commited on
Commit
1edbc6c
Β·
verified Β·
1 Parent(s): da13ad4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -52
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 (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.",
@@ -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 box -->
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: 'breadthfirst',
47
- directed: true,
48
- padding: 10,
49
- orientation: 'horizontal'
 
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
- 'width': 'label',
64
- 'height': 'label',
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: {{ 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)
 
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: