jdesiree commited on
Commit
adcb190
·
verified ·
1 Parent(s): a42e9f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -51
app.py CHANGED
@@ -356,20 +356,32 @@ custom_css = """
356
  }
357
 
358
  .send-button, .clear-button {
359
- background-color: #f09c7d !important;
360
- color: #120f0e !important;
361
- border: 1pt solid #59524f !important;
362
- border-radius: 6px !important;
363
- font-family: "Oswald", sans-serif !important;
364
- font-weight: 500 !important;
365
- padding: 8px 16px !important;
366
- margin-bottom: 5px !important;
367
- width: 100% !important;
 
 
 
 
 
 
 
368
  }
369
 
370
- .send-button:hover, .clear-button:hover {
371
- background-color: #e8895a !important;
372
- border-color: #4a3f3c !important;
 
 
 
 
 
373
  }
374
 
375
  /* Responsive design */
@@ -467,45 +479,61 @@ def clear_chat():
467
 
468
  # --- UI: Interface Creation ---
469
  def create_interface():
470
- """Creates and configures the complete Gradio interface."""
471
-
472
- with gr.Blocks(css=custom_css, title="EduBot", fill_width=True, fill_height=True) as demo:
473
- # Add head content and MathJax
474
- gr.HTML(html_head_content)
475
- gr.HTML('<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>')
476
- gr.HTML(mathjax_config)
477
-
478
- # Title Section
479
- gr.HTML('<div class="title-header"><h1>🎓 EduBot</h1></div>')
480
-
481
- # Chat Section
482
- chatbot = gr.Chatbot(
483
- type="messages",
484
- show_copy_button=True,
485
- show_share_button=False,
486
- avatar_images=None,
487
- elem_id="main-chatbot"
488
- )
489
-
490
- # Input Section
491
- with gr.Row(elem_classes=["input-controls"]):
492
- msg = gr.Textbox(
493
- placeholder="Ask me about math, research, study strategies, or any educational topic...",
494
- show_label=False,
495
- lines=1,
496
- max_lines=1,
497
- elem_classes=["input-textbox"]
498
- )
499
- with gr.Column(elem_classes=["button-column"]):
500
- send = gr.Button("Send", elem_classes=["send-button"], size="sm")
501
- clear = gr.Button("Clear", elem_classes=["clear-button"], size="sm")
502
-
503
- # Set up event handlers
504
- msg.submit(respond_and_update, [msg, chatbot], [chatbot, msg])
505
- send.click(respond_and_update, [msg, chatbot], [chatbot, msg])
506
- clear.click(clear_chat, outputs=[chatbot, msg])
507
-
508
- return demo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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