Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,159 +129,323 @@ def retry_last_response(history, temperature, max_length):
|
|
| 129 |
|
| 130 |
return new_history
|
| 131 |
|
| 132 |
-
#
|
| 133 |
custom_css = """
|
| 134 |
.gradio-container {
|
| 135 |
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
| 136 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 137 |
min-height: 100vh;
|
| 138 |
-
padding:
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
.main-container {
|
| 142 |
-
max-width:
|
| 143 |
margin: 0 auto;
|
| 144 |
background: white;
|
| 145 |
-
border-radius:
|
| 146 |
-
box-shadow: 0
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
}
|
| 149 |
|
| 150 |
.header {
|
| 151 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 152 |
color: white;
|
| 153 |
-
padding: 30px;
|
| 154 |
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
}
|
| 156 |
|
| 157 |
.header h1 {
|
| 158 |
margin: 0;
|
| 159 |
-
font-size:
|
| 160 |
-
font-weight:
|
|
|
|
|
|
|
| 161 |
}
|
| 162 |
|
| 163 |
.header p {
|
| 164 |
-
margin:
|
| 165 |
-
opacity: 0.
|
| 166 |
-
font-size: 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
}
|
| 168 |
|
| 169 |
-
.
|
| 170 |
-
|
| 171 |
-
min-height: 600px;
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
.chat-column {
|
| 175 |
-
flex: 3;
|
| 176 |
display: flex;
|
| 177 |
flex-direction: column;
|
|
|
|
| 178 |
}
|
| 179 |
|
| 180 |
-
.
|
| 181 |
flex: 1;
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
|
|
|
| 185 |
}
|
| 186 |
|
| 187 |
-
.chatbot-
|
| 188 |
flex: 1;
|
| 189 |
-
display: flex;
|
| 190 |
-
flex-direction: column;
|
| 191 |
min-height: 500px;
|
|
|
|
|
|
|
| 192 |
}
|
| 193 |
|
| 194 |
#chatbot {
|
| 195 |
-
flex: 1;
|
| 196 |
min-height: 500px !important;
|
|
|
|
| 197 |
border: none !important;
|
| 198 |
background: white !important;
|
| 199 |
-
padding:
|
| 200 |
margin: 0 !important;
|
|
|
|
| 201 |
}
|
| 202 |
|
| 203 |
#chatbot .message {
|
| 204 |
-
padding:
|
| 205 |
-
margin:
|
| 206 |
-
border-radius:
|
| 207 |
-
max-width:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
}
|
| 209 |
|
| 210 |
#chatbot .user-message {
|
| 211 |
-
background: #667eea !important;
|
| 212 |
color: white !important;
|
| 213 |
margin-left: auto !important;
|
|
|
|
| 214 |
}
|
| 215 |
|
| 216 |
#chatbot .bot-message {
|
| 217 |
-
background: #
|
| 218 |
-
color: #
|
|
|
|
| 219 |
margin-right: auto !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
}
|
| 221 |
|
| 222 |
.input-container {
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
}
|
| 227 |
|
| 228 |
.control-panel {
|
| 229 |
background: white;
|
| 230 |
-
padding:
|
| 231 |
-
border-radius:
|
| 232 |
-
|
| 233 |
-
|
| 234 |
}
|
| 235 |
|
| 236 |
-
.model-info {
|
| 237 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 238 |
color: white;
|
| 239 |
-
padding:
|
| 240 |
-
border-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
}
|
| 242 |
|
| 243 |
.gr-button {
|
| 244 |
-
background: linear-gradient(
|
| 245 |
border: none !important;
|
| 246 |
color: white !important;
|
| 247 |
-
border-radius:
|
| 248 |
-
padding:
|
| 249 |
font-weight: 600 !important;
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
}
|
| 252 |
|
| 253 |
.clear-btn {
|
| 254 |
-
background: linear-gradient(
|
|
|
|
| 255 |
}
|
| 256 |
|
| 257 |
.retry-btn {
|
| 258 |
-
background: linear-gradient(
|
|
|
|
| 259 |
}
|
| 260 |
|
| 261 |
.textbox {
|
| 262 |
-
border-radius:
|
| 263 |
-
border: 2px solid #
|
| 264 |
-
padding:
|
| 265 |
font-size: 16px !important;
|
|
|
|
|
|
|
| 266 |
}
|
| 267 |
|
| 268 |
.textbox:focus {
|
| 269 |
border-color: #667eea !important;
|
| 270 |
-
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
}
|
| 272 |
|
| 273 |
.examples-panel {
|
| 274 |
background: white;
|
| 275 |
-
padding:
|
| 276 |
-
border-top: 1px solid #
|
| 277 |
}
|
| 278 |
|
| 279 |
-
.
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
}
|
| 286 |
"""
|
| 287 |
|
|
@@ -291,15 +455,16 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 291 |
with gr.Column(elem_classes="main-container"):
|
| 292 |
# Header
|
| 293 |
with gr.Column(elem_classes="header"):
|
| 294 |
-
gr.Markdown("#
|
| 295 |
-
gr.Markdown("
|
| 296 |
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
with gr.Column(elem_classes="chat-
|
| 300 |
-
|
|
|
|
| 301 |
chatbot = gr.Chatbot(
|
| 302 |
-
value=[],
|
| 303 |
label="",
|
| 304 |
elem_id="chatbot",
|
| 305 |
show_copy_button=True,
|
|
@@ -309,83 +474,111 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
|
|
| 309 |
show_label=False
|
| 310 |
)
|
| 311 |
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
gr.
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
label="Temperature",
|
| 342 |
-
info="Lower = more predictable, Higher = more creative"
|
| 343 |
-
)
|
| 344 |
-
|
| 345 |
-
max_length = gr.Slider(
|
| 346 |
-
minimum=50,
|
| 347 |
-
maximum=1000,
|
| 348 |
-
value=256,
|
| 349 |
-
step=50,
|
| 350 |
-
label="Max Response Length",
|
| 351 |
-
info="Tokens in generated response"
|
| 352 |
-
)
|
| 353 |
-
|
| 354 |
-
with gr.Column(elem_classes="model-info"):
|
| 355 |
-
gr.Markdown("### βΉοΈ Model Info")
|
| 356 |
-
if tokenizer and model:
|
| 357 |
-
gr.Markdown("""
|
| 358 |
-
**Model:** Qwen3-0.6B β
|
| 359 |
-
**Status:** Ready to chat!
|
| 360 |
-
**Think Tags:** Auto-removed β
|
| 361 |
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
|
| 373 |
# Examples Section
|
| 374 |
with gr.Column(elem_classes="examples-panel"):
|
| 375 |
-
gr.
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
|
| 390 |
# Event handlers
|
| 391 |
submit_event = msg.submit(
|
|
|
|
| 129 |
|
| 130 |
return new_history
|
| 131 |
|
| 132 |
+
# Enhanced CSS for beautiful UI with settings below chat
|
| 133 |
custom_css = """
|
| 134 |
.gradio-container {
|
| 135 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
| 136 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 137 |
min-height: 100vh;
|
| 138 |
+
padding: 0;
|
| 139 |
+
margin: 0;
|
| 140 |
}
|
| 141 |
|
| 142 |
.main-container {
|
| 143 |
+
max-width: 1400px;
|
| 144 |
margin: 0 auto;
|
| 145 |
background: white;
|
| 146 |
+
border-radius: 0;
|
| 147 |
+
box-shadow: 0 0 50px rgba(0,0,0,0.1);
|
| 148 |
+
min-height: 100vh;
|
| 149 |
+
display: flex;
|
| 150 |
+
flex-direction: column;
|
| 151 |
}
|
| 152 |
|
| 153 |
.header {
|
| 154 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 155 |
color: white;
|
| 156 |
+
padding: 40px 30px 30px 30px;
|
| 157 |
text-align: center;
|
| 158 |
+
position: relative;
|
| 159 |
+
overflow: hidden;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.header::before {
|
| 163 |
+
content: '';
|
| 164 |
+
position: absolute;
|
| 165 |
+
top: 0;
|
| 166 |
+
left: 0;
|
| 167 |
+
right: 0;
|
| 168 |
+
bottom: 0;
|
| 169 |
+
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" opacity="0.1"><polygon points="0,0 1000,100 1000,0" fill="white"/></svg>');
|
| 170 |
+
background-size: cover;
|
| 171 |
}
|
| 172 |
|
| 173 |
.header h1 {
|
| 174 |
margin: 0;
|
| 175 |
+
font-size: 3em;
|
| 176 |
+
font-weight: 800;
|
| 177 |
+
position: relative;
|
| 178 |
+
text-shadow: 0 2px 10px rgba(0,0,0,0.3);
|
| 179 |
}
|
| 180 |
|
| 181 |
.header p {
|
| 182 |
+
margin: 15px 0 0 0;
|
| 183 |
+
opacity: 0.95;
|
| 184 |
+
font-size: 1.3em;
|
| 185 |
+
font-weight: 300;
|
| 186 |
+
position: relative;
|
| 187 |
+
max-width: 600px;
|
| 188 |
+
margin-left: auto;
|
| 189 |
+
margin-right: auto;
|
| 190 |
}
|
| 191 |
|
| 192 |
+
.chat-main-area {
|
| 193 |
+
flex: 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
display: flex;
|
| 195 |
flex-direction: column;
|
| 196 |
+
min-height: 70vh;
|
| 197 |
}
|
| 198 |
|
| 199 |
+
.chat-container {
|
| 200 |
flex: 1;
|
| 201 |
+
display: flex;
|
| 202 |
+
flex-direction: column;
|
| 203 |
+
background: white;
|
| 204 |
+
position: relative;
|
| 205 |
}
|
| 206 |
|
| 207 |
+
.chatbot-wrapper {
|
| 208 |
flex: 1;
|
|
|
|
|
|
|
| 209 |
min-height: 500px;
|
| 210 |
+
max-height: 65vh;
|
| 211 |
+
border-bottom: 1px solid #eef2f7;
|
| 212 |
}
|
| 213 |
|
| 214 |
#chatbot {
|
|
|
|
| 215 |
min-height: 500px !important;
|
| 216 |
+
max-height: 65vh !important;
|
| 217 |
border: none !important;
|
| 218 |
background: white !important;
|
| 219 |
+
padding: 30px !important;
|
| 220 |
margin: 0 !important;
|
| 221 |
+
border-radius: 0 !important;
|
| 222 |
}
|
| 223 |
|
| 224 |
#chatbot .message {
|
| 225 |
+
padding: 20px 25px !important;
|
| 226 |
+
margin: 15px 0 !important;
|
| 227 |
+
border-radius: 20px !important;
|
| 228 |
+
max-width: 85% !important;
|
| 229 |
+
line-height: 1.6 !important;
|
| 230 |
+
font-size: 16px !important;
|
| 231 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.08) !important;
|
| 232 |
+
border: 1px solid rgba(0,0,0,0.05) !important;
|
| 233 |
}
|
| 234 |
|
| 235 |
#chatbot .user-message {
|
| 236 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
| 237 |
color: white !important;
|
| 238 |
margin-left: auto !important;
|
| 239 |
+
margin-right: 0 !important;
|
| 240 |
}
|
| 241 |
|
| 242 |
#chatbot .bot-message {
|
| 243 |
+
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
|
| 244 |
+
color: #2d3748 !important;
|
| 245 |
+
margin-left: 0 !important;
|
| 246 |
margin-right: auto !important;
|
| 247 |
+
border: 1px solid #e2e8f0 !important;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.input-section {
|
| 251 |
+
background: #fafbfc;
|
| 252 |
+
padding: 30px;
|
| 253 |
+
border-top: 1px solid #eef2f7;
|
| 254 |
}
|
| 255 |
|
| 256 |
.input-container {
|
| 257 |
+
max-width: 1000px;
|
| 258 |
+
margin: 0 auto;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.controls-section {
|
| 262 |
+
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
|
| 263 |
+
padding: 40px 30px;
|
| 264 |
+
border-top: 1px solid #e2e8f0;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
.controls-container {
|
| 268 |
+
max-width: 1200px;
|
| 269 |
+
margin: 0 auto;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
.controls-grid {
|
| 273 |
+
display: grid;
|
| 274 |
+
grid-template-columns: 1fr 1fr;
|
| 275 |
+
gap: 30px;
|
| 276 |
+
margin-bottom: 30px;
|
| 277 |
}
|
| 278 |
|
| 279 |
.control-panel {
|
| 280 |
background: white;
|
| 281 |
+
padding: 30px;
|
| 282 |
+
border-radius: 20px;
|
| 283 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.08);
|
| 284 |
+
border: 1px solid #eef2f7;
|
| 285 |
}
|
| 286 |
|
| 287 |
+
.model-info-panel {
|
| 288 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 289 |
color: white;
|
| 290 |
+
padding: 30px;
|
| 291 |
+
border-radius: 20px;
|
| 292 |
+
box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
|
| 293 |
+
position: relative;
|
| 294 |
+
overflow: hidden;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.model-info-panel::before {
|
| 298 |
+
content: '';
|
| 299 |
+
position: absolute;
|
| 300 |
+
top: 0;
|
| 301 |
+
right: 0;
|
| 302 |
+
width: 100px;
|
| 303 |
+
height: 100px;
|
| 304 |
+
background: rgba(255,255,255,0.1);
|
| 305 |
+
border-radius: 50%;
|
| 306 |
+
transform: translate(30px, -30px);
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
.control-group {
|
| 310 |
+
margin-bottom: 25px;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
.control-group:last-child {
|
| 314 |
+
margin-bottom: 0;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
.control-label {
|
| 318 |
+
display: block;
|
| 319 |
+
font-weight: 600;
|
| 320 |
+
color: #2d3748;
|
| 321 |
+
margin-bottom: 12px;
|
| 322 |
+
font-size: 16px;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
.control-info {
|
| 326 |
+
font-size: 14px;
|
| 327 |
+
color: #718096;
|
| 328 |
+
margin-top: 8px;
|
| 329 |
+
line-height: 1.5;
|
| 330 |
}
|
| 331 |
|
| 332 |
.gr-button {
|
| 333 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
| 334 |
border: none !important;
|
| 335 |
color: white !important;
|
| 336 |
+
border-radius: 15px !important;
|
| 337 |
+
padding: 16px 32px !important;
|
| 338 |
font-weight: 600 !important;
|
| 339 |
+
font-size: 16px !important;
|
| 340 |
+
transition: all 0.3s ease !important;
|
| 341 |
+
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3) !important;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
.gr-button:hover {
|
| 345 |
+
transform: translateY(-2px) !important;
|
| 346 |
+
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4) !important;
|
| 347 |
}
|
| 348 |
|
| 349 |
.clear-btn {
|
| 350 |
+
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%) !important;
|
| 351 |
+
box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3) !important;
|
| 352 |
}
|
| 353 |
|
| 354 |
.retry-btn {
|
| 355 |
+
background: linear-gradient(135deg, #00b894 0%, #00a085 100%) !important;
|
| 356 |
+
box-shadow: 0 4px 15px rgba(0, 184, 148, 0.3) !important;
|
| 357 |
}
|
| 358 |
|
| 359 |
.textbox {
|
| 360 |
+
border-radius: 15px !important;
|
| 361 |
+
border: 2px solid #e2e8f0 !important;
|
| 362 |
+
padding: 20px !important;
|
| 363 |
font-size: 16px !important;
|
| 364 |
+
background: white !important;
|
| 365 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.05) !important;
|
| 366 |
}
|
| 367 |
|
| 368 |
.textbox:focus {
|
| 369 |
border-color: #667eea !important;
|
| 370 |
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), 0 2px 10px rgba(0,0,0,0.05) !important;
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
.slider-container {
|
| 374 |
+
margin: 20px 0;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
.model-features {
|
| 378 |
+
margin-top: 20px;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
.feature-list {
|
| 382 |
+
list-style: none;
|
| 383 |
+
padding: 0;
|
| 384 |
+
margin: 15px 0 0 0;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
.feature-list li {
|
| 388 |
+
padding: 8px 0;
|
| 389 |
+
position: relative;
|
| 390 |
+
padding-left: 25px;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
.feature-list li::before {
|
| 394 |
+
content: 'β';
|
| 395 |
+
position: absolute;
|
| 396 |
+
left: 0;
|
| 397 |
+
color: #48bb78;
|
| 398 |
+
font-weight: bold;
|
| 399 |
}
|
| 400 |
|
| 401 |
.examples-panel {
|
| 402 |
background: white;
|
| 403 |
+
padding: 40px 30px;
|
| 404 |
+
border-top: 1px solid #eef2f7;
|
| 405 |
}
|
| 406 |
|
| 407 |
+
.examples-container {
|
| 408 |
+
max-width: 1200px;
|
| 409 |
+
margin: 0 auto;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
.examples-grid {
|
| 413 |
+
display: grid;
|
| 414 |
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
| 415 |
+
gap: 15px;
|
| 416 |
+
margin-top: 20px;
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
@media (max-width: 768px) {
|
| 420 |
+
.controls-grid {
|
| 421 |
+
grid-template-columns: 1fr;
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
.header h1 {
|
| 425 |
+
font-size: 2.2em;
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
.header p {
|
| 429 |
+
font-size: 1.1em;
|
| 430 |
+
}
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
.status-indicator {
|
| 434 |
+
display: inline-block;
|
| 435 |
+
width: 12px;
|
| 436 |
+
height: 12px;
|
| 437 |
+
border-radius: 50%;
|
| 438 |
+
margin-right: 8px;
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
.status-online {
|
| 442 |
+
background: #48bb78;
|
| 443 |
+
box-shadow: 0 0 10px #48bb78;
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
.status-offline {
|
| 447 |
+
background: #ed8936;
|
| 448 |
+
box-shadow: 0 0 10px #ed8936;
|
| 449 |
}
|
| 450 |
"""
|
| 451 |
|
|
|
|
| 455 |
with gr.Column(elem_classes="main-container"):
|
| 456 |
# Header
|
| 457 |
with gr.Column(elem_classes="header"):
|
| 458 |
+
gr.Markdown("# π Qwen3-0.6B Chatbot")
|
| 459 |
+
gr.Markdown("Experience intelligent conversations with Alibaba's advanced AI - Think tags automatically removed! β¨")
|
| 460 |
|
| 461 |
+
# Main Chat Area
|
| 462 |
+
with gr.Column(elem_classes="chat-main-area"):
|
| 463 |
+
with gr.Column(elem_classes="chat-container"):
|
| 464 |
+
# Chatbot
|
| 465 |
+
with gr.Column(elem_classes="chatbot-wrapper"):
|
| 466 |
chatbot = gr.Chatbot(
|
| 467 |
+
value=[["Hello! How can I assist you today? π", ""]],
|
| 468 |
label="",
|
| 469 |
elem_id="chatbot",
|
| 470 |
show_copy_button=True,
|
|
|
|
| 474 |
show_label=False
|
| 475 |
)
|
| 476 |
|
| 477 |
+
# Input Section
|
| 478 |
+
with gr.Column(elem_classes="input-section"):
|
| 479 |
+
with gr.Column(elem_classes="input-container"):
|
| 480 |
+
with gr.Row():
|
| 481 |
+
msg = gr.Textbox(
|
| 482 |
+
label="",
|
| 483 |
+
placeholder="π Type your message here... (Press Enter to send, Shift+Enter for new line)",
|
| 484 |
+
lines=2,
|
| 485 |
+
scale=4,
|
| 486 |
+
container=False,
|
| 487 |
+
show_label=False
|
| 488 |
+
)
|
| 489 |
+
with gr.Column(scale=1):
|
| 490 |
+
submit_btn = gr.Button("Send Message π", size="lg")
|
| 491 |
+
|
| 492 |
+
with gr.Row():
|
| 493 |
+
clear_btn = gr.Button("ποΈ Clear Chat", elem_classes="clear-btn")
|
| 494 |
+
retry_btn = gr.Button("π Retry Last", elem_classes="retry-btn")
|
| 495 |
+
gr.HTML("""<div style="flex: 1; text-align: center; color: #666; font-size: 14px; padding: 12px;">
|
| 496 |
+
β¨ Powered by Qwen3-0.6B β’ Think tags automatically removed
|
| 497 |
+
</div>""")
|
| 498 |
+
|
| 499 |
+
# Controls Section (Below Chat)
|
| 500 |
+
with gr.Column(elem_classes="controls-section"):
|
| 501 |
+
with gr.Column(elem_classes="controls-container"):
|
| 502 |
+
with gr.Row(elem_classes="controls-grid"):
|
| 503 |
+
# Settings Panel
|
| 504 |
+
with gr.Column(elem_classes="control-panel"):
|
| 505 |
+
gr.Markdown("### βοΈ Generation Settings")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
|
| 507 |
+
with gr.Column(elem_classes="control-group"):
|
| 508 |
+
gr.Markdown("**ποΈ Temperature**")
|
| 509 |
+
temperature = gr.Slider(
|
| 510 |
+
minimum=0.1,
|
| 511 |
+
maximum=1.5,
|
| 512 |
+
value=0.7,
|
| 513 |
+
step=0.1,
|
| 514 |
+
label="",
|
| 515 |
+
show_label=False,
|
| 516 |
+
info=""
|
| 517 |
+
)
|
| 518 |
+
gr.Markdown("<div class='control-info'>Lower values for more predictable responses, higher values for more creativity</div>")
|
| 519 |
+
|
| 520 |
+
with gr.Column(elem_classes="control-group"):
|
| 521 |
+
gr.Markdown("**π Max Response Length**")
|
| 522 |
+
max_length = gr.Slider(
|
| 523 |
+
minimum=50,
|
| 524 |
+
maximum=1000,
|
| 525 |
+
value=256,
|
| 526 |
+
step=50,
|
| 527 |
+
label="",
|
| 528 |
+
show_label=False,
|
| 529 |
+
info=""
|
| 530 |
+
)
|
| 531 |
+
gr.Markdown("<div class='control-info'>Number of tokens in the generated response (50-1000)</div>")
|
| 532 |
+
|
| 533 |
+
# Model Info Panel
|
| 534 |
+
with gr.Column(elem_classes="model-info-panel"):
|
| 535 |
+
gr.Markdown("### βΉοΈ Model Information")
|
| 536 |
+
if tokenizer and model:
|
| 537 |
+
gr.Markdown("""
|
| 538 |
+
<span class="status-indicator status-online"></span> **Status:** Online & Ready
|
| 539 |
+
|
| 540 |
+
**Model:** Qwen3-0.6B β
|
| 541 |
+
**Think Tags:** Auto-Removed β
|
| 542 |
+
|
| 543 |
+
<div class="model-features">
|
| 544 |
+
**Key Features:**
|
| 545 |
+
<ul class="feature-list">
|
| 546 |
+
<li>0.6 Billion Parameters</li>
|
| 547 |
+
<li>128K Context Window</li>
|
| 548 |
+
<li>Multilingual Support</li>
|
| 549 |
+
<li>Advanced Reasoning</li>
|
| 550 |
+
<li>Chat Optimized</li>
|
| 551 |
+
</ul>
|
| 552 |
+
</div>
|
| 553 |
+
""")
|
| 554 |
+
else:
|
| 555 |
+
gr.Markdown("""
|
| 556 |
+
<span class="status-indicator status-offline"></span> **Status:** Loading Issue
|
| 557 |
+
|
| 558 |
+
Please check the console for error details.
|
| 559 |
+
The interface will use fallback responses.
|
| 560 |
+
""")
|
| 561 |
|
| 562 |
# Examples Section
|
| 563 |
with gr.Column(elem_classes="examples-panel"):
|
| 564 |
+
with gr.Column(elem_classes="examples-container"):
|
| 565 |
+
gr.Markdown("### π‘ Quick Start Examples")
|
| 566 |
+
gr.Markdown("Click any example below to start chatting:")
|
| 567 |
+
|
| 568 |
+
with gr.Column(elem_classes="examples-grid"):
|
| 569 |
+
gr.Examples(
|
| 570 |
+
examples=[
|
| 571 |
+
"Explain quantum computing in simple terms",
|
| 572 |
+
"Write a short poem about artificial intelligence",
|
| 573 |
+
"What are the benefits of renewable energy?",
|
| 574 |
+
"How do I learn programming effectively?",
|
| 575 |
+
"Tell me an interesting fact about space exploration",
|
| 576 |
+
"Help me plan a healthy weekly meal plan"
|
| 577 |
+
],
|
| 578 |
+
inputs=msg,
|
| 579 |
+
label="",
|
| 580 |
+
examples_per_page=6
|
| 581 |
+
)
|
| 582 |
|
| 583 |
# Event handlers
|
| 584 |
submit_event = msg.submit(
|