import gradio as gr from transformers import AutoModelForCausalLM, AutoTokenizer import time import os from utils.zip_generator import create_zip from utils.code_explainer import explain_code # Load the AI model (using DeepSeek Coder 1.3B as default) MODEL_NAME = "deepseek-ai/deepseek-coder-1.3b" tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) model = AutoModelForCausalLM.from_pretrained(MODEL_NAME) # Predefined prompts for common website types PREBUILT_PROMPTS = { "Portfolio": "Create a modern portfolio website with dark mode toggle, hero section, about me, projects grid, and contact form. Use Tailwind CSS for styling.", "Blog": "Build a blog homepage with responsive navbar, featured post section, article cards grid, and newsletter subscription. Make it minimalist and elegant.", "Landing Page": "Design a one-page landing page for a SaaS product with hero section, features, testimonials, pricing table, and CTA button. Use bright colors.", "E-commerce": "Create an e-commerce product page with image gallery, product details, add to cart button, and related products section. Make it mobile-friendly." } def generate_website(prompt, use_prebuilt=False, explain=False): start_time = time.time() # Use prebuilt prompt if selected if use_prebuilt and prompt in PREBUILT_PROMPTS: prompt = PREBUILT_PROMPTS[prompt] # Construct the full prompt for the AI full_prompt = f"""Create a complete, responsive website based on this description: {prompt} Requirements: - Use HTML, CSS, and minimal JavaScript - Make it mobile-friendly - Include all necessary UI elements - Add comments in the code Here's the complete code: