update to hide import and sidebar
Browse files4071 unmodified lines40724073407440754076407740789 unmodified lines4088408940904091409240934094144 unmodified lines423942404241424242434244424512 unmodified lines42584259426042614262426342644265426642678 unmodified lines427642774278427942804281428242834284428542869 unmodified lines4296429742984299430043014302430343044305430698 unmodified lines44054406440744084409441044114412441344144415441644174071 unmodified linesopen_panel = gr.State(None)last_login_state = gr.State(None)with gr.Sidebar():login_button = gr.LoginButton()# Theme Selector (hidden for end users, developers can modify code)9 unmodified linestheme_status = gr.Markdown("")# Unified Import sectiongr.Markdown("π₯ Import Project (Space, GitHub, or Model)")load_project_url = gr.Textbox(label="Project URL",placeholder="https://huggingface.co/spaces/user/space OR https://huggingface.co/user/model OR https://github.com/owner/repo",144 unmodified lines# --- Remove deploy/app name/sdk from bottom column ---# (delete the gr.Column() block containing space_name_input, sdk_dropdown, deploy_btn, deploy_status)with gr.Column():with gr.Tabs():with gr.Tab("Code"):code_output = gr.Code(12 unmodified lines# Keep history_output as hidden component to maintain functionalityhistory_output = gr.Chatbot(show_label=False, height=400, type="messages", visible=False)# Unified import handlerdef handle_import_project(url):if not url.strip():return [gr.update(value="Please enter a URL.", visible=True), gr.update(), gr.update(), gr.update(), [], [], gr.update(value="", visible=False), gr.update(value="π Deploy App", visible=False)]kind, meta = _parse_repo_or_model_url(url)if kind == "hf_space":8 unmodified linesgr.update(value=status, visible=True),gr.update(value=code, language=code_lang),gr.update(value=""),gr.update(value=""),loaded_history,history_to_chatbot_messages(loaded_history),gr.update(value=space_info, visible=True),gr.update(value="Update Existing Space", visible=True)]else:# GitHub or HF model β return raw snippet for LLM starting point9 unmodified linesgr.update(value=status, visible=True),gr.update(value=code, language=code_lang),gr.update(value=""),gr.update(value=""),loaded_history,history_to_chatbot_messages(loaded_history),gr.update(value="", visible=False),gr.update(value="π Deploy App", visible=False)]# Import repo/model handler98 unmodified linesload_project_btn.click(handle_import_project,inputs=[load_project_url],outputs=[load_project_status, code_output, sandbox, load_project_url, history, history_output, space_name_input, deploy_btn])btn.click(generation_code,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],outputs=[code_output, history, sandbox, history_output]).then(show_deploy_components,None,4071 unmodified lines40724073407440754076407740789 unmodified lines4088408940904091409240934094144 unmodified lines423942404241424242434244424512 unmodified lines4258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042818 unmodified lines42904291429242934294429542964297429842994300430143029 unmodified lines431243134314431543164317431843194320432143224323432498 unmodified lines442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634071 unmodified linesopen_panel = gr.State(None)last_login_state = gr.State(None)with gr.Sidebar() as sidebar:login_button = gr.LoginButton()# Theme Selector (hidden for end users, developers can modify code)9 unmodified linestheme_status = gr.Markdown("")# Unified Import sectionimport_header_md = gr.Markdown("π₯ Import Project (Space, GitHub, or Model)")load_project_url = gr.Textbox(label="Project URL",placeholder="https://huggingface.co/spaces/user/space OR https://huggingface.co/user/model OR https://github.com/owner/repo",144 unmodified lines# --- Remove deploy/app name/sdk from bottom column ---# (delete the gr.Column() block containing space_name_input, sdk_dropdown, deploy_btn, deploy_status)with gr.Column() as main_column:with gr.Tabs():with gr.Tab("Code"):code_output = gr.Code(12 unmodified lines# Keep history_output as hidden component to maintain functionalityhistory_output = gr.Chatbot(show_label=False, height=400, type="messages", visible=False)# Global generation status view (disabled placeholder)generating_status = gr.Markdown("", visible=False)# Unified import handlerdef handle_import_project(url):if not url.strip():return [gr.update(value="Please enter a URL.", visible=True),gr.update(),gr.update(),gr.update(),[],[],gr.update(value="", visible=False),gr.update(value="π Deploy App", visible=False),gr.update(), # keep import header as-isgr.update() # keep import button as-is]kind, meta = _parse_repo_or_model_url(url)if kind == "hf_space":8 unmodified linesgr.update(value=status, visible=True),gr.update(value=code, language=code_lang),gr.update(value=""),gr.update(value="", visible=False), # hide import textbox after submitloaded_history,history_to_chatbot_messages(loaded_history),gr.update(value=space_info, visible=True),gr.update(value="Update Existing Space", visible=True),gr.update(visible=False), # hide import headergr.update(visible=False) # hide import button]else:# GitHub or HF model β return raw snippet for LLM starting point9 unmodified linesgr.update(value=status, visible=True),gr.update(value=code, language=code_lang),gr.update(value=""),gr.update(value="", visible=False), # hide import textbox after submitloaded_history,history_to_chatbot_messages(loaded_history),gr.update(value="", visible=False),gr.update(value="π Deploy App", visible=False),gr.update(visible=False), # hide import headergr.update(visible=False) # hide import button]# Import repo/model handler98 unmodified linesload_project_btn.click(handle_import_project,inputs=[load_project_url],outputs=[load_project_status,code_output,sandbox,load_project_url,history,history_output,space_name_input,deploy_btn,import_header_md,load_project_btn,],)def begin_generation_ui():# Hide only the sidebar; keep main UI visible; do not show any status textreturn [gr.update(visible=False), gr.update(visible=False)]def end_generation_ui():# Keep sidebar visible but collapsed; hide the statusreturn [gr.update(visible=True, open=False), gr.update(visible=False)]btn.click(begin_generation_ui,inputs=None,outputs=[sidebar, generating_status],show_progress="hidden",).then(generation_code,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],outputs=[code_output, history, sandbox, history_output]).then(end_generation_ui,inputs=None,outputs=[sidebar, generating_status]).then(show_deploy_components,None,
app.py+55-9