DawnC commited on
Commit
407d216
1 Parent(s): 38537cb

Update breed_recommendation.py

Browse files
Files changed (1) hide show
  1. breed_recommendation.py +12 -9
breed_recommendation.py CHANGED
@@ -182,13 +182,22 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
182
  # return "Error getting recommendations"
183
 
184
  html_result = format_recommendation_html(recommendations, is_description_search=False)
185
- return gr.update(value=html_result, visible=True)
 
 
 
 
 
 
 
186
 
 
 
187
  except Exception as e:
188
  print(f"Error in find match: {str(e)}")
189
  import traceback
190
  print(traceback.format_exc())
191
- return gr.update(value="Error getting recommendations", visible=True)
192
 
193
 
194
  # get_recommendations_btn.click(
@@ -222,13 +231,7 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
222
  children_age,
223
  noise_tolerance
224
  ],
225
- outputs=recommendation_output,
226
- api_name="get_recommendations" # 添加API名稱以便追蹤
227
- ).then( # 添加清理函數
228
- lambda: None,
229
- None,
230
- None,
231
- _js="() => {document.getElementById('recommendation-output').scrollIntoView({behavior: 'smooth'})}"
232
  )
233
 
234
  return {
 
182
  # return "Error getting recommendations"
183
 
184
  html_result = format_recommendation_html(recommendations, is_description_search=False)
185
+ enhanced_html = f"""
186
+ {html_result}
187
+ <script>
188
+ document.getElementById('recommendation-output').scrollIntoView({{
189
+ behavior: 'smooth'
190
+ }});
191
+ </script>
192
+ """
193
 
194
+ return gr.update(value=enhanced_html)
195
+
196
  except Exception as e:
197
  print(f"Error in find match: {str(e)}")
198
  import traceback
199
  print(traceback.format_exc())
200
+ return gr.update(value="Error getting recommendations")
201
 
202
 
203
  # get_recommendations_btn.click(
 
231
  children_age,
232
  noise_tolerance
233
  ],
234
+ outputs=recommendation_output
 
 
 
 
 
 
235
  )
236
 
237
  return {