diff --git a/ui/__init__.py b/ui/__init__.py index f8a2755..43fcf69 100644 --- a/ui/__init__.py +++ b/ui/__init__.py @@ -1,2 +1 @@ -from .gradio_ui import GenerateUI -from .launcher import launch \ No newline at end of file +from .gradio_ui import GenerateUI, launch diff --git a/ui/gradio_ui.py b/ui/gradio_ui.py index d6276fb..d5d1e1c 100644 --- a/ui/gradio_ui.py +++ b/ui/gradio_ui.py @@ -1,4 +1,3 @@ -import os import gradio as gr import orjson import sys @@ -6,12 +5,14 @@ import sys from src.engines import ENGINES, BaseEngine from src.chore import GenerationContext + class GenerateUI: def __init__(self): self.css = """.generate_button { font-size: 5rem !important } """ + def get_presets(self): with open("local/presets.json", "r") as f: return orjson.loads(f.read()) @@ -35,8 +36,8 @@ class GenerateUI: return ui def launch_ui(self): - self.ui = self.get_ui() - self.ui.launch() + ui = self.get_ui() + ui.launch() def get_interfaces(self) -> tuple[list[gr.Blocks], list[str]]: """ @@ -53,9 +54,9 @@ class GenerateUI: def get_settings_interface(self) -> gr.Blocks: with gr.Blocks() as interface: reload_ui = gr.Button("Reload UI", variant="primary") + def reload(): - self.ui.close() - sys.exit("Reload") + gr.Warning("Please restart the server to apply changes.") reload_ui.click(reload) for engine_type, engines in ENGINES.items(): @@ -201,4 +202,9 @@ class GenerateUI: else: # we don't care about this, it's not the selected engine, we throw it away args = args[engine.num_options :] - return options \ No newline at end of file + return options + + +def launch(): + ui_generator = GenerateUI() + ui_generator.launch_ui() diff --git a/ui/launcher.py b/ui/launcher.py deleted file mode 100644 index cd02a10..0000000 --- a/ui/launcher.py +++ /dev/null @@ -1,6 +0,0 @@ -from . import GenerateUI - - -def launch(): - ui_generator = GenerateUI() - ui_generator.launch_ui()