Nymbo commited on
Commit
4c3fbd3
·
verified ·
1 Parent(s): 1bdb7e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -49
app.py CHANGED
@@ -557,13 +557,13 @@ 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", 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"),
569
  title="Fetch Webpage",
@@ -576,20 +576,19 @@ fetch_interface = gr.Interface(
576
  "control verbosity, whether to include metadata/text/links, and limits "
577
  "for characters and number of links."
578
  ),
579
- flagging_mode="never",
580
- fill_width=True,
581
  )
582
 
583
  # --- Concise DDG tab (JSONL with short keys, minimal tokens) ---
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),
595
  title="DuckDuckGo Search",
@@ -601,9 +600,8 @@ concise_interface = gr.Interface(
601
  "t=title, u=url, optional s=snippet. Options control result count, "
602
  "snippet inclusion and length, domain deduping, and title length."
603
  ),
604
- flagging_mode="never",
605
  submit_btn="Search",
606
- fill_width=True,
607
  )
608
 
609
  ##
@@ -611,7 +609,7 @@ 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", scale=1, min_width=400),
615
  outputs=gr.Textbox(label="Output"),
616
  title="Python Code Executor",
617
  description=(
@@ -624,17 +622,52 @@ code_interface = gr.Interface(
624
  "Returns:\n"
625
  "- string: Combined stdout produced by the code, or the exception text if execution failed."
626
  ),
627
- flagging_mode="never",
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"),
640
  title="Kokoro TTS",
@@ -646,8 +679,7 @@ kokoro_interface = gr.Interface(
646
  "Parameters: text (str), speed (float 0.5–2.0), voice (str). "
647
  "Return the generated image to the user."
648
  ),
649
- flagging_mode="never",
650
- fill_width=True,
651
  )
652
 
653
  # ==========================
@@ -741,8 +773,8 @@ def Generate_Image( # <-- MCP tool #5 (Generate Image)
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,17 +783,15 @@ image_generation_interface = gr.Interface(
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"),
767
  title="Image Generation",
@@ -775,8 +805,7 @@ image_generation_interface = gr.Interface(
775
  "sampler (str, label only), seed (int, -1=random), width/height (int, 64–1216). Returns a PIL.Image. "
776
  "Return the generated image to the user in this format `![Alt text](URL)`"
777
  ),
778
- flagging_mode="never",
779
- fill_width=True,
780
  )
781
 
782
  # ==========================
@@ -931,16 +960,16 @@ def Generate_Video( # <-- MCP tool #6 (Generate Video)
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"),
946
  title="Video Generation",
@@ -953,8 +982,7 @@ video_generation_interface = gr.Interface(
953
  "Parameters: prompt (str), model_id (str), negative_prompt (str), steps (int), cfg_scale (float), seed (int), "
954
  "width/height (int), fps (int), duration (float). Returns a file path to an MP4 that MCP exposes as a file URL."
955
  ),
956
- flagging_mode="never",
957
- fill_width=True,
958
  )
959
 
960
  # Build tabbed app; disable Image/Video tools if no HF token is present
@@ -982,6 +1010,7 @@ demo = gr.TabbedInterface(
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
 
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",
 
576
  "control verbosity, whether to include metadata/text/links, and limits "
577
  "for characters and number of links."
578
  ),
579
+ allow_flagging="never",
 
580
  )
581
 
582
  # --- Concise DDG tab (JSONL with short keys, minimal tokens) ---
583
  concise_interface = gr.Interface(
584
  fn=Search_DuckDuckGo,
585
  inputs=[
586
+ gr.Textbox(label="Query", placeholder="topic OR site:example.com"),
587
+ gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Max results"),
588
+ gr.Checkbox(value=False, label="Include snippets (adds tokens)"),
589
+ gr.Slider(minimum=20, maximum=200, value=80, step=5, label="Max snippet chars"),
590
+ gr.Checkbox(value=True, label="Dedupe by domain"),
591
+ gr.Slider(minimum=20, maximum=120, value=80, step=5, label="Max title chars"),
592
  ],
593
  outputs=gr.Textbox(label="Results (JSONL)", interactive=False),
594
  title="DuckDuckGo Search",
 
600
  "t=title, u=url, optional s=snippet. Options control result count, "
601
  "snippet inclusion and length, domain deduping, and title length."
602
  ),
603
+ allow_flagging="never",
604
  submit_btn="Search",
 
605
  )
606
 
607
  ##
 
609
  # --- Execute Python tab (simple code interpreter) ---
610
  code_interface = gr.Interface(
611
  fn=Execute_Python,
612
+ inputs=gr.Code(label="Python Code", language="python"),
613
  outputs=gr.Textbox(label="Output"),
614
  title="Python Code Executor",
615
  description=(
 
622
  "Returns:\n"
623
  "- string: Combined stdout produced by the code, or the exception text if execution failed."
624
  ),
625
+ allow_flagging="never",
 
626
  )
627
 
