Update app.py
Browse files
app.py
CHANGED
|
@@ -55,7 +55,7 @@ def demo_card_click(evt: gr.EventData):
|
|
| 55 |
with gr.Blocks(
|
| 56 |
theme=gr.themes.Base(
|
| 57 |
primary_hue="blue",
|
| 58 |
-
secondary_hue="
|
| 59 |
neutral_hue="gray",
|
| 60 |
font=gr.themes.GoogleFont("Inter"),
|
| 61 |
font_mono=gr.themes.GoogleFont("JetBrains Mono"),
|
|
@@ -75,7 +75,7 @@ with gr.Blocks(
|
|
| 75 |
open_panel = gr.State(None)
|
| 76 |
last_login_state = gr.State(None)
|
| 77 |
|
| 78 |
-
with gr.Row():
|
| 79 |
with gr.Column(scale=1):
|
| 80 |
gr.Markdown("## Controls", elem_classes=["col-header"])
|
| 81 |
input = gr.Textbox(
|
|
@@ -106,7 +106,7 @@ with gr.Blocks(
|
|
| 106 |
label="UI design image",
|
| 107 |
visible=False # Hidden by default; shown only for ERNIE-VL or GLM-VL
|
| 108 |
)
|
| 109 |
-
with gr.Row():
|
| 110 |
btn = gr.Button("Generate", variant="primary", size="lg", scale=2, interactive=False)
|
| 111 |
clear_btn = gr.Button("Clear", variant="secondary", size="sm", scale=1)
|
| 112 |
|
|
@@ -130,12 +130,13 @@ with gr.Blocks(
|
|
| 130 |
)
|
| 131 |
|
| 132 |
with gr.Accordion("Advanced Settings", open=False):
|
| 133 |
-
|
| 134 |
value=HTML_SYSTEM_PROMPT,
|
| 135 |
label="System Prompt",
|
| 136 |
lines=5
|
| 137 |
)
|
| 138 |
-
save_prompt_btn = gr.Button("Save Prompt", variant="secondary", size="sm")
|
|
|
|
| 139 |
|
| 140 |
with gr.Column(scale=3):
|
| 141 |
model_display = gr.Markdown(f"**Model:** {AVAILABLE_MODELS[0]['name']}", visible=True)
|
|
@@ -145,13 +146,13 @@ with gr.Blocks(
|
|
| 145 |
language="html",
|
| 146 |
lines=28,
|
| 147 |
interactive=False,
|
| 148 |
-
label="Generated Code"
|
| 149 |
)
|
| 150 |
with gr.Tab("Preview"):
|
| 151 |
sandbox = gr.HTML(label="Live Preview")
|
| 152 |
with gr.Tab("History"):
|
| 153 |
history_output = gr.Chatbot(show_label=False, height=600, type="messages")
|
| 154 |
-
|
| 155 |
# --- Event Handlers ---
|
| 156 |
def on_model_change(model_name):
|
| 157 |
for m in AVAILABLE_MODELS:
|
|
@@ -187,7 +188,7 @@ with gr.Blocks(
|
|
| 187 |
inputs=model_dropdown,
|
| 188 |
outputs=[current_model, model_display, image_input]
|
| 189 |
)
|
| 190 |
-
save_prompt_btn.click(save_prompt, inputs=
|
| 191 |
# Update preview when code or language changes
|
| 192 |
language_dropdown.change(update_code_language, inputs=language_dropdown, outputs=code_output)
|
| 193 |
code_output.change(preview_logic, inputs=[code_output, language_dropdown], outputs=sandbox)
|
|
|
|
| 55 |
with gr.Blocks(
|
| 56 |
theme=gr.themes.Base(
|
| 57 |
primary_hue="blue",
|
| 58 |
+
secondary_hue="sky", # Changed secondary hue for a more modern palette
|
| 59 |
neutral_hue="gray",
|
| 60 |
font=gr.themes.GoogleFont("Inter"),
|
| 61 |
font_mono=gr.themes.GoogleFont("JetBrains Mono"),
|
|
|
|
| 75 |
open_panel = gr.State(None)
|
| 76 |
last_login_state = gr.State(None)
|
| 77 |
|
| 78 |
+
with gr.Row(equal_height=False): # Ensure columns can have different heights
|
| 79 |
with gr.Column(scale=1):
|
| 80 |
gr.Markdown("## Controls", elem_classes=["col-header"])
|
| 81 |
input = gr.Textbox(
|
|
|
|
| 106 |
label="UI design image",
|
| 107 |
visible=False # Hidden by default; shown only for ERNIE-VL or GLM-VL
|
| 108 |
)
|
| 109 |
+
with gr.Row(equal_height=True): #Keep buttons vertically aligned
|
| 110 |
btn = gr.Button("Generate", variant="primary", size="lg", scale=2, interactive=False)
|
| 111 |
clear_btn = gr.Button("Clear", variant="secondary", size="sm", scale=1)
|
| 112 |
|
|
|
|
| 130 |
)
|
| 131 |
|
| 132 |
with gr.Accordion("Advanced Settings", open=False):
|
| 133 |
+
system_prompt_input = gr.Textbox(
|
| 134 |
value=HTML_SYSTEM_PROMPT,
|
| 135 |
label="System Prompt",
|
| 136 |
lines=5
|
| 137 |
)
|
| 138 |
+
save_prompt_btn = gr.Button("Save Prompt", variant="secondary", size="sm", min_width=100)
|
| 139 |
+
|
| 140 |
|
| 141 |
with gr.Column(scale=3):
|
| 142 |
model_display = gr.Markdown(f"**Model:** {AVAILABLE_MODELS[0]['name']}", visible=True)
|
|
|
|
| 146 |
language="html",
|
| 147 |
lines=28,
|
| 148 |
interactive=False,
|
| 149 |
+
label="Generated Code",
|
| 150 |
)
|
| 151 |
with gr.Tab("Preview"):
|
| 152 |
sandbox = gr.HTML(label="Live Preview")
|
| 153 |
with gr.Tab("History"):
|
| 154 |
history_output = gr.Chatbot(show_label=False, height=600, type="messages")
|
| 155 |
+
|
| 156 |
# --- Event Handlers ---
|
| 157 |
def on_model_change(model_name):
|
| 158 |
for m in AVAILABLE_MODELS:
|
|
|
|
| 188 |
inputs=model_dropdown,
|
| 189 |
outputs=[current_model, model_display, image_input]
|
| 190 |
)
|
| 191 |
+
save_prompt_btn.click(save_prompt, inputs=system_prompt_input, outputs=setting)
|
| 192 |
# Update preview when code or language changes
|
| 193 |
language_dropdown.change(update_code_language, inputs=language_dropdown, outputs=code_output)
|
| 194 |
code_output.change(preview_logic, inputs=[code_output, language_dropdown], outputs=sandbox)
|