|
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(): |
|
|
|
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 |
|
|