628
+ CSS_STYLES = """
629
+ .gradio-container h1 {
630
+ text-align: center;
631
+ /* Ensure main title appears first, then our two subtitle lines */
632
+ display: grid;
633
+ justify-items: center;
634
+ }
635
+ /* Place bold tools list on line 2, normal auth note on line 3 (below title) */
636
+ .gradio-container h1::before {
637
+ grid-row: 2;
638
+ content: "Fetch Webpage | Search DuckDuckGo | Code Interpreter | Kokoro TTS | Image Generation | Video Generation";
639
+ display: block;
640
+ font-size: 1rem;
641
+ font-weight: 700;
642
+ opacity: 0.9;
643
+ margin-top: 6px;
644
+ white-space: pre-wrap;
645
+ }
646
+ .gradio-container h1::after {
647
+ grid-row: 3;
648
+ content: "Authentication is optional but Image/Video Generation require a `HF_READ_TOKEN` in env variables. They are hidden otherwise.";
649
+ display: block;
650
+ font-size: 1rem;
651
+ font-weight: 400;
652
+ opacity: 0.9;
653
+ margin-top: 2px;
654
+ white-space: pre-wrap;
655
+ }
656
+
657
+ /* Remove inside tab panels so it doesn't duplicate under each tool title */
658
+ .gradio-container [role=\"tabpanel\"] h1::before,
659
+ .gradio-container [role=\"tabpanel\"] h1::after {
660
+ content: none !important;
661
+ }
662
+ """
663
+
664
  # --- Kokoro TTS tab (text to speech) ---
665
  kokoro_interface = gr.Interface(
666
  fn=Generate_Speech,
667
  inputs=[
668
+ gr.Textbox(label="Text", placeholder="Type text to synthesize…", lines=4),
669
+ gr.Slider(minimum=0.5, maximum=2.0, value=1.0, step=0.1, label="Speed"),
670
+ gr.Textbox(label="Voice", value="af_heart", placeholder="e.g., af_heart"),
671
  ],
672
  outputs=gr.Audio(label="Audio", type="numpy"),
673
  title="Kokoro TTS",
 
679
  "Parameters: text (str), speed (float 0.5–2.0), voice (str). "
680
  "Return the generated image to the user."
681
  ),
682
+ allow_flagging="never",
 
683
  )
684
 
685
  # ==========================
 
773
  image_generation_interface = gr.Interface(
774
  fn=Generate_Image,
775
  inputs=[
776
+ gr.Textbox(label="Prompt", placeholder="Enter a prompt", lines=2),
777
+ gr.Textbox(label="Model", value="black-forest-labs/FLUX.1-Krea-dev", placeholder="creator/model-name"),
778
  gr.Textbox(
779
  label="Negative Prompt",
780
  value=(
 
783
  "mutated, ugly, disgusting, blurry, amputation, misspellings, typos"
784
  ),
785
  lines=2,
 
 
786
  ),
787
+ gr.Slider(minimum=1, maximum=100, value=35, step=1, label="Steps"),
788
+ gr.Slider(minimum=1.0, maximum=20.0, value=7.0, step=0.1, label="CFG Scale"),
789
  gr.Radio(label="Sampler", value="DPM++ 2M Karras", choices=[
790
  "DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"
791
+ ]),
792
+ gr.Slider(minimum=-1, maximum=1_000_000_000, value=-1, step=1, label="Seed (-1 = random)"),
793
+ gr.Slider(minimum=64, maximum=1216, value=1024, step=32, label="Width"),
794
+ gr.Slider(minimum=64, maximum=1216, value=1024, step=32, label="Height"),
795
  ],
796
  outputs=gr.Image(label="Generated Image"),
797
  title="Image Generation",
 
805
  "sampler (str, label only), seed (int, -1=random), width/height (int, 64–1216). Returns a PIL.Image. "
806
  "Return the generated image to the user in this format `![Alt text](URL)`"
807
  ),
808
+ allow_flagging="never",
 
809
  )
810
 
811
  # ==========================
 
960
  video_generation_interface = gr.Interface(
961
  fn=Generate_Video,
962
  inputs=[
963
+ gr.Textbox(label="Prompt", placeholder="Enter a prompt for the video", lines=2),
964
+ gr.Textbox(label="Model", value="Wan-AI/Wan2.2-T2V-A14B", placeholder="creator/model-name"),
965
+ gr.Textbox(label="Negative Prompt", value="", lines=2),
966
+ gr.Slider(minimum=1, maximum=100, value=25, step=1, label="Steps"),
967
+ gr.Slider(minimum=1.0, maximum=20.0, value=3.5, step=0.1, label="CFG Scale"),
968
+ gr.Slider(minimum=-1, maximum=1_000_000_000, value=-1, step=1, label="Seed (-1 = random)"),
969
+ gr.Slider(minimum=64, maximum=1920, value=768, step=8, label="Width"),
970
+ gr.Slider(minimum=64, maximum=1920, value=768, step=8, label="Height"),
971
+ gr.Slider(minimum=4, maximum=60, value=24, step=1, label="FPS"),
972
+ gr.Slider(minimum=1.0, maximum=10.0, value=4.0, step=0.5, label="Duration (s)"),
973
  ],
974
  outputs=gr.Video(label="Generated Video"),
975
  title="Video Generation",
 
982
  "Parameters: prompt (str), model_id (str), negative_prompt (str), steps (int), cfg_scale (float), seed (int), "
983
  "width/height (int), fps (int), duration (float). Returns a file path to an MP4 that MCP exposes as a file URL."
984
  ),
985
+ allow_flagging="never",
 
986
  )
987
 
988
  # Build tabbed app; disable Image/Video tools if no HF token is present
 
1010
  tab_names=_tab_names,
1011
  title="Tools MCP",
1012
  theme="Nymbo/Nymbo_Theme",
1013
+ css=CSS_STYLES,
1014
  )
1015
 
1016
  # Launch the UI and expose all functions as MCP tools in one server