Spaces:
Running
on
Zero
Running
on
Zero
Update breed_recommendation.py
Browse files- breed_recommendation.py +16 -4
breed_recommendation.py
CHANGED
@@ -115,10 +115,22 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
115 |
|
116 |
def on_description_search(description: str):
|
117 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
matcher = SmartBreedMatcher(dog_data)
|
|
|
|
|
|
|
119 |
breed_recommendations = matcher.match_user_preference(description, top_n=10)
|
120 |
|
121 |
-
#
|
|
|
122 |
user_prefs = UserPreferences(
|
123 |
living_space="apartment" if "apartment" in description.lower() else "house_small",
|
124 |
exercise_time=60,
|
@@ -196,10 +208,10 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
196 |
return format_recommendation_html(final_recommendations)
|
197 |
|
198 |
except Exception as e:
|
199 |
-
print(f"Error in description search: {str(e)}")
|
200 |
import traceback
|
201 |
-
|
202 |
-
|
|
|
203 |
|
204 |
|
205 |
get_recommendations_btn.click(
|
|
|
115 |
|
116 |
def on_description_search(description: str):
|
117 |
try:
|
118 |
+
# 1. 檢查導入的模組
|
119 |
+
print("Checking imports...")
|
120 |
+
print(f"breed_health_info available: {breed_health_info is not None}")
|
121 |
+
print(f"breed_noise_info available: {breed_noise_info is not None}")
|
122 |
+
print(f"dog_data available: {len(dog_data) if dog_data else None}")
|
123 |
+
|
124 |
+
# 2. 初始化 matcher
|
125 |
+
print("Initializing matcher...")
|
126 |
matcher = SmartBreedMatcher(dog_data)
|
127 |
+
|
128 |
+
# 3. 獲取推薦
|
129 |
+
print(f"Getting recommendations for: {description}")
|
130 |
breed_recommendations = matcher.match_user_preference(description, top_n=10)
|
131 |
|
132 |
+
# 4. 建立 user_prefs
|
133 |
+
print("Creating user preferences...")
|
134 |
user_prefs = UserPreferences(
|
135 |
living_space="apartment" if "apartment" in description.lower() else "house_small",
|
136 |
exercise_time=60,
|
|
|
208 |
return format_recommendation_html(final_recommendations)
|
209 |
|
210 |
except Exception as e:
|
|
|
211 |
import traceback
|
212 |
+
error_details = traceback.format_exc()
|
213 |
+
print(f"Detailed error:\n{error_details}")
|
214 |
+
return f"Error processing your description. Details: {str(e)}"
|
215 |
|
216 |
|
217 |
get_recommendations_btn.click(
|