EvalsOnTheHub / app.py
Clémentine
change it into a command writer
c97be0a
import gradio as gr
from utils import get_models, get_available_tasks, get_providers_for_model, build_lighteval_command
# Handle login and token storage
def on_login(profile: gr.OAuthProfile):
if profile is None:
return "Not logged in"
return f"Logged in as **{profile.name}** (@{profile.username})"
# Update command when selections change
def update_command_display(model, provider, tasks, results_org, profile: gr.OAuthProfile):
username = profile.username if profile else "YOUR_USERNAME"
return build_lighteval_command(model, provider, tasks, results_org, username)
with gr.Blocks(title="LightEval ❤️ Jobs") as demo:
gr.Markdown("# Run evaluations in 5 lines of code!")
gr.Markdown("Generate your own snippet to run lighteval easily using jobs and inference providers")
# Add login button and user info
with gr.Row():
login_btn = gr.LoginButton()
with gr.Row():
with gr.Column():
model_dropdown = gr.Dropdown(
label="Model",
choices=get_models(),
value=None,
interactive=True
)
provider_dropdown = gr.Dropdown(
label="Inference Provider",
choices=[],
value=None,
interactive=True
)
tasks_dropdown = gr.Dropdown(
label="Tasks (searchable - type to filter)",
choices=get_available_tasks(),
value=get_available_tasks()[0],
multiselect=True,
interactive=True,
allow_custom_value=False,
filterable=True
)
results_org = gr.Textbox(
label="Results Organization",
placeholder="Enter HF organization to save detailed results to",
interactive=True
)
command_display = gr.Code(
label="Get the command for your model",
value=build_lighteval_command(),
language="python",
lines=15,
interactive=False
)
# Link model to providers
model_dropdown.change(
fn=get_providers_for_model,
inputs=model_dropdown,
outputs=provider_dropdown
)
# Update command display when any input changes
for component in [model_dropdown, provider_dropdown, tasks_dropdown, results_org]:
component.change(
fn=update_command_display,
inputs=[model_dropdown, provider_dropdown, tasks_dropdown, results_org],
outputs=command_display
)
if __name__ == "__main__":
demo.launch()