This commit is contained in:
parent
38f680e1eb
commit
0582fcd439
17
gradio_ui.py
17
gradio_ui.py
|
|
@ -134,12 +134,6 @@ def toggle_run(
|
|||
|
||||
# ---------------- 互斥逻辑 ----------------
|
||||
def enforce_input_exclusive_and_toggle_fields(selected):
|
||||
"""
|
||||
1. API Models / Local Models 二选一
|
||||
2. Benchmarks / Custom Datasets 二选一
|
||||
3. 保持顺序稳定,避免死循环
|
||||
4. 根据选择决定 api_fields 和 run_params_section 的显隐
|
||||
"""
|
||||
order = ["API Models", "Local Models", "Benchmarks", "Custom Datasets"]
|
||||
group1 = {"API Models", "Local Models"}
|
||||
group2 = {"Benchmarks", "Custom Datasets"}
|
||||
|
|
@ -156,19 +150,14 @@ def enforce_input_exclusive_and_toggle_fields(selected):
|
|||
|
||||
final_list = [itm for itm in order if itm in final_sel]
|
||||
|
||||
# ① 输入框更新(仅在变化时才触发)
|
||||
if list(selected) == final_list:
|
||||
input_update = gr.update()
|
||||
else:
|
||||
input_update = gr.update(value=final_list)
|
||||
input_update = gr.update() if list(selected) == final_list else gr.update(value=final_list)
|
||||
|
||||
# ② URL/Token 行仅在选中 API Models 时显示
|
||||
show_api_fields = "API Models" in final_sel
|
||||
api_row_update = gr.Row.update(visible=show_api_fields)
|
||||
|
||||
# ③ 运行参数区域在选中 API Models 或 Local Models 时显示
|
||||
show_run_params = bool(final_sel & {"API Models", "Local Models"})
|
||||
run_params_update = gr.Column.update(visible=show_run_params)
|
||||
# 👇 修复:用通用 gr.update 而非 Column.update
|
||||
run_params_update = gr.update(visible=show_run_params)
|
||||
|
||||
return input_update, api_row_update, run_params_update
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue