Spaces:
Running
on
Zero
Running
on
Zero
Upload description_search_ui.py
Browse files- description_search_ui.py +208 -0
description_search_ui.py
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def create_description_search_tab():
|
5 |
+
"""顯示描述搜尋頁面的UI"""
|
6 |
+
guide_html = """
|
7 |
+
<div class="breed-search-container">
|
8 |
+
<div class="description-guide">
|
9 |
+
<div style="
|
10 |
+
text-align: center;
|
11 |
+
position: relative;
|
12 |
+
margin-bottom: 20px;
|
13 |
+
padding-top: 15px; /* 為 BETA 徽章留出空間 */
|
14 |
+
">
|
15 |
+
<!-- BETA 徽章 -->
|
16 |
+
<div style="
|
17 |
+
position: absolute;
|
18 |
+
top: 0;
|
19 |
+
right: 20px;
|
20 |
+
background: linear-gradient(90deg, #4299e1, #48bb78);
|
21 |
+
color: white;
|
22 |
+
padding: 4px 12px;
|
23 |
+
border-radius: 15px;
|
24 |
+
font-size: 0.85em;
|
25 |
+
font-weight: 600;
|
26 |
+
letter-spacing: 1px;
|
27 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
28 |
+
">BETA</div>
|
29 |
+
|
30 |
+
<!-- 主標題 -->
|
31 |
+
<h2 class="guide-title" style="
|
32 |
+
display: inline-block;
|
33 |
+
background: linear-gradient(90deg, #4299e1, #48bb78);
|
34 |
+
-webkit-background-clip: text;
|
35 |
+
-webkit-text-fill-color: transparent;
|
36 |
+
font-weight: 600;
|
37 |
+
font-size: 1.8em;
|
38 |
+
">🐾 Describe Your Ideal Dog</h2>
|
39 |
+
</div>
|
40 |
+
|
41 |
+
<div style="
|
42 |
+
background: linear-gradient(to right, rgba(66, 153, 225, 0.15), rgba(72, 187, 120, 0.15));
|
43 |
+
border-left: 4px solid;
|
44 |
+
border-image: linear-gradient(to bottom, #4299e1, #48bb78) 1;
|
45 |
+
border-radius: 4px;
|
46 |
+
padding: 12px 16px;
|
47 |
+
margin: 15px 0;
|
48 |
+
font-weight: 500;
|
49 |
+
color: #2D3748;
|
50 |
+
display: flex;
|
51 |
+
align-items: center;
|
52 |
+
gap: 8px;
|
53 |
+
">
|
54 |
+
<span style="font-size: 1.2em;">🔬</span>
|
55 |
+
<span style="
|
56 |
+
font-size: 1em;
|
57 |
+
letter-spacing: 0.3px;
|
58 |
+
line-height: 1.4;
|
59 |
+
"><strong>Beta Feature:</strong> We're continuously improving our breed description matching. Results may vary.</span>
|
60 |
+
</div>
|
61 |
+
|
62 |
+
<div class="guide-content">
|
63 |
+
<p class="intro-text" style="
|
64 |
+
background: linear-gradient(90deg, #4299e1, #48bb78);
|
65 |
+
-webkit-background-clip: text;
|
66 |
+
-webkit-text-fill-color: transparent;
|
67 |
+
font-weight: 600;
|
68 |
+
font-size: 1.2em;
|
69 |
+
margin-bottom: 20px;
|
70 |
+
">Help us find your perfect companion! Please consider including the following details:</p>
|
71 |
+
|
72 |
+
<div class="criteria-grid" style="
|
73 |
+
background: linear-gradient(to right, rgba(66, 153, 225, 0.1), rgba(72, 187, 120, 0.1));
|
74 |
+
border-radius: 10px;
|
75 |
+
padding: 20px;
|
76 |
+
">
|
77 |
+
<div class="criteria-item">
|
78 |
+
<span class="icon">🏃</span>
|
79 |
+
<div class="criteria-content">
|
80 |
+
<h3>Activity Level</h3>
|
81 |
+
<p>Low • Moderate • High • Very Active</p>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
|
85 |
+
<div class="criteria-item">
|
86 |
+
<span class="icon">🏠</span>
|
87 |
+
<div class="criteria-content">
|
88 |
+
<h3>Living Environment</h3>
|
89 |
+
<p>Apartment • House • Yard Space</p>
|
90 |
+
</div>
|
91 |
+
</div>
|
92 |
+
|
93 |
+
<div class="criteria-item">
|
94 |
+
<span class="icon">👨👩👧👦</span>
|
95 |
+
<div class="criteria-content">
|
96 |
+
<h3>Family Situation</h3>
|
97 |
+
<p>Children • Other Pets • Single Adult</p>
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
|
101 |
+
<div class="criteria-item">
|
102 |
+
<span class="icon">✂️</span>
|
103 |
+
<div class="criteria-content">
|
104 |
+
<h3>Grooming Commitment</h3>
|
105 |
+
<p>Low • Medium • High Maintenance</p>
|
106 |
+
</div>
|
107 |
+
</div>
|
108 |
+
|
109 |
+
<div class="criteria-item">
|
110 |
+
<span class="icon">🎭</span>
|
111 |
+
<div class="criteria-content">
|
112 |
+
<h3>Desired Personality</h3>
|
113 |
+
<p>Friendly • Independent • Intelligent • Calm</p>
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
</div>
|
120 |
+
"""
|
121 |
+
|
122 |
+
# 增加 CSS 的樣式
|
123 |
+
css = """
|
124 |
+
<style>
|
125 |
+
.breed-search-container {
|
126 |
+
background: white;
|
127 |
+
border-radius: 12px;
|
128 |
+
padding: 24px;
|
129 |
+
margin-bottom: 20px;
|
130 |
+
}
|
131 |
+
.guide-title {
|
132 |
+
font-size: 1.8rem;
|
133 |
+
color: #2c3e50;
|
134 |
+
margin-bottom: 20px;
|
135 |
+
text-align: center;
|
136 |
+
}
|
137 |
+
.intro-text {
|
138 |
+
color: #666;
|
139 |
+
text-align: center;
|
140 |
+
margin-bottom: 24px;
|
141 |
+
font-size: 1.1rem;
|
142 |
+
}
|
143 |
+
.criteria-grid {
|
144 |
+
display: grid;
|
145 |
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
146 |
+
gap: 20px;
|
147 |
+
margin-bottom: 24px;
|
148 |
+
}
|
149 |
+
.criteria-item {
|
150 |
+
display: flex;
|
151 |
+
align-items: flex-start;
|
152 |
+
padding: 16px;
|
153 |
+
background: #f8fafc;
|
154 |
+
border-radius: 8px;
|
155 |
+
transition: all 0.3s ease;
|
156 |
+
}
|
157 |
+
.criteria-item:hover {
|
158 |
+
transform: translateY(-2px);
|
159 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
|
160 |
+
}
|
161 |
+
.criteria-item .icon {
|
162 |
+
font-size: 24px;
|
163 |
+
margin-right: 12px;
|
164 |
+
margin-top: 3px;
|
165 |
+
}
|
166 |
+
.criteria-content h3 {
|
167 |
+
font-size: 1.1rem;
|
168 |
+
color: #2c3e50;
|
169 |
+
margin: 0 0 4px 0;
|
170 |
+
}
|
171 |
+
.criteria-content p {
|
172 |
+
color: #666;
|
173 |
+
margin: 0;
|
174 |
+
font-size: 0.95rem;
|
175 |
+
}
|
176 |
+
</style>
|
177 |
+
"""
|
178 |
+
|
179 |
+
with gr.Column():
|
180 |
+
# 顯示指南和樣式
|
181 |
+
gr.HTML(css + guide_html)
|
182 |
+
|
183 |
+
# 描述輸入區
|
184 |
+
description_input = gr.Textbox(
|
185 |
+
label="",
|
186 |
+
placeholder="Example: I'm looking for a medium-sized, friendly dog that's good with kids...",
|
187 |
+
lines=5
|
188 |
+
)
|
189 |
+
|
190 |
+
# 搜索按鈕
|
191 |
+
search_button = gr.Button(
|
192 |
+
"Find My Perfect Match! 🔍",
|
193 |
+
variant="primary",
|
194 |
+
size="lg"
|
195 |
+
)
|
196 |
+
|
197 |
+
# 加載消息
|
198 |
+
loading_msg = gr.HTML("""
|
199 |
+
<div style='text-align: center; color: #666;'>
|
200 |
+
<p><b>Finding your perfect match...</b></p>
|
201 |
+
<p>Please wait 25-30 seconds while we analyze your preferences.</p>
|
202 |
+
</div>
|
203 |
+
""", visible=False)
|
204 |
+
|
205 |
+
# 結果顯示區域
|
206 |
+
result_output = gr.HTML(label="Breed Recommendations")
|
207 |
+
|
208 |
+
return description_input, search_button, result_output, loading_msg
|