Spaces:
Running
on
Zero
Running
on
Zero
Update description_search_ui.py
Browse files- description_search_ui.py +30 -7
description_search_ui.py
CHANGED
|
@@ -275,17 +275,14 @@ def create_description_search_tab() -> gr.Column:
|
|
| 275 |
"""
|
| 276 |
|
| 277 |
with gr.Column():
|
| 278 |
-
# 顯示指南和樣式
|
| 279 |
gr.HTML(css + guide_html)
|
| 280 |
|
| 281 |
-
# 描述輸入區
|
| 282 |
description_input = gr.Textbox(
|
| 283 |
label="",
|
| 284 |
placeholder="Example: I'm looking for a medium-sized, friendly dog that's good with kids...",
|
| 285 |
lines=5
|
| 286 |
)
|
| 287 |
|
| 288 |
-
# 搜索按鈕
|
| 289 |
search_button = gr.Button(
|
| 290 |
"Find My Perfect Match! 🔍",
|
| 291 |
variant="primary",
|
|
@@ -293,9 +290,35 @@ def create_description_search_tab() -> gr.Column:
|
|
| 293 |
)
|
| 294 |
|
| 295 |
# 加載狀態提示
|
| 296 |
-
processing_message = gr.HTML(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
-
|
| 299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
|
| 301 |
-
return description_input, search_button, result_output
|
|
|
|
| 275 |
"""
|
| 276 |
|
| 277 |
with gr.Column():
|
|
|
|
| 278 |
gr.HTML(css + guide_html)
|
| 279 |
|
|
|
|
| 280 |
description_input = gr.Textbox(
|
| 281 |
label="",
|
| 282 |
placeholder="Example: I'm looking for a medium-sized, friendly dog that's good with kids...",
|
| 283 |
lines=5
|
| 284 |
)
|
| 285 |
|
|
|
|
| 286 |
search_button = gr.Button(
|
| 287 |
"Find My Perfect Match! 🔍",
|
| 288 |
variant="primary",
|
|
|
|
| 290 |
)
|
| 291 |
|
| 292 |
# 加載狀態提示
|
| 293 |
+
processing_message = gr.HTML(
|
| 294 |
+
value="<div style='text-align: center; padding: 20px; color: #666;'><p><b>Finding your perfect match...</b></p><p>Please wait 15-20 seconds while we analyze your preferences.</p></div>",
|
| 295 |
+
visible=False
|
| 296 |
+
)
|
| 297 |
+
|
| 298 |
+
result_output = gr.HTML(label="Breed Recommendations", visible=True)
|
| 299 |
|
| 300 |
+
def on_search_start(description):
|
| 301 |
+
return {
|
| 302 |
+
processing_message: gr.update(visible=True),
|
| 303 |
+
result_output: gr.update(visible=False),
|
| 304 |
+
description_input: gr.update(interactive=False)
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
def on_search_complete(output):
|
| 308 |
+
return {
|
| 309 |
+
processing_message: gr.update(visible=False),
|
| 310 |
+
result_output: gr.update(visible=True, value=output),
|
| 311 |
+
description_input: gr.update(interactive=True)
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
search_button.click(
|
| 315 |
+
fn=on_search_start,
|
| 316 |
+
inputs=[description_input],
|
| 317 |
+
outputs=[processing_message, result_output, description_input]
|
| 318 |
+
).success(
|
| 319 |
+
fn=lambda x: x,
|
| 320 |
+
inputs=[description_input],
|
| 321 |
+
outputs=[description_input]
|
| 322 |
+
)
|
| 323 |
|
| 324 |
+
return description_input, search_button, result_output
|