File size: 2,146 Bytes
3b39b49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d15e788
 
 
 
 
 
 
 
02b7dec
 
d15e788
97fcd0c
 
 
 
 
eaa5563
 
97fcd0c
 
f10a835
 
 
 
c1ae336
f10a835
 
 
 
 
 
 
 
 
c1ae336
 
 
 
 
 
 
f10a835
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import gradio as gr


def get_qid_selector(dataset_size: int):
    return gr.Number(
        info="Question ID",
        value=1,
        precision=0,
        minimum=1,
        maximum=dataset_size,
        show_label=False,
        scale=0,
        container=False,
        elem_classes="qid-selector",
    )


def get_pipeline_selector(model_options: list[str]):
    return gr.Dropdown(
        label="User Submissions and Examples",
        choices=model_options,
        value="",
        interactive=True,
        container=False,
        elem_classes="pipeline-selector",
    )


def get_panel_header(header: str, subheader: str | None = None):
    html = f"<h4 class='panel-header'>{header}</h4>"
    if subheader:
        html += f"<p class='md panel-subheader'>{subheader}</p>"
    with gr.Row(elem_classes="md panel-header-container") as row:
        gr.HTML(html)
    return row


def get_model_submission_accordion(app: gr.Blocks):
    with gr.Accordion(
        "🤗 Feel happy with your agent? Make a submission!", elem_classes="model-submission-accordion", open=True
    ):
        with gr.Row():
            model_name_input = gr.Textbox(label="Submission Name")
            description_input = gr.Textbox(label="Submission Description")
        with gr.Row():
            # login_btn = gr.LoginButton()
            submit_btn = gr.Button("Submit", variant="primary", interactive=False)

        submit_status = gr.HTML(label="Submission Status")
        gr.Markdown(
            """**Submission Name Guidelines**
            1. Must start with a letter.
            2. Can only contain letters, numbers, underscores, and hyphens.
            3. Cannot contain white spaces or other special characters.
            """
        )

    def check_user_login(profile: gr.OAuthProfile | None):
        if profile is not None:
            return gr.update(interactive=True, value="Submit Agent")
        return gr.update(interactive=False, value="Login to submit your agent")

    gr.on(triggers=app.load, fn=check_user_login, inputs=[], outputs=[submit_btn])
    return model_name_input, description_input, submit_btn, submit_status