faerazo commited on
Commit
d6b2a9e
Β·
verified Β·
1 Parent(s): 6c33bc5

Update ui.py

Browse files
Files changed (1) hide show
  1. ui.py +144 -51
ui.py CHANGED
@@ -84,7 +84,7 @@ def create_interface(agent):
84
 
85
  /* Header with same gradient as send button */
86
  .header {
87
- background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%) !important;
88
  color: #ffffff !important;
89
  text-align: center;
90
  padding: 1rem;
@@ -95,16 +95,33 @@ def create_interface(agent):
95
  .header h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }
96
  .header p { margin: .5rem 0 0 0; color: rgba(255,255,255,0.9); font-size: .95rem; }
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  /* Chat container - flexible height for HF Spaces */
99
  .chat-container {
100
- min-height: 400px !important;
101
- max-height: 600px !important;
102
  height: auto !important;
103
  background: var(--panel) !important;
104
  border-radius: 16px !important;
105
  border: 1px solid var(--border) !important;
106
  box-shadow: 0 2px 12px rgba(0,0,0,.35) !important;
107
  overflow-y: auto !important;
 
108
  }
109
 
110
  /* Message row alignment */
@@ -370,6 +387,23 @@ def create_interface(agent):
370
  background: var(--muted);
371
  }
372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  /* Hugging Face Spaces specific fixes */
374
  .gradio-container {
375
  min-height: 100vh !important;
@@ -402,31 +436,92 @@ def create_interface(agent):
402
  min-height: 100% !important;
403
  }
404
 
405
- /* Responsive */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  @media (max-width: 768px) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  .chat-container {
408
  min-height: 300px !important;
409
  max-height: 400px !important;
410
  }
411
-
412
  .gradio-container [data-testid="bot"] .message > *,
413
  .gradio-container [data-testid="user"] .message > * {
414
  max-width: 85% !important;
415
  }
416
-
417
  .header h1 {
418
  font-size: 1.2rem !important;
419
  }
 
 
 
 
 
420
  }
421
 
422
  @media (max-width: 480px) {
 
 
 
 
 
 
423
  .gradio-container [data-testid="bot"] .message > *,
424
  .gradio-container [data-testid="user"] .message > * {
425
  max-width: 90% !important;
 
426
  }
427
-
428
- .send-button {
429
- width: 100% !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  }
431
  }
