CamiloVega commited on
Commit
a3f38ff
·
verified ·
1 Parent(s): 65460f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +122 -94
app.py CHANGED
@@ -390,83 +390,89 @@ def generate_news(instructions, facts, size, tone, *args):
390
  # Create Gradio interface
391
  def create_demo():
392
  with gr.Blocks(css="""
 
393
  .gradio-container {
394
  max-width: 1200px !important;
395
  margin: auto !important;
396
  }
397
 
 
398
  .header {
399
- margin-bottom: 2rem;
400
  }
401
 
402
- .content-area {
403
- display: flex;
404
- gap: 2rem;
405
  }
406
 
407
- .input-column {
408
- flex: 1;
409
- max-width: 400px;
 
 
 
410
  }
411
 
412
- .tabs-column {
413
- flex: 2;
 
414
  }
415
 
416
- .tab-nav {
 
417
  display: flex !important;
418
  flex-wrap: wrap !important;
419
- gap: 0.5rem !important;
420
- margin-bottom: 1rem !important;
421
  border-bottom: 1px solid #e5e7eb !important;
422
  padding-bottom: 0.5rem !important;
 
423
  }
424
 
425
- .tab-nav button {
426
- font-size: 0.875rem !important;
427
- padding: 0.25rem 0.75rem !important;
428
- border-radius: 0.375rem !important;
429
- border: none !important;
430
  background: transparent !important;
431
- color: #6b7280 !important;
 
432
  }
433
 
434
- .tab-nav button.selected {
435
- background: #f3f4f6 !important;
436
- color: #111827 !important;
437
- }
438
-
439
- .upload-box {
440
- height: 150px !important;
441
- min-height: 150px !important;
442
- max-height: 150px !important;
443
- border: 2px dashed #e5e7eb !important;
444
- border-radius: 8px !important;
445
  display: flex !important;
446
  align-items: center !important;
447
  justify-content: center !important;
448
- margin-bottom: 1rem !important;
 
449
  }
450
 
451
- .upload-box .icon {
452
- width: 40px !important;
453
- height: 40px !important;
454
  opacity: 0.5 !important;
455
  }
456
 
457
- .file-upload {
458
- padding: 1rem !important;
459
- background: #f9fafb !important;
460
- border-radius: 8px !important;
461
- margin-bottom: 1rem !important;
 
 
 
462
  }
463
 
464
- .file-upload input {
465
- max-width: 100% !important;
466
- }
467
-
468
- .output-area {
469
- margin-top: 2rem;
470
  }
471
  """) as demo:
472
  # Header
