This commit is contained in:
parent
9f6fe28212
commit
85d16ef782
18
gradio_ui.py
18
gradio_ui.py
|
|
@ -19,7 +19,7 @@ def enforce_input_exclusive_and_toggle_fields(selected):
|
|||
|
||||
def keep_only_one(group):
|
||||
filtered = [item for item in selected if item in group]
|
||||
return filtered[-1:] # 只保留最后一个
|
||||
return filtered[-1:] # 保留最后一个
|
||||
|
||||
final_selection = set(selected)
|
||||
final_selection -= group1
|
||||
|
|
@ -32,8 +32,7 @@ def enforce_input_exclusive_and_toggle_fields(selected):
|
|||
|
||||
return (
|
||||
gr.update(value=list(final_selection)),
|
||||
gr.update(visible=show_api_fields),
|
||||
gr.update(visible=show_api_fields)
|
||||
gr.Row.update(visible=show_api_fields) # ✅ 用 Row 的更新
|
||||
)
|
||||
|
||||
with gr.Blocks(title="EvalScope 全功能界面") as demo:
|
||||
|
|
@ -71,16 +70,23 @@ with gr.Blocks(title="EvalScope 全功能界面") as demo:
|
|||
run_button = gr.Button("Run Evaluation")
|
||||
output_text = gr.Textbox(label="执行结果", lines=10)
|
||||
|
||||
# 绑定输入源选择的变化,控制互斥+是否显示API字段
|
||||
# ✅ 绑定变化,更新互斥选项与 API 表单显示
|
||||
input_choices.change(
|
||||
fn=enforce_input_exclusive_and_toggle_fields,
|
||||
inputs=input_choices,
|
||||
outputs=[input_choices, api_url_input, api_token_input]
|
||||
outputs=[input_choices, api_fields]
|
||||
)
|
||||
|
||||
run_button.click(
|
||||
run_eval,
|
||||
inputs=[input_choices, native_choices, other_choices, output_choices, api_url_input, api_token_input],
|
||||
inputs=[
|
||||
input_choices,
|
||||
native_choices,
|
||||
other_choices,
|
||||
output_choices,
|
||||
api_url_input,
|
||||
api_token_input
|
||||
],
|
||||
outputs=output_text
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue