Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,108 +1,141 @@
|
|
1 |
# app.py
|
2 |
-
import os
|
3 |
import streamlit as st
|
4 |
-
|
5 |
import time
|
6 |
import plotly.express as px
|
|
|
7 |
from dotenv import load_dotenv
|
8 |
|
9 |
# Load environment variables
|
10 |
load_dotenv()
|
11 |
|
12 |
-
# Initialize Groq client
|
13 |
-
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
14 |
-
|
15 |
# Set up Streamlit page
|
16 |
st.set_page_config(
|
17 |
page_title="Legal Rights Explorer",
|
18 |
page_icon="⚖️",
|
19 |
layout="wide",
|
20 |
-
initial_sidebar_state="
|
21 |
)
|
22 |
|
23 |
-
# Custom CSS for styling
|
24 |
st.markdown("""
|
25 |
<style>
|
26 |
:root {
|
27 |
-
--primary: #
|
28 |
-
--secondary: #
|
29 |
-
--accent: #
|
30 |
-
--
|
31 |
-
--dark: #
|
32 |
-
--
|
33 |
-
--
|
34 |
}
|
35 |
|
36 |
.stApp {
|
37 |
-
background: linear-gradient(135deg, #
|
38 |
-
color:
|
|
|
39 |
}
|
40 |
|
41 |
.header {
|
42 |
-
background: linear-gradient(90deg, var(--
|
43 |
color: white;
|
44 |
-
padding: 1.
|
45 |
border-radius: 0 0 20px 20px;
|
46 |
-
box-shadow:
|
47 |
-
margin-bottom:
|
48 |
}
|
49 |
|
50 |
.card {
|
51 |
background: white;
|
52 |
border-radius: 15px;
|
53 |
-
padding: 1.
|
54 |
-
box-shadow:
|
55 |
-
margin-bottom: 1.
|
56 |
-
transition:
|
|
|
57 |
}
|
58 |
|
59 |
.card:hover {
|
|
|
60 |
transform: translateY(-5px);
|
61 |
-
box-shadow: 0 10px 25px rgba(0,0,0,0.15);
|
62 |
}
|
63 |
|
64 |
.scenario-btn {
|
65 |
width: 100%;
|
66 |
-
padding: 1rem;
|
67 |
-
background: linear-gradient(
|
68 |
color: white;
|
69 |
border: none;
|
70 |
border-radius: 12px;
|
71 |
font-weight: 600;
|
72 |
-
margin: 0.
|
73 |
cursor: pointer;
|
74 |
transition: all 0.3s ease;
|
|
|
|
|
|
|
75 |
}
|
76 |
|
77 |
.scenario-btn:hover {
|
78 |
-
background: linear-gradient(
|
79 |
transform: scale(1.02);
|
80 |
}
|
81 |
|
82 |
.response-card {
|
83 |
-
background:
|
84 |
-
border-left: 5px solid var(--
|
85 |
-
border-radius:
|
86 |
-
padding:
|
87 |
-
margin-top:
|
88 |
-
box-shadow:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
|
91 |
.footer {
|
92 |
text-align: center;
|
93 |
-
padding:
|
94 |
-
margin-top:
|
95 |
-
color: var(--
|
96 |
-
font-size: 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
|
99 |
@media (max-width: 768px) {
|
100 |
.header {
|
101 |
-
padding:
|
102 |
}
|
103 |
|
104 |
.card {
|
105 |
-
padding:
|
106 |
}
|
107 |
}
|
108 |
</style>
|
@@ -112,16 +145,16 @@ st.markdown("""
|
|
112 |
COUNTRIES = {
|
113 |
"🇺🇸 United States": "US",
|
114 |
"🇬🇧 United Kingdom": "UK",
|
115 |
-
"🇨🇦 Canada": "
|
116 |
-
"🇦🇺 Australia": "
|
117 |
-
"🇮🇳 India": "
|
118 |
-
"🇩🇪 Germany": "
|
119 |
-
"🇫🇷 France": "
|
120 |
-
"🇯🇵 Japan": "
|
121 |
-
"🇧🇷 Brazil": "
|
122 |
-
"🇿🇦 South Africa": "
|
123 |
-
"🇪🇸 Spain": "
|
124 |
-
"🇮🇹 Italy": "
|
125 |
}
|
126 |
|
127 |
# Common legal scenarios
|
@@ -140,166 +173,211 @@ SCENARIOS = [
|
|
140 |
"Immigration Rights"
|
141 |
]
|
142 |
|
143 |
-
#
|
144 |
-
|
145 |
-
"
|
146 |
-
|
147 |
-
|
148 |
-
"Gemma-7b-It": "gemma-7b-it"
|
149 |
-
}
|
150 |
-
|
151 |
-
# Function to get rights information from Groq API
|
152 |
-
def get_legal_rights(country, scenario, model_name):
|
153 |
-
"""Get legal rights information using Groq API"""
|
154 |
-
system_prompt = f"""
|
155 |
-
You are an expert legal assistant specializing in {country} law.
|
156 |
-
Provide clear, accurate information about an individual's rights in the given scenario.
|
157 |
|
158 |
-
|
159 |
-
|
160 |
-
- Use plain language understandable to non-lawyers
|
161 |
-
- Include relevant legal references when appropriate
|
162 |
-
- Highlight any critical actions the person should take
|
163 |
-
- Mention any country-specific variations
|
164 |
-
- Keep response under 300 words
|
165 |
-
- Format with emojis for readability
|
166 |
-
"""
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
206 |
|
207 |
-
#
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
# Add a blinking cursor to simulate typing
|
212 |
-
message_placeholder.markdown(f'<div class="response-card">{full_response}▌</div>', unsafe_allow_html=True)
|
213 |
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
# Main app
|
218 |
def main():
|
219 |
# Header section
|
220 |
st.markdown("""
|
221 |
<div class="header">
|
222 |
-
<h1>Legal Rights Explorer</h1>
|
223 |
-
<p>Know your rights in any situation, anywhere in the world</p>
|
224 |
</div>
|
225 |
""", unsafe_allow_html=True)
|
226 |
|
227 |
-
#
|
228 |
-
|
229 |
-
st.
|
230 |
-
|
231 |
-
|
232 |
-
st.
|
233 |
-
st.markdown("### About")
|
234 |
-
st.markdown("This app helps you understand your legal rights in various situations across different countries using AI technology.")
|
235 |
-
st.markdown("Powered by Groq API and open-source LLMs.")
|
236 |
-
|
237 |
-
st.markdown("---")
|
238 |
-
st.markdown("### How to Use")
|
239 |
-
st.markdown("1. Select your country 🇬🇧")
|
240 |
-
st.markdown("2. Choose a legal scenario 🚔")
|
241 |
-
st.markdown("3. Get instant rights information ⚖️")
|
242 |
-
|
243 |
-
st.markdown("---")
|
244 |
-
st.markdown("Built with ❤️ for legal empowerment")
|
245 |
|
246 |
# Main content columns
|
247 |
-
col1, col2 = st.columns([1, 2])
|
248 |
|
249 |
with col1:
|
250 |
st.markdown("### 🌍 Select Your Country")
|
251 |
-
|
252 |
-
country_code = COUNTRIES[country_display]
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
st.session_state.selected_scenario = custom_scenario
|
266 |
|
267 |
-
#
|
268 |
-
st.markdown("### 📊 Global Rights
|
269 |
countries = list(COUNTRIES.values())
|
270 |
-
awareness = [
|
271 |
|
272 |
fig = px.bar(
|
273 |
x=countries,
|
274 |
y=awareness,
|
275 |
-
labels={'x': 'Country', 'y': 'Awareness
|
276 |
color=awareness,
|
277 |
-
color_continuous_scale='Blues'
|
|
|
278 |
)
|
279 |
fig.update_layout(
|
280 |
-
title='Rights Awareness by Country',
|
281 |
plot_bgcolor='rgba(0,0,0,0)',
|
282 |
-
paper_bgcolor='rgba(0,0,0,0)'
|
|
|
283 |
)
|
284 |
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
with col2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
st.markdown("### ⚖️ Your Legal Rights")
|
288 |
|
289 |
-
if
|
290 |
-
|
|
|
|
|
291 |
response = get_legal_rights(
|
292 |
country_code,
|
293 |
-
st.session_state.selected_scenario
|
294 |
-
MODELS[selected_model]
|
295 |
)
|
296 |
|
297 |
if response:
|
298 |
-
|
299 |
else:
|
300 |
st.error("Failed to get response. Please try again.")
|
301 |
else:
|
302 |
-
st.info("Please select a legal scenario
|
303 |
st.image("https://images.unsplash.com/photo-1589391886645-d51941baf7fb?auto=format&fit=crop&w=600&h=400",
|
304 |
caption="Know Your Rights, Exercise Your Freedom")
|
305 |
|
@@ -309,21 +387,40 @@ def main():
|
|
309 |
<p>Understanding your legal rights empowers you to:</p>
|
310 |
<ul>
|
311 |
<li>Protect yourself in difficult situations</li>
|
312 |
-
<li>Make informed decisions</li>
|
313 |
-
<li>Prevent exploitation</li>
|
314 |
-
<li>Access justice when
|
315 |
-
<li>Confidently navigate legal systems</li>
|
316 |
</ul>
|
|
|
317 |
</div>
|
318 |
""", unsafe_allow_html=True)
|
319 |
|
320 |
# Footer
|
321 |
st.markdown("""
|
322 |
<div class="footer">
|
323 |
-
<p>Legal Rights Explorer | For Educational Purposes Only | Not Legal Advice</p>
|
324 |
-
<p>Always consult a qualified attorney for your specific legal situation</p>
|
325 |
</div>
|
326 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
|
328 |
if __name__ == "__main__":
|
329 |
main()
|
|
|
1 |
# app.py
|
|
|
2 |
import streamlit as st
|
3 |
+
import requests
|
4 |
import time
|
5 |
import plotly.express as px
|
6 |
+
import os
|
7 |
from dotenv import load_dotenv
|
8 |
|
9 |
# Load environment variables
|
10 |
load_dotenv()
|
11 |
|
|
|
|
|
|
|
12 |
# Set up Streamlit page
|
13 |
st.set_page_config(
|
14 |
page_title="Legal Rights Explorer",
|
15 |
page_icon="⚖️",
|
16 |
layout="wide",
|
17 |
+
initial_sidebar_state="collapsed"
|
18 |
)
|
19 |
|
20 |
+
# Custom CSS for professional styling
|
21 |
st.markdown("""
|
22 |
<style>
|
23 |
:root {
|
24 |
+
--primary: #2c3e50;
|
25 |
+
--secondary: #3498db;
|
26 |
+
--accent: #e74c3c;
|
27 |
+
--light: #ecf0f1;
|
28 |
+
--dark: #2c3e50;
|
29 |
+
--success: #27ae60;
|
30 |
+
--card-shadow: 0 6px 20px rgba(0,0,0,0.1);
|
31 |
}
|
32 |
|
33 |
.stApp {
|
34 |
+
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
|
35 |
+
color: #333;
|
36 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
37 |
}
|
38 |
|
39 |
.header {
|
40 |
+
background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
|
41 |
color: white;
|
42 |
+
padding: 1.8rem 2rem;
|
43 |
border-radius: 0 0 20px 20px;
|
44 |
+
box-shadow: var(--card-shadow);
|
45 |
+
margin-bottom: 2.5rem;
|
46 |
}
|
47 |
|
48 |
.card {
|
49 |
background: white;
|
50 |
border-radius: 15px;
|
51 |
+
padding: 1.8rem;
|
52 |
+
box-shadow: var(--card-shadow);
|
53 |
+
margin-bottom: 1.8rem;
|
54 |
+
transition: all 0.3s ease;
|
55 |
+
border-left: 4px solid var(--secondary);
|
56 |
}
|
57 |
|
58 |
.card:hover {
|
59 |
+
box-shadow: 0 12px 30px rgba(0,0,0,0.15);
|
60 |
transform: translateY(-5px);
|
|
|
61 |
}
|
62 |
|
63 |
.scenario-btn {
|
64 |
width: 100%;
|
65 |
+
padding: 1.1rem;
|
66 |
+
background: linear-gradient(135deg, var(--secondary) 0%, #2980b9 100%);
|
67 |
color: white;
|
68 |
border: none;
|
69 |
border-radius: 12px;
|
70 |
font-weight: 600;
|
71 |
+
margin: 0.7rem 0;
|
72 |
cursor: pointer;
|
73 |
transition: all 0.3s ease;
|
74 |
+
text-align: left;
|
75 |
+
padding-left: 20px;
|
76 |
+
font-size: 1.05rem;
|
77 |
}
|
78 |
|
79 |
.scenario-btn:hover {
|
80 |
+
background: linear-gradient(135deg, var(--primary) 0%, #2c3e50 100%);
|
81 |
transform: scale(1.02);
|
82 |
}
|
83 |
|
84 |
.response-card {
|
85 |
+
background: white;
|
86 |
+
border-left: 5px solid var(--success);
|
87 |
+
border-radius: 12px;
|
88 |
+
padding: 2rem;
|
89 |
+
margin-top: 2rem;
|
90 |
+
box-shadow: var(--card-shadow);
|
91 |
+
animation: fadeIn 0.6s ease;
|
92 |
+
}
|
93 |
+
|
94 |
+
.country-card {
|
95 |
+
display: flex;
|
96 |
+
align-items: center;
|
97 |
+
gap: 15px;
|
98 |
+
padding: 1.2rem;
|
99 |
+
border-radius: 12px;
|
100 |
+
background: white;
|
101 |
+
box-shadow: var(--card-shadow);
|
102 |
+
margin-bottom: 15px;
|
103 |
+
cursor: pointer;
|
104 |
+
transition: all 0.3s ease;
|
105 |
+
}
|
106 |
+
|
107 |
+
.country-card:hover {
|
108 |
+
transform: translateX(5px);
|
109 |
+
box-shadow: 0 8px 25px rgba(0,0,0,0.15);
|
110 |
+
}
|
111 |
+
|
112 |
+
.country-card.selected {
|
113 |
+
background: linear-gradient(135deg, var(--light) 0%, var(--secondary) 100%);
|
114 |
+
border-left: 4px solid var(--accent);
|
115 |
}
|
116 |
|
117 |
.footer {
|
118 |
text-align: center;
|
119 |
+
padding: 2rem;
|
120 |
+
margin-top: 3rem;
|
121 |
+
color: var(--dark);
|
122 |
+
font-size: 0.95rem;
|
123 |
+
background: rgba(236, 240, 241, 0.7);
|
124 |
+
border-radius: 15px;
|
125 |
+
}
|
126 |
+
|
127 |
+
@keyframes fadeIn {
|
128 |
+
from { opacity: 0; transform: translateY(20px); }
|
129 |
+
to { opacity: 1; transform: translateY(0); }
|
130 |
}
|
131 |
|
132 |
@media (max-width: 768px) {
|
133 |
.header {
|
134 |
+
padding: 1.3rem;
|
135 |
}
|
136 |
|
137 |
.card {
|
138 |
+
padding: 1.3rem;
|
139 |
}
|
140 |
}
|
141 |
</style>
|
|
|
145 |
COUNTRIES = {
|
146 |
"🇺🇸 United States": "US",
|
147 |
"🇬🇧 United Kingdom": "UK",
|
148 |
+
"🇨🇦 Canada": "CA",
|
149 |
+
"🇦🇺 Australia": "AU",
|
150 |
+
"🇮🇳 India": "IN",
|
151 |
+
"🇩🇪 Germany": "DE",
|
152 |
+
"🇫🇷 France": "FR",
|
153 |
+
"🇯🇵 Japan": "JP",
|
154 |
+
"🇧🇷 Brazil": "BR",
|
155 |
+
"🇿🇦 South Africa": "ZA",
|
156 |
+
"🇪🇸 Spain": "ES",
|
157 |
+
"🇮🇹 Italy": "IT"
|
158 |
}
|
159 |
|
160 |
# Common legal scenarios
|
|
|
173 |
"Immigration Rights"
|
174 |
]
|
175 |
|
176 |
+
# Simulated API function
|
177 |
+
def get_legal_rights(country, scenario):
|
178 |
+
"""Simulate API response with country-specific legal rights"""
|
179 |
+
# In a real implementation, this would call an external API
|
180 |
+
# For this demo, we'll return simulated responses
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
+
# Simulate API delay
|
183 |
+
time.sleep(1.5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
+
# Base rights that apply to most countries
|
186 |
+
base_rights = [
|
187 |
+
"Right to remain silent",
|
188 |
+
"Right to legal representation",
|
189 |
+
"Right to be treated with dignity and respect",
|
190 |
+
"Right to understand the charges against you",
|
191 |
+
"Right to a fair and impartial process"
|
192 |
+
]
|
193 |
|
194 |
+
# Country-specific additions
|
195 |
+
country_specific = {
|
196 |
+
"US": [
|
197 |
+
"Right to refuse unwarranted searches (4th Amendment)",
|
198 |
+
"Right to due process (5th Amendment)",
|
199 |
+
"Right to a speedy and public trial (6th Amendment)"
|
200 |
+
],
|
201 |
+
"UK": [
|
202 |
+
"Right to legal advice under the Police and Criminal Evidence Act",
|
203 |
+
"Right to have someone informed of your arrest",
|
204 |
+
"Protection under the Human Rights Act 1998"
|
205 |
+
],
|
206 |
+
"CA": [
|
207 |
+
"Right to be informed of the reason for detention (Charter of Rights)",
|
208 |
+
"Right to retain and instruct counsel without delay",
|
209 |
+
"Right to habeas corpus"
|
210 |
+
],
|
211 |
+
"AU": [
|
212 |
+
"Right to silence during police questioning",
|
213 |
+
"Right to communicate with a friend or relative",
|
214 |
+
"Protection under the Australian Human Rights Commission Act"
|
215 |
+
],
|
216 |
+
"IN": [
|
217 |
+
"Right to free legal aid under Article 39A of the Constitution",
|
218 |
+
"Protection against self-incrimination (Article 20)",
|
219 |
+
"Right to be informed of grounds for arrest (Article 22)"
|
220 |
+
]
|
221 |
+
}
|
222 |
|
223 |
+
# Scenario-specific additions
|
224 |
+
scenario_specific = {
|
225 |
+
"Traffic Stop by Police": [
|
226 |
+
"Right to see official identification",
|
227 |
+
"Right to know the reason for the stop",
|
228 |
+
"Right to refuse a search without probable cause",
|
229 |
+
"Right to record the interaction"
|
230 |
+
],
|
231 |
+
"Workplace Discrimination": [
|
232 |
+
"Right to a discrimination-free workplace",
|
233 |
+
"Right to report without retaliation",
|
234 |
+
"Right to reasonable accommodations",
|
235 |
+
"Right to equal pay for equal work"
|
236 |
+
],
|
237 |
+
"Medical Emergency Rights": [
|
238 |
+
"Right to emergency treatment regardless of insurance",
|
239 |
+
"Right to informed consent",
|
240 |
+
"Right to access medical records",
|
241 |
+
"Right to privacy of health information"
|
242 |
+
],
|
243 |
+
"Arrest or Detention": [
|
244 |
+
"Right to be informed of charges",
|
245 |
+
"Right to contact your embassy if foreign national",
|
246 |
+
"Right to humane treatment",
|
247 |
+
"Right to challenge the lawfulness of detention"
|
248 |
+
]
|
249 |
+
}
|
250 |
|
251 |
+
# Combine rights based on country and scenario
|
252 |
+
rights = base_rights.copy()
|
253 |
+
|
254 |
+
if country in country_specific:
|
255 |
+
rights.extend(country_specific[country])
|
256 |
+
|
257 |
+
for key, value in scenario_specific.items():
|
258 |
+
if key in scenario:
|
259 |
+
rights.extend(value)
|
260 |
+
break
|
261 |
|
262 |
+
# Format the response
|
263 |
+
response = f"## 🔍 Your Rights in {country}\n"
|
264 |
+
response += f"### Situation: {scenario}\n\n"
|
265 |
+
response += "Based on the laws of your selected country, you have the following rights:\n\n"
|
|
|
|
|
266 |
|
267 |
+
for i, right in enumerate(set(rights), 1):
|
268 |
+
response += f"✅ **{right}**\n\n"
|
269 |
+
|
270 |
+
response += "\n**Important Notes:**\n"
|
271 |
+
response += "- This information is for educational purposes only\n"
|
272 |
+
response += "- Laws vary by jurisdiction and circumstances\n"
|
273 |
+
response += "- Consult a qualified attorney for legal advice\n"
|
274 |
+
|
275 |
+
return response
|
276 |
|
277 |
# Main app
|
278 |
def main():
|
279 |
# Header section
|
280 |
st.markdown("""
|
281 |
<div class="header">
|
282 |
+
<h1 style="margin:0;font-size:2.3rem;">Legal Rights Explorer</h1>
|
283 |
+
<p style="margin:0;font-size:1.2rem;opacity:0.9;">Know your rights in any situation, anywhere in the world</p>
|
284 |
</div>
|
285 |
""", unsafe_allow_html=True)
|
286 |
|
287 |
+
# Initialize session state
|
288 |
+
if 'selected_country' not in st.session_state:
|
289 |
+
st.session_state.selected_country = "🇺🇸 United States"
|
290 |
+
|
291 |
+
if 'selected_scenario' not in st.session_state:
|
292 |
+
st.session_state.selected_scenario = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
|
294 |
# Main content columns
|
295 |
+
col1, col2 = st.columns([1, 2], gap="large")
|
296 |
|
297 |
with col1:
|
298 |
st.markdown("### 🌍 Select Your Country")
|
299 |
+
st.markdown("Choose your country to see jurisdiction-specific rights information")
|
|
|
300 |
|
301 |
+
# Country selection cards
|
302 |
+
for country_display in COUNTRIES.keys():
|
303 |
+
is_selected = st.session_state.selected_country == country_display
|
304 |
+
card_class = "country-card selected" if is_selected else "country-card"
|
305 |
+
|
306 |
+
st.markdown(f"""
|
307 |
+
<div class="{card_class}" onclick="selectCountry('{country_display}')">
|
308 |
+
<span style="font-size:1.8rem;">{country_display.split()[0]}</span>
|
309 |
+
<span style="font-weight:500;">{country_display.split(' ', 1)[1]}</span>
|
310 |
+
</div>
|
311 |
+
""", unsafe_allow_html=True)
|
|
|
312 |
|
313 |
+
# Country visualization
|
314 |
+
st.markdown("### 📊 Global Rights Index")
|
315 |
countries = list(COUNTRIES.values())
|
316 |
+
awareness = [92, 89, 87, 85, 82, 88, 86, 84, 79, 81, 85, 83] # Simulated data
|
317 |
|
318 |
fig = px.bar(
|
319 |
x=countries,
|
320 |
y=awareness,
|
321 |
+
labels={'x': 'Country', 'y': 'Rights Awareness'},
|
322 |
color=awareness,
|
323 |
+
color_continuous_scale='Blues',
|
324 |
+
height=300
|
325 |
)
|
326 |
fig.update_layout(
|
|
|
327 |
plot_bgcolor='rgba(0,0,0,0)',
|
328 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
329 |
+
margin=dict(l=0, r=0, t=30, b=0)
|
330 |
)
|
331 |
st.plotly_chart(fig, use_container_width=True)
|
332 |
+
|
333 |
+
# Legal resources
|
334 |
+
with st.expander("📚 Legal Resources"):
|
335 |
+
st.markdown("""
|
336 |
+
- [United Nations Human Rights](https://www.ohchr.org/)
|
337 |
+
- [International Justice Resource Center](https://ijrcenter.org/)
|
338 |
+
- [Global Legal Information Network](https://www.loc.gov/law/help/legal-info.php)
|
339 |
+
- [World Legal Information Institute](https://www.worldlii.org/)
|
340 |
+
""")
|
341 |
|
342 |
with col2:
|
343 |
+
st.markdown("### 🚨 Select a Legal Scenario")
|
344 |
+
st.markdown("Choose a situation to understand your rights and protections")
|
345 |
+
|
346 |
+
# Create buttons for each scenario
|
347 |
+
cols = st.columns(2)
|
348 |
+
for i, scenario in enumerate(SCENARIOS):
|
349 |
+
with cols[i % 2]:
|
350 |
+
if st.button(
|
351 |
+
f"**{scenario}**",
|
352 |
+
key=scenario,
|
353 |
+
use_container_width=True,
|
354 |
+
help=f"Click to see your rights for {scenario}"
|
355 |
+
):
|
356 |
+
st.session_state.selected_scenario = scenario
|
357 |
+
|
358 |
+
# Custom scenario input
|
359 |
+
custom_scenario = st.text_input("**Or describe your specific situation:**", placeholder="e.g., 'Rights during home search'")
|
360 |
+
if custom_scenario:
|
361 |
+
st.session_state.selected_scenario = custom_scenario
|
362 |
+
|
363 |
+
# Response area
|
364 |
st.markdown("### ⚖️ Your Legal Rights")
|
365 |
|
366 |
+
if st.session_state.selected_scenario:
|
367 |
+
country_code = COUNTRIES[st.session_state.selected_country]
|
368 |
+
|
369 |
+
with st.spinner(f"Analyzing your rights for {st.session_state.selected_scenario} in {country_code}..."):
|
370 |
response = get_legal_rights(
|
371 |
country_code,
|
372 |
+
st.session_state.selected_scenario
|
|
|
373 |
)
|
374 |
|
375 |
if response:
|
376 |
+
st.markdown(f'<div class="response-card">{response}</div>', unsafe_allow_html=True)
|
377 |
else:
|
378 |
st.error("Failed to get response. Please try again.")
|
379 |
else:
|
380 |
+
st.info("Please select a legal scenario to see your rights information")
|
381 |
st.image("https://images.unsplash.com/photo-1589391886645-d51941baf7fb?auto=format&fit=crop&w=600&h=400",
|
382 |
caption="Know Your Rights, Exercise Your Freedom")
|
383 |
|
|
|
387 |
<p>Understanding your legal rights empowers you to:</p>
|
388 |
<ul>
|
389 |
<li>Protect yourself in difficult situations</li>
|
390 |
+
<li>Make informed decisions when facing legal issues</li>
|
391 |
+
<li>Prevent exploitation and rights violations</li>
|
392 |
+
<li>Access justice when your rights are infringed</li>
|
393 |
+
<li>Confidently navigate complex legal systems</li>
|
394 |
</ul>
|
395 |
+
<p style="margin-top:15px;font-style:italic;">"Knowledge of the law is the first defense against injustice."</p>
|
396 |
</div>
|
397 |
""", unsafe_allow_html=True)
|
398 |
|
399 |
# Footer
|
400 |
st.markdown("""
|
401 |
<div class="footer">
|
402 |
+
<p>Legal Rights Explorer | © 2023 | For Educational Purposes Only | Not Legal Advice</p>
|
403 |
+
<p>Always consult a qualified attorney in your jurisdiction for your specific legal situation</p>
|
404 |
</div>
|
405 |
""", unsafe_allow_html=True)
|
406 |
+
|
407 |
+
# JavaScript for country selection
|
408 |
+
st.markdown("""
|
409 |
+
<script>
|
410 |
+
function selectCountry(country) {
|
411 |
+
window.parent.document.querySelectorAll("button[kind='secondary']")[0].click();
|
412 |
+
setTimeout(function() {
|
413 |
+
const countryButtons = window.parent.document.querySelectorAll("button[kind='secondary']");
|
414 |
+
for (let btn of countryButtons) {
|
415 |
+
if (btn.innerText.includes(country)) {
|
416 |
+
btn.click();
|
417 |
+
break;
|
418 |
+
}
|
419 |
+
}
|
420 |
+
}, 100);
|
421 |
+
}
|
422 |
+
</script>
|
423 |
+
""", unsafe_allow_html=True)
|
424 |
|
425 |
if __name__ == "__main__":
|
426 |
main()
|