shreyasmeher commited on
Commit
b5be9e5
·
verified ·
1 Parent(s): be50748

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -158
app.py CHANGED
@@ -425,164 +425,13 @@ def chatbot(task, text=None, context=None, question=None, file=None):
425
  return "Please select a valid task."
426
 
427
 
428
- css = """
429
- :root {
430
- --primary-color: #2563eb;
431
- --secondary-color: #1e40af;
432
- --accent-color: #3b82f6;
433
- --background-color: #f8fafc;
434
- --card-background: #ffffff;
435
- --text-color: #1e293b;
436
- --border-color: #e2e8f0;
437
- }
438
-
439
- body {
440
- background-color: var(--background-color);
441
- font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
442
- color: var(--text-color);
443
- }
444
-
445
- .gradio-container {
446
- max-width: 1200px !important;
447
- margin: 2rem auto !important;
448
- padding: 0 1rem;
449
- }
450
-
451
- .header-container {
452
- background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
453
- padding: 2rem 1rem;
454
- margin: -1rem -1rem 2rem -1rem;
455
- border-radius: 1rem;
456
- box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
457
- }
458
-
459
- .header-title-center a {
460
- font-size: 2.5rem !important;
461
- font-weight: 800;
462
- color: white !important;
463
- text-align: center;
464
- display: block;
465
- text-decoration: none;
466
- letter-spacing: -0.025em;
467
- margin-bottom: 0.5rem;
468
- }
469
-
470
- .task-container {
471
- background: var(--card-background);
472
- padding: 2rem;
473
- border-radius: 1rem;
474
- box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
475
- margin-bottom: 2rem;
476
- }
477
-
478
- .gr-input, .gr-box {
479
- border: 1px solid var(--border-color) !important;
480
- border-radius: 0.75rem !important;
481
- padding: 1rem !important;
482
- background: var(--card-background) !important;
483
- transition: border-color 0.15s ease;
484
- }
485
-
486
- .gr-input:focus, .gr-box:focus {
487
- border-color: var(--accent-color) !important;
488
- outline: none !important;
489
- box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
490
- }
491
-
492
- .gr-button {
493
- background: var(--primary-color) !important;
494
- border: none;
495
- padding: 0.75rem 1.5rem !important;
496
- font-weight: 600 !important;
497
- border-radius: 0.75rem !important;
498
- cursor: pointer;
499
- transition: all 0.15s ease;
500
- }
501
-
502
- .gr-button:hover {
503
- background: var(--secondary-color) !important;
504
- transform: translateY(-1px);
505
- }
506
-
507
- .gr-button:active {
508
- transform: translateY(0);
509
- }
510
-
511
- select.gr-box {
512
- cursor: pointer;
513
- padding-right: 2.5rem !important;
514
- appearance: none;
515
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
516
- background-repeat: no-repeat;
517
- background-position: right 1rem center;
518
- background-size: 1.5em 1.5em;
519
- }
520
-
521
- .footer {
522
- text-align: center;
523
- margin-top: 2rem;
524
- padding: 2rem 0;
525
- border-top: 1px solid var(--border-color);
526
- color: #64748b;
527
- }
528
-
529
- .footer a {
530
- color: var(--primary-color);
531
- font-weight: 500;
532
- text-decoration: none;
533
- transition: color 0.15s ease;
534
- }
535
-
536
- .footer a:hover {
537
- color: var(--secondary-color);
538
- }
539
-
540
- /* File upload styles */
541
- .gr-file-drop {
542
- border: 2px dashed var(--border-color) !important;
543
- border-radius: 0.75rem !important;
544
- padding: 2rem !important;
545
- text-align: center;
546
- transition: all 0.15s ease;
547
- }
548
-
549
- .gr-file-drop:hover {
550
- border-color: var(--accent-color) !important;
551
- background-color: rgba(59, 130, 246, 0.05) !important;
552
- }
553
-
554
- /* Output container */
555
- .output-html {
556
- background: var(--card-background);
557
- padding: 1.5rem;
558
- border-radius: 0.75rem;
559
- box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
560
- }
561
-
562
- /* Labels */
563
- label {
564
- font-weight: 500;
565
- margin-bottom: 0.5rem;
566
- color: #475569;
567
- }
568
-
569
- /* Spacing between elements */
570
- .gr-form {
571
- gap: 1.5rem !important;
572
- }
573
-
574
- .gr-row {
575
- gap: 1rem !important;
576
- }
577
- """
578
-
579
- with gr.Blocks(css=css) as demo:
580
  with gr.Column():
