Nischal Subedi commited on
Commit
1b02536
·
1 Parent(s): 57afd75
Files changed (1) hide show
  1. app.py +57 -47
app.py CHANGED
@@ -255,7 +255,10 @@ Answer:"""
255
  if "<div class='error-message'>" in answer:
256
  return answer
257
  else:
258
- formatted_response_content = f"<div class='response-header'><span class='response-icon'>📜</span>Response for {state}</div><hr class='divider'>{answer}"
 
 
 
259
  return f"<div class='animated-output-content'>{formatted_response_content}</div>"
260
 
261
  try:
@@ -290,19 +293,23 @@ Answer:"""
290
 
291
  /* Root variables for consistent theming - based on image's dark theme */
292
  :root {
293
- --primary-color: hsl(150, 60%, 50%); /* Vibrant Seafoam Green for highlights */
294
  --primary-hover: hsl(150, 60%, 45%);
 
295
 
296
  --background-app: hsl(210, 15%, 15%); /* Dark charcoal/navy for overall background */
297
- --background-card: hsl(210, 30%, 20%); /* Deep blue for content cards */
298
- --background-input-output: hsl(210, 25%, 28%); /* Slightly lighter blue for input/output elements */
299
-
300
- --text-light: hsl(0, 0%, 95%); /* Very light text for dark backgrounds */
301
- --text-muted-light: hsl(210, 10%, 70%); /* Muted light text for secondary info */
302
 
303
- --border-light: hsl(210, 10%, 65%); /* Light gray for borders */
304
- --border-input: hsl(210, 15%, 45%); /* Mid-tone blue-gray for input borders */
 
 
305
 
 
 
 
 
306
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.15);
307
  --shadow-md: 0 4px 10px rgba(0,0,0,0.3);
308
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.4);
@@ -330,18 +337,18 @@ Answer:"""
330
  border-radius: 16px !important;
331
  }
332
 
333
- /* Header Styling */
334
  .app-header-wrapper {
335
- background: var(--background-card) !important; /* Consistent dark blue with other cards */
336
  border: 2px solid var(--border-light) !important;
337
  border-radius: 16px !important;
338
  padding: 2.5rem 1.5rem !important;
339
  margin-bottom: 1.5rem !important;
340
- text-align: center !important;
341
  box-shadow: var(--shadow-md) !important;
342
  position: relative;
343
  overflow: hidden;
344
- color: var(--text-light) !important; /* Ensure header text is light */
345
  }
346
  .app-header-wrapper::before { /* Subtle background pattern */
347
  content: '';
@@ -429,32 +436,32 @@ Answer:"""
429
  }
430
  .dashboard-card-section p {
431
  line-height: 1.7 !important;
432
- color: var(--text-light) !important;
433
  font-size: 1rem !important;
434
  }
435
  .dashboard-card-section strong {
436
- color: var(--primary-color) !important; /* Green for strong text */
437
  }
438
 
439
- /* Input Styling */
440
  .gradio-textbox textarea,
441
  .gradio-textbox input,
442
  .gradio-dropdown > div > input[type="text"],
443
  .gradio-dropdown .primary-wrap,
444
  .gradio-dropdown .scroll-hide {
445
- background: var(--background-input-output) !important; /* Lighter blue for inputs */
446
- border: 2px solid var(--border-input) !important; /* Mid-tone blue-gray border */
447
  border-radius: 8px !important;
448
  padding: 0.85rem 1rem !important;
449
  font-size: 0.98rem !important;
450
  font-family: 'Inter', sans-serif !important;
451
- color: var(--text-light) !important; /* White text for inputs */
452
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
453
  box-shadow: var(--shadow-sm) !important;
454
  }
455
  .gradio-textbox textarea::placeholder,
456
  .gradio-textbox input::placeholder {
457
- color: var(--text-muted-light) !important; /* Muted light placeholder text */
458
  opacity: 0.7;
459
  }
460
  .gradio-textbox textarea:focus,
@@ -468,7 +475,7 @@ Answer:"""
468
  .gradio-textbox label,
469
  .gradio-dropdown label {
470
  font-weight: 600 !important;
471
- color: var(--text-light) !important; /* White labels */
472
  font-size: 1rem !important;
473
  margin-bottom: 0.6rem !important;
474
  display: block !important;
@@ -476,7 +483,7 @@ Answer:"""
476
  .gradio-textbox .gr-form,
477
  .gradio-dropdown .gr-form {
478
  font-size: 0.9rem !important;
479
- color: var(--text-muted-light) !important; /* Muted light info text */
480
  margin-top: 0.4rem !important;
481
  }
