def main()

in community-efforts/prompt_translation/dashboard_template/app.py [0:0]


def main() -> None:

    # Connect to the space with rg.init()
    rg.init(
        api_url=os.getenv("ARGILLA_API_URL"),
        api_key=os.getenv("ARGILLA_API_KEY"),
    )

    # Fetch the data initially
    fetch_data()

    # To avoid the orange border for the Gradio elements that are in constant loading
    css = """
    .generating {
        border: none;
    }
    """

    with gr.Blocks(css=css, delete_cache=(300, 300)) as demo:
        gr.Markdown(
            """
            # 🌍 [YOUR LANGUAGE] - Multilingual Prompt Evaluation Project

            Hugging Face and @argilla are developing [Multilingual Prompt Evaluation Project](https://github.com/huggingface/data-is-better-together/tree/main/prompt_translation) project. It is an open multilingual benchmark for evaluating language models, and of course, also for [YOUR LANGUAGE].

            ## The goal is to translate 500 Prompts
            And as always: data is needed for that! The community selected the best 500 prompts that will form the benchmark. In English, of course.
            **That's why we need your help**: if we all translate the 500 prompts, we can add [YOUR LANGUAGE] to the leaderboard.

            ## How to participate
            Participating is easy. Go to the [annotation space][add a link to your annotation dataset], log in or create a Hugging Face account, and you can start working.
            Thanks in advance! Oh, and we'll give you a little push: GPT4 has already prepared a translation suggestion for you.
            """
        )

        gr.Markdown(
            f"""
            ## 🚀 Current Progress
            This is what we've achieved so far!
            """
        )
        with gr.Row():

            kpi_submitted_plot = gr.Plot(label="Plot")
            demo.load(
                kpi_chart_submitted,
                inputs=[],
                outputs=[kpi_submitted_plot],
            )

            kpi_remaining_plot = gr.Plot(label="Plot")
            demo.load(
                kpi_chart_remaining,
                inputs=[],
                outputs=[kpi_remaining_plot],
            )

            donut_total_plot = gr.Plot(label="Plot")
            demo.load(
                donut_chart_total,
                inputs=[],
                outputs=[donut_total_plot],
            )

        gr.Markdown(
            """
            ## 👾 Hall of Fame
            Here you can see the top contributors and the number of annotations they have made.
            """
        )

        with gr.Row():

            kpi_hall_plot = gr.Plot(label="Plot")
            demo.load(kpi_chart_total_annotators, inputs=[], outputs=[kpi_hall_plot])

            top_df_plot = gr.Dataframe(
                headers=[NAME, NUMBER_ANNOTATIONS],
                datatype=[
                    "markdown",
                    "number",
                ],
                row_count=50,
                col_count=(2, "fixed"),
                interactive=False,
            )
            demo.load(get_top, None, [top_df_plot])

    # Manage background refresh
    scheduler = BackgroundScheduler()
    _ = scheduler.add_job(restart, "interval", minutes=30)
    scheduler.start()

    # Launch the Gradio interface
    demo.launch()