Amit commited on
Commit
916081e
·
1 Parent(s): ed505fe

Fix: Force dark theme and move voice toggle to main view

Browse files
Files changed (1) hide show
  1. app.py +64 -60
app.py CHANGED
@@ -486,10 +486,10 @@ def set_pip_mode(mode: str, session_id: str = "mcp_default") -> str:
486
 
487
  # Custom CSS for styling
488
  CUSTOM_CSS = """
489
- /* Main layout */
490
- body {
491
- background-color: #f0f2f5;
492
- color: #1a1a2e;
493
  }
494
 
495
  /* Pip avatar container */
@@ -499,37 +499,42 @@ body {
499
  align-items: center;
500
  min-height: 200px;
501
  max-height: 250px;
502
- background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
503
  border-radius: 20px;
504
- box-shadow: 0 4px 20px rgba(0,0,0,0.05);
505
  margin-bottom: 12px;
506
  transition: transform 0.3s ease;
507
  padding: 16px;
 
508
  }
509
 
510
  .pip-container:hover {
511
  transform: translateY(-2px);
 
512
  }
513
 
514
  .pip-container svg {
515
  max-width: 180px;
516
  max-height: 180px;
 
517
  }
518
 
519
  /* Chat container */
520
  .chatbot-container {
521
  border-radius: 20px !important;
522
- box-shadow: 0 4px 20px rgba(0,0,0,0.05) !important;
523
- border: 1px solid rgba(0,0,0,0.08) !important;
524
- background: #fafafa !important;
525
  }
526
 
527
  /* Mood image */
528
  .mood-image {
529
  border-radius: 16px !important;
530
- box-shadow: 0 4px 16px rgba(0,0,0,0.08) !important;
531
  overflow: hidden;
532
  transition: transform 0.3s ease;
 
 
533
  }
534
 
535
  .mood-image:hover {
@@ -540,11 +545,11 @@ body {
540
  .image-explanation {
541
  text-align: center;
542
  font-style: italic;
543
- color: #555;
544
  font-size: 0.9em;
545
  padding: 10px 14px;
546
  margin-top: 8px;
547
- background: linear-gradient(135deg, rgba(108, 92, 231, 0.06) 0%, rgba(168, 230, 207, 0.06) 100%);
548
  border-radius: 10px;
549
  border-left: 3px solid #6c5ce7;
550
  }
@@ -552,38 +557,21 @@ body {
552
  /* Status bar */
553
  .status-bar {
554
  font-size: 0.85em;
555
- color: #555;
556
  padding: 10px 14px;
557
- background: white;
558
- border-radius: 12px;
559
- border: 1px solid #e8e8e8;
560
- box-shadow: 0 2px 6px rgba(0,0,0,0.02);
561
- }
562
-
563
- /* Dark theme */
564
- .dark body {
565
- background-color: #1a1a2e;
566
- }
567
-
568
- .dark .pip-container {
569
- background: linear-gradient(135deg, #1e2a4a 0%, #16213e 100%);
570
- box-shadow: 0 4px 20px rgba(0,0,0,0.3);
571
- }
572
-
573
- .dark .status-bar {
574
  background: #1e2a4a;
575
- color: #b0b0b0;
576
- border-color: #2d3a5a;
577
- }
578
-
579
- .dark .chatbot-container {
580
- background: #1e2a4a !important;
581
- border-color: #2d3a5a !important;
582
  }
583
 
584
- .dark .image-explanation {
585
- color: #b0b0b0;
586
- background: linear-gradient(135deg, rgba(108, 92, 231, 0.12) 0%, rgba(168, 230, 207, 0.12) 100%);
 
 
 
 
587
  }
588
 
589
  /* Header */
@@ -596,11 +584,12 @@ body {
596
  -webkit-background-clip: text;
597
  -webkit-text-fill-color: transparent;
598
  background-clip: text;
 
599
  }
600
 
601
  .header-subtitle {
602
  text-align: center;
603
- color: #666;
604
  font-size: 1.1em;
605
  margin-top: 0;
606
  margin-bottom: 20px;
@@ -621,24 +610,37 @@ button.primary:hover {
621
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3) !important;
622
  }
623
 
624
- /* Action buttons row */
625
- .action-buttons button {
626
- min-height: 42px;
 
 
 
627
  }
 
628
 
629
- /* Make messages area more visible in dark mode */
630
- .dark .message {
631
- background: #252d48 !important;
 
 
 
 
 
 
632
  }
633
  """
634
 
635
  # Build the Gradio app
636
- demo = gr.Blocks(title="Pip - Emotional AI Companion")
637
- demo.theme = gr.themes.Soft(
638
- primary_hue="indigo",
639
- secondary_hue="teal",
640
- radius_size="lg",
641
- font=["Nunito", "sans-serif"]
 
 
 
642
  )
643
 
644
  with demo:
@@ -676,6 +678,14 @@ with demo:
676
  show_label=True
677
  )
678
 
 
 
 
 
 
 
 
 
679
  # Mood Image (moved up - more prominent)
680
  mood_image = gr.Image(
681
  label="Pip's Visualization",
@@ -698,19 +708,13 @@ with demo:
698
  )
699
 
700
  # Controls Group (moved below image)
701
- with gr.Accordion("⚙️ Settings", open=False):
702
  mode_selector = gr.Radio(
703
  ["Auto", "Alchemist", "Artist", "Dream", "Night"],
704
  value="Auto",
705
  label="Interaction Mode",
706
  info="How should Pip visualize your feelings?"
707
  )
708
-
709
- voice_toggle = gr.Checkbox(
710
- value=False,
711
- label="Enable Voice Response",
712
- info="Pip will speak the response"
713
- )
714
 
715
  # Audio Output
