Update app.py
Browse files
app.py
CHANGED
@@ -557,15 +557,15 @@ def Generate_Speech( # <-- MCP tool #4 (Generate Speech)
|
|
557 |
fetch_interface = gr.Interface(
|
558 |
fn=Fetch_Webpage, # connect the function to the UI
|
559 |
inputs=[
|
560 |
-
gr.Textbox(label="URL", placeholder="https://example.com/article"),
|
561 |
-
gr.Dropdown(label="Verbosity", choices=["Brief", "Standard", "Full"], value="Standard"),
|
562 |
-
gr.Checkbox(value=True, label="Include Metadata"),
|
563 |
-
gr.Checkbox(value=True, label="Include Main Text"),
|
564 |
-
gr.Checkbox(value=True, label="Include Links"),
|
565 |
-
gr.Slider(400, 12000, value=3000, step=100, label="Max Characters (body text)"),
|
566 |
-
gr.Slider(0, 100, value=20, step=1, label="Max Links"),
|
567 |
],
|
568 |
-
outputs=gr.Markdown(label="Extracted Summary"),
|
569 |
title="Fetch Webpage",
|
570 |
description=(
|
571 |
"<div style=\"text-align:center\">Extract title, key metadata, readable text, and links from webpages. No noisy HTML.</div>"
|
@@ -584,14 +584,14 @@ fetch_interface = gr.Interface(
|
|
584 |
concise_interface = gr.Interface(
|
585 |
fn=Search_DuckDuckGo,
|
586 |
inputs=[
|
587 |
-
gr.Textbox(label="Query", placeholder="topic OR site:example.com"),
|
588 |
-
gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Max results"),
|
589 |
-
gr.Checkbox(value=False, label="Include snippets (adds tokens)"),
|
590 |
-
gr.Slider(minimum=20, maximum=200, value=80, step=5, label="Max snippet chars"),
|
591 |
-
gr.Checkbox(value=True, label="Dedupe by domain"),
|
592 |
-
gr.Slider(minimum=20, maximum=120, value=80, step=5, label="Max title chars"),
|
593 |
],
|
594 |
-
outputs=gr.Textbox(label="Results (JSONL)", interactive=False),
|
595 |
title="DuckDuckGo Search",
|
596 |
description=(
|
597 |
"<div style=\"text-align:center\">Very concise web search to avoid unnecessary context. Emits JSONL with short keys (t,u[,s]). Defaults avoid snippets and duplicate domains.</div>"
|
@@ -611,8 +611,8 @@ concise_interface = gr.Interface(
|
|
611 |
# --- Execute Python tab (simple code interpreter) ---
|
612 |
code_interface = gr.Interface(
|
613 |
fn=Execute_Python,
|
614 |
-
inputs=gr.Code(label="Python Code", language="python"),
|
615 |
-
outputs=gr.Textbox(label="Output"),
|
616 |
title="Python Code Executor",
|
617 |
description=(
|
618 |
"<div style=\"text-align:center\">Execute Python code and see the output.</div>"
|
@@ -628,67 +628,15 @@ code_interface = gr.Interface(
|
|
628 |
fill_width=True,
|
629 |
)
|
630 |
|
631 |
-
CSS_STYLES = """
|
632 |
-
.gradio-container h1 {
|
633 |
-
text-align: center;
|
634 |
-
/* Ensure main title appears first, then our two subtitle lines */
|
635 |
-
display: grid;
|
636 |
-
justify-items: center;
|
637 |
-
}
|
638 |
-
/* Place bold tools list on line 2, normal auth note on line 3 (below title) */
|
639 |
-
.gradio-container h1::before {
|
640 |
-
grid-row: 2;
|
641 |
-
content: "Fetch Webpage | Search DuckDuckGo | Code Interpreter | Kokoro TTS | Image Generation | Video Generation";
|
642 |
-
display: block;
|
643 |
-
font-size: 1rem;
|
644 |
-
font-weight: 700;
|
645 |
-
opacity: 0.9;
|
646 |
-
margin-top: 6px;
|
647 |
-
white-space: pre-wrap;
|
648 |
-
}
|
649 |
-
.gradio-container h1::after {
|
650 |
-
grid-row: 3;
|
651 |
-
content: "Authentication is optional but Image/Video Generation require a `HF_READ_TOKEN` in env variables. They are hidden otherwise.";
|
652 |
-
display: block;
|
653 |
-
font-size: 1rem;
|
654 |
-
font-weight: 400;
|
655 |
-
opacity: 0.9;
|
656 |
-
margin-top: 2px;
|
657 |
-
white-space: pre-wrap;
|
658 |
-
}
|
659 |
-
|
660 |
-
/* Remove inside tab panels so it doesn't duplicate under each tool title */
|
661 |
-
.gradio-container [role=\"tabpanel\"] h1::before,
|
662 |
-
.gradio-container [role=\"tabpanel\"] h1::after {
|
663 |
-
content: none !important;
|
664 |
-
}
|
665 |
-
|
666 |
-
/* Force full width for the container and all interfaces */
|
667 |
-
.gradio-container,
|
668 |
-
.gradio-container > div,
|
669 |
-
.gradio-container .tab-nav,
|
670 |
-
.gradio-container .tabitem,
|
671 |
-
.gradio-container .interface-wrapper {
|
672 |
-
width: 100% !important;
|
673 |
-
max-width: none !important;
|
674 |
-
}
|
675 |
-
|
676 |
-
/* Ensure tab content fills available width */
|
677 |
-
.gradio-container .tabitem > div {
|
678 |
-
width: 100% !important;
|
679 |
-
max-width: none !important;
|
680 |
-
}
|
681 |
-
"""
|
682 |
-
|
683 |
# --- Kokoro TTS tab (text to speech) ---
|
684 |
kokoro_interface = gr.Interface(
|
685 |
fn=Generate_Speech,
|
686 |
inputs=[
|
687 |
-
gr.Textbox(label="Text", placeholder="Type text to synthesize…", lines=4),
|
688 |
-
gr.Slider(minimum=0.5, maximum=2.0, value=1.0, step=0.1, label="Speed"),
|
689 |
-
gr.Textbox(label="Voice", value="af_heart", placeholder="e.g., af_heart"),
|
690 |
],
|
691 |
-
outputs=gr.Audio(label="Audio", type="numpy"),
|
692 |
title="Kokoro TTS",
|
693 |
description=(
|
694 |
"<div style=\"text-align:center\">Generate English speech with Kokoro-82M. 30 second max output. Runs on CPU or CUDA if available.</div>"
|
@@ -793,8 +741,8 @@ def Generate_Image( # <-- MCP tool #5 (Generate Image)
|
|
793 |
image_generation_interface = gr.Interface(
|
794 |
fn=Generate_Image,
|
795 |
inputs=[
|
796 |
-
gr.Textbox(label="Prompt", placeholder="Enter a prompt", lines=2),
|
797 |
-
gr.Textbox(label="Model", value="black-forest-labs/FLUX.1-Krea-dev", placeholder="creator/model-name"),
|
798 |
gr.Textbox(
|
799 |
label="Negative Prompt",
|
800 |
value=(
|
@@ -803,17 +751,19 @@ image_generation_interface = gr.Interface(
|
|
803 |
"mutated, ugly, disgusting, blurry, amputation, misspellings, typos"
|
804 |
),
|
805 |
lines=2,
|
|
|
|
|
806 |
),
|
807 |
-
gr.Slider(minimum=1, maximum=100, value=35, step=1, label="Steps"),
|
808 |
-
gr.Slider(minimum=1.0, maximum=20.0, value=7.0, step=0.1, label="CFG Scale"),
|
809 |
gr.Radio(label="Sampler", value="DPM++ 2M Karras", choices=[
|
810 |
"DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"
|
811 |
-
]),
|
812 |
-
gr.Slider(minimum=-1, maximum=1_000_000_000, value=-1, step=1, label="Seed (-1 = random)"),
|
813 |
-
gr.Slider(minimum=64, maximum=1216, value=1024, step=32, label="Width"),
|
814 |
-
gr.Slider(minimum=64, maximum=1216, value=1024, step=32, label="Height"),
|
815 |
],
|
816 |
-
outputs=gr.Image(label="Generated Image"),
|
817 |
title="Image Generation",
|
818 |
description=(
|
819 |
"<div style=\"text-align:center\">Generate images via Hugging Face Inference. "
|
@@ -981,18 +931,18 @@ def Generate_Video( # <-- MCP tool #6 (Generate Video)
|
|
981 |
video_generation_interface = gr.Interface(
|
982 |
fn=Generate_Video,
|
983 |
inputs=[
|
984 |
-
gr.Textbox(label="Prompt", placeholder="Enter a prompt for the video", lines=2),
|
985 |
-
gr.Textbox(label="Model", value="Wan-AI/Wan2.2-T2V-A14B", placeholder="creator/model-name"),
|
986 |
-
gr.Textbox(label="Negative Prompt", value="", lines=2),
|
987 |
-
gr.Slider(minimum=1, maximum=100, value=25, step=1, label="Steps"),
|
988 |
-
gr.Slider(minimum=1.0, maximum=20.0, value=3.5, step=0.1, label="CFG Scale"),
|
989 |
-
gr.Slider(minimum=-1, maximum=1_000_000_000, value=-1, step=1, label="Seed (-1 = random)"),
|
990 |
-
gr.Slider(minimum=64, maximum=1920, value=768, step=8, label="Width"),
|
991 |
-
gr.Slider(minimum=64, maximum=1920, value=768, step=8, label="Height"),
|
992 |
-
gr.Slider(minimum=4, maximum=60, value=24, step=1, label="FPS"),
|
993 |
-
gr.Slider(minimum=1.0, maximum=10.0, value=4.0, step=0.5, label="Duration (s)"),
|
994 |
],
|
995 |
-
outputs=gr.Video(label="Generated Video"),
|
996 |
title="Video Generation",
|
997 |
description=(
|
998 |
"<div style=\"text-align:center\">Generate short videos via Hugging Face Inference Providers. "
|
@@ -1032,7 +982,6 @@ demo = gr.TabbedInterface(
|
|
1032 |
tab_names=_tab_names,
|
1033 |
title="Tools MCP",
|
1034 |
theme="Nymbo/Nymbo_Theme",
|
1035 |
-
css=CSS_STYLES,
|
1036 |
)
|
1037 |
|
1038 |
# Launch the UI and expose all functions as MCP tools in one server
|
|
|
557 |
fetch_interface = gr.Interface(
|
558 |
fn=Fetch_Webpage, # connect the function to the UI
|
559 |
inputs=[
|
560 |
+
gr.Textbox(label="URL", placeholder="https://example.com/article", scale=2, min_width=300),
|
561 |
+
gr.Dropdown(label="Verbosity", choices=["Brief", "Standard", "Full"], value="Standard", scale=1, min_width=150),
|
562 |
+
gr.Checkbox(value=True, label="Include Metadata", scale=1, min_width=120),
|
563 |
+
gr.Checkbox(value=True, label="Include Main Text", scale=1, min_width=120),
|
564 |
+
gr.Checkbox(value=True, label="Include Links", scale=1, min_width=120),
|
565 |
+
gr.Slider(400, 12000, value=3000, step=100, label="Max Characters (body text)", scale=2, min_width=200),
|
566 |
+
gr.Slider(0, 100, value=20, step=1, label="Max Links", scale=1, min_width=150),
|
567 |
],
|
568 |
+
outputs=gr.Markdown(label="Extracted Summary", scale=1),
|
569 |
title="Fetch Webpage",
|
570 |
description=(
|
571 |
"<div style=\"text-align:center\">Extract title, key metadata, readable text, and links from webpages. No noisy HTML.</div>"
|
|
|
584 |
concise_interface = gr.Interface(
|
585 |
fn=Search_DuckDuckGo,
|
586 |
inputs=[
|
587 |
+
gr.Textbox(label="Query", placeholder="topic OR site:example.com", scale=2, min_width=300),
|
588 |
+
gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Max results", scale=1, min_width=150),
|
589 |
+
gr.Checkbox(value=False, label="Include snippets (adds tokens)", scale=1, min_width=180),
|
590 |
+
gr.Slider(minimum=20, maximum=200, value=80, step=5, label="Max snippet chars", scale=1, min_width=150),
|
591 |
+
gr.Checkbox(value=True, label="Dedupe by domain", scale=1, min_width=150),
|
592 |
+
gr.Slider(minimum=20, maximum=120, value=80, step=5, label="Max title chars", scale=1, min_width=150),
|
593 |
],
|
594 |
+
outputs=gr.Textbox(label="Results (JSONL)", interactive=False, scale=1),
|
595 |
title="DuckDuckGo Search",
|
596 |
description=(
|
597 |
"<div style=\"text-align:center\">Very concise web search to avoid unnecessary context. Emits JSONL with short keys (t,u[,s]). Defaults avoid snippets and duplicate domains.</div>"
|
|
|
611 |
# --- Execute Python tab (simple code interpreter) ---
|
612 |
code_interface = gr.Interface(
|
613 |
fn=Execute_Python,
|
614 |
+
inputs=gr.Code(label="Python Code", language="python", scale=1, min_width=400),
|
615 |
+
outputs=gr.Textbox(label="Output", scale=1, min_width=400),
|
616 |
title="Python Code Executor",
|
617 |
description=(
|
618 |
"<div style=\"text-align:center\">Execute Python code and see the output.</div>"
|
|
|
628 |
fill_width=True,
|
629 |
)
|
630 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
631 |
# --- Kokoro TTS tab (text to speech) ---
|
632 |
kokoro_interface = gr.Interface(
|
633 |
fn=Generate_Speech,
|
634 |
inputs=[
|
635 |
+
gr.Textbox(label="Text", placeholder="Type text to synthesize…", lines=4, scale=2, min_width=300),
|
636 |
+
gr.Slider(minimum=0.5, maximum=2.0, value=1.0, step=0.1, label="Speed", scale=1, min_width=150),
|
637 |
+
gr.Textbox(label="Voice", value="af_heart", placeholder="e.g., af_heart", scale=1, min_width=150),
|
638 |
],
|
639 |
+
outputs=gr.Audio(label="Audio", type="numpy", scale=1),
|
640 |
title="Kokoro TTS",
|
641 |
description=(
|
642 |
"<div style=\"text-align:center\">Generate English speech with Kokoro-82M. 30 second max output. Runs on CPU or CUDA if available.</div>"
|
|
|
741 |
image_generation_interface = gr.Interface(
|
742 |
fn=Generate_Image,
|
743 |
inputs=[
|
744 |
+
gr.Textbox(label="Prompt", placeholder="Enter a prompt", lines=2, scale=2, min_width=300),
|
745 |
+
gr.Textbox(label="Model", value="black-forest-labs/FLUX.1-Krea-dev", placeholder="creator/model-name", scale=2, min_width=250),
|
746 |
gr.Textbox(
|
747 |
label="Negative Prompt",
|
748 |
value=(
|
|
|
751 |
"mutated, ugly, disgusting, blurry, amputation, misspellings, typos"
|
752 |
),
|
753 |
lines=2,
|
754 |
+
scale=2,
|
755 |
+
min_width=300,
|
756 |
),
|
757 |
+
gr.Slider(minimum=1, maximum=100, value=35, step=1, label="Steps", scale=1, min_width=150),
|
758 |
+
gr.Slider(minimum=1.0, maximum=20.0, value=7.0, step=0.1, label="CFG Scale", scale=1, min_width=150),
|
759 |
gr.Radio(label="Sampler", value="DPM++ 2M Karras", choices=[
|
760 |
"DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"
|
761 |
+
], scale=1, min_width=200),
|
762 |
+
gr.Slider(minimum=-1, maximum=1_000_000_000, value=-1, step=1, label="Seed (-1 = random)", scale=1, min_width=180),
|
763 |
+
gr.Slider(minimum=64, maximum=1216, value=1024, step=32, label="Width", scale=1, min_width=150),
|
764 |
+
gr.Slider(minimum=64, maximum=1216, value=1024, step=32, label="Height", scale=1, min_width=150),
|
765 |
],
|
766 |
+
outputs=gr.Image(label="Generated Image", scale=1),
|
767 |
title="Image Generation",
|
768 |
description=(
|
769 |
"<div style=\"text-align:center\">Generate images via Hugging Face Inference. "
|
|
|
931 |
video_generation_interface = gr.Interface(
|
932 |
fn=Generate_Video,
|
933 |
inputs=[
|
934 |
+
gr.Textbox(label="Prompt", placeholder="Enter a prompt for the video", lines=2, scale=2, min_width=300),
|
935 |
+
gr.Textbox(label="Model", value="Wan-AI/Wan2.2-T2V-A14B", placeholder="creator/model-name", scale=2, min_width=250),
|
936 |
+
gr.Textbox(label="Negative Prompt", value="", lines=2, scale=2, min_width=300),
|
937 |
+
gr.Slider(minimum=1, maximum=100, value=25, step=1, label="Steps", scale=1, min_width=150),
|
938 |
+
gr.Slider(minimum=1.0, maximum=20.0, value=3.5, step=0.1, label="CFG Scale", scale=1, min_width=150),
|
939 |
+
gr.Slider(minimum=-1, maximum=1_000_000_000, value=-1, step=1, label="Seed (-1 = random)", scale=1, min_width=180),
|
940 |
+
gr.Slider(minimum=64, maximum=1920, value=768, step=8, label="Width", scale=1, min_width=150),
|
941 |
+
gr.Slider(minimum=64, maximum=1920, value=768, step=8, label="Height", scale=1, min_width=150),
|
942 |
+
gr.Slider(minimum=4, maximum=60, value=24, step=1, label="FPS", scale=1, min_width=120),
|
943 |
+
gr.Slider(minimum=1.0, maximum=10.0, value=4.0, step=0.5, label="Duration (s)", scale=1, min_width=150),
|
944 |
],
|
945 |
+
outputs=gr.Video(label="Generated Video", scale=1),
|
946 |
title="Video Generation",
|
947 |
description=(
|
948 |
"<div style=\"text-align:center\">Generate short videos via Hugging Face Inference Providers. "
|
|
|
982 |
tab_names=_tab_names,
|
983 |
title="Tools MCP",
|
984 |
theme="Nymbo/Nymbo_Theme",
|
|
|
985 |
)
|
986 |
|
987 |
# Launch the UI and expose all functions as MCP tools in one server
|