import gradio as gr def create_comparison_tab(dog_breeds, get_dog_description): """创建品种比较标签页 Args: dog_breeds: 狗品种列表 get_dog_description: 获取品种描述的函数 """ with gr.TabItem("Breed Comparison"): gr.HTML("
Select two dog breeds to compare their characteristics and care requirements.
") with gr.Row(): breed1_dropdown = gr.Dropdown( choices=dog_breeds, label="Select First Breed", value="Golden_Retriever" ) breed2_dropdown = gr.Dropdown( choices=dog_breeds, label="Select Second Breed", value="Border_Collie" ) compare_btn = gr.Button("Compare Breeds") comparison_output = gr.HTML(label="Comparison Results") def show_comparison(breed1, breed2): if not breed1 or not breed2: return "Please select two breeds to compare" breed1_info = get_dog_description(breed1) breed2_info = get_dog_description(breed2) html_output = f"""