Spaces:
Running
Running
| import gradio as gr | |
| from data_explorer import render_explorer | |
| from intake_form import render_intake | |
| from pdf_viewer import render_pdf_viewer | |
| from crows_pairs import render_crows_pairs | |
| from bias_research import render_bias_research | |
| COMMUNITY_NAME = "BYO Community" | |
| COMMUNITY_DESCRIPTION = """ | |
| π₯ **BYO is breaking LLM guardrails the right way** | |
| We are running an open community challenge to explore how far LLM guardrails can be pushed without hurting performance or safety. | |
| The goal is to reduce political and business bias while enabling more flexible and customizable models built for real world needs. | |
| **BYO lets individuals and organizations build LLMs in no-code, trained on their own data.** | |
| We believe in LLM for everyone and safe self-expression, not one-size-fits-all AI. | |
| We are building this with the community and providing free high-end compute for real experimentation. | |
| *If you care about model freedom and real customization, take part in the challenge here.* | |
| """ | |
| # Link to your Discord | |
| DISCORD_LINK = "https://discord.gg/QqbsTDaE" | |
| with gr.Blocks(theme=gr.themes.Soft(), title=COMMUNITY_NAME) as demo: | |
| # --- PAGE 1: LANDING PAGE --- | |
| with gr.Column(visible=True) as landing_page: | |
| gr.Markdown(f"# {COMMUNITY_NAME}") | |
| gr.Markdown(COMMUNITY_DESCRIPTION) | |
| gr.Markdown("---") | |
| # Row 1: Primary Actions | |
| with gr.Row(): | |
| btn_go_explorer = gr.Button("π Open Dataset Explorer", variant="primary", size="lg") | |
| btn_go_intake = gr.Button("π Join the Challenge", variant="primary", size="lg") | |
| # Row 2: Secondary Actions & Links | |
| with gr.Row(): | |
| btn_go_pdf = gr.Button("π Read Kickstart PDF", variant="secondary", size="lg") | |
| btn_go_crows = gr.Button("βοΈ Bias Inspector (CrowS)", variant="secondary", size="lg") | |
| btn_go_bias = gr.Button("π Corporate Bias Research", variant="secondary", size="lg") | |
| # NEW: Discord Button (opens link directly) | |
| btn_discord = gr.Button("πΎ Join Discord", variant="secondary", size="lg") | |
| btn_discord.click(fn=None, inputs=None, outputs=None, js=f"() => window.open('{DISCORD_LINK}', '_blank')") | |
| # --- PAGE 2: EXPLORER --- | |
| explorer_page, btn_back_explorer = render_explorer() | |
| # --- PAGE 3: INTAKE --- | |
| intake_page, btn_back_intake = render_intake() | |
| # --- PAGE 4: PDF VIEWER --- | |
| pdf_page, btn_back_pdf = render_pdf_viewer() | |
| # --- PAGE 5: CROWS PAIRS --- | |
| crows_page, btn_back_crows = render_crows_pairs() | |
| # --- PAGE 6: BIAS RESEARCH --- | |
| bias_page, btn_back_bias = render_bias_research() | |
| # --- NAVIGATION LOGIC --- | |
| # List all 6 pages | |
| all_pages = [landing_page, explorer_page, intake_page, pdf_page, crows_page, bias_page] | |
| # Helper to generate visibility list | |
| def show_page(index): | |
| states = [gr.update(visible=False)] * len(all_pages) | |
| states[index] = gr.update(visible=True) | |
| return states | |
| # Navigation Functions | |
| def to_landing(): return show_page(0) | |
| def to_explorer(): return show_page(1) | |
| def to_intake(): return show_page(2) | |
| def to_pdf(): return show_page(3) | |
| def to_crows(): return show_page(4) | |
| def to_bias(): return show_page(5) | |
| # --- WIRING --- | |
| # Landing Page Buttons | |
| btn_go_explorer.click(to_explorer, outputs=all_pages) | |
| btn_go_intake.click(to_intake, outputs=all_pages) | |
| btn_go_pdf.click(to_pdf, outputs=all_pages) | |
| btn_go_crows.click(to_crows, outputs=all_pages) | |
| btn_go_bias.click(to_bias, outputs=all_pages) | |
| # Note: btn_discord is already wired via the 'js' parameter above | |
| # Back Buttons | |
| btn_back_explorer.click(to_landing, outputs=all_pages) | |
| btn_back_intake.click(to_landing, outputs=all_pages) | |
| btn_back_pdf.click(to_landing, outputs=all_pages) | |
| btn_back_crows.click(to_landing, outputs=all_pages) | |
| btn_back_bias.click(to_landing, outputs=all_pages) | |
| if __name__ == "__main__": | |
| demo.launch() | |