Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -356,20 +356,32 @@ custom_css = """
|
|
| 356 |
}
|
| 357 |
|
| 358 |
.send-button, .clear-button {
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
}
|
| 369 |
|
| 370 |
-
.
|
| 371 |
-
|
| 372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
}
|
| 374 |
|
| 375 |
/* Responsive design */
|
|
@@ -467,45 +479,61 @@ def clear_chat():
|
|
| 467 |
|
| 468 |
# --- UI: Interface Creation ---
|
| 469 |
def create_interface():
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
|
| 510 |
# ===============================================================================
|
| 511 |
# END UI CONFIGURATION SECTION
|
|
|
|
| 356 |
}
|
| 357 |
|
| 358 |
.send-button, .clear-button {
|
| 359 |
+
border: 1pt solid #59524f !important;
|
| 360 |
+
border-radius: 6px !important;
|
| 361 |
+
font-weight: 500 !important;
|
| 362 |
+
padding: 8px 16px !important;
|
| 363 |
+
margin-bottom: 5px !important;
|
| 364 |
+
width: 100% !important;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
.send-button {
|
| 368 |
+
background-color: #f09c7d !important;
|
| 369 |
+
color: #120f0e !important;
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
.send-button:hover {
|
| 373 |
+
background-color: #e8895a !important;
|
| 374 |
+
border-color: #4a3f3c !important;
|
| 375 |
}
|
| 376 |
|
| 377 |
+
.clear-button {
|
| 378 |
+
background-color: #a69189 !important;
|
| 379 |
+
color: #120f0e !important;
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
.clear-button:hover {
|
| 383 |
+
background-color: #8f7d73 !important;
|
| 384 |
+
border-color: #4a3f3c !important;
|
| 385 |
}
|
| 386 |
|
| 387 |
/* Responsive design */
|
|
|
|
| 479 |
|
| 480 |
# --- UI: Interface Creation ---
|
| 481 |
def create_interface():
|
| 482 |
+
"""Creates and configures the complete Gradio interface."""
|
| 483 |
+
|
| 484 |
+
with gr.Blocks(
|
| 485 |
+
css=custom_css,
|
| 486 |
+
title="EduBot",
|
| 487 |
+
fill_width=True,
|
| 488 |
+
fill_height=True,
|
| 489 |
+
theme=gr.themes.Base()
|
| 490 |
+
) as demo:
|
| 491 |
+
# Add head content and MathJax
|
| 492 |
+
gr.HTML(html_head_content)
|
| 493 |
+
gr.HTML('<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>')
|
| 494 |
+
gr.HTML(mathjax_config)
|
| 495 |
+
|
| 496 |
+
# Force full height container with aggressive CSS
|
| 497 |
+
gr.HTML('<style>.main-container { height: 100vh !important; display: flex !important; flex-direction: column !important; }</style>')
|
| 498 |
+
|
| 499 |
+
with gr.Column(elem_classes=["main-container"]):
|
| 500 |
+
# Title Section - in its own row
|
| 501 |
+
with gr.Row():
|
| 502 |
+
gr.HTML('<div class="title-header"><h1>🎓 EduBot</h1></div>')
|
| 503 |
+
|
| 504 |
+
# Chat Section - this should expand to fill ALL available space
|
| 505 |
+
chatbot = gr.Chatbot(
|
| 506 |
+
type="messages",
|
| 507 |
+
show_copy_button=True,
|
| 508 |
+
show_share_button=False,
|
| 509 |
+
avatar_images=None,
|
| 510 |
+
elem_id="main-chatbot",
|
| 511 |
+
container=False, # Remove wrapper
|
| 512 |
+
scale=1,
|
| 513 |
+
height="70vh" # Explicit height instead of min_height
|
| 514 |
+
)
|
| 515 |
+
|
| 516 |
+
# Input Section - fixed height
|
| 517 |
+
with gr.Row(elem_classes=["input-controls"]):
|
| 518 |
+
msg = gr.Textbox(
|
| 519 |
+
placeholder="Ask me about math, research, study strategies, or any educational topic...",
|
| 520 |
+
show_label=False,
|
| 521 |
+
lines=1,
|
| 522 |
+
max_lines=1,
|
| 523 |
+
elem_classes=["input-textbox"],
|
| 524 |
+
container=False,
|
| 525 |
+
scale=4
|
| 526 |
+
)
|
| 527 |
+
with gr.Column(elem_classes=["button-column"], scale=1):
|
| 528 |
+
send = gr.Button("Send", elem_classes=["send-button"], size="sm")
|
| 529 |
+
clear = gr.Button("Clear", elem_classes=["clear-button"], size="sm")
|
| 530 |
+
|
| 531 |
+
# Set up event handlers
|
| 532 |
+
msg.submit(respond_and_update, [msg, chatbot], [chatbot, msg])
|
| 533 |
+
send.click(respond_and_update, [msg, chatbot], [chatbot, msg])
|
| 534 |
+
clear.click(clear_chat, outputs=[chatbot, msg])
|
| 535 |
+
|
| 536 |
+
return demo
|
| 537 |
|
| 538 |
# ===============================================================================
|
| 539 |
# END UI CONFIGURATION SECTION
|