Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -367,13 +367,23 @@ custom_css = """
|
|
| 367 |
/* Import Oswald font - Google Fonts */
|
| 368 |
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
|
| 369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
/* Apply Oswald globally */
|
| 371 |
*, *::before, *::after {
|
| 372 |
font-family: "Oswald", sans-serif !important;
|
| 373 |
color: #120f0e !important;
|
| 374 |
}
|
| 375 |
|
| 376 |
-
/* Main container styling - viewport height */
|
| 377 |
.gradio-container-5-42-0 {
|
| 378 |
background-color: rgb(240, 236, 230) !important;
|
| 379 |
font-family: "Oswald", sans-serif !important;
|
|
@@ -383,16 +393,30 @@ custom_css = """
|
|
| 383 |
height: 100vh !important;
|
| 384 |
max-height: 100vh !important;
|
| 385 |
overflow: hidden !important;
|
|
|
|
|
|
|
| 386 |
}
|
| 387 |
|
| 388 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
.title-header {
|
| 390 |
background-color: rgb(240, 236, 230) !important;
|
| 391 |
padding: 10px 20px;
|
| 392 |
-
margin: 0;
|
| 393 |
border-bottom: 1pt solid #59524f;
|
| 394 |
text-align: left;
|
| 395 |
-
flex-shrink: 0;
|
|
|
|
|
|
|
|
|
|
| 396 |
}
|
| 397 |
.title-header h1 {
|
| 398 |
font-size: 1.5rem;
|
|
@@ -402,41 +426,17 @@ custom_css = """
|
|
| 402 |
padding: 0;
|
| 403 |
}
|
| 404 |
|
| 405 |
-
/*
|
| 406 |
-
.
|
| 407 |
-
height: calc(100vh - 60px) !important;
|
| 408 |
-
display: flex !important;
|
| 409 |
-
flex-direction: column !important;
|
| 410 |
-
}
|
| 411 |
-
|
| 412 |
-
.title-row {
|
| 413 |
-
flex-shrink: 0 !important;
|
| 414 |
-
height: 60px !important;
|
| 415 |
-
}
|
| 416 |
-
|
| 417 |
-
.chat-row {
|
| 418 |
-
flex: 1 !important;
|
| 419 |
-
overflow: hidden !important;
|
| 420 |
-
padding: 10px 20px !important;
|
| 421 |
-
}
|
| 422 |
-
|
| 423 |
-
.input-row {
|
| 424 |
-
flex-shrink: 0 !important;
|
| 425 |
-
height: 120px !important;
|
| 426 |
-
padding: 15px 20px !important;
|
| 427 |
-
}
|
| 428 |
-
|
| 429 |
-
/* Chat styling - use remaining space */
|
| 430 |
-
.chat-container,
|
| 431 |
-
.gradio-container-5-42-0 .gradio-chatbot,
|
| 432 |
-
.gradio-container-5-42-0 #main-chatbot {
|
| 433 |
background-color: #d9d1ce !important;
|
| 434 |
border: 1pt solid #59524f !important;
|
| 435 |
border-radius: 6px !important;
|
| 436 |
padding: 15px !important;
|
| 437 |
-
height:
|
| 438 |
-
max-height:
|
| 439 |
overflow-y: auto !important;
|
|
|
|
|
|
|
| 440 |
}
|
| 441 |
|
| 442 |
/* Message styling */
|
|
@@ -468,29 +468,37 @@ custom_css = """
|
|
| 468 |
margin-bottom: 10px !important;
|
| 469 |
}
|
| 470 |
|
| 471 |
-
/* Input
|
| 472 |
-
.input-
|
| 473 |
-
background-color: rgb(240, 236, 230) !important;
|
| 474 |
-
border-top: 1pt solid #59524f;
|
| 475 |
-
padding: 0 !important;
|
| 476 |
-
height: 100% !important;
|
| 477 |
display: flex !important;
|
| 478 |
-
|
| 479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
}
|
| 481 |
|
| 482 |
/* Button styling - compact */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 483 |
.gradio-container-5-42-0 .send-button,
|
| 484 |
.gradio-container-5-42-0 .clear-button {
|
| 485 |
color: #120f0e !important;
|
| 486 |
border: 1pt solid #59524f !important;
|
| 487 |
border-radius: 6px !important;
|
| 488 |
-
padding:
|
| 489 |
cursor: pointer !important;
|
| 490 |
margin: 0 !important;
|
| 491 |
font-weight: 500 !important;
|
| 492 |
-
height:
|
| 493 |
-
|
| 494 |
}
|
| 495 |
|
| 496 |
.gradio-container-5-42-0 .send-button {
|
|
@@ -501,31 +509,46 @@ custom_css = """
|
|
| 501 |
background-color: #ada3a0 !important;
|
| 502 |
}
|
| 503 |
|
| 504 |
-
/* Textbox styling -
|
| 505 |
.gradio-container-5-42-0 .input-textbox {
|
| 506 |
background-color: #d9d1ce !important;
|
| 507 |
border: 1pt solid #59524f !important;
|
| 508 |
border-radius: 8px !important;
|
| 509 |
flex: 1 !important;
|
|
|
|
| 510 |
}
|
| 511 |
|
| 512 |
.gradio-container-5-42-0 .input-textbox textarea {
|
| 513 |
background-color: #d9d1ce !important;
|
| 514 |
border: none !important;
|
| 515 |
color: #120f0e !important;
|
| 516 |
-
padding:
|
| 517 |
font-size: 14px !important;
|
| 518 |
font-weight: 400 !important;
|
| 519 |
resize: none !important;
|
| 520 |
-
height:
|
| 521 |
-
min-height:
|
| 522 |
-
max-height:
|
|
|
|
| 523 |
}
|
| 524 |
|
| 525 |
.gradio-container-5-42-0 .input-textbox textarea::placeholder {
|
| 526 |
font-weight: 300 !important;
|
| 527 |
color: rgba(18, 15, 14, 0.6) !important;
|
| 528 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
"""
|
| 530 |
|
| 531 |
# --- UI: HTML Head Content ---
|
|
@@ -609,36 +632,30 @@ def create_interface():
|
|
| 609 |
gr.HTML('<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>')
|
| 610 |
gr.HTML(mathjax_config)
|
| 611 |
|
| 612 |
-
#
|
| 613 |
-
|
| 614 |
-
gr.HTML('<div class="title-header"><h1>🎓 EduBot</h1></div>')
|
| 615 |
|
| 616 |
-
#
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
elem_classes=["chat-container"],
|
| 625 |
-
container=True,
|
| 626 |
-
elem_id="main-chatbot"
|
| 627 |
-
)
|
| 628 |
|
| 629 |
-
#
|
| 630 |
-
with gr.Row(elem_classes=["input-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
clear = gr.Button("Clear", elem_classes=["clear-button"])
|
| 642 |
|
| 643 |
# Set up event handlers
|
| 644 |
msg.submit(respond_and_update, [msg, chatbot], [chatbot, msg])
|
|
|
|
| 367 |
/* Import Oswald font - Google Fonts */
|
| 368 |
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
|
| 369 |
|
| 370 |
+
/* HIDE the HTML components that create scrollbars */
|
| 371 |
+
#component-1, #component-2, #component-3 {
|
| 372 |
+
display: none !important;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
/* Hide any block containers with auto-margin that might be causing spacing */
|
| 376 |
+
.block.svelte-1svsvh2.hide-container.auto-margin {
|
| 377 |
+
display: none !important;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
/* Apply Oswald globally */
|
| 381 |
*, *::before, *::after {
|
| 382 |
font-family: "Oswald", sans-serif !important;
|
| 383 |
color: #120f0e !important;
|
| 384 |
}
|
| 385 |
|
| 386 |
+
/* Main container styling - viewport height with no top margin */
|
| 387 |
.gradio-container-5-42-0 {
|
| 388 |
background-color: rgb(240, 236, 230) !important;
|
| 389 |
font-family: "Oswald", sans-serif !important;
|
|
|
|
| 393 |
height: 100vh !important;
|
| 394 |
max-height: 100vh !important;
|
| 395 |
overflow: hidden !important;
|
| 396 |
+
display: flex !important;
|
| 397 |
+
flex-direction: column !important;
|
| 398 |
}
|
| 399 |
|
| 400 |
+
/* Target Gradio's internal structure */
|
| 401 |
+
.gradio-container-5-42-0 > div {
|
| 402 |
+
height: 100% !important;
|
| 403 |
+
display: flex !important;
|
| 404 |
+
flex-direction: column !important;
|
| 405 |
+
padding-top: 0 !important;
|
| 406 |
+
margin-top: 0 !important;
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
/* Title styling - compact and at very top */
|
| 410 |
.title-header {
|
| 411 |
background-color: rgb(240, 236, 230) !important;
|
| 412 |
padding: 10px 20px;
|
| 413 |
+
margin: 0 !important;
|
| 414 |
border-bottom: 1pt solid #59524f;
|
| 415 |
text-align: left;
|
| 416 |
+
flex-shrink: 0 !important;
|
| 417 |
+
height: 60px !important;
|
| 418 |
+
display: flex !important;
|
| 419 |
+
align-items: center !important;
|
| 420 |
}
|
| 421 |
.title-header h1 {
|
| 422 |
font-size: 1.5rem;
|
|
|
|
| 426 |
padding: 0;
|
| 427 |
}
|
| 428 |
|
| 429 |
+
/* Chat styling - use available space */
|
| 430 |
+
.gradio-container-5-42-0 .gradio-chatbot {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
background-color: #d9d1ce !important;
|
| 432 |
border: 1pt solid #59524f !important;
|
| 433 |
border-radius: 6px !important;
|
| 434 |
padding: 15px !important;
|
| 435 |
+
height: calc(100vh - 160px) !important;
|
| 436 |
+
max-height: calc(100vh - 160px) !important;
|
| 437 |
overflow-y: auto !important;
|
| 438 |
+
flex: 1 !important;
|
| 439 |
+
margin: 15px 20px !important;
|
| 440 |
}
|
| 441 |
|
| 442 |
/* Message styling */
|
|
|
|
| 468 |
margin-bottom: 10px !important;
|
| 469 |
}
|
| 470 |
|
| 471 |
+
/* Input controls layout */
|
| 472 |
+
.input-controls {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
display: flex !important;
|
| 474 |
+
gap: 15px !important;
|
| 475 |
+
align-items: stretch !important;
|
| 476 |
+
height: 60px !important;
|
| 477 |
+
padding: 15px 20px !important;
|
| 478 |
+
background-color: rgb(240, 236, 230) !important;
|
| 479 |
+
border-top: 1pt solid #59524f !important;
|
| 480 |
+
flex-shrink: 0 !important;
|
| 481 |
}
|
| 482 |
|
| 483 |
/* Button styling - compact */
|
| 484 |
+
.button-column {
|
| 485 |
+
display: flex !important;
|
| 486 |
+
flex-direction: column !important;
|
| 487 |
+
gap: 5px !important;
|
| 488 |
+
min-width: 80px !important;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
.gradio-container-5-42-0 .send-button,
|
| 492 |
.gradio-container-5-42-0 .clear-button {
|
| 493 |
color: #120f0e !important;
|
| 494 |
border: 1pt solid #59524f !important;
|
| 495 |
border-radius: 6px !important;
|
| 496 |
+
padding: 6px 12px !important;
|
| 497 |
cursor: pointer !important;
|
| 498 |
margin: 0 !important;
|
| 499 |
font-weight: 500 !important;
|
| 500 |
+
height: 22px !important;
|
| 501 |
+
font-size: 11px !important;
|
| 502 |
}
|
| 503 |
|
| 504 |
.gradio-container-5-42-0 .send-button {
|
|
|
|
| 509 |
background-color: #ada3a0 !important;
|
| 510 |
}
|
| 511 |
|
| 512 |
+
/* Textbox styling - single line */
|
| 513 |
.gradio-container-5-42-0 .input-textbox {
|
| 514 |
background-color: #d9d1ce !important;
|
| 515 |
border: 1pt solid #59524f !important;
|
| 516 |
border-radius: 8px !important;
|
| 517 |
flex: 1 !important;
|
| 518 |
+
height: 50px !important;
|
| 519 |
}
|
| 520 |
|
| 521 |
.gradio-container-5-42-0 .input-textbox textarea {
|
| 522 |
background-color: #d9d1ce !important;
|
| 523 |
border: none !important;
|
| 524 |
color: #120f0e !important;
|
| 525 |
+
padding: 12px !important;
|
| 526 |
font-size: 14px !important;
|
| 527 |
font-weight: 400 !important;
|
| 528 |
resize: none !important;
|
| 529 |
+
height: 50px !important;
|
| 530 |
+
min-height: 50px !important;
|
| 531 |
+
max-height: 50px !important;
|
| 532 |
+
line-height: 1.2 !important;
|
| 533 |
}
|
| 534 |
|
| 535 |
.gradio-container-5-42-0 .input-textbox textarea::placeholder {
|
| 536 |
font-weight: 300 !important;
|
| 537 |
color: rgba(18, 15, 14, 0.6) !important;
|
| 538 |
}
|
| 539 |
+
|
| 540 |
+
/* Hide any scrollbars that might appear incorrectly */
|
| 541 |
+
body {
|
| 542 |
+
overflow: hidden !important;
|
| 543 |
+
margin: 0 !important;
|
| 544 |
+
padding: 0 !important;
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
html {
|
| 548 |
+
overflow: hidden !important;
|
| 549 |
+
margin: 0 !important;
|
| 550 |
+
padding: 0 !important;
|
| 551 |
+
}
|
| 552 |
"""
|
| 553 |
|
| 554 |
# --- UI: HTML Head Content ---
|
|
|
|
| 632 |
gr.HTML('<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>')
|
| 633 |
gr.HTML(mathjax_config)
|
| 634 |
|
| 635 |
+
# Title Section
|
| 636 |
+
gr.HTML('<div class="title-header"><h1>🎓 EduBot</h1></div>')
|
|
|
|
| 637 |
|
| 638 |
+
# Chat Section
|
| 639 |
+
chatbot = gr.Chatbot(
|
| 640 |
+
type="messages",
|
| 641 |
+
show_copy_button=True,
|
| 642 |
+
show_share_button=False,
|
| 643 |
+
avatar_images=None,
|
| 644 |
+
elem_id="main-chatbot"
|
| 645 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
|
| 647 |
+
# Input Section
|
| 648 |
+
with gr.Row(elem_classes=["input-controls"]):
|
| 649 |
+
msg = gr.Textbox(
|
| 650 |
+
placeholder="Ask me about math, research, study strategies, or any educational topic...",
|
| 651 |
+
show_label=False,
|
| 652 |
+
lines=1,
|
| 653 |
+
max_lines=1,
|
| 654 |
+
elem_classes=["input-textbox"]
|
| 655 |
+
)
|
| 656 |
+
with gr.Column(elem_classes=["button-column"]):
|
| 657 |
+
send = gr.Button("Send", elem_classes=["send-button"], size="sm")
|
| 658 |
+
clear = gr.Button("Clear", elem_classes=["clear-button"], size="sm")
|
|
|
|
| 659 |
|
| 660 |
# Set up event handlers
|
| 661 |
msg.submit(respond_and_update, [msg, chatbot], [chatbot, msg])
|