import gradio as gr import numpy as np # Define the function to handle the image editor def handle_image_editor(image): # Placeholder function to handle the image editor return image # Define the function to handle the chatbox def handle_chatbox(message, history): # Placeholder function to handle the chatbox response = "Echo: " + message history.append({"role": "user", "content": message}) history.append({"role": "assistant", "content": response}) return "", history # Define the function to handle the prompt box def handle_prompt_box(prompt, image_generation, checkboxes, slider): # Placeholder function to handle the prompt box return f"Prompt: {prompt}, Image Generation: {image_generation}, Checkboxes: {checkboxes}, Slider: {slider}" # Define the function to handle the model and API accordions def handle_accordions(model, api, settings): # Placeholder function to handle the model and API accordions return f"Model: {model}, API: {api}, Settings: {settings}" # Define the main Gradio app with gr.Blocks(css=""" :root { --primary-800: #1f2937; --secondary-500: #3b82f6; --text-color: #000000; --radius-sm: 8px; } .gr-button { background-color: var(--secondary-500); color: var(--text-color); border-radius: var(--radius-sm); } .gr-button:hover { background-color: #2563eb; } .gr-button:active { background-color: #1d4ed8; } .gr-button:disabled { background-color: #c7d2fe; color: #6b7280; } .gr-button--icon { padding: 0.5rem; } .gr-button--icon img { width: 1rem; height: 1rem; } .gr-image-editor { border: 1px solid var(--secondary-500); border-radius: var(--radius-sm); } .gr-gallery { border: 1px solid var(--secondary-500); border-radius: var(--radius-sm); } .gr-chatbot { border: 1px solid var(--secondary-500); border-radius: var(--radius-sm); } .gr-accordion { border: 1px solid var(--secondary-500); border-radius: var(--radius-sm); } """) as demo: # Top left: 3x Buttons with image icon with gr.Row(): with gr.Column(): hamburger_btn = gr.Button("Hamburger", elem_classes="gr-button--icon") hamburger_btn.click(lambda: gr.Info("Hamburger button clicked"), None, None) color_picker = gr.ColorPicker(value="#3b82f6", label="Color Picker", show_label=False) toggle_dark = gr.Button("Toggle Dark", elem_classes="gr-button--icon") toggle_dark.click(lambda: gr.Info("Dark mode toggled"), None, None) # Main body: square boxes with gr.Row(): with gr.Column(): image_editor = gr.ImageEditor(type="numpy", label="Image Editor", show_download_button=True) image = gr.Image(type="numpy", label="Image", show_download_button=True) gallery = gr.Gallery(columns=4, label="Gallery", show_download_button=True) # Bottom: Chat box with switch with gr.Row(): with gr.Column(): chatbox = gr.Chatbot(type="messages", label="Chatbox") msg = gr.Textbox(label="Message") msg.submit(handle_chatbox, [msg, chatbox], [msg, chatbox]) # Bottom: Prompt box with switch with gr.Row(): with gr.Column(): prompt_box = gr.Textbox(label="Prompt") image_generation = gr.Checkbox(label="Image Generation") checkboxes = gr.CheckboxGroup(["Checkbox 1", "Checkbox 2", "Checkbox 3"], label="Checkboxes") slider = gr.Slider(0, 100, step=1, label="Slider") prompt_box.submit(handle_prompt_box, [prompt_box, image_generation, checkboxes, slider], None) # Bottom: Model, API, and Settings accordions with gr.Row(): with gr.Column(): model_accordion = gr.Accordion("Model", open=False) with model_accordion: model