DawnC commited on
Commit
309504b
1 Parent(s): e0adbed

Update breed_recommendation.py

Browse files
Files changed (1) hide show
  1. breed_recommendation.py +7 -8
breed_recommendation.py CHANGED
@@ -199,7 +199,8 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
199
 
200
  search_status = gr.HTML(
201
  '<div id="search-status">🔍 Sniffing out your perfect furry companion...</div>',
202
- visible=False
 
203
  )
204
 
205
  get_recommendations_btn = gr.Button(
@@ -218,6 +219,7 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
218
 
219
  def on_find_match_click(*args):
220
  try:
 
221
  print("Starting breed matching process...")
222
  user_prefs = UserPreferences(
223
  living_space=args[0],
@@ -267,9 +269,9 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
267
  results=history_results
268
  )
269
 
270
- return [
271
  format_recommendation_html(recommendations, is_description_search=False),
272
- gr.HTML.update(visible=False) # 隱藏搜尋狀態
273
  ]
274
 
275
  except Exception as e:
@@ -279,10 +281,6 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
279
  return ["Error getting recommendations", gr.HTML.update(visible=False)]
280
 
281
  get_recommendations_btn.click(
282
- fn=show_loading_status,
283
- outputs=search_status,
284
- queue=False
285
- ).then(
286
  fn=on_find_match_click,
287
  inputs=[
288
  living_space,
@@ -297,7 +295,8 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
297
  children_age,
298
  noise_tolerance
299
  ],
300
- outputs=[recommendation_output, search_status]
 
301
  )
302
 
303
  return {
 
199
 
200
  search_status = gr.HTML(
201
  '<div id="search-status">🔍 Sniffing out your perfect furry companion...</div>',
202
+ visible=False,
203
+ elem_id="search-status-container"
204
  )
205
 
206
  get_recommendations_btn = gr.Button(
 
219
 
220
  def on_find_match_click(*args):
221
  try:
222
+ yield ["", gr.HTML.update(visible=True)]
223
  print("Starting breed matching process...")
224
  user_prefs = UserPreferences(
225
  living_space=args[0],
 
269
  results=history_results
270
  )
271
 
272
+ yield [
273
  format_recommendation_html(recommendations, is_description_search=False),
274
+ gr.HTML.update(visible=False)
275
  ]
276
 
277
  except Exception as e:
 
281
  return ["Error getting recommendations", gr.HTML.update(visible=False)]
282
 
283
  get_recommendations_btn.click(
 
 
 
 
284
  fn=on_find_match_click,
285
  inputs=[
286
  living_space,
 
295
  children_age,
296
  noise_tolerance
297
  ],
298
+ outputs=[recommendation_output, search_status],
299
+ queue=True # 確保異步處理
300
  )
301
 
302
  return {