Spaces:
Running
on
Zero
Running
on
Zero
Update breed_recommendation.py
Browse files- breed_recommendation.py +17 -1
breed_recommendation.py
CHANGED
|
@@ -88,7 +88,7 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
| 88 |
description_input, description_search_btn, description_output, loading_msg = create_description_search_tab()
|
| 89 |
|
| 90 |
|
| 91 |
-
def on_find_match_click(*args):
|
| 92 |
try:
|
| 93 |
user_prefs = UserPreferences(
|
| 94 |
living_space=args[0],
|
|
@@ -138,6 +138,22 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
| 138 |
print(traceback.format_exc())
|
| 139 |
return "Error getting recommendations"
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
def on_description_search(description: str):
|
| 142 |
try:
|
| 143 |
# 初始化匹配器
|
|
|
|
| 88 |
description_input, description_search_btn, description_output, loading_msg = create_description_search_tab()
|
| 89 |
|
| 90 |
|
| 91 |
+
async def on_find_match_click(*args):
|
| 92 |
try:
|
| 93 |
user_prefs = UserPreferences(
|
| 94 |
living_space=args[0],
|
|
|
|
| 138 |
print(traceback.format_exc())
|
| 139 |
return "Error getting recommendations"
|
| 140 |
|
| 141 |
+
# 使用 async 和 queue=True
|
| 142 |
+
get_recommendations_btn.click(
|
| 143 |
+
fn=on_find_match_click,
|
| 144 |
+
inputs=[
|
| 145 |
+
living_space,
|
| 146 |
+
exercise_time,
|
| 147 |
+
grooming_commitment,
|
| 148 |
+
experience_level,
|
| 149 |
+
has_children,
|
| 150 |
+
noise_tolerance
|
| 151 |
+
],
|
| 152 |
+
outputs=recommendation_output,
|
| 153 |
+
queue=True
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
def on_description_search(description: str):
|
| 158 |
try:
|
| 159 |
# 初始化匹配器
|