482
  .input-row {
@@ -522,11 +529,11 @@ Answer:"""
522
  .gr-button-secondary {
523
  background: var(--button-secondary-bg) !important; /* Light gray button */
524
  color: var(--button-secondary-text) !important; /* Dark text */
525
- border-color: var(--border-light) !important;
526
  }
527
  .gr-button-secondary:hover {
528
  background: hsl(0, 0%, 75%) !important; /* Darker gray on hover */
529
- border-color: var(--primary-color) !important;
530
  transform: translateY(-2px) !important;
531
  }
532
  .gr-button-secondary:active {
@@ -534,14 +541,14 @@ Answer:"""
534
  box-shadow: none !important;
535
  }
536
 
537
- /* Output Styling */
538
  .output-content-wrapper {
539
- background: var(--background-input-output) !important; /* Lighter blue for output box */
540
- border: 2px dashed var(--border-input) !important; /* Dashed border as per image */
541
  border-radius: 8px !important;
542
  padding: 1.5rem !important;
543
  min-height: 150px !important;
544
- color: var(--text-light) !important; /* White text for output */
545
  display: flex;
546
  flex-direction: column;
547
  justify-content: center;
@@ -555,6 +562,7 @@ Answer:"""
555
  overflow-wrap: break-word;
556
  word-break: break-word;
557
  text-align: left !important;
 
558
  }
559
  @keyframes fadeInAndSlideUp {
560
  from { opacity: 0; transform: translateY(15px); }
@@ -563,7 +571,7 @@ Answer:"""
563
  .response-header {
564
  font-size: 1.3rem !important;
565
  font-weight: 700 !important;
566
- color: var(--primary-color) !important;
567
  margin-bottom: 0.75rem !important;
568
  display: flex !important;
569
  align-items: center !important;
@@ -575,7 +583,7 @@ Answer:"""
575
  }
576
  .divider {
577
  border: none !important;
578
- border-top: 1px dashed rgba(255, 255, 255, 0.15) !important; /* Light dashed divider */
579
  margin: 1rem 0 !important;
580
  }
581
  .error-message {
@@ -610,21 +618,21 @@ Answer:"""
610
  opacity: 0.8;
611
  }
612
  .placeholder {
613
- background: var(--background-input-output) !important; /* Lighter blue for placeholder */
614
- border: 2px dashed var(--border-input) !important; /* Dashed border */
615
  border-radius: 8px !important;
616
  padding: 2.5rem 1.5rem !important;
617
  text-align: center !important;
618
- color: var(--text-muted-light) !important; /* Muted light text */
619
  font-style: italic !important;
620
  font-size: 1.1rem !important;
621
  width: 100%;
622
  box-sizing: border-box;
623
  }
624
 
625
- /* Examples Table Styling */
626
  .examples-section .gr-samples-table {
627
- border: 2px solid var(--border-light) !important;
628
  border-radius: 8px !important;
629
  overflow: hidden !important;
630
  margin-top: 1rem !important;
@@ -635,20 +643,21 @@ Answer:"""
635
  border: none !important;
636
  font-size: 0.95rem !important;
637
  text-align: left !important;
638
- color: var(--text-light) !important; /* White text for examples */
639
  }
640
  .examples-section .gr-samples-table th {
641
  background: var(--background-card) !important; /* Deep blue for example header */
642
  font-weight: 700 !important;
 
643
  }
644
  .examples-section .gr-samples-table td {
645
- background: var(--background-input-output) !important; /* Lighter blue for example rows */
646
- border-top: 1px solid var(--border-input) !important; /* Mid-tone blue-gray border */
 
647
  cursor: pointer !important;
648
  transition: background 0.2s ease, transform 0.1s ease !important;
649
  }
650
  .examples-section .gr-samples-table tr:hover td {
651
- background: hsl(210, 28%, 32%) !important; /* Slightly darker light blue on hover */
652
  transform: translateX(5px);
653
  }
654
  .gr-examples .gr-label,
@@ -674,7 +683,7 @@ Answer:"""
674
  line-height: 1.6 !important;
675
  }
676
  .app-footer a {
677
- color: var(--primary-color) !important; /* Green highlight for links */
678
  text-decoration: none !important;
679
  font-weight: 600 !important;
680
  transition: text-decoration 0.2s ease, text-decoration-color 0.2s ease !important;
@@ -735,22 +744,23 @@ Answer:"""
735
  with gr.Column(elem_classes="main-dashboard-container"):
736
 
737
  with gr.Group(elem_classes="dashboard-card-section"):
 
738
  gr.Markdown("<h3 class='sub-section-title'>Welcome & Disclaimer</h3>")
739
  gr.Markdown(
740
  """
741
  Navigate landlord-tenant laws with ease. This assistant provides detailed, state-specific answers grounded in legal authority.
742
 
743
- **Disclaimer:** This tool is for informational purposes only and does not constitute legal advice. For specific legal guidance, always consult a licensed attorney in your jurisdiction.
744
  """
745
  )
746
 
747
  with gr.Group(elem_classes="dashboard-card-section"):
748
  gr.Markdown("<h3 class='sub-section-title'>OpenAI API Key</h3>")
749
  api_key_input = gr.Textbox(
750
- label="API Key",
751
  type="password",
752
  placeholder="Enter your OpenAI API key (e.g., sk-...)",
753
- info="Required to process your query. Get one from OpenAI: platform.openai.com/api-keys",
754
  lines=1,
755
  elem_classes=["input-field-group"]
756
  )
@@ -760,7 +770,7 @@ Answer:"""
760
  with gr.Row(elem_classes="input-row"):
761
  with gr.Column(elem_classes="input-field", scale=3):
762
  query_input = gr.Textbox(
763
- label="Your Question",
764
  placeholder="E.g., What are the rules for security deposit returns in my state?",
765
  lines=4,
766
  max_lines=8,
@@ -768,7 +778,7 @@ Answer:"""
768
  )
769
  with gr.Column(elem_classes="input-field", scale=1):
770
  state_input = gr.Dropdown(
771
- label="Select State",
772
  choices=dropdown_choices,
773
  value=initial_value,
774
  allow_custom_value=False,
@@ -780,9 +790,9 @@ Answer:"""
780
 
781
  with gr.Group(elem_classes="dashboard-card-section"):
782
  gr.Markdown("<h3 class='sub-section-title'>Legal Assistant's Response</h3>")
783
- output = gr.HTML(
784
  value="<div class='placeholder'>The answer will appear here after submitting your query.</div>",
785
- elem_classes="output-content-wrapper"
786
  )
787
 
788
  with gr.Group(elem_classes="dashboard-card-section examples-section"):
 
255
  if "<div class='error-message'>" in answer:
256
  return answer
257
  else:
258
+ # Use Markdown to allow for text styling within the HTML output
259
+ formatted_response_content = gr.Markdown.format(
260
+ f"<div class='response-header'><span class='response-icon'>📜</span>Response for {state}</div><hr class='divider'>{answer}"
261
+ )
262
  return f"<div class='animated-output-content'>{formatted_response_content}</div>"
263
 
264
  try:
 
293
 
294
  /* Root variables for consistent theming - based on image's dark theme */
295
  :root {
296
+ --primary-color: hsl(150, 60%, 50%); /* Vibrant Seafoam Green for highlights (Submit button, links) */
297
  --primary-hover: hsl(150, 60%, 45%);
298
+ --accent-orange: hsl(30, 90%, 55%); /* Vibrant Orange for specific highlights (Disclaimer) */
299
 
300
  --background-app: hsl(210, 15%, 15%); /* Dark charcoal/navy for overall background */
301
+ --background-card: hsl(210, 30%, 20%); /* Deep blue for content cards (as in image) */
302
+ --background-input-output: hsl(0, 0%, 100%); /* White for input/output elements (as per request) */
 
 
 
303
 
304
+ --text-light: hsl(0, 0%, 95%); /* Very light text for dark backgrounds (main card text) */
305
+ --text-dark: hsl(210, 20%, 20%); /* Dark text for light backgrounds (input/output text) */
306
+ --text-muted-light: hsl(210, 10%, 70%); /* Muted light text for secondary info on dark backgrounds */
307
+ --text-muted-dark: hsl(210, 10%, 45%); /* Muted dark text for secondary info on light backgrounds (placeholders) */
308
 
309
+ --border-light: hsl(210, 10%, 65%); /* Light gray for outer card borders */
310
+ --border-input: hsl(210, 15%, 45%); /* Mid-tone blue-gray for borders on dark input fields (original image) */
311
+ --border-white-input: hsl(210, 5%, 80%); /* Light gray border for white input fields (new) */
312
+
313
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.15);
314
  --shadow-md: 0 4px 10px rgba(0,0,0,0.3);
315
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.4);
 
337
  border-radius: 16px !important;
338
  }
339
 
340
+ /* Header Styling (title box) */
341
  .app-header-wrapper {
342
+ background: var(--background-card) !important; /* Consistent deep blue with other cards (as per image) */
343
  border: 2px solid var(--border-light) !important;
344
  border-radius: 16px !important;
345
  padding: 2.5rem 1.5rem !important;
346
  margin-bottom: 1.5rem !important;
347
+ text-align: center !important; /* Centered */
348
  box-shadow: var(--shadow-md) !important;
349
  position: relative;
350
  overflow: hidden;
351
+ color: var(--text-light) !important;
352
  }
353
  .app-header-wrapper::before { /* Subtle background pattern */
354
  content: '';
 
436
  }
437
  .dashboard-card-section p {
438
  line-height: 1.7 !important;
439
+ color: var(--text-light) !important; /* Text on dark cards is white */
440
  font-size: 1rem !important;
441
  }
442
  .dashboard-card-section strong {
443
+ color: var(--accent-orange) !important; /* Orange for specific strong text (e.g., Disclaimer) */
444
  }
445
 
446
+ /* Input Styling (textboxes, dropdowns) - now white backgrounds */
447
  .gradio-textbox textarea,
448
  .gradio-textbox input,
449
  .gradio-dropdown > div > input[type="text"],
450
  .gradio-dropdown .primary-wrap,
451
  .gradio-dropdown .scroll-hide {
452
+ background: var(--background-input-output) !important; /* WHITE background for inputs */
453
+ border: 2px solid var(--border-white-input) !important; /* Light gray border for white inputs */
454
  border-radius: 8px !important;
455
  padding: 0.85rem 1rem !important;
456
  font-size: 0.98rem !important;
457
  font-family: 'Inter', sans-serif !important;
458
+ color: var(--text-dark) !important; /* Dark text for inputs */
459
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
460
  box-shadow: var(--shadow-sm) !important;
461
  }
462
  .gradio-textbox textarea::placeholder,
463
  .gradio-textbox input::placeholder {
464
+ color: var(--text-muted-dark) !important; /* Muted dark placeholder text */
465
  opacity: 0.7;
466
  }
467
  .gradio-textbox textarea:focus,
 
475
  .gradio-textbox label,
476
  .gradio-dropdown label {
477
  font-weight: 600 !important;
478
+ color: var(--text-light) !important; /* Labels (on dark card background) are white */
479
  font-size: 1rem !important;
480
  margin-bottom: 0.6rem !important;
481
  display: block !important;
 
483
  .gradio-textbox .gr-form,
484
  .gradio-dropdown .gr-form {
485
  font-size: 0.9rem !important;
486
+ color: var(--text-muted-light) !important; /* Info text (on dark card background) is muted light */
487
  margin-top: 0.4rem !important;
488
  }
489
  .input-row {
 
529
  .gr-button-secondary {
530
  background: var(--button-secondary-bg) !important; /* Light gray button */
531
  color: var(--button-secondary-text) !important; /* Dark text */
532
+ border-color: var(--border-light) !important; /* Overall light border from the main theme */
533
  }
534
  .gr-button-secondary:hover {
535
  background: hsl(0, 0%, 75%) !important; /* Darker gray on hover */
536
+ border-color: var(--primary-color) !important; /* Green border on hover */
537
  transform: translateY(-2px) !important;
538
  }
539
  .gr-button-secondary:active {
 
541
  box-shadow: none !important;
542
  }
543
 
544
+ /* Output Styling - now white background */
545
  .output-content-wrapper {
546
+ background: var(--background-input-output) !important; /* WHITE background for output box */
547
+ border: 2px dashed var(--border-white-input) !important; /* Dashed light gray border */
548
  border-radius: 8px !important;
549
  padding: 1.5rem !important;
550
  min-height: 150px !important;
551
+ color: var(--text-dark) !important; /* Dark text for output */
552
  display: flex;
553
  flex-direction: column;
554
  justify-content: center;
 
562
  overflow-wrap: break-word;
563
  word-break: break-word;
564
  text-align: left !important;
565
+ color: var(--text-dark) !important; /* Ensure this also overrides to dark text */
566
  }
567
  @keyframes fadeInAndSlideUp {
568
  from { opacity: 0; transform: translateY(15px); }
 
571
  .response-header {
572
  font-size: 1.3rem !important;
573
  font-weight: 700 !important;
574
+ color: var(--primary-color) !important; /* Green for response header */
575
  margin-bottom: 0.75rem !important;
576
  display: flex !important;
577
  align-items: center !important;
 
583
  }
584
  .divider {
585
  border: none !important;
586
+ border-top: 1px dashed var(--border-white-input) !important; /* Dashed light gray divider */
587
  margin: 1rem 0 !important;
588
  }
589
  .error-message {
 
618
  opacity: 0.8;
619
  }
620
  .placeholder {
621
+ background: var(--background-input-output) !important; /* WHITE background for placeholder */
622
+ border: 2px dashed var(--border-white-input) !important; /* Dashed light gray border */
623
  border-radius: 8px !important;
624
  padding: 2.5rem 1.5rem !important;
625
  text-align: center !important;
626
+ color: var(--text-muted-dark) !important; /* Muted dark text for placeholder */
627
  font-style: italic !important;
628
  font-size: 1.1rem !important;
629
  width: 100%;
630
  box-sizing: border-box;
631
  }
632
 
633
+ /* Examples Table Styling - now white background rows */
634
  .examples-section .gr-samples-table {
635
+ border: 2px solid var(--border-light) !important; /* Outer table border matches cards */
636
  border-radius: 8px !important;
637
  overflow: hidden !important;
638
  margin-top: 1rem !important;
 
643
  border: none !important;
644
  font-size: 0.95rem !important;
645
  text-align: left !important;
 
646
  }
647
  .examples-section .gr-samples-table th {
648
  background: var(--background-card) !important; /* Deep blue for example header */
649
  font-weight: 700 !important;
650
+ color: var(--text-light) !important; /* White text for header */
651
  }
652
  .examples-section .gr-samples-table td {
653
+ background: var(--background-input-output) !important; /* WHITE for example rows */
654
+ color: var(--text-dark) !important; /* Dark text for example rows */
655
+ border-top: 1px solid var(--border-white-input) !important; /* Light gray border between rows */
656
  cursor: pointer !important;
657
  transition: background 0.2s ease, transform 0.1s ease !important;
658
  }
659
  .examples-section .gr-samples-table tr:hover td {
660
+ background: hsl(0, 0%, 95%) !important; /* Slightly darker white on hover */
661
  transform: translateX(5px);
662
  }
663
  .gr-examples .gr-label,
 
683
  line-height: 1.6 !important;
684
  }
685
  .app-footer a {
686
+ color: var(--primary-color) !important; /* GREEN highlight for links (same as submit button) */
687
  text-decoration: none !important;
688
  font-weight: 600 !important;
689
  transition: text-decoration 0.2s ease, text-decoration-color 0.2s ease !important;
 
744
  with gr.Column(elem_classes="main-dashboard-container"):
745
 
746
  with gr.Group(elem_classes="dashboard-card-section"):
747
+ # Use a span to color "Disclaimer:" orange
748
  gr.Markdown("<h3 class='sub-section-title'>Welcome & Disclaimer</h3>")
749
  gr.Markdown(
750
  """
751
  Navigate landlord-tenant laws with ease. This assistant provides detailed, state-specific answers grounded in legal authority.
752
 
753
+ <span style="color: var(--accent-orange);">**Disclaimer:**</span> This tool is for informational purposes only and does not constitute legal advice. For specific legal guidance, always consult a licensed attorney in your jurisdiction.
754
  """
755
  )
756
 
757
  with gr.Group(elem_classes="dashboard-card-section"):
758
  gr.Markdown("<h3 class='sub-section-title'>OpenAI API Key</h3>")
759
  api_key_input = gr.Textbox(
760
+ label="API Key", # Label color handled by CSS on .gradio-textbox label
761
  type="password",
762
  placeholder="Enter your OpenAI API key (e.g., sk-...)",
763
+ info="Required to process your query. Get one from OpenAI: platform.openai.com/api-keys", # Info text color handled by CSS on .gradio-textbox .gr-form
764
  lines=1,
765
  elem_classes=["input-field-group"]
766
  )
 
770
  with gr.Row(elem_classes="input-row"):
771
  with gr.Column(elem_classes="input-field", scale=3):
772
  query_input = gr.Textbox(
773
+ label="Your Question", # Label color handled by CSS
774
  placeholder="E.g., What are the rules for security deposit returns in my state?",
775
  lines=4,
776
  max_lines=8,
 
778
  )
779
  with gr.Column(elem_classes="input-field", scale=1):
780
  state_input = gr.Dropdown(
781
+ label="Select State", # Label color handled by CSS
782
  choices=dropdown_choices,
783
  value=initial_value,
784
  allow_custom_value=False,
 
790
 
791
  with gr.Group(elem_classes="dashboard-card-section"):
792
  gr.Markdown("<h3 class='sub-section-title'>Legal Assistant's Response</h3>")
793
+ output = gr.HTML( # Changed to gr.HTML to wrap content with animation class
794
  value="<div class='placeholder'>The answer will appear here after submitting your query.</div>",
795
+ elem_classes="output-content-wrapper" # Custom class for output styling
796
  )
797
 
798
  with gr.Group(elem_classes="dashboard-card-section examples-section"):