Spaces:
Sleeping
Sleeping
| # Federal FOIA Intelligence Search | |
| # Public Electronic Reading Rooms Only | |
| import gradio as gr | |
| import asyncio | |
| from ingest.registry import get_all_adapters | |
| from ingest.cluster import semantic_cluster | |
| from ingest.export import export_zip | |
| from ingest.foia_request import generate_foia_packet | |
| from ingest.health import adapter_health | |
| adapters = get_all_adapters() | |
| async def run_search(query, live_only): | |
| results = [] | |
| for adapter in adapters: | |
| if live_only and not adapter.is_live: | |
| continue | |
| try: | |
| r = await adapter.search(query) | |
| results.extend(r) | |
| except Exception: | |
| adapter.health = "down" | |
| return results | |
| def search_ui(query, live_only): | |
| results = asyncio.run(run_search(query, live_only)) | |
| clusters = semantic_cluster(results) | |
| return results, clusters | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## Federal FOIA Intelligence Search") | |
| gr.Markdown("*Public Electronic Reading Rooms Only*") | |
| query = gr.Textbox(label="Search FOIA Reading Rooms") | |
| live_toggle = gr.Checkbox(label="Enable Live Agencies (Public Only)") | |
| search_btn = gr.Button("Search") | |
| results_table = gr.Dataframe(label="Results") | |
| cluster_plot = gr.Plot(label="Semantic Clusters") | |
| with gr.Tab("📄 Document Preview"): | |
| preview = gr.HTML() | |
| with gr.Tab("🧾 FOIA Request Generator"): | |
| agency = gr.Textbox(label="Agency") | |
| subject = gr.Textbox(label="Subject") | |
| packet_btn = gr.Button("Generate FOIA Packet") | |
| packet_out = gr.File() | |
| search_btn.click( | |
| search_ui, | |
| inputs=[query, live_toggle], | |
| outputs=[results_table, cluster_plot] | |
| ) | |
| packet_btn.click( | |
| generate_foia_packet, | |
| inputs=[agency, subject], | |
| outputs=packet_out | |
| ) | |
| demo.launch() |