432
  """
@@ -442,49 +537,47 @@ def create_interface(agent):
442
 
443
  # Main Chat Tab
444
  with gr.Tab("πŸ’¬ Chat with Agent"):
445
- chatbot = gr.Chatbot(
446
- height=None,
447
- show_label=False,
448
- bubble_full_width=False,
449
- type='messages',
450
- elem_classes=["chat-container"],
451
- container=True
452
- )
453
-
454
- # Clear chat button
455
  with gr.Row():
456
- clear_btn = gr.Button("πŸ—‘οΈ Clear Chat", variant="secondary", scale=1)
457
-
458
- # Organized Query Sections
459
- gr.Markdown("### πŸ“Š Overdue Analysis Examples")
460
- gr.Markdown("*Analyze overdue accounts and risk factors*")
461
-
462
- with gr.Row():
463
- overdue_btn1 = gr.Button("Show me all late-payment customers", elem_classes=["overdue-btn"], scale=1)
464
- overdue_btn2 = gr.Button("Which invoices are more than 30 days overdue?", elem_classes=["overdue-btn"], scale=1)
465
- with gr.Row():
466
- overdue_btn3 = gr.Button("Top 5 customers at risk of default", elem_classes=["overdue-btn"], scale=1)
467
- overdue_btn4 = gr.Button("What's the most overdue account?", elem_classes=["overdue-btn"], scale=1)
468
-
469
- gr.Markdown("### πŸ‘₯ Customer Segmentation Examples")
470
- gr.Markdown("*Explore customer segments and payment patterns*")
471
-
472
- with gr.Row():
473
- segment_btn1 = gr.Button("Who are the VIPs with unpaid invoices?", elem_classes=["segment-btn"], scale=1)
474
- segment_btn2 = gr.Button("Show me all Swedish customers with overdue invoices", elem_classes=["segment-btn"], scale=1)
475
- with gr.Row():
476
- segment_btn3 = gr.Button("Which customers are repeat late-payers in the last 12 months?", elem_classes=["segment-btn"], scale=1)
477
- segment_btn4 = gr.Button("How much total money is outstanding?", elem_classes=["segment-btn"], scale=1)
478
-
479
- gr.Markdown("### ⚑ Action Examples - AI Agent Email Campaigns")
480
- gr.Markdown("*Take action by generating collection emails for multiple customers*")
481
-
482
- with gr.Row():
483
- action_btn1 = gr.Button("Send collection emails to all overdue customers", elem_classes=["action-btn"], scale=1)
484
- action_btn2 = gr.Button("Generate bulk emails for VIP customers only", elem_classes=["action-btn"], scale=1)
485
- with gr.Row():
486
- action_btn3 = gr.Button("Create targeted collection campaign for Swedish customers", elem_classes=["action-btn"], scale=1)
487
- action_btn4 = gr.Button("Send emails to high-risk accounts only", elem_classes=["action-btn"], scale=1)
 
 
 
 
 
 
 
 
488
 
489
  # Email Activity Log Tab
490
  with gr.Tab("πŸ“§ Email Activity"):
 
84
 
85
  /* Header with same gradient as send button */
86
  .header {
87
+ background: #f50082 !important;
88
  color: #ffffff !important;
89
  text-align: center;
90
  padding: 1rem;
 
95
  .header h1 { margin: 0; font-size: 1.4rem; font-weight: 600; }
96
  .header p { margin: .5rem 0 0 0; color: rgba(255,255,255,0.9); font-size: .95rem; }
97
 
98
+ /* Sidebar styling */
99
+ .sidebar {
100
+ background: var(--panel) !important;
101
+ border-radius: 16px !important;
102
+ border: 1px solid var(--border) !important;
103
+ padding: 16px !important;
104
+ margin-right: 16px !important;
105
+ min-width: 280px !important;
106
+ }
107
+
108
+ /* Main chat area */
109
+ .chat-main {
110
+ display: flex !important;
111
+ flex-direction: column !important;
112
+ }
113
+
114
  /* Chat container - flexible height for HF Spaces */
115
  .chat-container {
116
+ min-height: 1000px !important;
117
+ max-height: 1200px !important;
118
  height: auto !important;
119
  background: var(--panel) !important;
120
  border-radius: 16px !important;
121
  border: 1px solid var(--border) !important;
122
  box-shadow: 0 2px 12px rgba(0,0,0,.35) !important;
123
  overflow-y: auto !important;
124
+ flex: 1 !important;
125
  }
126
 
127
  /* Message row alignment */
 
387
  background: var(--muted);
388
  }
389
 
390
+ /* Responsive tables */
391
+ .gradio-container .dataframe {
392
+ overflow-x: auto !important;
393
+ max-width: 100% !important;
394
+ }
395
+
396
+ .gradio-container table {
397
+ min-width: 600px !important; /* Ensure minimum width for readability */
398
+ font-size: 14px !important;
399
+ }
400
+
401
+ @media (max-width: 768px) {
402
+ .gradio-container table {
403
+ font-size: 12px !important;
404
+ }
405
+ }
406
+
407
  /* Hugging Face Spaces specific fixes */
408
  .gradio-container {
409
  min-height: 100vh !important;
 
436
  min-height: 100% !important;
437
  }
438
 
439
+ /* Responsive Design */
440
+ @media (max-width: 1024px) {
441
+ /* Tablet and small laptop adjustments */
442
+ .sidebar {
443
+ min-width: 240px !important;
444
+ margin-right: 12px !important;
445
+ padding: 12px !important;
446
+ }
447
+
448
+ .chat-container {
449
+ min-height: 350px !important;
450
+ max-height: 500px !important;
451
+ }
452
+
453
+ .header h1 {
454
+ font-size: 1.3rem !important;
455
+ }
456
+ }
457
+
458
  @media (max-width: 768px) {
459
+ /* Mobile landscape and small tablets */
460
+ .gradio-container .tabitem [role="tabpanel"] {
461
+ flex-direction: column !important;
462
+ }
463
+
464
+ .sidebar {
465
+ width: 100% !important;
466
+ margin-right: 0 !important;
467
+ margin-bottom: 16px !important;
468
+ order: 2 !important; /* Chat first on mobile */
469
+ }
470
+
471
+ .chat-main {
472
+ order: 1 !important;
473
+ width: 100% !important;
474
+ }
475
+
476
  .chat-container {
477
  min-height: 300px !important;
478
  max-height: 400px !important;
479
  }
480
+
481
  .gradio-container [data-testid="bot"] .message > *,
482
  .gradio-container [data-testid="user"] .message > * {
483
  max-width: 85% !important;
484
  }
485
+
486
  .header h1 {
487
  font-size: 1.2rem !important;
488
  }
489
+
490
+ .gradio-container .gr-button {
491
+ font-size: 13px !important;
492
+ padding: 12px 16px !important;
493
+ }
494
  }
495
 
496
  @media (max-width: 480px) {
497
+ /* Mobile portrait */
498
+ .chat-container {
499
+ min-height: 250px !important;
500
+ max-height: 350px !important;
501
+ }
502
+
503
  .gradio-container [data-testid="bot"] .message > *,
504
  .gradio-container [data-testid="user"] .message > * {
505
  max-width: 90% !important;
506
+ padding: 10px 12px !important;
507
  }
508
+
509
+ .sidebar {
510
+ padding: 8px !important;
511
+ }
512
+
513
+ .gradio-container .gr-button {
514
+ font-size: 12px !important;
515
+ padding: 10px 14px !important;
516
+ margin: 2px !important;
517
+ }
518
+
519
+ .header h1 {
520
+ font-size: 1.1rem !important;
521
+ }
522
+
523
+ .header p {
524
+ font-size: 0.9rem !important;
525
  }
526
  }
527
  """
 
