Spaces:
Running
Running
update
Browse files
app.py
CHANGED
@@ -1104,18 +1104,18 @@ with gr.Blocks(
|
|
1104 |
last_login_state = gr.State(None)
|
1105 |
|
1106 |
with gr.Sidebar():
|
1107 |
-
#
|
1108 |
-
login_button = gr.LoginButton(
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
)
|
1113 |
-
login_required_msg = gr.Markdown("**Please sign in with Hugging Face to use the app.**", visible=True)
|
1114 |
input = gr.Textbox(
|
1115 |
label="What would you like to build?",
|
1116 |
placeholder="Describe your application...",
|
1117 |
lines=3,
|
1118 |
-
visible=
|
1119 |
)
|
1120 |
# Language dropdown for code generation
|
1121 |
language_choices = [
|
@@ -1125,39 +1125,39 @@ with gr.Blocks(
|
|
1125 |
choices=language_choices,
|
1126 |
value="html",
|
1127 |
label="Code Language",
|
1128 |
-
visible=
|
1129 |
)
|
1130 |
website_url_input = gr.Textbox(
|
1131 |
label="Website URL for redesign",
|
1132 |
placeholder="https://example.com",
|
1133 |
lines=1,
|
1134 |
-
visible=
|
1135 |
)
|
1136 |
file_input = gr.File(
|
1137 |
label="Reference file",
|
1138 |
file_types=[".pdf", ".txt", ".md", ".csv", ".docx", ".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif", ".gif", ".webp"],
|
1139 |
-
visible=
|
1140 |
)
|
1141 |
image_input = gr.Image(
|
1142 |
label="UI design image",
|
1143 |
-
visible=False
|
1144 |
)
|
1145 |
with gr.Row():
|
1146 |
-
btn = gr.Button("Generate", variant="primary", size="lg", scale=2, visible=
|
1147 |
-
clear_btn = gr.Button("Clear", variant="secondary", size="sm", scale=1, visible=
|
1148 |
search_toggle = gr.Checkbox(
|
1149 |
label="🔍 Web search",
|
1150 |
value=False,
|
1151 |
-
visible=
|
1152 |
)
|
1153 |
model_dropdown = gr.Dropdown(
|
1154 |
choices=[model['name'] for model in AVAILABLE_MODELS],
|
1155 |
value=AVAILABLE_MODELS[0]['name'], # Moonshot Kimi-K2
|
1156 |
label="Model",
|
1157 |
-
visible=
|
1158 |
)
|
1159 |
-
gr.Markdown("**Quick start**", visible=
|
1160 |
-
with gr.Column(visible=
|
1161 |
for i, demo_item in enumerate(DEMO_LIST[:3]):
|
1162 |
demo_card = gr.Button(
|
1163 |
value=demo_item['title'],
|
@@ -1169,10 +1169,10 @@ with gr.Blocks(
|
|
1169 |
outputs=input
|
1170 |
)
|
1171 |
if not tavily_client:
|
1172 |
-
gr.Markdown("⚠️ Web search unavailable", visible=
|
1173 |
else:
|
1174 |
-
gr.Markdown("✅ Web search available", visible=
|
1175 |
-
model_display = gr.Markdown(f"**Model:** {AVAILABLE_MODELS[0]['name']}", visible=
|
1176 |
def on_model_change(model_name):
|
1177 |
for m in AVAILABLE_MODELS:
|
1178 |
if m['name'] == model_name:
|
@@ -1185,7 +1185,7 @@ with gr.Blocks(
|
|
1185 |
inputs=model_dropdown,
|
1186 |
outputs=[current_model, model_display, image_input]
|
1187 |
)
|
1188 |
-
with gr.Accordion("Advanced", open=False, visible=
|
1189 |
systemPromptInput = gr.Textbox(
|
1190 |
value=HTML_SYSTEM_PROMPT,
|
1191 |
label="System prompt",
|
@@ -1194,34 +1194,34 @@ with gr.Blocks(
|
|
1194 |
save_prompt_btn = gr.Button("Save", variant="primary", size="sm")
|
1195 |
save_prompt_btn.click(save_prompt, inputs=systemPromptInput, outputs=setting)
|
1196 |
|
1197 |
-
#
|
1198 |
-
login_state = gr.State(False)
|
1199 |
-
timer = gr.Timer(1, active=True)
|
1200 |
-
def check_login(label, last_state):
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
timer.tick(
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
)
|
1225 |
|
1226 |
with gr.Column():
|
1227 |
with gr.Tabs():
|
|
|
1104 |
last_login_state = gr.State(None)
|
1105 |
|
1106 |
with gr.Sidebar():
|
1107 |
+
# Remove Hugging Face Login Button and login-required message
|
1108 |
+
# login_button = gr.LoginButton(
|
1109 |
+
# value="Sign in with Hugging Face",
|
1110 |
+
# variant="huggingface",
|
1111 |
+
# size="lg"
|
1112 |
+
# )
|
1113 |
+
# login_required_msg = gr.Markdown("**Please sign in with Hugging Face to use the app.**", visible=True)
|
1114 |
input = gr.Textbox(
|
1115 |
label="What would you like to build?",
|
1116 |
placeholder="Describe your application...",
|
1117 |
lines=3,
|
1118 |
+
visible=True # Always visible
|
1119 |
)
|
1120 |
# Language dropdown for code generation
|
1121 |
language_choices = [
|
|
|
1125 |
choices=language_choices,
|
1126 |
value="html",
|
1127 |
label="Code Language",
|
1128 |
+
visible=True # Always visible
|
1129 |
)
|
1130 |
website_url_input = gr.Textbox(
|
1131 |
label="Website URL for redesign",
|
1132 |
placeholder="https://example.com",
|
1133 |
lines=1,
|
1134 |
+
visible=True # Always visible
|
1135 |
)
|
1136 |
file_input = gr.File(
|
1137 |
label="Reference file",
|
1138 |
file_types=[".pdf", ".txt", ".md", ".csv", ".docx", ".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif", ".gif", ".webp"],
|
1139 |
+
visible=True # Always visible
|
1140 |
)
|
1141 |
image_input = gr.Image(
|
1142 |
label="UI design image",
|
1143 |
+
visible=False # Hidden by default; shown only for ERNIE-VL or GLM-VL
|
1144 |
)
|
1145 |
with gr.Row():
|
1146 |
+
btn = gr.Button("Generate", variant="primary", size="lg", scale=2, visible=True) # Always visible
|
1147 |
+
clear_btn = gr.Button("Clear", variant="secondary", size="sm", scale=1, visible=True) # Always visible
|
1148 |
search_toggle = gr.Checkbox(
|
1149 |
label="🔍 Web search",
|
1150 |
value=False,
|
1151 |
+
visible=True # Always visible
|
1152 |
)
|
1153 |
model_dropdown = gr.Dropdown(
|
1154 |
choices=[model['name'] for model in AVAILABLE_MODELS],
|
1155 |
value=AVAILABLE_MODELS[0]['name'], # Moonshot Kimi-K2
|
1156 |
label="Model",
|
1157 |
+
visible=True # Always visible
|
1158 |
)
|
1159 |
+
gr.Markdown("**Quick start**", visible=True)
|
1160 |
+
with gr.Column(visible=True) as quick_examples_col:
|
1161 |
for i, demo_item in enumerate(DEMO_LIST[:3]):
|
1162 |
demo_card = gr.Button(
|
1163 |
value=demo_item['title'],
|
|
|
1169 |
outputs=input
|
1170 |
)
|
1171 |
if not tavily_client:
|
1172 |
+
gr.Markdown("⚠️ Web search unavailable", visible=True)
|
1173 |
else:
|
1174 |
+
gr.Markdown("✅ Web search available", visible=True)
|
1175 |
+
model_display = gr.Markdown(f"**Model:** {AVAILABLE_MODELS[0]['name']}", visible=True) # Moonshot Kimi-K2
|
1176 |
def on_model_change(model_name):
|
1177 |
for m in AVAILABLE_MODELS:
|
1178 |
if m['name'] == model_name:
|
|
|
1185 |
inputs=model_dropdown,
|
1186 |
outputs=[current_model, model_display, image_input]
|
1187 |
)
|
1188 |
+
with gr.Accordion("Advanced", open=False, visible=True) as advanced_accordion:
|
1189 |
systemPromptInput = gr.Textbox(
|
1190 |
value=HTML_SYSTEM_PROMPT,
|
1191 |
label="System prompt",
|
|
|
1194 |
save_prompt_btn = gr.Button("Save", variant="primary", size="sm")
|
1195 |
save_prompt_btn.click(save_prompt, inputs=systemPromptInput, outputs=setting)
|
1196 |
|
1197 |
+
# Remove login state and timer logic
|
1198 |
+
# login_state = gr.State(False)
|
1199 |
+
# timer = gr.Timer(1, active=True)
|
1200 |
+
# def check_login(label, last_state):
|
1201 |
+
# logged_in = label.startswith("Logout (")
|
1202 |
+
# # Only update if state changes
|
1203 |
+
# if last_state == logged_in:
|
1204 |
+
# return [gr.skip()] * 13 # skip updating all outputs
|
1205 |
+
# return (
|
1206 |
+
# logged_in, # login_state
|
1207 |
+
# gr.update(visible=not logged_in), # login_required_msg
|
1208 |
+
# gr.update(visible=logged_in), # input
|
1209 |
+
# gr.update(visible=logged_in), # website_url_input
|
1210 |
+
# gr.update(visible=logged_in), # file_input
|
1211 |
+
# gr.update(visible=logged_in), # btn
|
1212 |
+
# gr.update(visible=logged_in), # clear_btn
|
1213 |
+
# gr.update(visible=logged_in), # search_toggle
|
1214 |
+
# gr.update(visible=logged_in), # model_dropdown
|
1215 |
+
# gr.update(visible=logged_in), # quick_examples_col
|
1216 |
+
# gr.update(visible=logged_in), # advanced_accordion
|
1217 |
+
# logged_in, # update last_login_state
|
1218 |
+
# gr.update(visible=logged_in), # language_dropdown
|
1219 |
+
# )
|
1220 |
+
# timer.tick(
|
1221 |
+
# fn=check_login,
|
1222 |
+
# inputs=[login_button, last_login_state],
|
1223 |
+
# outputs=[login_state, login_required_msg, input, website_url_input, file_input, btn, clear_btn, search_toggle, model_dropdown, quick_examples_col, advanced_accordion, last_login_state, language_dropdown]
|
1224 |
+
# )
|
1225 |
|
1226 |
with gr.Column():
|
1227 |
with gr.Tabs():
|