581
  with gr.Row(elem_id="header", elem_classes="header-container"):
582
- gr.Markdown("<div class='header-title-center'><a href='https://eventdata.utdallas.edu/conflibert/'>ConfliBERT</a></div>")
583
 
584
  with gr.Column(elem_classes="task-container"):
585
- gr.Markdown("<h2 style='font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; color: #0f172a;'>Select a task and provide the necessary inputs:</h2>")
586
 
587
  task = gr.Dropdown(
588
  choices=["Question Answering", "Named Entity Recognition", "Text Classification", "Multilabel Classification"],
@@ -637,7 +486,6 @@ with gr.Blocks(css=css) as demo:
637
  gr.Markdown("<a href='https://eventdata.utdallas.edu/'>UTD Event Data</a> | <a href='https://www.utdallas.edu/'>University of Texas at Dallas</a>")
638
  gr.Markdown("Developed By: <a href='https://www.linkedin.com/in/sultan-alsarra-phd-56977a63/' target='_blank'>Sultan Alsarra</a> and <a href='http://shreyasmeher.com' target='_blank'>Shreyas Meher</a>")
639
 
640
- # Define the update_inputs function
641
  def update_inputs(task_name):
642
  """Updates the visibility of input components based on the selected task."""
643
  if task_name == "Question Answering":
@@ -657,7 +505,6 @@ with gr.Blocks(css=css) as demo:
657
  gr.update(visible=True)
658
  ]
659
 
660
- # Define the chatbot_interface function
661
  def chatbot_interface(task, text, context, question, file):
662
  """Handles both file and text inputs for different tasks."""
663
  if file:
@@ -669,7 +516,6 @@ with gr.Blocks(css=css) as demo:
669
  result = chatbot(task, text, context, question)
670
  return gr.update(value=result, visible=True), gr.update(visible=False)
671
 
672
- # Define the main chatbot function
673
  def chatbot(task, text=None, context=None, question=None, file=None):
674
  """Main function to process different types of inputs and tasks."""
675
  if file is not None: # Handle CSV file input
@@ -706,7 +552,6 @@ with gr.Blocks(css=css) as demo:
706
  else:
707
  return "Please select a valid task."
708
 
709
- # Event handlers
710
  task.change(fn=update_inputs, inputs=task, outputs=[text_input, context_input, question_input, file_input, file_output])
711
  submit_button.click(
712
  fn=chatbot_interface,
 
425
  return "Please select a valid task."
426
 
427
 
428
+ with gr.Blocks(theme="ParityError/Interstellar") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  with gr.Column():
430
  with gr.Row(elem_id="header", elem_classes="header-container"):
431
+ gr.Markdown("<div class='header-title-center'><a href='https://eventdata.utdallas.edu/conflibert/' style='font-size: 4rem; font-weight: 900;'>ConfliBERT</a></div>")
432
 
433
  with gr.Column(elem_classes="task-container"):
434
+ gr.Markdown("<h2 style='font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem;'>Select a task and provide the necessary inputs:</h2>")
435
 
436
  task = gr.Dropdown(
437
  choices=["Question Answering", "Named Entity Recognition", "Text Classification", "Multilabel Classification"],
 
486
  gr.Markdown("<a href='https://eventdata.utdallas.edu/'>UTD Event Data</a> | <a href='https://www.utdallas.edu/'>University of Texas at Dallas</a>")
487
  gr.Markdown("Developed By: <a href='https://www.linkedin.com/in/sultan-alsarra-phd-56977a63/' target='_blank'>Sultan Alsarra</a> and <a href='http://shreyasmeher.com' target='_blank'>Shreyas Meher</a>")
488
 
 
489
  def update_inputs(task_name):
490
  """Updates the visibility of input components based on the selected task."""
491
  if task_name == "Question Answering":
 
505
  gr.update(visible=True)
506
  ]
507
 
 
508
  def chatbot_interface(task, text, context, question, file):
509
  """Handles both file and text inputs for different tasks."""
510
  if file:
 
516
  result = chatbot(task, text, context, question)
517
  return gr.update(value=result, visible=True), gr.update(visible=False)
518
 
 
519
  def chatbot(task, text=None, context=None, question=None, file=None):
520
  """Main function to process different types of inputs and tasks."""
521
  if file is not None: # Handle CSV file input
 
552
  else:
553
  return "Please select a valid task."
554
 
 
555
  task.change(fn=update_inputs, inputs=task, outputs=[text_input, context_input, question_input, file_input, file_output])
556
  submit_button.click(
557
  fn=chatbot_interface,