Spaces:
Running
on
Zero
Running
on
Zero
Update search_history.py
Browse files- search_history.py +2 -56
search_history.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
import traceback
|
| 4 |
from typing import Optional, Dict, List
|
|
@@ -58,59 +57,6 @@ class SearchHistoryComponent:
|
|
| 58 |
</div>
|
| 59 |
"""
|
| 60 |
|
| 61 |
-
# if search_type == "criteria":
|
| 62 |
-
# # 原有的條件搜尋顯示邏輯
|
| 63 |
-
# prefs = entry.get('preferences', {})
|
| 64 |
-
# html += f"""
|
| 65 |
-
# <div class="params-list">
|
| 66 |
-
# <h4>Search Parameters:</h4>
|
| 67 |
-
# <ul>
|
| 68 |
-
# <li><span class="param-label">Living Space:</span> {prefs.get('living_space', 'N/A')}</li>
|
| 69 |
-
# <li><span class="param-label">Exercise Time:</span> {prefs.get('exercise_time', 'N/A')} minutes</li>
|
| 70 |
-
# <li><span class="param-label">Grooming:</span> {prefs.get('grooming_commitment', 'N/A')}</li>
|
| 71 |
-
# <li><span class="param-label">Experience:</span> {prefs.get('experience_level', 'N/A')}</li>
|
| 72 |
-
# <li><span class="param-label">Children at Home:</span> {"Yes" if prefs.get('has_children') else "No"}</li>
|
| 73 |
-
# <li><span class="param-label">Noise Tolerance:</span> {prefs.get('noise_tolerance', 'N/A')}</li>
|
| 74 |
-
# </ul>
|
| 75 |
-
# </div>
|
| 76 |
-
# """
|
| 77 |
-
# else:
|
| 78 |
-
# # Description 搜尋的顯示邏輯
|
| 79 |
-
# description = entry.get('description', 'No description provided')
|
| 80 |
-
# html += f"""
|
| 81 |
-
# <div class="description-section">
|
| 82 |
-
# <h4>Search Description:</h4>
|
| 83 |
-
# <p class="user-description">{description}</p>
|
| 84 |
-
# </div>
|
| 85 |
-
# """
|
| 86 |
-
|
| 87 |
-
# # 共用的結果顯示邏輯
|
| 88 |
-
# html += """
|
| 89 |
-
# <div class="results-list">
|
| 90 |
-
# <h4>Top 10 Breed Matches:</h4>
|
| 91 |
-
# <div class="breed-list">
|
| 92 |
-
# """
|
| 93 |
-
|
| 94 |
-
# if results:
|
| 95 |
-
# for i, result in enumerate(results[:10], 1):
|
| 96 |
-
# breed_name = result.get('breed', 'Unknown breed').replace('_', ' ')
|
| 97 |
-
# score = result.get('overall_score', result.get('final_score', 0))
|
| 98 |
-
# html += f"""
|
| 99 |
-
# <div class="breed-item">
|
| 100 |
-
# <div class="breed-info">
|
| 101 |
-
# <span class="breed-rank">#{i}</span>
|
| 102 |
-
# <span class="breed-name">{breed_name}</span>
|
| 103 |
-
# <span class="breed-score">{score*100:.1f}%</span>
|
| 104 |
-
# </div>
|
| 105 |
-
# </div>
|
| 106 |
-
# """
|
| 107 |
-
|
| 108 |
-
# html += """
|
| 109 |
-
# </div>
|
| 110 |
-
# </div>
|
| 111 |
-
# </div>
|
| 112 |
-
# """
|
| 113 |
-
|
| 114 |
if search_type == "criteria":
|
| 115 |
prefs = entry.get('preferences', {})
|
| 116 |
html += f"""
|
|
@@ -221,7 +167,7 @@ def create_history_tab(history_component: SearchHistoryComponent):
|
|
| 221 |
"""創建歷史紀錄的頁面
|
| 222 |
|
| 223 |
Args:
|
| 224 |
-
history_component:
|
| 225 |
"""
|
| 226 |
with gr.TabItem("Recommendation Search History"):
|
| 227 |
gr.HTML("""
|
|
@@ -288,4 +234,4 @@ def create_history_tab(history_component: SearchHistoryComponent):
|
|
| 288 |
fn=history_component.refresh_history,
|
| 289 |
outputs=[history_display],
|
| 290 |
api_name="refresh_history"
|
| 291 |
-
)
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import traceback
|
| 3 |
from typing import Optional, Dict, List
|
|
|
|
| 57 |
</div>
|
| 58 |
"""
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
if search_type == "criteria":
|
| 61 |
prefs = entry.get('preferences', {})
|
| 62 |
html += f"""
|
|
|
|
| 167 |
"""創建歷史紀錄的頁面
|
| 168 |
|
| 169 |
Args:
|
| 170 |
+
history_component:
|
| 171 |
"""
|
| 172 |
with gr.TabItem("Recommendation Search History"):
|
| 173 |
gr.HTML("""
|
|
|
|
| 234 |
fn=history_component.refresh_history,
|
| 235 |
outputs=[history_display],
|
| 236 |
api_name="refresh_history"
|
| 237 |
+
)
|