mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 01:06:19 +00:00
🔧 chore(ui): refactor imports and remove unused code in __init__.py and gradio_ui.py
🔥 chore(ui): remove unused launcher.py file
The imports in __init__.py and gradio_ui.py have been refactored to remove the unused import statements. The launcher.py file has been removed as it is no longer needed. This improves code cleanliness and reduces unnecessary clutter.
This commit is contained in:
@@ -1,2 +1 @@
|
||||
from .gradio_ui import GenerateUI
|
||||
from .launcher import launch
|
||||
from .gradio_ui import GenerateUI, launch
|
||||
|
||||
@@ -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():
|
||||
@@ -202,3 +203,8 @@ class GenerateUI:
|
||||
# we don't care about this, it's not the selected engine, we throw it away
|
||||
args = args[engine.num_options :]
|
||||
return options
|
||||
|
||||
|
||||
def launch():
|
||||
ui_generator = GenerateUI()
|
||||
ui_generator.launch_ui()
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
from . import GenerateUI
|
||||
|
||||
|
||||
def launch():
|
||||
ui_generator = GenerateUI()
|
||||
ui_generator.launch_ui()
|
||||
Reference in New Issue
Block a user