Update app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371382 unmodified lines14114214314414514614714814915015115215315415515615715832 unmodified lines19119219319419519610 unmodified lines2072082092102112126 unmodified lines2192202212222232245 unmodified lines230231232233234235236237238239139 unmodified lines37938038138238338438538638738838939039168 unmodified lines4604614624634644654664674684691 unmodified line4714724734744754766 unmodified lines483484485486487488108 unmodified lines59759859960060160260360460560660760812 unmodified lines62162262362462562662762862963063163263315 unmodified lines649650651652653654655656657658659660661662663"""Rahbar v9.0 β Pakistan AI Civic Complaint Platformββββββββββββββββββββββββββββββββββββββββββββββββββ’ Gradio 6+ compatible (css in launch, no type= on Chatbot)β’ GPS: IP geolocation β shows city on map automaticallyβ’ Map: Plotly Scattermap, click-to-fill street/landmark boxβ’ Full Pakistan coverage (not just big cities β any area)β’ PDF via ReportLab (professional, no grid lines)β’ Voice input/output fully working in chatbotβ’ Light + Dark mode CSS (auto + manual toggle)β’ All UI in English; report content in selected language"""import os, io, re, uuid, base64, datetime, urllib.parsefrom PIL import Imageimport gradio as grGOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY", "")GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")complaint_log = []# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# IP GEOLOCATION# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββdef get_location_from_ip():try:import requestsr = requests.get("https://ipinfo.io/json", timeout=6)if r.status_code == 200:d = r.json()loc = d.get("loc", "")if loc and "," in loc:lat, lon = map(float, loc.split(","))return lat, lon, d.get("city", "Unknown"), d.get("region", "Unknown")except:passtry:import requestsr = requests.get("http://ip-api.com/json/", timeout=6)if r.status_code == 200:d = r.json()if d.get("status") == "success":return float(d["lat"]), float(d["lon"]), d.get("city", "Unknown"), d.get("regionName", "Unknown")except:passreturn Nonedef reverse_geocode(lat, lon):try:import requestsurl = f"https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat={lat}&lon={lon}&zoom=17&addressdetails=1"r = requests.get(url, headers={"User-Agent": "Rahbar/9.0"}, timeout=6)if r.status_code == 200:d = r.json()a = d.get("address", {})parts = []for k in ("road", "pedestrian", "footway", "residential"):if a.get(k):parts.append(a[k])breakfor k in ("suburb", "neighbourhood", "quarter", "village", "town"):if a.get(k):parts.append(a[k])breakfor k in ("city", "county", "state_district", "state"):if a.get(k):parts.append(a[k])breakif parts:return ", ".join(p.strip() for p in parts if p.strip())except:passreturn f"{lat:.5f}, {lon:.5f}"# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# PLOTLY MAP# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββPAKISTAN_CENTRE = (30.3753, 69.3451)CITY_COORDS = {"Lahore": (31.5204, 74.3587), "Karachi": (24.8607, 67.0011),"Islamabad": (33.6844, 73.0479), "Rawalpindi": (33.5651, 73.0169),"Faisalabad": (31.4181, 73.0776), "Multan": (30.1575, 71.5249),"Peshawar": (34.0151, 71.5249), "Quetta": (30.1798, 66.9750),"Gujranwala": (32.1877, 74.1945), "Sialkot": (32.4945, 74.5229),"Sukkur": (27.7052, 68.8574), "Hyderabad": (25.3960, 68.3578),"Bahawalpur": (29.3956, 71.6836), "Sargodha": (32.0836, 72.6711),"Abbottabad": (34.1558, 73.2194), "Gilgit": (35.9221, 74.3085),"Gwadar": (25.1216, 62.3254), "Skardu": (35.2971, 75.6360),}ALL_CITIES = sorted(CITY_COORDS.keys())def build_map(lat, lon, label="", zoom=13):try:import plotly.graph_objects as golabel = label or f"{lat:.4f}, {lon:.4f}"fig = go.Figure(go.Scattermap(lat=[lat], lon=[lon],mode="markers+text",marker=dict(size=16, color="#e8410a", symbol="marker"),text=[label[:50]],textposition="top right",hovertemplate=f"<b>{label}</b><br>Lat: {lat:.5f}<br>Lon: {lon:.5f}<extra></extra>"))fig.update_layout(map=dict(style="open-street-map", center=dict(lat=lat, lon=lon), zoom=zoom),margin=dict(r=0, t=0, l=0, b=0),height=280,paper_bgcolor="rgba(0,0,0,0)",plot_bgcolor="rgba(0,0,0,0)",clickmode="event+select")return figexcept:return Nonedef build_map_city(city_name):coords = CITY_COORDS.get(city_name)if coords:return build_map(coords[0], coords[1], city_name, 12)return build_map(PAKISTAN_CENTRE[0], PAKISTAN_CENTRE[1], "Pakistan", 5)def gps_detect(city_hint):result = get_location_from_ip()if result:lat, lon, city, region = resultaddr = reverse_geocode(lat, lon)status = f"π Location detected: **{city}, {region}** (lat {lat:.4f}, lon {lon:.4f})"fig = build_map(lat, lon, addr)return fig, status, addr, lat, lonelse:status = "β οΈ Could not detect location automatically. Please select your city/area."fig = build_map_city(city_hint)return fig, status, "", None, None# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# KNOWLEDGE BASE2 unmodified linesLANGUAGES = ["English", "Urdu", "Punjabi", "Sindhi"]LANG_CODES = {"English": "en", "Urdu": "ur", "Punjabi": "ur", "Sindhi": "ur"}LEGAL_KNOWLEDGE = [{"category": "Garbage", "title": "Punjab Waste Management Act 2014","content": "Local government must act within 48 hours. Fine: Rs.500-50,000. Helpline: 1139","hotline": "1139", "response": "48 hours"},{"category": "Pot Hole", "title": "National Highways Safety Ordinance 2000","content": "Road repairs within 72 hours. Compensation for vehicle damage. NHA: 051-9032800","hotline": "051-9032800", "response": "72 hours"},{"category": "Pipe Leakage", "title": "Punjab Water Act 2019","content": "WASA must repair within 24 hours. Clean water is a fundamental right. WASA: 042-99200300","hotline": "042-99200300", "response": "24 hours"},]LEGAL_INFO = {"Garbage": {"laws": ["Punjab Waste Management Act 2014", "EPA 1997 Section 11"],32 unmodified lines"Sindhi": "ΩΎΨ§Ψ¦ΩΎ ΩΩΪͺΩΨ¬ 24 ΪͺΩΨ§ΪͺΩ ΫΎ Ω Ψ±Ω Ψͺ ΨΆΨ±ΩΨ±Ω Ψ’ΩΩ."}}# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# IMAGE ANALYSIS# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ10 unmodified linesdef get_legal_advice(issue, location, severity, language="English"):info = LEGAL_INFO.get(issue, LEGAL_INFO.get("Garbage", {}))rights = "\n".join(f"β’ {r}" for r in info.get("citizen_rights", []))return f"""## Your Legal Rights for {issue}6 unmodified lines**Fine/Penalty:** {info.get('fine', 'N/A')}**Escalation Path:** {info.get('escalation', 'CM Portal: 0800-02345')}"""# βββββββββββοΏ½οΏ½ββββββββββββββββββββββββββββββββββββββββββββββββββ5 unmodified linesif not message or not message.strip():return history, ""response = "**Rahbar Legal Assistant**\n\nI can help with:\n"for item in LEGAL_KNOWLEDGE:response += f"β’ **{item['title']}**: {item['content'][:100]}...\n"response += "\nPlease describe your specific issue for detailed guidance."history.append({"role": "user", "content": message})history.append({"role": "assistant", "content": response})139 unmodified linesdef make_report(image, issue_type, city, location, name, cnic, phone,description, language, enable_tts):if image is None:return (None, "Please upload an image.", "", "", None, "", None, None, None)if not location or not location.strip():return (None, "Please enter a location.", "", "", None, "", None, None, None)if not name or not name.strip():return (None, "Please enter your full name.", "", "", None, "", None, None, None)if not cnic or not cnic.strip():return (None, "Please enter your CNIC number.", "", "", None, "", None, None, None)cid = f"RB-{uuid.uuid4().hex[:8].upper()}"ts = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")68 unmodified linesreport_tts = text_to_speech(report[:800], language) if enable_tts else Noneadvice_tts = text_to_speech(legal_advice[:600], language) if enable_tts else Nonepdf_path = generate_pdf(cid, ts, name, cnic, phone, city, location, issue_type, language, severity, status, reason, confidence, info, description or "")map_fig = build_map_city(city)return (annotated_img, report, wa_md, legal_advice, report_tts, cid, advice_tts, pdf_path, map_fig)# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# HELPER FUNCTIONS1 unmodified linedef law_info(issue, language):info = LEGAL_INFO.get(issue, LEGAL_INFO.get("Garbage", {}))rights = "\n".join(f"β’ {r}" for r in info.get("citizen_rights", []))return f"""## Legal Reference: {issue}**Applicable Laws:**6 unmodified lines**Helpline:** {info.get('hotline', 'N/A')}**Response Time:** {info.get('response', 'N/A')}**Escalation:** {info.get('escalation', 'CM Portal: 0800-02345')}"""def get_admin_stats():108 unmodified lines</div>"""# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# BUILD UI# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββdef build_ui():default_map = build_map_city("Lahore")with gr.Blocks(title="Rahbar | Pakistan Civic Complaint System") as demo:gr.HTML(HEADER_HTML)12 unmodified linesgr.HTML('<div class="sec-title">Complaint Details</div>')issue_type = gr.Radio(choices=ISSUE_TYPES, label="Issue Type")city_dd = gr.Dropdown(choices=ALL_CITIES, value="Lahore", label="City", allow_custom_value=True)gr.HTML('<div class="sec-title">Location</div>')gps_btn = gr.Button("π Detect My Location", variant="secondary")gps_status = gr.Markdown("_Click the button above to detect your location_")location_tb = gr.Textbox(label="Street / Landmark / Area", placeholder="Enter exact location")map_plot = gr.Plot(label="Map", value=default_map)desc_tb = gr.Textbox(label="Description (optional)", lines=3)language_dd = gr.Dropdown(choices=LANGUAGES, value="English", label="Language")15 unmodified lineslegal_out = gr.Markdown()advice_tts_out = gr.Audio(label="Legal Advice Audio")# GPS and map interactionsgps_btn.click(fn=gps_detect, inputs=[city_dd], outputs=[map_plot, gps_status, location_tb, gr.State(), gr.State()])city_dd.change(fn=build_map_city, inputs=[city_dd], outputs=[map_plot])location_tb.change(fn=build_map_city, inputs=[city_dd], outputs=[map_plot])submit_btn.click(fn=make_report,inputs=[image_input, issue_type, city_dd, location_tb, name_tb, cnic_tb, phone_tb, desc_tb, language_dd, tts_cb],outputs=[annotated_out, report_out, wa_out, legal_out, report_tts_out, complaint_id_out, advice_tts_out, pdf_out, map_plot])# Tab 2 - Legal Rights12345678910111213142 unmodified lines17181920212232 unmodified lines55565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122210 unmodified lines2332342352362372382396 unmodified lines2462472482492502512522532545 unmodified lines260261262263264265266267268269270271272273274275276277278279139 unmodified lines41942042142242342442542642742842943043168 unmodified lines5005015025035045055065071 unmodified line5095105115125135145156 unmodified lines522523524525526527528529530108 unmodified lines63964064164264364464564664764864965065165265365465512 unmodified lines66866967067167267367467567667767867915 unmodified lines695696697698699700701702703704"""Rahbar v9.0 β Pakistan AI Civic Complaint PlatformFull Pakistan Coverage | GPS Location | Interactive Map"""import os, io, re, uuid, base64, datetime, urllib.parsefrom PIL import Imageimport gradio as grGROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")complaint_log = []# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# KNOWLEDGE BASE2 unmodified linesLANGUAGES = ["English", "Urdu", "Punjabi", "Sindhi"]LANG_CODES = {"English": "en", "Urdu": "ur", "Punjabi": "ur", "Sindhi": "ur"}LEGAL_INFO = {"Garbage": {"laws": ["Punjab Waste Management Act 2014", "EPA 1997 Section 11"],32 unmodified lines"Sindhi": "ΩΎΨ§Ψ¦ΩΎ ΩΩΪͺΩΨ¬ 24 ΪͺΩΨ§ΪͺΩ ΫΎ Ω Ψ±Ω Ψͺ ΨΆΨ±ΩΨ±Ω Ψ’ΩΩ."}}# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# HTML with GPS and Interactive Map (Works everywhere in Pakistan)# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββMAP_HTML = """<div id="map-container" style="margin-bottom: 10px;"><div id="gps-status" style="background: #e8f5e9; padding: 10px 12px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; border-left: 4px solid #2e7d32;">π <span id="gps-status-text">Click "Get My Location" or click on map to set address</span></div><div id="map" style="height: 300px; width: 100%; border-radius: 12px; border: 2px solid #c8e6c9;"></div><button id="gps-button" style="margin-top: 8px; width: 100%; padding: 10px; background: #2e7d32; color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 500;">π Get My Current Location (GPS)</button></div><link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/><script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script><script>(function() {var map = null;var marker = null;// Initialize map centered on Pakistanfunction initMap(lat, lng, zoom) {if (map) return;map = L.map('map').setView([lat || 30.3753, lng || 69.3451], zoom || 5);L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', {attribution: '© <a href="https://www.openstreetmap.org/copyright">OSM</a>',subdomains: 'abcd',maxZoom: 19}).addTo(map);marker = L.marker([lat || 30.3753, lng || 69.3451], { draggable: true }).addTo(map);// Update address when marker is draggedmarker.on('dragend', function(e) {var pos = e.target.getLatLng();reverseGeocode(pos.lat, pos.lng);});// Update address when map is clickedmap.on('click', function(e) {marker.setLatLng(e.latlng);reverseGeocode(e.latlng.lat, e.latlng.lng);});}// Reverse geocode using Nominatim (works for all of Pakistan)function reverseGeocode(lat, lng) {var statusEl = document.getElementById('gps-status-text');statusEl.textContent = 'Getting address...';statusEl.style.color = '#f9a825';fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lng}&zoom=18&addressdetails=1&accept-language=en`).then(r => r.json()).then(data => {var address = '';if (data.address) {var parts = [];// Get road/street nameif (data.address.road) parts.push(data.address.road);if (data.address.hamlet) parts.push(data.address.hamlet);if (data.address.village) parts.push(data.address.village);if (data.address.town) parts.push(data.address.town);if (data.address.city) parts.push(data.address.city);if (data.address.district) parts.push(data.address.district);if (data.address.state_district) parts.push(data.address.state_district);if (data.address.state) parts.push(data.address.state);if (parts.length === 0 && data.display_name) {parts = data.display_name.split(',').slice(0, 4);}address = parts.join(', ');}if (!address) address = `${lat.toFixed(5)}, ${lng.toFixed(5)}`;// Find and fill the location textboxvar locationInput = document.querySelector('#location-input textarea, #location-input input, [data-testid="textbox"]');if (locationInput) {locationInput.value = address;locationInput.dispatchEvent(new Event('input', { bubbles: true }));locationInput.dispatchEvent(new Event('change', { bubbles: true }));}statusEl.textContent = `β Location set: ${address.substring(0, 60)}`;statusEl.style.color = '#2e7d32';}).catch(() => {var addr = `${lat.toFixed(5)}, ${lng.toFixed(5)}`;var locationInput = document.querySelector('#location-input textarea, #location-input input, [data-testid="textbox"]');if (locationInput) {locationInput.value = addr;locationInput.dispatchEvent(new Event('input', { bubbles: true }));}statusEl.textContent = `β οΈ Approximate: ${addr}`;statusEl.style.color = '#f9a825';});}function getLocation() {var statusEl = document.getElementById('gps-status-text');statusEl.textContent = 'Requesting GPS access...';statusEl.style.color = '#f9a825';if (!navigator.geolocation) {statusEl.textContent = 'β GPS not supported by your browser';statusEl.style.color = '#d32f2f';if (!map) initMap(30.3753, 69.3451, 5);return;}navigator.geolocation.getCurrentPosition(function(pos) {var lat = pos.coords.latitude;var lng = pos.coords.longitude;statusEl.textContent = 'π GPS acquired! Getting address...';statusEl.style.color = '#2e7d32';if (!map) {initMap(lat, lng, 14);} else {map.setView([lat, lng], 14);marker.setLatLng([lat, lng]);}reverseGeocode(lat, lng);},function(err) {var msg = '';if (err.code === 1) msg = 'β Permission denied. Please allow location access.';else if (err.code === 2) msg = 'β οΈ Location unavailable. Check GPS/WiFi.';else if (err.code === 3) msg = 'β±οΈ GPS timed out. Try again.';else msg = 'β GPS error: ' + err.message;statusEl.textContent = msg;statusEl.style.color = '#d32f2f';if (!map) initMap(30.3753, 69.3451, 5);},{ enableHighAccuracy: true, timeout: 10000, maximumAge: 0 });}// Initialize on page loadif (document.readyState === 'loading') {document.addEventListener('DOMContentLoaded', function() {initMap(30.3753, 69.3451, 5);var btn = document.getElementById('gps-button');if (btn) btn.onclick = getLocation;});} else {initMap(30.3753, 69.3451, 5);var btn = document.getElementById('gps-button');if (btn) btn.onclick = getLocation;}// Fallback: retry after 1 secondsetTimeout(function() {if (!map) initMap(30.3753, 69.3451, 5);}, 1000);})();</script>"""# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# IMAGE ANALYSIS# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ10 unmodified linesdef get_legal_advice(issue, location, severity, language="English"):info = LEGAL_INFO.get(issue, LEGAL_INFO.get("Garbage", {}))rights = "\n".join(f"β’ {r}" for r in info.get("citizen_rights", []))local_msg = LOCALIZED.get(issue, {}).get(language, "")return f"""## Your Legal Rights for {issue}6 unmodified lines**Fine/Penalty:** {info.get('fine', 'N/A')}**Escalation Path:** {info.get('escalation', 'CM Portal: 0800-02345')}---*Notice in {language}:* {local_msg}"""# βββββββββββοΏ½οΏ½ββββββββββββββββββββββββββββββββββββββββββββββββββ5 unmodified linesif not message or not message.strip():return history, ""response = """**Rahbar Legal Assistant**I can help you with civic issues in Pakistan:β’ **Garbage Complaints** - Punjab Waste Management Act 2014, Helpline: 1139β’ **Road/Pothole Complaints** - NHA helpline: 051-9032800β’ **Water/Pipe Leakage** - WASA helpline: 042-99200300Please describe your specific issue for detailed guidance, including:- What happened?- When did it happen?- Which authority have you contacted?I'll provide your legal rights and the exact steps to file a complaint."""history.append({"role": "user", "content": message})history.append({"role": "assistant", "content": response})139 unmodified linesdef make_report(image, issue_type, city, location, name, cnic, phone,description, language, enable_tts):if image is None:return (None, "Please upload an image.", "", "", None, "", None, None)if not location or not location.strip():return (None, "Please enter a location.", "", "", None, "", None, None)if not name or not name.strip():return (None, "Please enter your full name.", "", "", None, "", None, None)if not cnic or not cnic.strip():return (None, "Please enter your CNIC number.", "", "", None, "", None, None)cid = f"RB-{uuid.uuid4().hex[:8].upper()}"ts = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")68 unmodified linesreport_tts = text_to_speech(report[:800], language) if enable_tts else Noneadvice_tts = text_to_speech(legal_advice[:600], language) if enable_tts else Nonepdf_path = generate_pdf(cid, ts, name, cnic, phone, city, location, issue_type, language, severity, status, reason, confidence, info, description or "")return (annotated_img, report, wa_md, legal_advice, report_tts, cid, advice_tts, pdf_path)# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# HELPER FUNCTIONS1 unmodified linedef law_info(issue, language):info = LEGAL_INFO.get(issue, LEGAL_INFO.get("Garbage", {}))rights = "\n".join(f"β’ {r}" for r in info.get("citizen_rights", []))local = LOCALIZED.get(issue, {}).get(language, "")return f"""## Legal Reference: {issue}**Applicable Laws:**6 unmodified lines**Helpline:** {info.get('hotline', 'N/A')}**Response Time:** {info.get('response', 'N/A')}**Escalation:** {info.get('escalation', 'CM Portal: 0800-02345')}---*Notice in {language}:* {local}"""def get_admin_stats():108 unmodified lines</div>"""CITIES = ["Lahore", "Karachi", "Islamabad", "Rawalpindi", "Faisalabad", "Multan","Peshawar", "Quetta", "Gujranwala", "Sialkot", "Sukkur", "Hyderabad","Bahawalpur", "Sargodha", "Abbottabad", "Gilgit", "Skardu", "Gwadar","Mardan", "Dera Ismail Khan", "Muzaffarabad", "Mirpur", "Chitral"]# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# BUILD UI# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββdef build_ui():with gr.Blocks(title="Rahbar | Pakistan Civic Complaint System") as demo:gr.HTML(HEADER_HTML)12 unmodified linesgr.HTML('<div class="sec-title">Complaint Details</div>')issue_type = gr.Radio(choices=ISSUE_TYPES, label="Issue Type")city_dd = gr.Dropdown(choices=sorted(CITIES), value="Lahore", label="City/District", allow_custom_value=True)gr.HTML('<div class="sec-title">Location Map</div>')gr.HTML(MAP_HTML)location_tb = gr.Textbox(label="Street / Landmark / Area", placeholder="Enter exact location", elem_id="location-input")desc_tb = gr.Textbox(label="Description (optional)", lines=3)language_dd = gr.Dropdown(choices=LANGUAGES, value="English", label="Language")15 unmodified lineslegal_out = gr.Markdown()advice_tts_out = gr.Audio(label="Legal Advice Audio")submit_btn.click(fn=make_report,inputs=[image_input, issue_type, city_dd, location_tb, name_tb, cnic_tb, phone_tb, desc_tb, language_dd, tts_cb],outputs=[annotated_out, report_out, wa_out, legal_out, report_tts_out, complaint_id_out, advice_tts_out, pdf_out])# Tab 2 - Legal Rights
app.py+205-164