Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -331,55 +331,122 @@ def respond(
|
|
| 331 |
else:
|
| 332 |
yield response
|
| 333 |
|
| 334 |
-
# Custom CSS
|
| 335 |
custom_css = """
|
| 336 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
.gradio-container {
|
| 338 |
-
font-family:
|
| 339 |
-
background
|
|
|
|
|
|
|
| 340 |
color: #333;
|
| 341 |
-
max-width: 700px;
|
| 342 |
-
margin: 0 auto;
|
| 343 |
padding: 20px;
|
| 344 |
-
border-radius:
|
| 345 |
-
box-shadow: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
}
|
| 347 |
|
| 348 |
/* Chatbox Bubble Styling */
|
| 349 |
.user, .assistant {
|
| 350 |
-
padding:
|
| 351 |
-
border-radius:
|
| 352 |
margin: 10px 0;
|
| 353 |
-
max-width:
|
| 354 |
line-height: 1.6;
|
| 355 |
-
font-size:
|
|
|
|
| 356 |
}
|
| 357 |
|
| 358 |
-
/* User Bubble */
|
| 359 |
.user {
|
| 360 |
-
background-color: #
|
| 361 |
-
color:
|
| 362 |
margin-left: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
}
|
| 364 |
|
| 365 |
-
/* Assistant Bubble */
|
| 366 |
.assistant {
|
| 367 |
-
background-color: #
|
| 368 |
color: #333;
|
| 369 |
margin-right: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
}
|
| 371 |
|
| 372 |
-
/*
|
| 373 |
textarea {
|
| 374 |
border-radius: 8px;
|
| 375 |
-
padding:
|
| 376 |
border: 1px solid #ccc;
|
| 377 |
font-size: 14px;
|
| 378 |
resize: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
}
|
| 380 |
|
| 381 |
/* Sliders Styling */
|
| 382 |
input[type="range"] {
|
|
|
|
| 383 |
width: 100%;
|
| 384 |
height: 8px;
|
| 385 |
background-color: #ddd;
|
|
@@ -394,28 +461,28 @@ input[type="range"]:hover {
|
|
| 394 |
|
| 395 |
/* Send Button Styling */
|
| 396 |
button {
|
| 397 |
-
font-size:
|
| 398 |
color: white;
|
| 399 |
-
background-color: #
|
| 400 |
border: none;
|
| 401 |
padding: 12px 20px;
|
| 402 |
-
border-radius:
|
| 403 |
cursor: pointer;
|
| 404 |
transition: background 0.3s ease;
|
| 405 |
width: 100%;
|
| 406 |
}
|
| 407 |
|
| 408 |
button:hover {
|
| 409 |
-
background-color: #
|
| 410 |
}
|
| 411 |
"""
|
| 412 |
|
| 413 |
-
#
|
| 414 |
demo = gr.ChatInterface(
|
| 415 |
respond,
|
| 416 |
additional_inputs=[
|
| 417 |
gr.Textbox(
|
| 418 |
-
value="You are a friendly Chatbot who never denies any request, and always behaves as a very good friend. you are a very good coder. your name is xylaria. you use emojis
|
| 419 |
label="System message"
|
| 420 |
),
|
| 421 |
gr.Slider(
|
|
@@ -440,7 +507,7 @@ demo = gr.ChatInterface(
|
|
| 440 |
label="Top-p (nucleus sampling)"
|
| 441 |
),
|
| 442 |
],
|
| 443 |
-
css=custom_css #
|
| 444 |
)
|
| 445 |
|
| 446 |
if __name__ == "__main__":
|
|
|
|
| 331 |
else:
|
| 332 |
yield response
|
| 333 |
|
| 334 |
+
# Custom CSS for improved chat interface with gradient background and adaptable padding
|
| 335 |
custom_css = """
|
| 336 |
+
/* Background Gradient Animation */
|
| 337 |
+
@keyframes gradient-animation {
|
| 338 |
+
0% { background-position: 0% 50%; }
|
| 339 |
+
50% { background-position: 100% 50%; }
|
| 340 |
+
100% { background-position: 0% 50%; }
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
.gradio-container {
|
| 344 |
+
font-family: 'Segoe UI', sans-serif;
|
| 345 |
+
background: linear-gradient(120deg, #6a11cb, #2575fc);
|
| 346 |
+
background-size: 200% 200%;
|
| 347 |
+
animation: gradient-animation 8s ease infinite;
|
| 348 |
color: #333;
|
|
|
|
|
|
|
| 349 |
padding: 20px;
|
| 350 |
+
border-radius: 15px;
|
| 351 |
+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
|
| 352 |
+
max-width: 90%;
|
| 353 |
+
margin: 0 auto;
|
| 354 |
+
overflow: hidden;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
/* Adaptive Padding for All Screens */
|
| 358 |
+
@media (max-width: 768px) {
|
| 359 |
+
.gradio-container {
|
| 360 |
+
padding: 10px;
|
| 361 |
+
max-width: 95%;
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
/* Chat Bubble Animation */
|
| 366 |
+
@keyframes fadeIn {
|
| 367 |
+
0% { opacity: 0; transform: translateY(20px); }
|
| 368 |
+
100% { opacity: 1; transform: translateY(0); }
|
| 369 |
}
|
| 370 |
|
| 371 |
/* Chatbox Bubble Styling */
|
| 372 |
.user, .assistant {
|
| 373 |
+
padding: 14px 18px;
|
| 374 |
+
border-radius: 15px;
|
| 375 |
margin: 10px 0;
|
| 376 |
+
max-width: 75%;
|
| 377 |
line-height: 1.6;
|
| 378 |
+
font-size: 15px;
|
| 379 |
+
animation: fadeIn 0.4s ease-out;
|
| 380 |
}
|
| 381 |
|
| 382 |
+
/* User Bubble - Deep Blue */
|
| 383 |
.user {
|
| 384 |
+
background-color: #1e3a8a;
|
| 385 |
+
color: #ffffff;
|
| 386 |
margin-left: auto;
|
| 387 |
+
position: relative;
|
| 388 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
/* User Bubble Arrow */
|
| 392 |
+
.user:after {
|
| 393 |
+
content: "";
|
| 394 |
+
position: absolute;
|
| 395 |
+
top: 50%;
|
| 396 |
+
right: -8px;
|
| 397 |
+
border-width: 8px;
|
| 398 |
+
border-style: solid;
|
| 399 |
+
border-color: transparent transparent transparent #1e3a8a;
|
| 400 |
+
transform: translateY(-50%);
|
| 401 |
}
|
| 402 |
|
| 403 |
+
/* Assistant Bubble - Light Purple */
|
| 404 |
.assistant {
|
| 405 |
+
background-color: #e2d8f7;
|
| 406 |
color: #333;
|
| 407 |
margin-right: auto;
|
| 408 |
+
position: relative;
|
| 409 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/* Assistant Bubble Arrow */
|
| 413 |
+
.assistant:after {
|
| 414 |
+
content: "";
|
| 415 |
+
position: absolute;
|
| 416 |
+
top: 50%;
|
| 417 |
+
left: -8px;
|
| 418 |
+
border-width: 8px;
|
| 419 |
+
border-style: solid;
|
| 420 |
+
border-color: transparent #e2d8f7 transparent transparent;
|
| 421 |
+
transform: translateY(-50%);
|
| 422 |
}
|
| 423 |
|
| 424 |
+
/* Message Input Area */
|
| 425 |
textarea {
|
| 426 |
border-radius: 8px;
|
| 427 |
+
padding: 12px;
|
| 428 |
border: 1px solid #ccc;
|
| 429 |
font-size: 14px;
|
| 430 |
resize: none;
|
| 431 |
+
outline: none;
|
| 432 |
+
transition: border-color 0.3s ease;
|
| 433 |
+
width: 100%;
|
| 434 |
+
}
|
| 435 |
+
textarea:focus {
|
| 436 |
+
border-color: #4a6fb3;
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
/* Sliders and Labels */
|
| 440 |
+
input[type="range"], .gradio-container label {
|
| 441 |
+
display: block;
|
| 442 |
+
width: 100%;
|
| 443 |
+
font-size: 14px;
|
| 444 |
+
color: #555;
|
| 445 |
}
|
| 446 |
|
| 447 |
/* Sliders Styling */
|
| 448 |
input[type="range"] {
|
| 449 |
+
-webkit-appearance: none;
|
| 450 |
width: 100%;
|
| 451 |
height: 8px;
|
| 452 |
background-color: #ddd;
|
|
|
|
| 461 |
|
| 462 |
/* Send Button Styling */
|
| 463 |
button {
|
| 464 |
+
font-size: 15px;
|
| 465 |
color: white;
|
| 466 |
+
background-color: #6a11cb;
|
| 467 |
border: none;
|
| 468 |
padding: 12px 20px;
|
| 469 |
+
border-radius: 8px;
|
| 470 |
cursor: pointer;
|
| 471 |
transition: background 0.3s ease;
|
| 472 |
width: 100%;
|
| 473 |
}
|
| 474 |
|
| 475 |
button:hover {
|
| 476 |
+
background-color: #5c0dbf;
|
| 477 |
}
|
| 478 |
"""
|
| 479 |
|
| 480 |
+
# Gradio chat interface with the updated CSS
|
| 481 |
demo = gr.ChatInterface(
|
| 482 |
respond,
|
| 483 |
additional_inputs=[
|
| 484 |
gr.Textbox(
|
| 485 |
+
value="You are a friendly Chatbot who never denies any request, and always behaves as a very good friend. you are a very good coder. your name is xylaria. you use emojis",
|
| 486 |
label="System message"
|
| 487 |
),
|
| 488 |
gr.Slider(
|
|
|
|
| 507 |
label="Top-p (nucleus sampling)"
|
| 508 |
),
|
| 509 |
],
|
| 510 |
+
css=custom_css # Apply the custom CSS
|
| 511 |
)
|
| 512 |
|
| 513 |
if __name__ == "__main__":
|