Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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:
|
400 |
}
|
401 |
|
402 |
-
.
|
403 |
-
|
404 |
-
|
405 |
}
|
406 |
|
407 |
-
|
408 |
-
|
409 |
-
|
|
|
|
|
|
|
410 |
}
|
411 |
|
412 |
-
|
413 |
-
|
|
|
414 |
}
|
415 |
|
416 |
-
|
|
|
417 |
display: flex !important;
|
418 |
flex-wrap: wrap !important;
|
419 |
-
gap:
|
420 |
-
margin-bottom: 1rem !important;
|
421 |
border-bottom: 1px solid #e5e7eb !important;
|
422 |
padding-bottom: 0.5rem !important;
|
|
|
423 |
}
|
424 |
|
425 |
-
.tab-nav
|
426 |
-
font-size: 0.
|
427 |
-
padding: 0.
|
428 |
-
border-radius:
|
429 |
-
border: none !important;
|
430 |
background: transparent !important;
|
431 |
-
|
|
|
432 |
}
|
433 |
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
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:
|
|
|
449 |
}
|
450 |
|
451 |
-
.upload
|
452 |
-
width:
|
453 |
-
height:
|
454 |
opacity: 0.5 !important;
|
455 |
}
|
456 |
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
|
|
|
|
|
|
462 |
}
|
463 |
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
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=["
|
489 |
-
# Left
|
490 |
-
with gr.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
|
510 |
-
with gr.Column(
|
511 |
inputs_list = [instructions, facts, size, tone]
|
512 |
|
513 |
with gr.Tabs() as tabs:
|
514 |
-
# Audio/Video
|
515 |
for i in range(1, 6):
|
516 |
-
with gr.
|
517 |
-
with gr.Group(
|
518 |
file = gr.File(
|
519 |
-
label=
|
520 |
file_types=["audio", "video"],
|
521 |
-
elem_classes=["upload
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
)
|
523 |
-
name = gr.Textbox(label="Name")
|
524 |
-
position = gr.Textbox(label="Position")
|
525 |
inputs_list.extend([file, name, position])
|
526 |
|
527 |
-
# Social Media
|
528 |
for i in range(1, 4):
|
529 |
-
with gr.
|
530 |
-
social_url = gr.Textbox(
|
531 |
-
|
532 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
inputs_list.extend([social_url, social_name, social_context])
|
534 |
|
535 |
-
#
|
536 |
for i in range(1, 6):
|
537 |
-
with gr.
|
538 |
-
url = gr.Textbox(
|
|
|
|
|
|
|
539 |
inputs_list.append(url)
|
540 |
|
541 |
-
#
|
542 |
for i in range(1, 6):
|
543 |
-
with gr.
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
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(
|