import gradio as gr # def create_description_search_tab() -> gr.Column: # """創建描述搜索頁面的UI組件""" # guide_html = """ #
#
#

🐾 Describe Your Ideal Dog

#
#

Help us find your perfect companion! Please consider including the following details:

#
#
# 📏 #
#

Size Preference

#

Small • Medium • Large

#
#
#
# 🏃 #
#

Activity Level

#

Low • Moderate • High • Very Active

#
#
#
# 🏠 #
#

Living Environment

#

Apartment • House • Yard Space

#
#
#
# 👨‍👩‍👧‍👦 #
#

Family Situation

#

Children • Other Pets • Single Adult

#
#
#
# ✂️ #
#

Grooming Commitment

#

Low • Medium • High Maintenance

#
#
#
# 🎭 #
#

Desired Personality

#

Friendly • Independent • Intelligent • Calm

#
#
#
#
#
#
# """ # # 添加CSS樣式 # css = """ # # """ # with gr.Column(): # # 顯示指南和樣式 # gr.HTML(css + guide_html) # # 描述輸入區 # description_input = gr.Textbox( # label="", # placeholder="Example: I'm looking for a medium-sized, friendly dog that's good with kids. I live in an apartment and can provide moderate exercise. Looking for an intelligent breed that's easy to train...", # lines=5 # ) # # 搜索按鈕(使用 Gradio 默認顏色) # search_button = gr.Button( # "Find My Perfect Match! 🔍", # variant="primary", # size="lg" # ) # # 結果顯示區域 # result_output = gr.HTML(label="Breed Recommendations") # return description_input, search_button, result_output def create_description_search_tab() -> gr.Column: """創建描述搜索頁面的UI組件""" guide_html = """

🐾 Describe Your Ideal Dog

Help us find your perfect companion! Please consider including the following details:

📏

Size Preference

Small • Medium • Large

🏃

Activity Level

Low • Moderate • High • Very Active

🏠

Living Environment

Apartment • House • Yard Space

👨‍👩‍👧‍👦

Family Situation

Children • Other Pets • Single Adult

✂️

Grooming Commitment

Low • Medium • High Maintenance

🎭

Desired Personality

Friendly • Independent • Intelligent • Calm

""" css = """ """ with gr.Column(): gr.HTML(css + guide_html) description_input = gr.Textbox( label="", placeholder="Example: I'm looking for a medium-sized, friendly dog...", lines=5 ) search_button = gr.Button( "Find My Perfect Match! 🔍", variant="primary", size="lg" ) processing_message = gr.HTML( value="

Finding your perfect match...

Please wait 15-20 seconds while we analyze your preferences.

", visible=False ) result_output = gr.HTML(label="Breed Recommendations", visible=True) def on_search_start(description): return { processing_message: gr.update(visible=True), result_output: gr.update(visible=False), description_input: gr.update(interactive=False) } def on_search_complete(output): return { processing_message: gr.update(visible=False), result_output: gr.update(visible=True, value=output), description_input: gr.update(interactive=True) } search_button.click( fn=on_search_start, inputs=[description_input], outputs=[processing_message, result_output, description_input] ).success( fn=lambda x: x, inputs=[description_input], outputs=[description_input] ) return description_input, search_button, result_output, processing_message