Spaces:
Running
Running
update to hide import and sidebar
Browse files
app.py
CHANGED
@@ -4072,7 +4072,7 @@ with gr.Blocks(
|
|
4072 |
open_panel = gr.State(None)
|
4073 |
last_login_state = gr.State(None)
|
4074 |
|
4075 |
-
with gr.Sidebar():
|
4076 |
login_button = gr.LoginButton()
|
4077 |
|
4078 |
# Theme Selector (hidden for end users, developers can modify code)
|
@@ -4088,7 +4088,7 @@ with gr.Blocks(
|
|
4088 |
theme_status = gr.Markdown("")
|
4089 |
|
4090 |
# Unified Import section
|
4091 |
-
gr.Markdown("π₯ Import Project (Space, GitHub, or Model)")
|
4092 |
load_project_url = gr.Textbox(
|
4093 |
label="Project URL",
|
4094 |
placeholder="https://huggingface.co/spaces/user/space OR https://huggingface.co/user/model OR https://github.com/owner/repo",
|
@@ -4239,7 +4239,7 @@ with gr.Blocks(
|
|
4239 |
# --- Remove deploy/app name/sdk from bottom column ---
|
4240 |
# (delete the gr.Column() block containing space_name_input, sdk_dropdown, deploy_btn, deploy_status)
|
4241 |
|
4242 |
-
with gr.Column():
|
4243 |
with gr.Tabs():
|
4244 |
with gr.Tab("Code"):
|
4245 |
code_output = gr.Code(
|
@@ -4258,10 +4258,24 @@ with gr.Blocks(
|
|
4258 |
# Keep history_output as hidden component to maintain functionality
|
4259 |
history_output = gr.Chatbot(show_label=False, height=400, type="messages", visible=False)
|
4260 |
|
|
|
|
|
|
|
4261 |
# Unified import handler
|
4262 |
def handle_import_project(url):
|
4263 |
if not url.strip():
|
4264 |
-
return [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4265 |
|
4266 |
kind, meta = _parse_repo_or_model_url(url)
|
4267 |
if kind == "hf_space":
|
@@ -4276,11 +4290,13 @@ with gr.Blocks(
|
|
4276 |
gr.update(value=status, visible=True),
|
4277 |
gr.update(value=code, language=code_lang),
|
4278 |
gr.update(value=""),
|
4279 |
-
gr.update(value=""),
|
4280 |
loaded_history,
|
4281 |
history_to_chatbot_messages(loaded_history),
|
4282 |
gr.update(value=space_info, visible=True),
|
4283 |
-
gr.update(value="Update Existing Space", visible=True)
|
|
|
|
|
4284 |
]
|
4285 |
else:
|
4286 |
# GitHub or HF model β return raw snippet for LLM starting point
|
@@ -4296,11 +4312,13 @@ with gr.Blocks(
|
|
4296 |
gr.update(value=status, visible=True),
|
4297 |
gr.update(value=code, language=code_lang),
|
4298 |
gr.update(value=""),
|
4299 |
-
gr.update(value=""),
|
4300 |
loaded_history,
|
4301 |
history_to_chatbot_messages(loaded_history),
|
4302 |
gr.update(value="", visible=False),
|
4303 |
-
gr.update(value="π Deploy App", visible=False)
|
|
|
|
|
4304 |
]
|
4305 |
|
4306 |
# Import repo/model handler
|
@@ -4405,13 +4423,41 @@ with gr.Blocks(
|
|
4405 |
load_project_btn.click(
|
4406 |
handle_import_project,
|
4407 |
inputs=[load_project_url],
|
4408 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4409 |
)
|
4410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4411 |
btn.click(
|
|
|
|
|
|
|
|
|
|
|
4412 |
generation_code,
|
4413 |
inputs=[input, image_input, file_input, website_url_input, setting, history, current_model, search_toggle, language_dropdown, provider_state, image_generation_toggle, image_to_image_toggle, image_to_image_prompt, text_to_image_prompt],
|
4414 |
outputs=[code_output, history, sandbox, history_output]
|
|
|
|
|
|
|
|
|
4415 |
).then(
|
4416 |
show_deploy_components,
|
4417 |
None,
|
|
|
4072 |
open_panel = gr.State(None)
|
4073 |
last_login_state = gr.State(None)
|
4074 |
|
4075 |
+
with gr.Sidebar() as sidebar:
|
4076 |
login_button = gr.LoginButton()
|
4077 |
|
4078 |
# Theme Selector (hidden for end users, developers can modify code)
|
|
|
4088 |
theme_status = gr.Markdown("")
|
4089 |
|
4090 |
# Unified Import section
|
4091 |
+
import_header_md = gr.Markdown("π₯ Import Project (Space, GitHub, or Model)")
|
4092 |
load_project_url = gr.Textbox(
|
4093 |
label="Project URL",
|
4094 |
placeholder="https://huggingface.co/spaces/user/space OR https://huggingface.co/user/model OR https://github.com/owner/repo",
|
|
|
4239 |
# --- Remove deploy/app name/sdk from bottom column ---
|
4240 |
# (delete the gr.Column() block containing space_name_input, sdk_dropdown, deploy_btn, deploy_status)
|
4241 |
|
4242 |
+
with gr.Column() as main_column:
|
4243 |
with gr.Tabs():
|
4244 |
with gr.Tab("Code"):
|
4245 |
code_output = gr.Code(
|
|
|
4258 |
# Keep history_output as hidden component to maintain functionality
|
4259 |
history_output = gr.Chatbot(show_label=False, height=400, type="messages", visible=False)
|
4260 |
|
4261 |
+
# Global generation status view (disabled placeholder)
|
4262 |
+
generating_status = gr.Markdown("", visible=False)
|
4263 |
+
|
4264 |
# Unified import handler
|
4265 |
def handle_import_project(url):
|
4266 |
if not url.strip():
|
4267 |
+
return [
|
4268 |
+
gr.update(value="Please enter a URL.", visible=True),
|
4269 |
+
gr.update(),
|
4270 |
+
gr.update(),
|
4271 |
+
gr.update(),
|
4272 |
+
[],
|
4273 |
+
[],
|
4274 |
+
gr.update(value="", visible=False),
|
4275 |
+
gr.update(value="π Deploy App", visible=False),
|
4276 |
+
gr.update(), # keep import header as-is
|
4277 |
+
gr.update() # keep import button as-is
|
4278 |
+
]
|
4279 |
|
4280 |
kind, meta = _parse_repo_or_model_url(url)
|
4281 |
if kind == "hf_space":
|
|
|
4290 |
gr.update(value=status, visible=True),
|
4291 |
gr.update(value=code, language=code_lang),
|
4292 |
gr.update(value=""),
|
4293 |
+
gr.update(value="", visible=False), # hide import textbox after submit
|
4294 |
loaded_history,
|
4295 |
history_to_chatbot_messages(loaded_history),
|
4296 |
gr.update(value=space_info, visible=True),
|
4297 |
+
gr.update(value="Update Existing Space", visible=True),
|
4298 |
+
gr.update(visible=False), # hide import header
|
4299 |
+
gr.update(visible=False) # hide import button
|
4300 |
]
|
4301 |
else:
|
4302 |
# GitHub or HF model β return raw snippet for LLM starting point
|
|
|
4312 |
gr.update(value=status, visible=True),
|
4313 |
gr.update(value=code, language=code_lang),
|
4314 |
gr.update(value=""),
|
4315 |
+
gr.update(value="", visible=False), # hide import textbox after submit
|
4316 |
loaded_history,
|
4317 |
history_to_chatbot_messages(loaded_history),
|
4318 |
gr.update(value="", visible=False),
|
4319 |
+
gr.update(value="π Deploy App", visible=False),
|
4320 |
+
gr.update(visible=False), # hide import header
|
4321 |
+
gr.update(visible=False) # hide import button
|
4322 |
]
|
4323 |
|
4324 |
# Import repo/model handler
|
|
|
4423 |
load_project_btn.click(
|
4424 |
handle_import_project,
|
4425 |
inputs=[load_project_url],
|
4426 |
+
outputs=[
|
4427 |
+
load_project_status,
|
4428 |
+
code_output,
|
4429 |
+
sandbox,
|
4430 |
+
load_project_url,
|
4431 |
+
history,
|
4432 |
+
history_output,
|
4433 |
+
space_name_input,
|
4434 |
+
deploy_btn,
|
4435 |
+
import_header_md,
|
4436 |
+
load_project_btn,
|
4437 |
+
],
|
4438 |
)
|
4439 |
|
4440 |
+
def begin_generation_ui():
|
4441 |
+
# Hide only the sidebar; keep main UI visible; do not show any status text
|
4442 |
+
return [gr.update(visible=False), gr.update(visible=False)]
|
4443 |
+
|
4444 |
+
def end_generation_ui():
|
4445 |
+
# Keep sidebar visible but collapsed; hide the status
|
4446 |
+
return [gr.update(visible=True, open=False), gr.update(visible=False)]
|
4447 |
+
|
4448 |
btn.click(
|
4449 |
+
begin_generation_ui,
|
4450 |
+
inputs=None,
|
4451 |
+
outputs=[sidebar, generating_status],
|
4452 |
+
show_progress="hidden",
|
4453 |
+
).then(
|
4454 |
generation_code,
|
4455 |
inputs=[input, image_input, file_input, website_url_input, setting, history, current_model, search_toggle, language_dropdown, provider_state, image_generation_toggle, image_to_image_toggle, image_to_image_prompt, text_to_image_prompt],
|
4456 |
outputs=[code_output, history, sandbox, history_output]
|
4457 |
+
).then(
|
4458 |
+
end_generation_ui,
|
4459 |
+
inputs=None,
|
4460 |
+
outputs=[sidebar, generating_status]
|
4461 |
).then(
|
4462 |
show_deploy_components,
|
4463 |
None,
|