716
  audio_output = gr.Audio(
 
486
 
487
  # Custom CSS for styling
488
  CUSTOM_CSS = """
489
+ /* Force Dark Theme Defaults */
490
+ body, .gradio-container {
491
+ background-color: #1a1a2e !important;
492
+ color: #e0e0e0 !important;
493
  }
494
 
495
  /* Pip avatar container */
 
499
  align-items: center;
500
  min-height: 200px;
501
  max-height: 250px;
502
+ background: linear-gradient(135deg, #1e2a4a 0%, #16213e 100%);
503
  border-radius: 20px;
504
+ box-shadow: 0 4px 20px rgba(0,0,0,0.3);
505
  margin-bottom: 12px;
506
  transition: transform 0.3s ease;
507
  padding: 16px;
508
+ border: 1px solid rgba(255,255,255,0.05);
509
  }
510
 
511
  .pip-container:hover {
512
  transform: translateY(-2px);
513
+ box-shadow: 0 6px 24px rgba(108, 92, 231, 0.15);
514
  }
515
 
516
  .pip-container svg {
517
  max-width: 180px;
518
  max-height: 180px;
519
+ filter: drop-shadow(0 0 10px rgba(108, 92, 231, 0.3));
520
  }
521
 
522
  /* Chat container */
523
  .chatbot-container {
524
  border-radius: 20px !important;
525
+ box-shadow: 0 4px 20px rgba(0,0,0,0.2) !important;
526
+ border: 1px solid rgba(255,255,255,0.08) !important;
527
+ background: #16213e !important;
528
  }
529
 
530
  /* Mood image */
531
  .mood-image {
532
  border-radius: 16px !important;
533
+ box-shadow: 0 4px 16px rgba(0,0,0,0.2) !important;
534
  overflow: hidden;
535
  transition: transform 0.3s ease;
536
+ border: 1px solid rgba(255,255,255,0.05);
537
+ background-color: #16213e;
538
  }
539
 
540
  .mood-image:hover {
 
545
  .image-explanation {
546
  text-align: center;
547
  font-style: italic;
548
+ color: #b0b0b0;
549
  font-size: 0.9em;
550
  padding: 10px 14px;
551
  margin-top: 8px;
552
+ background: linear-gradient(135deg, rgba(108, 92, 231, 0.12) 0%, rgba(168, 230, 207, 0.12) 100%);
553
  border-radius: 10px;
554
  border-left: 3px solid #6c5ce7;
555
  }
 
557
  /* Status bar */
558
  .status-bar {
559
  font-size: 0.85em;
560
+ color: #b0b0b0;
561
  padding: 10px 14px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
562
  background: #1e2a4a;
563
+ border-radius: 12px;
564
+ border: 1px solid #2d3a5a;
565
+ box-shadow: 0 2px 6px rgba(0,0,0,0.1);
 
 
 
 
566
  }
567
 
568
+ /* Voice Toggle */
569
+ .voice-toggle {
570
+ background: rgba(108, 92, 231, 0.1);
571
+ padding: 8px 12px;
572
+ border-radius: 10px;
573
+ border: 1px solid rgba(108, 92, 231, 0.2);
574
+ margin-bottom: 10px;
575
  }
576
 
577
  /* Header */
 
584
  -webkit-background-clip: text;
585
  -webkit-text-fill-color: transparent;
586
  background-clip: text;
587
+ text-shadow: 0 0 30px rgba(108, 92, 231, 0.3);
588
  }
589
 
590
  .header-subtitle {
591
  text-align: center;
592
+ color: #888;
593
  font-size: 1.1em;
594
  margin-top: 0;
595
  margin-bottom: 20px;
 
610
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3) !important;
611
  }
612
 
613
+ /* Footer */
614
+ .footer {
615
+ text-align: center;
616
+ margin-top: 40px;
617
+ color: #555;
618
+ font-size: 0.8em;
619
  }
620
+ """
621
 
622
+ # JS to force dark mode
623
+ JS_DARK_MODE = """
624
+ function refresh() {
625
+ document.body.classList.add('dark');
626
+ const url = new URL(window.location);
627
+ if (url.searchParams.get('__theme') !== 'dark') {
628
+ url.searchParams.set('__theme', 'dark');
629
+ window.history.pushState({}, '', url);
630
+ }
631
  }
632
  """
633
 
634
  # Build the Gradio app
635
+ demo = gr.Blocks(
636
+ title="Pip - Emotional AI Companion",
637
+ theme=gr.themes.Soft(
638
+ primary_hue="indigo",
639
+ secondary_hue="teal",
640
+ radius_size="lg",
641
+ font=["Nunito", "sans-serif"]
642
+ ),
643
+ js=JS_DARK_MODE
644
  )
645
 
646
  with demo:
 
678
  show_label=True
679
  )
680
 
681
+ # Voice Toggle (Visible now!)
682
+ voice_toggle = gr.Checkbox(
683
+ value=False,
684
+ label="🗣️ Enable Voice Response",
685
+ info="Pip will speak back to you",
686
+ elem_classes=["voice-toggle"]
687
+ )
688
+
689
  # Mood Image (moved up - more prominent)
690
  mood_image = gr.Image(
691
  label="Pip's Visualization",
 
708
  )
709
 
710
  # Controls Group (moved below image)
711
+ with gr.Accordion("⚙️ Advanced Settings", open=False):
712
  mode_selector = gr.Radio(
713
  ["Auto", "Alchemist", "Artist", "Dream", "Night"],
714
  value="Auto",
715
  label="Interaction Mode",
716
  info="How should Pip visualize your feelings?"
717
  )
 
 
 
 
 
 
718
 
719
  # Audio Output
720
  audio_output = gr.Audio(