@@ -485,86 +491,108 @@ def create_demo():
485
  """)
486
  gr.Markdown("*Created by Camilo Vega, AI Consultant*")
487
 
488
- with gr.Row(elem_classes=["content-area"]):
489
- # Left Column - Main Controls
490
- with gr.Column(elem_classes=["input-column"]):
491
  instructions = gr.Textbox(
492
  label="News article instructions",
493
- lines=3
 
494
  )
495
  facts = gr.Textbox(
496
  label="Describe the news facts",
497
- lines=4
 
498
  )
499
  size = gr.Number(
500
  label="Content body size (in words)",
501
- value=100
 
502
  )
503
  tone = gr.Dropdown(
504
  label="News tone",
505
  choices=["serious", "neutral", "lighthearted"],
506
- value="neutral"
 
507
  )
508
 
509
- # Right Column - Source Inputs
510
- with gr.Column(elem_classes=["tabs-column"]):
511
  inputs_list = [instructions, facts, size, tone]
512
 
513
  with gr.Tabs() as tabs:
514
- # Audio/Video Tabs
515
  for i in range(1, 6):
516
- with gr.TabItem(f"Audio/Video {i}"):
517
- with gr.Group(elem_classes=["file-upload"]):
518
  file = gr.File(
519
- label=f"Audio/Video {i}",
520
  file_types=["audio", "video"],
521
- elem_classes=["upload-box"]
 
 
 
 
 
 
 
 
522
  )
523
- name = gr.Textbox(label="Name")
524
- position = gr.Textbox(label="Position")
525
  inputs_list.extend([file, name, position])
526
 
527
- # Social Media Tabs
528
  for i in range(1, 4):
529
- with gr.TabItem(f"Social Media {i}"):
530
- social_url = gr.Textbox(label="URL")
531
- social_name = gr.Textbox(label="Person/account name")
532
- social_context = gr.Textbox(label="Content context")
 
 
 
 
 
 
 
 
 
533
  inputs_list.extend([social_url, social_name, social_context])
534
 
535
- # URL Tabs
536
  for i in range(1, 6):
537
- with gr.TabItem(f"URL {i}"):
538
- url = gr.Textbox(label=f"URL {i}")
 
 
 
539
  inputs_list.append(url)
540
 
541
- # Document Tabs
542
  for i in range(1, 6):
543
- with gr.TabItem(f"Document {i}"):
544
- with gr.Group(elem_classes=["file-upload"]):
545
- document = gr.File(
546
- label=f"Document {i}",
547
- file_types=["pdf", "docx", "xlsx", "csv"],
548
- elem_classes=["upload-box"]
549
- )
550
- inputs_list.append(document)
551
-
552
- # Output Section
553
- with gr.Group(elem_classes=["output-area"]):
554
- transcriptions_output = gr.Textbox(
555
- label="Transcriptions",
556
- lines=8
557
- )
558
-
559
- generate = gr.Button(
560
- "Generate Draft",
561
- variant="primary"
562
- )
563
-
564
- news_output = gr.Textbox(
565
- label="Generated Draft",
566
- lines=12
567
- )
568
 
569
  # Connect the generate button
570
  generate.click(
 
390
  # Create Gradio interface
391
  def create_demo():
392
  with gr.Blocks(css="""
393
+ /* Container styles */
394
  .gradio-container {
395
  max-width: 1200px !important;
396
  margin: auto !important;
397
  }
398
 
399
+ /* Header styles */
400
  .header {
401
+ margin-bottom: 1rem;
402
  }
403
 
404
+ .header h1 {
405
+ font-size: 1.5rem !important;
406
+ margin-bottom: 0.5rem !important;
407
  }
408
 
409
+ /* Two column layout */
410
+ .two-columns {
411
+ display: grid !important;
412
+ grid-template-columns: 300px 1fr !important;
413
+ gap: 2rem !important;
414
+ margin-top: 1rem !important;
415
  }
416
 
417
+ /* Input fields */
418
+ .input-field {
419
+ margin-bottom: 1rem !important;
420
  }
421
 
422
+ /* Tab navigation */
423
+ .tabs > .tab-nav {
424
  display: flex !important;
425
  flex-wrap: wrap !important;
426
+ gap: 4px !important;
 
427
  border-bottom: 1px solid #e5e7eb !important;
428
  padding-bottom: 0.5rem !important;
429
+ margin-bottom: 1rem !important;
430
  }
431
 
432
+ .tab-nav * {
433
+ font-size: 0.8rem !important;
434
+ padding: 0.2rem 0.5rem !important;
435
+ border-radius: 4px !important;
 
436
  background: transparent !important;
437
+ border: 1px solid #e5e7eb !important;
438
+ color: #374151 !important;
439
  }
440
 
441
+ /* File upload area */
442
+ .file-upload {
443
+ max-height: 120px !important;
444
+ min-height: 120px !important;
445
+ border: 1px dashed #e5e7eb !important;
446
+ border-radius: 4px !important;
 
 
 
 
 
447
  display: flex !important;
448
  align-items: center !important;
449
  justify-content: center !important;
450
+ margin-bottom: 0.5rem !important;
451
+ padding: 1rem !important;
452
  }
453
 
454
+ .file-upload svg {
455
+ width: 24px !important;
456
+ height: 24px !important;
457
  opacity: 0.5 !important;
458
  }
459
 
