diff --git a/gradio_ui.py b/gradio_ui.py index c870592..c1b72d7 100644 --- a/gradio_ui.py +++ b/gradio_ui.py @@ -16,7 +16,8 @@ with gr.Blocks(title="EvalScope 全功能界面") as demo: with gr.Row(): input_choices = gr.CheckboxGroup( label="选择输入源", - choices=["API Models", "Local Models", "Benchmarks", "Custom Datasets"] + choices=["API Models", "Local Models", "Benchmarks", "Custom Datasets"], + interactive=True ) with gr.Row(): @@ -44,6 +45,28 @@ with gr.Blocks(title="EvalScope 全功能界面") as demo: run_button = gr.Button("Run Evaluation") output_text = gr.Textbox(label="执行结果", lines=10) + def enforce_input_exclusive(selected): + # 互斥组1 + group1 = {"API Models", "Local Models"} + # 互斥组2 + group2 = {"Benchmarks", "Custom Datasets"} + + # 判断是否需要清除某个组 + def enforce_group_exclusive(group): + selected_set = set(selected) + selected_in_group = selected_set & group + if len(selected_in_group) > 1: + # 如果同时选中多个,就保留最后一个 + last_selected = next((item for item in reversed(selected) if item in group), None) + return (selected_set - group) | {last_selected} + return selected_set + + final_selection = enforce_group_exclusive(group1) + final_selection = enforce_group_exclusive(group2 | final_selection) + return list(final_selection) + + input_choices.change(fn=enforce_input_exclusive, inputs=input_choices, outputs=input_choices) + run_button.click(run_eval, inputs=[input_choices, native_choices, other_choices, output_choices], outputs=output_text) if __name__ == '__main__':