DawnC commited on
Commit
38537cb
1 Parent(s): 04d0016

Update breed_recommendation.py

Browse files
Files changed (1) hide show
  1. breed_recommendation.py +30 -2
breed_recommendation.py CHANGED
@@ -118,7 +118,12 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
118
  )
119
 
120
  get_recommendations_btn = gr.Button("Find My Perfect Match! 🔍", variant="primary")
121
- recommendation_output = gr.HTML(label="Breed Recommendations")
 
 
 
 
 
122
 
123
  def on_find_match_click(*args):
124
  try:
@@ -186,6 +191,23 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
186
  return gr.update(value="Error getting recommendations", visible=True)
187
 
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  get_recommendations_btn.click(
190
  fn=on_find_match_click,
191
  inputs=[
@@ -200,7 +222,13 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
200
  children_age,
201
  noise_tolerance
202
  ],
203
- outputs=recommendation_output
 
 
 
 
 
 
204
  )
205
 
206
  return {
 
118
  )
119
 
120
  get_recommendations_btn = gr.Button("Find My Perfect Match! 🔍", variant="primary")
121
+ # recommendation_output = gr.HTML(label="Breed Recommendations")
122
+ recommendation_output = gr.HTML(
123
+ label="Breed Recommendations",
124
+ visible=True, # 確保可見性
125
+ elem_id="recommendation-output" # 添加唯一ID以便追蹤
126
+ )
127
 
128
  def on_find_match_click(*args):
129
  try:
 
191
  return gr.update(value="Error getting recommendations", visible=True)
192
 
193
 
194
+ # get_recommendations_btn.click(
195
+ # fn=on_find_match_click,
196
+ # inputs=[
197
+ # living_space,
198
+ # yard_access,
199
+ # exercise_time,
200
+ # exercise_type,
201
+ # grooming_commitment,
202
+ # experience_level,
203
+ # time_availability,
204
+ # has_children,
205
+ # children_age,
206
+ # noise_tolerance
207
+ # ],
208
+ # outputs=recommendation_output
209
+ # )
210
+
211
  get_recommendations_btn.click(
212
  fn=on_find_match_click,
213
  inputs=[
 
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 {