537
 
538
  # Main Chat Tab
539
  with gr.Tab("πŸ’¬ Chat with Agent"):
 
 
 
 
 
 
 
 
 
 
540
  with gr.Row():
541
+ # Left Sidebar - Buttons
542
+ with gr.Column(scale=1, elem_classes=["sidebar"]):
543
+ # Clear chat button
544
+ clear_btn = gr.Button("πŸ—‘οΈ Clear Chat", variant="secondary", scale=1)
545
+
546
+ # Organized Query Sections
547
+ gr.Markdown("### πŸ“Š Overdue Analysis")
548
+ gr.Markdown("*Analyze overdue accounts*")
549
+
550
+ overdue_btn1 = gr.Button("Show me all late-payment customers", elem_classes=["overdue-btn"], scale=1)
551
+ overdue_btn2 = gr.Button("Which invoices are more than 30 days overdue?", elem_classes=["overdue-btn"], scale=1)
552
+ overdue_btn3 = gr.Button("Top 5 customers at risk of default", elem_classes=["overdue-btn"], scale=1)
553
+ overdue_btn4 = gr.Button("What's the most overdue account?", elem_classes=["overdue-btn"], scale=1)
554
+
555
+ gr.Markdown("### πŸ‘₯ Customer Segmentation")
556
+ gr.Markdown("*Explore customer segments*")
557
+
558
+ segment_btn1 = gr.Button("Who are the VIPs with unpaid invoices?", elem_classes=["segment-btn"], scale=1)
559
+ segment_btn2 = gr.Button("Show me all Swedish customers with overdue invoices", elem_classes=["segment-btn"], scale=1)
560
+ segment_btn3 = gr.Button("Which customers are repeat late-payers in the last 12 months?", elem_classes=["segment-btn"], scale=1)
561
+ segment_btn4 = gr.Button("How much total money is outstanding?", elem_classes=["segment-btn"], scale=1)
562
+
563
+ gr.Markdown("### ⚑ Action Examples")
564
+ gr.Markdown("*AI Agent Email Campaigns*")
565
+
566
+ action_btn1 = gr.Button("Send collection emails to all overdue customers", elem_classes=["action-btn"], scale=1)
567
+ action_btn2 = gr.Button("Generate bulk emails for VIP customers only", elem_classes=["action-btn"], scale=1)
568
+ action_btn3 = gr.Button("Create targeted collection campaign for Swedish customers", elem_classes=["action-btn"], scale=1)
569
+ action_btn4 = gr.Button("Send emails to high-risk accounts only", elem_classes=["action-btn"], scale=1)
570
+
571
+ # Right Side - Chat Interface
572
+ with gr.Column(scale=2, elem_classes=["chat-main"]):
573
+ chatbot = gr.Chatbot(
574
+ height=None,
575
+ show_label=False,
576
+ bubble_full_width=False,
577
+ type='messages',
578
+ elem_classes=["chat-container"],
579
+ container=True
580
+ )
581
 
582
  # Email Activity Log Tab
583
  with gr.Tab("πŸ“§ Email Activity"):