UI updates
Browse files174 unmodified lines175176177178179180181182183184945 unmodified lines113011311132113311341135113621 unmodified lines1158115911601161116211631164116511661167116811691170117111729 unmodified lines118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123931 unmodified lines12711272127312741275127612771278127912801281128212831284174 unmodified lines"title": "Calculator","description": "Build a basic calculator with addition, subtraction, multiplication, and division"},{"title": "Weather Dashboard","description": "Create a weather dashboard that displays current weather information"},{"title": "Chat Interface","description": "Build a chat interface with message history and user input"945 unmodified linesvisible=True # Always visible)website_url_input = gr.Textbox(label="Website URL for redesign",placeholder="https://example.com",lines=1,visible=True # Always visible21 unmodified lineslabel="Model",visible=True # Always visible)provider_choices = ["auto", "black-forest-labs", "cerebras", "cohere", "fal-ai", "featherless-ai", "fireworks-ai", "groq", "hf-inference", "hyperbolic", "nebius", "novita", "nscale", "openai", "replicate", "sambanova", "together"]provider_dropdown = gr.Dropdown(choices=provider_choices,value="auto",label="Provider",visible=True)provider_state = gr.State("auto")gr.Markdown("**Quick start**", visible=True)with gr.Column(visible=True) as quick_examples_col:9 unmodified lines)if not tavily_client:gr.Markdown("⚠️ Web search unavailable", visible=True)else:gr.Markdown("✅ Web search available", visible=True)model_display = gr.Markdown(f"**Model:** {AVAILABLE_MODELS[0]['name']}", visible=True) # Moonshot Kimi-K2def on_model_change(model_name):for m in AVAILABLE_MODELS:if m['name'] == model_name:return m, f"**Model:** {m['name']}", update_image_input_visibility(m)return AVAILABLE_MODELS[0], f"**Model:** {AVAILABLE_MODELS[0]['name']}", update_image_input_visibility(AVAILABLE_MODELS[0]) # Moonshot Kimi-K2 fallbackdef save_prompt(input):return {setting: {"system": input}}model_dropdown.change(on_model_change,inputs=model_dropdown,outputs=[current_model, model_display, image_input])with gr.Accordion("Advanced", open=False, visible=True) as advanced_accordion:systemPromptInput = gr.Textbox(value=HTML_SYSTEM_PROMPT,label="System prompt",lines=5)save_prompt_btn = gr.Button("Save", variant="primary", size="sm")save_prompt_btn.click(save_prompt, inputs=systemPromptInput, outputs=setting)# Remove login state and timer logic# login_state = gr.State(False)# timer = gr.Timer(1, active=True)# def check_login(label, last_state):# logged_in = label.startswith("Logout (")# # Only update if state changes# if last_state == logged_in:# return [gr.skip()] * 13 # skip updating all outputs# return (# logged_in, # login_state# gr.update(visible=not logged_in), # login_required_msg# gr.update(visible=logged_in), # input# gr.update(visible=logged_in), # website_url_input# gr.update(visible=logged_in), # file_input# gr.update(visible=logged_in), # btn# gr.update(visible=logged_in), # clear_btn# gr.update(visible=logged_in), # search_toggle# gr.update(visible=logged_in), # model_dropdown# gr.update(visible=logged_in), # quick_examples_col# gr.update(visible=logged_in), # advanced_accordion# logged_in, # update last_login_state# gr.update(visible=logged_in), # language_dropdown# )# timer.tick(# fn=check_login,# inputs=[login_button, last_login_state],# 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]# )with gr.Column():with gr.Tabs():31 unmodified lineslanguage_dropdown.change(preview_logic, inputs=[code_output, language_dropdown], outputs=sandbox)clear_btn.click(clear_history, outputs=[history, history_output, file_input, website_url_input])def on_provider_change(provider):return providerprovider_dropdown.change(on_provider_change,inputs=provider_dropdown,outputs=provider_state)if __name__ == "__main__":demo.queue(api_open=False, default_concurrency_limit=20).launch(ssr_mode=True, mcp_server=False, show_api=False)174 unmodified lines175176177178179180945 unmodified lines112611271128112911301131113221 unmodified lines11541155115611571158115911609 unmodified lines1170117111721173117411751176117711781179118011811182118311841185118611871188118931 unmodified lines12211222122312241225174 unmodified lines"title": "Calculator","description": "Build a basic calculator with addition, subtraction, multiplication, and division"},{"title": "Chat Interface","description": "Build a chat interface with message history and user input"945 unmodified linesvisible=True # Always visible)website_url_input = gr.Textbox(label="website for redesign",placeholder="https://example.com",lines=1,visible=True # Always visible21 unmodified lineslabel="Model",visible=True # Always visible)# Remove provider_choices and provider_dropdown, set provider_state to 'auto' onlyprovider_state = gr.State("auto")gr.Markdown("**Quick start**", visible=True)with gr.Column(visible=True) as quick_examples_col:9 unmodified lines)if not tavily_client:gr.Markdown("⚠️ Web search unavailable", visible=True)# Remove model display and web search available linedef on_model_change(model_name):for m in AVAILABLE_MODELS:if m['name'] == model_name:return m, update_image_input_visibility(m)return AVAILABLE_MODELS[0], update_image_input_visibility(AVAILABLE_MODELS[0]) # Moonshot Kimi-K2 fallbackdef save_prompt(input):return {setting: {"system": input}}model_dropdown.change(lambda model_name: on_model_change(model_name),inputs=model_dropdown,outputs=[current_model, image_input])# Remove the Advanced accordion and system prompt editing UIwith gr.Column():with gr.Tabs():31 unmodified lineslanguage_dropdown.change(preview_logic, inputs=[code_output, language_dropdown], outputs=sandbox)clear_btn.click(clear_history, outputs=[history, history_output, file_input, website_url_input])if __name__ == "__main__":demo.queue(api_open=False, default_concurrency_limit=20).launch(ssr_mode=True, mcp_server=False, show_api=False)
app.py+8-67