Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -515,62 +515,62 @@ def clear_chat():
|
|
| 515 |
|
| 516 |
# --- UI: Interface Creation ---
|
| 517 |
def create_interface():
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
|
| 575 |
# ===============================================================================
|
| 576 |
# END UI CONFIGURATION SECTION
|
|
|
|
| 515 |
|
| 516 |
# --- UI: Interface Creation ---
|
| 517 |
def create_interface():
|
| 518 |
+
"""Creates and configures the complete Gradio interface."""
|
| 519 |
+
|
| 520 |
+
with gr.Blocks(
|
| 521 |
+
css=custom_css,
|
| 522 |
+
title="EduBot",
|
| 523 |
+
fill_width=True,
|
| 524 |
+
fill_height=True,
|
| 525 |
+
theme=gr.themes.Base()
|
| 526 |
+
) as demo:
|
| 527 |
+
# Add head content and MathJax
|
| 528 |
+
gr.HTML(html_head_content)
|
| 529 |
+
gr.HTML('<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>')
|
| 530 |
+
gr.HTML(mathjax_config)
|
| 531 |
+
|
| 532 |
+
# Force full height container with aggressive CSS
|
| 533 |
+
gr.HTML('<style>.main-container { height: 100vh !important; display: flex !important; flex-direction: column !important; }</style>')
|
| 534 |
+
|
| 535 |
+
with gr.Column(elem_classes=["main-container"]):
|
| 536 |
+
# Title Section
|
| 537 |
+
with gr.Row(height="10vh"):
|
| 538 |
+
gr.HTML('<div class="title-header"><h1>🎓 EduBot</h1></div>')
|
| 539 |
+
|
| 540 |
+
# Chat Section
|
| 541 |
+
with gr.Row():
|
| 542 |
+
chatbot = gr.Chatbot(
|
| 543 |
+
type="messages",
|
| 544 |
+
show_copy_button=True,
|
| 545 |
+
show_share_button=False,
|
| 546 |
+
avatar_images=None,
|
| 547 |
+
elem_id="main-chatbot",
|
| 548 |
+
container=False, # Remove wrapper
|
| 549 |
+
scale=1,
|
| 550 |
+
height="70vh" # Explicit height instead of min_height
|
| 551 |
+
)
|
| 552 |
+
|
| 553 |
+
# Input Section - fixed height
|
| 554 |
+
with gr.Row(elem_classes=["input-controls"]):
|
| 555 |
+
msg = gr.Textbox(
|
| 556 |
+
placeholder="Ask me about math, research, study strategies, or any educational topic...",
|
| 557 |
+
show_label=False,
|
| 558 |
+
lines=4,
|
| 559 |
+
max_lines=6,
|
| 560 |
+
elem_classes=["input-textbox"],
|
| 561 |
+
container=False,
|
| 562 |
+
scale=4
|
| 563 |
+
)
|
| 564 |
+
with gr.Column(elem_classes=["button-column"], scale=1):
|
| 565 |
+
send = gr.Button("Send", elem_classes=["send-button"], size="sm")
|
| 566 |
+
clear = gr.Button("Clear", elem_classes=["clear-button"], size="sm")
|
| 567 |
+
|
| 568 |
+
# Set up event handlers
|
| 569 |
+
msg.submit(respond_and_update, [msg, chatbot], [chatbot, msg])
|
| 570 |
+
send.click(respond_and_update, [msg, chatbot], [chatbot, msg])
|
| 571 |
+
clear.click(clear_chat, outputs=[chatbot, msg])
|
| 572 |
+
|
| 573 |
+
return demo
|
| 574 |
|
| 575 |
# ===============================================================================
|
| 576 |
# END UI CONFIGURATION SECTION
|