Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -42,8 +42,9 @@ st.markdown("""
|
|
42 |
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
|
43 |
color: #333;
|
44 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
45 |
-
max-width:
|
46 |
margin: 0 auto;
|
|
|
47 |
}
|
48 |
|
49 |
.header {
|
@@ -103,26 +104,30 @@ st.markdown("""
|
|
103 |
animation: fadeIn 0.8s ease;
|
104 |
}
|
105 |
|
106 |
-
.country-
|
107 |
display: flex;
|
108 |
align-items: center;
|
109 |
-
|
110 |
-
|
|
|
|
|
111 |
border-radius: 15px;
|
112 |
background: white;
|
113 |
box-shadow: var(--card-shadow);
|
114 |
-
margin-bottom:
|
115 |
cursor: pointer;
|
116 |
transition: var(--transition);
|
117 |
border: 2px solid transparent;
|
|
|
|
|
118 |
}
|
119 |
|
120 |
-
.country-
|
121 |
-
transform:
|
122 |
box-shadow: 0 10px 25px rgba(0,0,0,0.15);
|
123 |
}
|
124 |
|
125 |
-
.country-
|
126 |
background: linear-gradient(135deg, var(--light) 0%, #d6eaf8 100%);
|
127 |
border: 2px solid var(--accent);
|
128 |
box-shadow: 0 8px 25px rgba(0,0,0,0.12);
|
@@ -160,19 +165,70 @@ st.markdown("""
|
|
160 |
animation: pulse 2s infinite;
|
161 |
}
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
@media (max-width: 768px) {
|
164 |
.header {
|
165 |
padding: 1.8rem 1.2rem;
|
|
|
166 |
}
|
167 |
|
168 |
.card {
|
169 |
padding: 1.5rem;
|
170 |
}
|
171 |
|
172 |
-
.scenario-btn {
|
173 |
padding: 1rem;
|
174 |
font-size: 1rem;
|
175 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
177 |
</style>
|
178 |
""", unsafe_allow_html=True)
|
@@ -190,7 +246,11 @@ COUNTRIES = {
|
|
190 |
"π§π· Brazil": "BR",
|
191 |
"πΏπ¦ South Africa": "ZA",
|
192 |
"πͺπΈ Spain": "ES",
|
193 |
-
"πΈπ¬ Singapore": "SG"
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
|
196 |
# Common legal scenarios
|
@@ -211,9 +271,9 @@ SCENARIOS = [
|
|
211 |
|
212 |
# LLM models available on Groq
|
213 |
MODELS = {
|
214 |
-
"Llama3-70b (
|
215 |
-
"Llama3-8b (Fast)": "llama3-8b-8192",
|
216 |
-
"Mixtral-8x7b": "mixtral-8x7b-32768"
|
217 |
}
|
218 |
|
219 |
# Function to get rights information from Groq API
|
@@ -303,13 +363,14 @@ def main():
|
|
303 |
|
304 |
# Model selection at top
|
305 |
st.markdown("### βοΈ AI Model Selection")
|
306 |
-
model_cols = st.columns(
|
307 |
with model_cols[0]:
|
308 |
selected_model = st.selectbox("Choose AI Model", list(MODELS.keys()), index=0)
|
309 |
|
310 |
with model_cols[1]:
|
311 |
-
st.markdown("### π Country")
|
312 |
-
st.
|
|
|
313 |
|
314 |
# Main content columns
|
315 |
col1, col2 = st.columns([1, 1.2], gap="large")
|
@@ -318,22 +379,49 @@ def main():
|
|
318 |
st.markdown("### π Select Your Country")
|
319 |
st.markdown("Choose your country to see jurisdiction-specific rights information")
|
320 |
|
321 |
-
#
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
|
333 |
# Country visualization
|
334 |
st.markdown("### π Global Rights Index")
|
335 |
countries = list(COUNTRIES.values())
|
336 |
-
awareness = [92, 89, 87, 85, 82, 88, 86, 84, 79, 81, 85, 83] # Simulated data
|
337 |
|
338 |
fig = px.bar(
|
339 |
x=countries,
|
@@ -341,43 +429,50 @@ def main():
|
|
341 |
labels={'x': 'Country', 'y': 'Rights Awareness'},
|
342 |
color=awareness,
|
343 |
color_continuous_scale='Teal',
|
344 |
-
height=
|
345 |
)
|
346 |
fig.update_layout(
|
347 |
plot_bgcolor='rgba(0,0,0,0)',
|
348 |
paper_bgcolor='rgba(0,0,0,0)',
|
349 |
-
margin=dict(l=0, r=0, t=30, b=0)
|
|
|
350 |
)
|
351 |
st.plotly_chart(fig, use_container_width=True)
|
352 |
|
353 |
# Legal resources
|
354 |
-
with st.expander("π Legal Resources & References"):
|
355 |
st.markdown("""
|
356 |
- [United Nations Human Rights](https://www.ohchr.org/)
|
357 |
- [International Justice Resource Center](https://ijrcenter.org/)
|
358 |
- [Global Legal Information Network](https://www.loc.gov/law/help/legal-info.php)
|
359 |
- [World Legal Information Institute](https://www.worldlii.org/)
|
360 |
- [Amnesty International](https://www.amnesty.org/)
|
|
|
361 |
""")
|
362 |
|
363 |
with col2:
|
364 |
st.markdown("### π¨ Select a Legal Scenario")
|
365 |
st.markdown("Choose a situation to understand your rights and protections")
|
366 |
|
367 |
-
# Create buttons for each scenario
|
368 |
-
|
369 |
for i, scenario in enumerate(SCENARIOS):
|
370 |
-
with
|
371 |
if st.button(
|
372 |
f"**{scenario}**",
|
373 |
-
key=scenario,
|
374 |
use_container_width=True,
|
375 |
help=f"Click to see your rights for {scenario}"
|
376 |
):
|
377 |
st.session_state.selected_scenario = scenario
|
378 |
|
379 |
# Custom scenario input
|
380 |
-
|
|
|
|
|
|
|
|
|
|
|
381 |
if custom_scenario:
|
382 |
st.session_state.selected_scenario = custom_scenario
|
383 |
|
@@ -400,21 +495,28 @@ def main():
|
|
400 |
st.error("Failed to get response. Please try again.")
|
401 |
else:
|
402 |
st.info("π Please select a legal scenario to see your rights information")
|
403 |
-
st.
|
404 |
-
|
|
|
|
|
|
|
|
|
|
|
405 |
|
406 |
st.markdown("""
|
407 |
<div class="card">
|
408 |
-
<h3>Why
|
409 |
<p>Understanding your legal rights empowers you to:</p>
|
410 |
<ul>
|
411 |
-
<li>Protect yourself in
|
412 |
-
<li>Make informed decisions when facing
|
413 |
<li>Prevent exploitation and rights violations</li>
|
414 |
<li>Access justice when your rights are infringed</li>
|
415 |
<li>Confidently navigate complex legal systems</li>
|
416 |
</ul>
|
417 |
-
<p style="margin-top:15px;font-style:italic;
|
|
|
|
|
418 |
</div>
|
419 |
""", unsafe_allow_html=True)
|
420 |
|
|
|
42 |
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
|
43 |
color: #333;
|
44 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
45 |
+
max-width: 1200px;
|
46 |
margin: 0 auto;
|
47 |
+
padding: 0 20px;
|
48 |
}
|
49 |
|
50 |
.header {
|
|
|
104 |
animation: fadeIn 0.8s ease;
|
105 |
}
|
106 |
|
107 |
+
.country-btn {
|
108 |
display: flex;
|
109 |
align-items: center;
|
110 |
+
justify-content: center;
|
111 |
+
gap: 10px;
|
112 |
+
width: 100%;
|
113 |
+
padding: 1.2rem;
|
114 |
border-radius: 15px;
|
115 |
background: white;
|
116 |
box-shadow: var(--card-shadow);
|
117 |
+
margin-bottom: 15px;
|
118 |
cursor: pointer;
|
119 |
transition: var(--transition);
|
120 |
border: 2px solid transparent;
|
121 |
+
font-weight: 600;
|
122 |
+
font-size: 1.1rem;
|
123 |
}
|
124 |
|
125 |
+
.country-btn:hover {
|
126 |
+
transform: translateY(-5px);
|
127 |
box-shadow: 0 10px 25px rgba(0,0,0,0.15);
|
128 |
}
|
129 |
|
130 |
+
.country-btn.selected {
|
131 |
background: linear-gradient(135deg, var(--light) 0%, #d6eaf8 100%);
|
132 |
border: 2px solid var(--accent);
|
133 |
box-shadow: 0 8px 25px rgba(0,0,0,0.12);
|
|
|
165 |
animation: pulse 2s infinite;
|
166 |
}
|
167 |
|
168 |
+
@media (max-width: 992px) {
|
169 |
+
.stApp {
|
170 |
+
padding: 0 15px;
|
171 |
+
}
|
172 |
+
|
173 |
+
.header {
|
174 |
+
padding: 2rem 1.5rem;
|
175 |
+
}
|
176 |
+
|
177 |
+
.card {
|
178 |
+
padding: 1.8rem;
|
179 |
+
}
|
180 |
+
|
181 |
+
.scenario-btn, .country-btn {
|
182 |
+
padding: 1.1rem;
|
183 |
+
font-size: 1.05rem;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
@media (max-width: 768px) {
|
188 |
.header {
|
189 |
padding: 1.8rem 1.2rem;
|
190 |
+
border-radius: 0 0 20px 20px;
|
191 |
}
|
192 |
|
193 |
.card {
|
194 |
padding: 1.5rem;
|
195 |
}
|
196 |
|
197 |
+
.scenario-btn, .country-btn {
|
198 |
padding: 1rem;
|
199 |
font-size: 1rem;
|
200 |
}
|
201 |
+
|
202 |
+
.response-card {
|
203 |
+
padding: 1.8rem;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
@media (max-width: 576px) {
|
208 |
+
.stApp {
|
209 |
+
padding: 0 10px;
|
210 |
+
}
|
211 |
+
|
212 |
+
.header h1 {
|
213 |
+
font-size: 2.2rem !important;
|
214 |
+
}
|
215 |
+
|
216 |
+
.header p {
|
217 |
+
font-size: 1.1rem !important;
|
218 |
+
}
|
219 |
+
|
220 |
+
.card {
|
221 |
+
padding: 1.2rem;
|
222 |
+
}
|
223 |
+
|
224 |
+
.scenario-btn, .country-btn {
|
225 |
+
padding: 0.9rem;
|
226 |
+
font-size: 0.95rem;
|
227 |
+
}
|
228 |
+
|
229 |
+
.response-card {
|
230 |
+
padding: 1.5rem;
|
231 |
+
}
|
232 |
}
|
233 |
</style>
|
234 |
""", unsafe_allow_html=True)
|
|
|
246 |
"π§π· Brazil": "BR",
|
247 |
"πΏπ¦ South Africa": "ZA",
|
248 |
"πͺπΈ Spain": "ES",
|
249 |
+
"πΈπ¬ Singapore": "SG",
|
250 |
+
"π²π½ Mexico": "MX",
|
251 |
+
"π³π± Netherlands": "NL",
|
252 |
+
"πΈπͺ Sweden": "SE",
|
253 |
+
"π³π΄ Norway": "NO"
|
254 |
}
|
255 |
|
256 |
# Common legal scenarios
|
|
|
271 |
|
272 |
# LLM models available on Groq
|
273 |
MODELS = {
|
274 |
+
"Llama3-70b (Highest Accuracy)": "llama3-70b-8192",
|
275 |
+
"Llama3-8b (Fast Response)": "llama3-8b-8192",
|
276 |
+
"Mixtral-8x7b (Balanced)": "mixtral-8x7b-32768"
|
277 |
}
|
278 |
|
279 |
# Function to get rights information from Groq API
|
|
|
363 |
|
364 |
# Model selection at top
|
365 |
st.markdown("### βοΈ AI Model Selection")
|
366 |
+
model_cols = st.columns([1, 1, 2])
|
367 |
with model_cols[0]:
|
368 |
selected_model = st.selectbox("Choose AI Model", list(MODELS.keys()), index=0)
|
369 |
|
370 |
with model_cols[1]:
|
371 |
+
st.markdown("### π Selected Country")
|
372 |
+
st.markdown(f"<div style='font-size:1.2rem;font-weight:bold;'>{st.session_state.selected_country}</div>",
|
373 |
+
unsafe_allow_html=True)
|
374 |
|
375 |
# Main content columns
|
376 |
col1, col2 = st.columns([1, 1.2], gap="large")
|
|
|
379 |
st.markdown("### π Select Your Country")
|
380 |
st.markdown("Choose your country to see jurisdiction-specific rights information")
|
381 |
|
382 |
+
# Create 2 columns for country buttons
|
383 |
+
country_col1, country_col2 = st.columns(2)
|
384 |
+
|
385 |
+
# Split countries into two groups
|
386 |
+
countries_list = list(COUNTRIES.keys())
|
387 |
+
mid_index = len(countries_list) // 2
|
388 |
+
countries_col1 = countries_list[:mid_index]
|
389 |
+
countries_col2 = countries_list[mid_index:]
|
390 |
+
|
391 |
+
# First column of countries
|
392 |
+
with country_col1:
|
393 |
+
for country_display in countries_col1:
|
394 |
+
is_selected = st.session_state.selected_country == country_display
|
395 |
+
btn_class = "country-btn selected" if is_selected else "country-btn"
|
396 |
+
|
397 |
+
if st.button(
|
398 |
+
country_display,
|
399 |
+
key=f"btn_{country_display}",
|
400 |
+
use_container_width=True
|
401 |
+
):
|
402 |
+
st.session_state.selected_country = country_display
|
403 |
+
st.session_state.selected_scenario = None
|
404 |
+
st.rerun()
|
405 |
+
|
406 |
+
# Second column of countries
|
407 |
+
with country_col2:
|
408 |
+
for country_display in countries_col2:
|
409 |
+
is_selected = st.session_state.selected_country == country_display
|
410 |
+
btn_class = "country-btn selected" if is_selected else "country-btn"
|
411 |
+
|
412 |
+
if st.button(
|
413 |
+
country_display,
|
414 |
+
key=f"btn_{country_display}",
|
415 |
+
use_container_width=True
|
416 |
+
):
|
417 |
+
st.session_state.selected_country = country_display
|
418 |
+
st.session_state.selected_scenario = None
|
419 |
+
st.rerun()
|
420 |
|
421 |
# Country visualization
|
422 |
st.markdown("### π Global Rights Index")
|
423 |
countries = list(COUNTRIES.values())
|
424 |
+
awareness = [92, 89, 87, 85, 82, 88, 86, 84, 79, 81, 85, 83, 80, 78, 90, 85] # Simulated data
|
425 |
|
426 |
fig = px.bar(
|
427 |
x=countries,
|
|
|
429 |
labels={'x': 'Country', 'y': 'Rights Awareness'},
|
430 |
color=awareness,
|
431 |
color_continuous_scale='Teal',
|
432 |
+
height=350
|
433 |
)
|
434 |
fig.update_layout(
|
435 |
plot_bgcolor='rgba(0,0,0,0)',
|
436 |
paper_bgcolor='rgba(0,0,0,0)',
|
437 |
+
margin=dict(l=0, r=0, t=30, b=0),
|
438 |
+
xaxis_tickangle=-45
|
439 |
)
|
440 |
st.plotly_chart(fig, use_container_width=True)
|
441 |
|
442 |
# Legal resources
|
443 |
+
with st.expander("π Legal Resources & References", expanded=True):
|
444 |
st.markdown("""
|
445 |
- [United Nations Human Rights](https://www.ohchr.org/)
|
446 |
- [International Justice Resource Center](https://ijrcenter.org/)
|
447 |
- [Global Legal Information Network](https://www.loc.gov/law/help/legal-info.php)
|
448 |
- [World Legal Information Institute](https://www.worldlii.org/)
|
449 |
- [Amnesty International](https://www.amnesty.org/)
|
450 |
+
- [Human Rights Watch](https://www.hrw.org/)
|
451 |
""")
|
452 |
|
453 |
with col2:
|
454 |
st.markdown("### π¨ Select a Legal Scenario")
|
455 |
st.markdown("Choose a situation to understand your rights and protections")
|
456 |
|
457 |
+
# Create buttons for each scenario in 2 columns
|
458 |
+
scenario_cols = st.columns(2)
|
459 |
for i, scenario in enumerate(SCENARIOS):
|
460 |
+
with scenario_cols[i % 2]:
|
461 |
if st.button(
|
462 |
f"**{scenario}**",
|
463 |
+
key=f"scen_{scenario}",
|
464 |
use_container_width=True,
|
465 |
help=f"Click to see your rights for {scenario}"
|
466 |
):
|
467 |
st.session_state.selected_scenario = scenario
|
468 |
|
469 |
# Custom scenario input
|
470 |
+
st.markdown("#### βοΈ Or describe your specific situation:")
|
471 |
+
custom_scenario = st.text_input(
|
472 |
+
"Describe your legal concern:",
|
473 |
+
placeholder="e.g., 'Rights during home search', 'Employee privacy rights'",
|
474 |
+
label_visibility="collapsed"
|
475 |
+
)
|
476 |
if custom_scenario:
|
477 |
st.session_state.selected_scenario = custom_scenario
|
478 |
|
|
|
495 |
st.error("Failed to get response. Please try again.")
|
496 |
else:
|
497 |
st.info("π Please select a legal scenario to see your rights information")
|
498 |
+
st.markdown("""
|
499 |
+
<div style="text-align:center; margin:20px 0;">
|
500 |
+
<img src="https://images.unsplash.com/photo-1589391886645-d51941baf7fb?auto=format&fit=crop&w=600&h=400"
|
501 |
+
style="width:100%; border-radius:15px; box-shadow:0 6px 20px rgba(0,0,0,0.1);">
|
502 |
+
<p style="margin-top:10px;font-style:italic;color:#666;">Know Your Rights, Exercise Your Freedom</p>
|
503 |
+
</div>
|
504 |
+
""", unsafe_allow_html=True)
|
505 |
|
506 |
st.markdown("""
|
507 |
<div class="card">
|
508 |
+
<h3>Why Knowing Your Rights Matters</h3>
|
509 |
<p>Understanding your legal rights empowers you to:</p>
|
510 |
<ul>
|
511 |
+
<li>Protect yourself in challenging legal situations</li>
|
512 |
+
<li>Make informed decisions when facing authorities</li>
|
513 |
<li>Prevent exploitation and rights violations</li>
|
514 |
<li>Access justice when your rights are infringed</li>
|
515 |
<li>Confidently navigate complex legal systems</li>
|
516 |
</ul>
|
517 |
+
<p style="margin-top:15px;font-style:italic;border-left:3px solid #3498db;padding-left:15px;">
|
518 |
+
"The first defense against injustice is knowledge of your rights."
|
519 |
+
</p>
|
520 |
</div>
|
521 |
""", unsafe_allow_html=True)
|
522 |
|