caustino commited on
Commit
51a7f4c
·
verified ·
1 Parent(s): 0605e59

Upload streamlit_app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. streamlit_app.py +278 -0
streamlit_app.py ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils import translate_text, fetch_pubmed_articles, fetch_arxiv_articles
3
+ import os
4
+
5
+ # Page configuration
6
+ st.set_page_config(
7
+ page_title="Gov-LLM Transaction Flow",
8
+ page_icon="🏛️",
9
+ layout="wide"
10
+ )
11
+
12
+ # Custom CSS
13
+ st.markdown("""
14
+ <style>
15
+ .main-header {
16
+ font-size: 2.5rem;
17
+ font-weight: bold;
18
+ color: #1f77b4;
19
+ text-align: center;
20
+ margin-bottom: 2rem;
21
+ }
22
+ .sub-header {
23
+ font-size: 1.5rem;
24
+ font-weight: bold;
25
+ color: #ff7f0e;
26
+ margin-top: 1.5rem;
27
+ }
28
+ .built-with {
29
+ font-size: 0.8rem;
30
+ color: #666;
31
+ text-align: right;
32
+ }
33
+ .phase-box {
34
+ border: 2px solid #1f77b4;
35
+ border-radius: 10px;
36
+ padding: 15px;
37
+ margin: 10px 0;
38
+ background-color: #f0f8ff;
39
+ }
40
+ .reference-box {
41
+ background-color: #e6f7ff;
42
+ padding: 10px;
43
+ border-left: 4px solid #1f77b4;
44
+ margin: 10px 0;
45
+ }
46
+ </style>
47
+ """, unsafe_allow_html=True)
48
+
49
+ # Header
50
+ st.markdown('<div class="main-header">Gov-LLM Transaction Flow</div>', unsafe_allow_html=True)
51
+ st.markdown('<div class="built-with">Built with <a href="https://huggingface.co/spaces/akhaliq/anycoder">anycoder</a></div>', unsafe_allow_html=True)
52
+
53
+ # Sidebar
54
+ with st.sidebar:
55
+ st.title("Navigation")
56
+ page = st.radio("Select Phase", ["Overview", "Phase 0", "Phase 1", "Phase 2", "Phase 3", "Phase 4", "Phase 5", "References"])
57
+
58
+ st.divider()
59
+ st.header("About")
60
+ st.markdown("""
61
+ This application demonstrates the Gov-LLM Transaction Flow, a comprehensive framework for ADA-compliant cognitive assistance in government services.
62
+ """)
63
+
64
+ # Main content based on selected page
65
+ if page == "Overview":
66
+ st.header("Gov-LLM Transaction Flow Overview")
67
+ st.markdown("""
68
+ This application presents a complete, executable framework for implementing cognitive accessibility in government services.
69
+ The Gov-LLM Transaction Flow is designed to comply with ADA Title II and Due Process requirements while maintaining
70
+ strict data privacy and security standards.
71
+ """)
72
+
73
+ st.subheader("Key Features")
74
+ st.markdown("""
75
+ - ✅ ADA Title II Compliance
76
+ - ✅ Due Process Protection
77
+ - ✅ Post-Quantum Cryptography
78
+ - ✅ Cognitive Load Reduction
79
+ - ✅ Audit Trail & Accountability
80
+ """)
81
+
82
+ st.subheader("Technical Implementation")
83
+ st.markdown("""
84
+ The system uses:
85
+ - **Kyber-768** for post-quantum key exchange
86
+ - **Dilithium** for digital signatures
87
+ - **RAG (Retrieval-Augmented Generation)** for legal document processing
88
+ - **NIST-compliant** security protocols
89
+ """)
90
+
91
+ elif page == "Phase 0":
92
+ st.markdown('<div class="sub-header">Phase 0: Event-Driven Trigger Mechanism</div>', unsafe_allow_html=True)
93
+
94
+ st.markdown("""
95
+ <div class="phase-box">
96
+ <h3>Operational Trigger</h3>
97
+ <p>A citizen interacts with a .gov interface (SSA, Federal Court, Benefits Portal).</p>
98
+
99
+ <h3>System Action</h3>
100
+ <p>Real-time detection of navigation latency or accessibility metadata triggers the "Cognitive Auxiliary Mode" (Gov-LLM Interface).</p>
101
+
102
+ <h3>Legal Basis</h3>
103
+ <p>Affirmative duty to provide "auxiliary aids and services" (28 C.F.R. § 35.160).</p>
104
+ </div>
105
+ """, unsafe_allow_html=True)
106
+
107
+ st.markdown("""
108
+ <div class="reference-box">
109
+ <h4>Technical & Academic Substantiation</h4>
110
+ <p><strong>Just-in-Time Adaptive Interventions (JITAI):</strong> The system utilizes JITAI principles to deliver support at the moment of cognitive need.</p>
111
+ <p>Reference: Nahum-Shani, I., et al. (2018). "Just-in-Time Adaptive Interventions (JITAIs) in Mobile Health." Annals of Behavioral Medicine.</p>
112
+ """, unsafe_allow_html=True)
113
+
114
+ elif page == "Phase 1":
115
+ st.markdown('<div class="sub-header">Phase 1: Ephemeral Session Initialization</div>', unsafe_allow_html=True)
116
+
117
+ st.markdown("""
118
+ <div class="phase-box">
119
+ <h3>Transaction Input</h3>
120
+ <p>User explicitly consents to "Cognitive Assistance" (Rights-preserving opt-in).</p>
121
+
122
+ <h3>Privacy Protocol</h3>
123
+ <ul>
124
+ <li>Generation of a Cryptographically Random Session ID (UUIDv4)</li>
125
+ <li>No PII Retention: Identity is verified via token, not database storage</li>
126
+ <li>Isolation: The session is "air-gapped" from third-party commercial model training pipelines</li>
127
+ </ul>
128
+
129
+ <h3>Time Point</h3>
130
+ <p>T1 (Cognitive Assistance Begins)</p>
131
+ </div>
132
+ """, unsafe_allow_html=True)
133
+
134
+ elif page == "Phase 2":
135
+ st.markdown('<div class="sub-header">Phase 2: Post-Quantum Cryptographic Enveloping</div>', unsafe_allow_html=True)
136
+
137
+ st.markdown("""
138
+ <div class="phase-box">
139
+ <h3>Transaction Behavior</h3>
140
+ <p>User inputs (medical evidence, pleadings, queries) are instantaneously encapsulated.</p>
141
+
142
+ <h3>Security Architecture</h3>
143
+ <ul>
144
+ <li><strong>Key Exchange:</strong> Kyber-768/1024 (NIST FIPS 203)</li>
145
+ <li><strong>Integrity Signing:</strong> Dilithium (NIST FIPS 204)</li>
146
+ </ul>
147
+
148
+ <h3>Legal Implications</h3>
149
+ <ul>
150
+ <li>✅ Complies with privacy protection standards</li>
151
+ <li>✅ Does not constitute medical data forced disclosure</li>
152
+ </ul>
153
+
154
+ <h3>Time Point</h3>
155
+ <p>T2 (Secure Transaction Established)</p>
156
+ </div>
157
+ """, unsafe_allow_html=True)
158
+
159
+ elif page == "Phase 3":
160
+ st.markdown('<div class="sub-header">Phase 3: Retrieval-Augmented Inference</div>', unsafe_allow_html=True)
161
+
162
+ st.markdown("""
163
+ <div class="phase-box">
164
+ <h3>Core Processing</h3>
165
+ <p>The Gov-LLM processes the query using RAG (Retrieval-Augmented Generation).</p>
166
+
167
+ <h3>Restricted Context Window</h3>
168
+ <ul>
169
+ <li><strong>Allowed Corpus:</strong> USC, CFR, POMS, HALLEX, Public Case Law</li>
170
+ <li><strong>Prohibited Actions:</strong> No internet browsing, no hallucination, no training on user data</li>
171
+ </ul>
172
+
173
+ <h3>Cognitive Transformation</h3>
174
+ <p>Text is processed for "Cognitive Load Reduction" (summarization, step-extraction).</p>
175
+
176
+ <h3>Time Point</h3>
177
+ <p>T3 (Cognitive Translation Complete)</p>
178
+ </div>
179
+ """, unsafe_allow_html=True)
180
+
181
+ elif page == "Phase 4":
182
+ st.markdown('<div class="sub-header">Phase 4: Accessibility Rendering & Verification</div>', unsafe_allow_html=True)
183
+
184
+ st.markdown("""
185
+ <div class="phase-box">
186
+ <h3>Output Format</h3>
187
+ <ul>
188
+ <li>Linearized Logic: Step-by-step instructions (List format)</li>
189
+ <li>State Markers: "You are at Step X of Y"</li>
190
+ <li>Rewind Capability: User can request "Repeat/Rephrase" without penalty</li>
191
+ </ul>
192
+
193
+ <h3>ADA Compliance Check</h3>
194
+ <p>The system verifies the output meets WCAG 2.2 AA/AAA standards for cognitive accessibility.</p>
195
+
196
+ <h3>Time Point</h3>
197
+ <p>T4 (Understandability Achieved)</p>
198
+ </div>
199
+ """, unsafe_allow_html=True)
200
+
201
+ elif page == "Phase 5":
202
+ st.markdown('<div class="sub-header">Phase 5: Secure Termination & Cryptographic Shredding</div>', unsafe_allow_html=True)
203
+
204
+ st.markdown("""
205
+ <div class="phase-box">
206
+ <h3>Termination Condition</h3>
207
+ <ul>
208
+ <li>User closes browser</li>
209
+ <li>Completes task</li>
210
+ <li>Timeout</li>
211
+ </ul>
212
+
213
+ <h3>Data Destruction</h3>
214
+ <ul>
215
+ <li>Forward Secrecy: Ephemeral session keys are destroyed from memory</li>
216
+ <li>Audit Trail: Only a hashed timestamp (SHA-3) remains</li>
217
+ </ul>
218
+
219
+ <h3>Guarantee</h3>
220
+ <ul>
221
+ <li>✅ No data persists for commercial reuse</li>
222
+ <li>✅ No government surveillance</li>
223
+ </ul>
224
+
225
+ <h3>Time Point</h3>
226
+ <p>T5 (Transaction Complete)</p>
227
+ </div>
228
+ """, unsafe_allow_html=True)
229
+
230
+ elif page == "References":
231
+ st.header("Academic and Technical References")
232
+
233
+ st.subheader("Phase 0 - JITAI")
234
+ st.markdown("""
235
+ <div class="reference-box">
236
+ <p>Nahum-Shani, I., et al. (2018). "Just-in-Time Adaptive Interventions (JITAIs) in Mobile Health: Key Components and Design Principles for Engineering and Science." Annals of Behavioral Medicine.</p>
237
+ </div>
238
+ """, unsafe_allow_html=True)
239
+
240
+ st.subheader("Phase 2 - Post-Quantum Cryptography")
241
+ st.markdown("""
242
+ <div class="reference-box">
243
+ <p>Albrecht, M. R., et al. "Lattice-based cryptography and the NIST standardization process." ArXiv.</p>
244
+ <p>NIST FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard</p>
245
+ <p>NIST FIPS 204: Module-Lattice-Based Digital Signature Standard</p>
246
+ </div>
247
+ """, unsafe_allow_html=True)
248
+
249
+ st.subheader("Phase 3 - RAG")
250
+ st.markdown("""
251
+ <div class="reference-box">
252
+ <p>Lewis, P., et al. (2020). "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks." NeurIPS.</p>
253
+ </div>
254
+ """, unsafe_allow_html=True)
255
+
256
+ st.subheader("Phase 4 - Cognitive Load Theory")
257
+ st.markdown("""
258
+ <div class="reference-box">
259
+ <p>Sweller, J. (2011). "Cognitive Load Theory." Psychology of Learning and Motivation.</p>
260
+ <p>WCAG 2.2 Guidelines: Success Criterion 3.3.2 (Labels or Instructions) and 3.1.5 (Reading Level)</p>
261
+ </div>
262
+ """, unsafe_allow_html=True)
263
+
264
+ st.subheader("Phase 5 - Secure Deletion")
265
+ st.markdown("""
266
+ <div class="reference-box">
267
+ <p>NIST SP 800-88 Rev. 1: Guidelines for Media Sanitization</p>
268
+ </div>
269
+ """, unsafe_allow_html=True)
270
+
271
+ # Footer
272
+ st.divider()
273
+ st.markdown("""
274
+ <div style="text-align: center; color: #666; padding: 20px;">
275
+ <p>Gov-LLM Transaction Flow Application | Built with Streamlit</p>
276
+ <p>© 2023 | All rights reserved</p>
277
+ </div>
278
+ """, unsafe_allow_html=True)