460
+ /* Button styles */
461
+ .generate-btn {
462
+ margin-top: 1rem !important;
463
+ background: #4b5563 !important;
464
+ color: white !important;
465
+ padding: 0.5rem 1rem !important;
466
+ border-radius: 4px !important;
467
+ width: auto !important;
468
  }
469
 
470
+ /* Output areas */
471
+ .output-box {
472
+ margin-top: 1rem !important;
473
+ border: 1px solid #e5e7eb !important;
474
+ border-radius: 4px !important;
475
+ padding: 0.5rem !important;
476
  }
477
  """) as demo:
478
  # Header
 
491
  """)
492
  gr.Markdown("*Created by Camilo Vega, AI Consultant*")
493
 
494
+ with gr.Row(elem_classes=["two-columns"]):
495
+ # Left column - Main inputs
496
+ with gr.Column():
497
  instructions = gr.Textbox(
498
  label="News article instructions",
499
+ lines=3,
500
+ elem_classes=["input-field"]
501
  )
502
  facts = gr.Textbox(
503
  label="Describe the news facts",
504
+ lines=4,
505
+ elem_classes=["input-field"]
506
  )
507
  size = gr.Number(
508
  label="Content body size (in words)",
509
+ value=100,
510
+ elem_classes=["input-field"]
511
  )
512
  tone = gr.Dropdown(
513
  label="News tone",
514
  choices=["serious", "neutral", "lighthearted"],
515
+ value="neutral",
516
+ elem_classes=["input-field"]
517
  )
518
 
519
+ # Right column - Source inputs
520
+ with gr.Column():
521
  inputs_list = [instructions, facts, size, tone]
522
 
523
  with gr.Tabs() as tabs:
524
+ # Audio/Video Sources
525
  for i in range(1, 6):
526
+ with gr.Tab(f"Audio/Video {i}"):
527
+ with gr.Group():
528
  file = gr.File(
529
+ label="Upload Audio/Video",
530
  file_types=["audio", "video"],
531
+ elem_classes=["file-upload"]
532
+ )
533
+ name = gr.Textbox(
534
+ label="Name",
535
+ elem_classes=["input-field"]
536
+ )
537
+ position = gr.Textbox(
538
+ label="Position",
539
+ elem_classes=["input-field"]
540
  )
 
 
541
  inputs_list.extend([file, name, position])
542
 
543
+ # Social Media Sources
544
  for i in range(1, 4):
545
+ with gr.Tab(f"Social Media {i}"):
546
+ social_url = gr.Textbox(
547
+ label="URL",
548
+ elem_classes=["input-field"]
549
+ )
550
+ social_name = gr.Textbox(
551
+ label="Person/account name",
552
+ elem_classes=["input-field"]
553
+ )
554
+ social_context = gr.Textbox(
555
+ label="Content context",
556
+ elem_classes=["input-field"]
557
+ )
558
  inputs_list.extend([social_url, social_name, social_context])
559
 
560
+ # URLs
561
  for i in range(1, 6):
562
+ with gr.Tab(f"URL {i}"):
563
+ url = gr.Textbox(
564
+ label=f"URL {i}",
565
+ elem_classes=["input-field"]
566
+ )
567
  inputs_list.append(url)
568
 
569
+ # Documents
570
  for i in range(1, 6):
571
+ with gr.Tab(f"Document {i}"):
572
+ document = gr.File(
573
+ label=f"Document {i}",
574
+ file_types=["pdf", "docx", "xlsx", "csv"],
575
+ elem_classes=["file-upload"]
576
+ )
577
+ inputs_list.append(document)
578
+
579
+ # Output areas
580
+ transcriptions_output = gr.Textbox(
581
+ label="Transcriptions",
582
+ lines=6,
583
+ elem_classes=["output-box"]
584
+ )
585
+
586
+ generate = gr.Button(
587
+ "Generate Draft",
588
+ elem_classes=["generate-btn"]
589
+ )
590
+
591
+ news_output = gr.Textbox(
592
+ label="Generated Draft",
593
+ lines=10,
594
+ elem_classes=["output-box"]
595
+ )
596
 
597
  # Connect the generate button
598
  generate.click(