AiCoderv2/quick-bright-demo
0
1import gradio as gr2from utils import generate_website_code, preview_website3 4with gr.Blocks(theme=gr.themes.Soft(), title="AI Website Builder") as demo:5 gr.Markdown("""6 # 🤖 AI Website Builder7 Create stunning websites using powerful Hugging Face models. Preview your code in real-time!8 9 [Built with anycoder](https://huggingface.co/spaces/akhaliq/anycoder)10 """)11 12 with gr.Row():13 with gr.Column(scale=1):14 prompt = gr.Textbox(15 label="Describe your website",16 placeholder="E.g., 'A modern portfolio website for a photographer with a dark theme'",17 lines=318 )19 20 model_choice = gr.Dropdown(21 choices=[22 "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",23 "Salesforce/codegen-350M-mono",24 "Salesforce/codegen-2B-mono",25 "bigcode/starcoder",26 "meta-llama/Llama-2-70b-chat-hf",27 "meta-llama/Llama-2-13b-chat-hf",28 "mistralai/Mistral-7B-Instruct-v0.2",29 "HuggingFaceH4/zephyr-7b-beta",30 "google/gemma-7b-it",31 "microsoft/Phi-3-mini-4k-instruct"32 ],33 value="Salesforce/codegen-2B-mono",34 label="Choose AI Model"35 )36 37 generate_btn = gr.Button("Generate Website", variant="primary")38 39 with gr.Column(scale=2):40 with gr.Tab("Code"):41 code_output = gr.Code(42 label="Generated HTML/CSS/JS",43 language="html",44 interactive=True,45 lines=2046 )47 with gr.Tab("Preview"):48 preview_output = gr.HTML(label="Website Preview")49 50 with gr.Row():51 with gr.Column():52 gr.Examples(53 examples=[54 ["A simple landing page for a startup with a blue theme"],55 ["A personal blog with a clean, minimalist design"],56 ["An e-commerce product showcase page with cards"],57 ["A restaurant menu with images and pricing"],58 ],59 inputs=[prompt]60 )61 62 generate_btn.click(63 generate_website_code,64 inputs=[prompt, model_choice],65 outputs=code_output66 ).then(67 preview_website,68 inputs=code_output,69 outputs=preview_output70 )71 72 code_output.change(73 preview_website,74 inputs=code_output,75 outputs=preview_output76 )77 78demo.launch()