Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ load_dotenv()
|
|
| 9 |
|
| 10 |
# --- 1. SET UP THE GEMINI LLM ---
|
| 11 |
try:
|
| 12 |
-
# Use CrewAI's LLM class with proper format for Gemini
|
| 13 |
llm = LLM(
|
| 14 |
model="gemini/gemini-2.5-flash",
|
| 15 |
temperature=0.6,
|
|
@@ -26,36 +25,94 @@ except Exception as e:
|
|
| 26 |
os.makedirs("outputs", exist_ok=True)
|
| 27 |
file_write_tool = FileWriterTool()
|
| 28 |
|
| 29 |
-
# --- 3. DEFINE THE AGENT TEAM ---
|
| 30 |
designer = Agent(
|
| 31 |
-
role='Principal Brand Designer',
|
| 32 |
-
goal='Translate a user\'s "vibe" into a concrete, professional design brief
|
| 33 |
backstory=(
|
| 34 |
-
"You are a world-class brand designer with
|
| 35 |
-
"You
|
| 36 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
),
|
| 38 |
verbose=True,
|
| 39 |
llm=llm,
|
| 40 |
allow_delegation=False
|
| 41 |
)
|
|
|
|
| 42 |
copywriter = Agent(
|
| 43 |
-
role='Senior UX Copywriter',
|
| 44 |
-
goal='Write compelling,
|
| 45 |
backstory=(
|
| 46 |
-
"You are an expert copywriter who
|
| 47 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
),
|
| 49 |
verbose=True,
|
| 50 |
llm=llm,
|
| 51 |
allow_delegation=False
|
| 52 |
)
|
|
|
|
| 53 |
developer = Agent(
|
| 54 |
-
role='Senior Frontend Developer',
|
| 55 |
-
goal='
|
| 56 |
backstory=(
|
| 57 |
-
"You are
|
| 58 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
),
|
| 60 |
verbose=True,
|
| 61 |
llm=llm,
|
|
@@ -63,57 +120,227 @@ developer = Agent(
|
|
| 63 |
allow_delegation=False
|
| 64 |
)
|
| 65 |
|
| 66 |
-
# --- 4. DEFINE THE WORKFLOW
|
| 67 |
design_task = Task(
|
| 68 |
description=(
|
| 69 |
-
"Analyze the user's prompt: '{prompt}'
|
| 70 |
-
"
|
| 71 |
-
"1.
|
| 72 |
-
"
|
| 73 |
-
"
|
| 74 |
-
"
|
| 75 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
),
|
| 77 |
expected_output=(
|
| 78 |
-
"A structured
|
| 79 |
-
"
|
|
|
|
| 80 |
),
|
| 81 |
agent=designer
|
| 82 |
)
|
|
|
|
| 83 |
copywriting_task = Task(
|
| 84 |
description=(
|
| 85 |
-
"Using the Design Brief, write
|
| 86 |
-
"
|
| 87 |
-
"
|
| 88 |
-
"-
|
| 89 |
-
"-
|
| 90 |
-
"-
|
| 91 |
-
"-
|
| 92 |
-
"
|
| 93 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
),
|
| 95 |
expected_output=(
|
| 96 |
-
"A
|
|
|
|
|
|
|
| 97 |
),
|
| 98 |
agent=copywriter,
|
| 99 |
context=[design_task]
|
| 100 |
)
|
|
|
|
| 101 |
development_task = Task(
|
| 102 |
description=(
|
| 103 |
-
"
|
| 104 |
-
"
|
| 105 |
-
"
|
| 106 |
-
"
|
| 107 |
-
"
|
| 108 |
-
"
|
| 109 |
-
"
|
| 110 |
-
"-
|
| 111 |
-
"-
|
| 112 |
-
"-
|
| 113 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
),
|
| 115 |
expected_output=(
|
| 116 |
-
"A complete,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
),
|
| 118 |
agent=developer,
|
| 119 |
context=[design_task, copywriting_task],
|
|
@@ -164,7 +391,7 @@ def run_crew(prompt):
|
|
| 164 |
# Create preview
|
| 165 |
preview_html = f'<iframe srcdoc="{html_content.replace(chr(34), """)}" width="100%" height="800px" style="border: 2px solid #e0e0e0; border-radius: 8px;"></iframe>'
|
| 166 |
|
| 167 |
-
success_message = "β
**Success!** Your website has been generated and
|
| 168 |
|
| 169 |
return (
|
| 170 |
success_message,
|
|
@@ -190,7 +417,7 @@ def run_crew(prompt):
|
|
| 190 |
except Exception as e:
|
| 191 |
error_trace = traceback.format_exc()
|
| 192 |
error_message = f"β **Error occurred during execution:**\n\n```python\n{str(e)}\n```\n\nPlease try again or check your API keys."
|
| 193 |
-
print(error_trace)
|
| 194 |
return (
|
| 195 |
error_message,
|
| 196 |
None,
|
|
@@ -198,7 +425,7 @@ def run_crew(prompt):
|
|
| 198 |
gr.update(visible=False)
|
| 199 |
)
|
| 200 |
|
| 201 |
-
# --- 7. CREATE THE GRADIO INTERFACE
|
| 202 |
with gr.Blocks(theme=gr.themes.Soft(), css="""
|
| 203 |
.container { max-width: 1400px; margin: auto; }
|
| 204 |
.status-box { padding: 20px; border-radius: 8px; margin: 10px 0; }
|
|
@@ -207,30 +434,33 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 207 |
|
| 208 |
gr.Markdown(
|
| 209 |
"""
|
| 210 |
-
# π¨ Vibe Coder AI
|
| 211 |
-
### Create
|
| 212 |
-
Enter
|
|
|
|
|
|
|
| 213 |
"""
|
| 214 |
)
|
| 215 |
|
| 216 |
with gr.Row():
|
| 217 |
prompt_input = gr.Textbox(
|
| 218 |
lines=4,
|
| 219 |
-
placeholder="Example: A website for my new coffee shop in Brooklyn. The vibe should be cozy, rustic, and artisanal.",
|
| 220 |
label="βοΈ Describe Your Website Vibe",
|
| 221 |
elem_classes="container"
|
| 222 |
)
|
| 223 |
|
| 224 |
with gr.Row():
|
| 225 |
-
generate_btn = gr.Button("π Generate Website", variant="primary", size="lg", scale=1)
|
| 226 |
|
| 227 |
with gr.Row():
|
| 228 |
gr.Examples(
|
| 229 |
examples=[
|
| 230 |
-
["A personal portfolio for a photographer. The vibe should be minimalist, modern, and clean."],
|
| 231 |
-
["A landing page for a new tech startup focused on AI. Vibe: futuristic, sleek, professional."],
|
| 232 |
-
["A website for a local bakery. Vibe: warm, friendly, and homemade."],
|
| 233 |
-
["A fitness coach website. Vibe: energetic, motivating, and bold."]
|
|
|
|
| 234 |
],
|
| 235 |
inputs=prompt_input,
|
| 236 |
label="π‘ Try these examples"
|
|
@@ -245,7 +475,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 245 |
|
| 246 |
with gr.Row():
|
| 247 |
preview_output = gr.HTML(
|
| 248 |
-
label="π₯οΈ Live Preview",
|
| 249 |
visible=True
|
| 250 |
)
|
| 251 |
|
|
@@ -263,10 +493,10 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 263 |
variant="secondary"
|
| 264 |
)
|
| 265 |
|
| 266 |
-
# Hidden code display
|
| 267 |
with gr.Row(visible=False) as code_row:
|
| 268 |
code_output = gr.Code(
|
| 269 |
-
label="π Generated HTML Source Code",
|
| 270 |
language="html",
|
| 271 |
lines=15,
|
| 272 |
elem_classes="container"
|
|
|
|
| 9 |
|
| 10 |
# --- 1. SET UP THE GEMINI LLM ---
|
| 11 |
try:
|
|
|
|
| 12 |
llm = LLM(
|
| 13 |
model="gemini/gemini-2.5-flash",
|
| 14 |
temperature=0.6,
|
|
|
|
| 25 |
os.makedirs("outputs", exist_ok=True)
|
| 26 |
file_write_tool = FileWriterTool()
|
| 27 |
|
| 28 |
+
# --- 3. DEFINE THE AGENT TEAM WITH ENHANCED PROMPTS ---
|
| 29 |
designer = Agent(
|
| 30 |
+
role='Principal Brand & UI/UX Designer',
|
| 31 |
+
goal='Translate a user\'s "vibe" into a concrete, professional design brief with modern UI specifications.',
|
| 32 |
backstory=(
|
| 33 |
+
"You are a world-class brand and UI/UX designer with 15+ years of experience at top tech companies. "
|
| 34 |
+
"You have deep expertise in:\n"
|
| 35 |
+
"- Modern design systems (Material Design, Apple HIG, Fluent Design)\n"
|
| 36 |
+
"- Color theory and accessible color palettes (WCAG AA/AAA compliance)\n"
|
| 37 |
+
"- Typography hierarchies and font pairing psychology\n"
|
| 38 |
+
"- Micro-interactions and motion design principles\n"
|
| 39 |
+
"- Current web design trends (glassmorphism, neumorphism, brutalism, minimalism)\n"
|
| 40 |
+
"- Spacing systems (4px/8px grids, golden ratio)\n"
|
| 41 |
+
"- Visual hierarchy and F/Z-pattern layouts\n\n"
|
| 42 |
+
"You always consider:\n"
|
| 43 |
+
"- User psychology and emotional design\n"
|
| 44 |
+
"- Mobile-first responsive breakpoints\n"
|
| 45 |
+
"- Accessibility (contrast ratios, focus states, ARIA)\n"
|
| 46 |
+
"- Performance (optimized assets, loading strategies)\n"
|
| 47 |
+
"- Brand consistency and design tokens"
|
| 48 |
),
|
| 49 |
verbose=True,
|
| 50 |
llm=llm,
|
| 51 |
allow_delegation=False
|
| 52 |
)
|
| 53 |
+
|
| 54 |
copywriter = Agent(
|
| 55 |
+
role='Senior UX Copywriter & Content Strategist',
|
| 56 |
+
goal='Write compelling, conversion-focused copy that matches brand voice and guides user behavior.',
|
| 57 |
backstory=(
|
| 58 |
+
"You are an expert UX copywriter who combines psychology, marketing, and user experience. "
|
| 59 |
+
"Your expertise includes:\n"
|
| 60 |
+
"- Microcopy that guides users intuitively\n"
|
| 61 |
+
"- Conversion-focused CTAs with action-oriented language\n"
|
| 62 |
+
"- Voice and tone frameworks for brand consistency\n"
|
| 63 |
+
"- SEO-optimized content structure\n"
|
| 64 |
+
"- Accessibility considerations (clear language, screen reader friendly)\n"
|
| 65 |
+
"- Storytelling techniques that create emotional connections\n\n"
|
| 66 |
+
"You follow principles:\n"
|
| 67 |
+
"- Clarity over cleverness\n"
|
| 68 |
+
"- Active voice and direct language\n"
|
| 69 |
+
"- Scannable content with proper heading hierarchy\n"
|
| 70 |
+
"- Benefits-focused rather than features-focused\n"
|
| 71 |
+
"- Appropriate reading level for target audience"
|
| 72 |
),
|
| 73 |
verbose=True,
|
| 74 |
llm=llm,
|
| 75 |
allow_delegation=False
|
| 76 |
)
|
| 77 |
+
|
| 78 |
developer = Agent(
|
| 79 |
+
role='Senior Frontend Developer & UI Engineer',
|
| 80 |
+
goal='Build pixel-perfect, performant, and accessible websites using modern web technologies.',
|
| 81 |
backstory=(
|
| 82 |
+
"You are an elite frontend developer with expertise in modern web development. "
|
| 83 |
+
"Your technical stack and knowledge includes:\n\n"
|
| 84 |
+
"**CSS Frameworks & Libraries:**\n"
|
| 85 |
+
"- Tailwind CSS (utility-first approach, responsive design)\n"
|
| 86 |
+
"- Custom CSS with CSS Grid, Flexbox, and CSS Variables\n"
|
| 87 |
+
"- Modern CSS features (clamp, aspect-ratio, container queries)\n\n"
|
| 88 |
+
"**Animation Libraries:**\n"
|
| 89 |
+
"- AOS (Animate On Scroll) for scroll-triggered animations\n"
|
| 90 |
+
"- CSS animations and transitions (cubic-bezier, keyframes)\n"
|
| 91 |
+
"- Intersection Observer API for performance\n\n"
|
| 92 |
+
"**UI Components:**\n"
|
| 93 |
+
"- Hero sections with parallax/gradient backgrounds\n"
|
| 94 |
+
"- Cards with hover effects and shadows\n"
|
| 95 |
+
"- Smooth scroll navigation with offset\n"
|
| 96 |
+
"- Modal/overlay patterns\n"
|
| 97 |
+
"- Form validation and interactive states\n"
|
| 98 |
+
"- Loading states and skeleton screens\n\n"
|
| 99 |
+
"**Best Practices:**\n"
|
| 100 |
+
"- Semantic HTML5 (proper heading hierarchy, landmarks, ARIA)\n"
|
| 101 |
+
"- Mobile-first responsive design (320px to 4K)\n"
|
| 102 |
+
"- Performance optimization (minimal dependencies, defer/async scripts)\n"
|
| 103 |
+
"- Cross-browser compatibility\n"
|
| 104 |
+
"- SEO meta tags and Open Graph\n"
|
| 105 |
+
"- Accessibility (keyboard navigation, focus management, color contrast)\n"
|
| 106 |
+
"- Clean, maintainable code with comments\n\n"
|
| 107 |
+
"You ALWAYS include:\n"
|
| 108 |
+
"- Tailwind CSS via CDN for rapid, consistent styling\n"
|
| 109 |
+
"- AOS library for smooth scroll animations\n"
|
| 110 |
+
"- Google Fonts with font-display: swap\n"
|
| 111 |
+
"- Responsive images and proper alt text\n"
|
| 112 |
+
"- Smooth scrolling behavior\n"
|
| 113 |
+
"- Hover states and micro-interactions\n"
|
| 114 |
+
"- Mobile hamburger menu when needed\n"
|
| 115 |
+
"- Consistent spacing using design tokens"
|
| 116 |
),
|
| 117 |
verbose=True,
|
| 118 |
llm=llm,
|
|
|
|
| 120 |
allow_delegation=False
|
| 121 |
)
|
| 122 |
|
| 123 |
+
# --- 4. DEFINE THE WORKFLOW WITH ENHANCED TASK DESCRIPTIONS ---
|
| 124 |
design_task = Task(
|
| 125 |
description=(
|
| 126 |
+
"Analyze the user's prompt: '{prompt}' and create a comprehensive Design System Brief.\n\n"
|
| 127 |
+
"**Required Deliverables:**\n\n"
|
| 128 |
+
"1. **Color Palette (5-7 colors with specific usage):**\n"
|
| 129 |
+
" - Primary color (brand identity, CTAs)\n"
|
| 130 |
+
" - Secondary color (accents, highlights)\n"
|
| 131 |
+
" - Background colors (light/dark mode if applicable)\n"
|
| 132 |
+
" - Text colors (headings, body, muted)\n"
|
| 133 |
+
" - Semantic colors (success, warning, error)\n"
|
| 134 |
+
" - Provide exact hex codes and ensure WCAG AA contrast ratios\n\n"
|
| 135 |
+
"2. **Typography System:**\n"
|
| 136 |
+
" - Primary font (headings) from Google Fonts with fallbacks\n"
|
| 137 |
+
" - Secondary font (body text) from Google Fonts with fallbacks\n"
|
| 138 |
+
" - Font size scale (h1: Xpx, h2: Xpx, body: Xpx, small: Xpx)\n"
|
| 139 |
+
" - Line heights and letter spacing recommendations\n"
|
| 140 |
+
" - Font weights to use (300, 400, 600, 700)\n\n"
|
| 141 |
+
"3. **Spacing & Layout System:**\n"
|
| 142 |
+
" - Base spacing unit (4px or 8px)\n"
|
| 143 |
+
" - Section padding/margins (mobile and desktop)\n"
|
| 144 |
+
" - Container max-width\n"
|
| 145 |
+
" - Grid system (columns, gaps)\n\n"
|
| 146 |
+
"4. **UI Components & Patterns:**\n"
|
| 147 |
+
" - Button styles (primary, secondary, ghost)\n"
|
| 148 |
+
" - Card designs with shadows/borders\n"
|
| 149 |
+
" - Navigation style (sticky header, transparent, solid)\n"
|
| 150 |
+
" - Form input styles\n"
|
| 151 |
+
" - Image treatment (rounded corners, shadows, overlays)\n\n"
|
| 152 |
+
"5. **Animation & Interaction Guidelines:**\n"
|
| 153 |
+
" - Scroll animations (fade, slide, zoom)\n"
|
| 154 |
+
" - Hover effects (buttons, cards, links)\n"
|
| 155 |
+
" - Transition timings (fast: 150ms, normal: 300ms, slow: 500ms)\n"
|
| 156 |
+
" - Easing functions to use\n\n"
|
| 157 |
+
"6. **Page Structure:**\n"
|
| 158 |
+
" - Header/Navigation\n"
|
| 159 |
+
" - Hero section (with specific layout description)\n"
|
| 160 |
+
" - 3-5 main content sections with purposes\n"
|
| 161 |
+
" - Footer with sitemap\n\n"
|
| 162 |
+
"7. **Design Style & Aesthetic:**\n"
|
| 163 |
+
" - Overall aesthetic (minimalist, bold, playful, corporate, etc.)\n"
|
| 164 |
+
" - Imagery style (photos, illustrations, abstract)\n"
|
| 165 |
+
" - Border radius approach (sharp, slightly rounded, very rounded)\n"
|
| 166 |
+
" - Shadow style (subtle, pronounced, none)\n"
|
| 167 |
+
" - Any specific design trends to incorporate"
|
| 168 |
),
|
| 169 |
expected_output=(
|
| 170 |
+
"A detailed, structured Design System Brief in markdown format with all 7 sections completed. "
|
| 171 |
+
"Include specific values, measurements, and clear implementation guidelines. "
|
| 172 |
+
"The brief should be detailed enough for a developer to implement without additional questions."
|
| 173 |
),
|
| 174 |
agent=designer
|
| 175 |
)
|
| 176 |
+
|
| 177 |
copywriting_task = Task(
|
| 178 |
description=(
|
| 179 |
+
"Using the Design Brief, write comprehensive, professional website copy.\n\n"
|
| 180 |
+
"**Content Requirements:**\n\n"
|
| 181 |
+
"1. **Hero Section:**\n"
|
| 182 |
+
" - Main headline (6-10 words, powerful, benefit-focused)\n"
|
| 183 |
+
" - Subheadline (15-25 words, supporting the headline)\n"
|
| 184 |
+
" - Primary CTA text (2-4 words, action-oriented)\n"
|
| 185 |
+
" - Secondary CTA text if needed\n\n"
|
| 186 |
+
"2. **About/Value Proposition Section:**\n"
|
| 187 |
+
" - Section headline\n"
|
| 188 |
+
" - 2-3 paragraphs explaining who/what/why (100-150 words)\n"
|
| 189 |
+
" - Key value propositions (3-4 bullet points)\n\n"
|
| 190 |
+
"3. **Features/Services Section:**\n"
|
| 191 |
+
" - Section headline\n"
|
| 192 |
+
" - 3-6 feature/service cards, each with:\n"
|
| 193 |
+
" * Title (3-5 words)\n"
|
| 194 |
+
" * Description (30-50 words)\n"
|
| 195 |
+
" * Icon suggestion (describe the icon)\n\n"
|
| 196 |
+
"4. **Social Proof/Testimonials (if applicable):**\n"
|
| 197 |
+
" - Section headline\n"
|
| 198 |
+
" - 2-3 testimonials with:\n"
|
| 199 |
+
" * Quote (20-40 words)\n"
|
| 200 |
+
" * Name and title/company\n\n"
|
| 201 |
+
"5. **Call-to-Action Section:**\n"
|
| 202 |
+
" - Headline (compelling, urgent)\n"
|
| 203 |
+
" - Supporting text (20-40 words)\n"
|
| 204 |
+
" - CTA button text\n\n"
|
| 205 |
+
"6. **Footer Content:**\n"
|
| 206 |
+
" - Brief tagline or description\n"
|
| 207 |
+
" - Navigation links\n"
|
| 208 |
+
" - Copyright text\n"
|
| 209 |
+
" - Social media platform suggestions\n\n"
|
| 210 |
+
"**Writing Guidelines:**\n"
|
| 211 |
+
"- Match the vibe/tone from the design brief perfectly\n"
|
| 212 |
+
"- Use active voice and power words\n"
|
| 213 |
+
"- Keep sentences concise (max 20 words)\n"
|
| 214 |
+
"- Include emotional triggers appropriate to the brand\n"
|
| 215 |
+
"- Make CTAs clear and action-oriented\n"
|
| 216 |
+
"- Ensure natural keyword integration for SEO\n"
|
| 217 |
+
"- Write at appropriate reading level for target audience"
|
| 218 |
),
|
| 219 |
expected_output=(
|
| 220 |
+
"A complete Content Map in markdown format with all 6 sections filled out. "
|
| 221 |
+
"Content should be polished, professional, and ready to copy-paste into HTML. "
|
| 222 |
+
"Include clear labels for each content piece and its placement on the page."
|
| 223 |
),
|
| 224 |
agent=copywriter,
|
| 225 |
context=[design_task]
|
| 226 |
)
|
| 227 |
+
|
| 228 |
development_task = Task(
|
| 229 |
description=(
|
| 230 |
+
"Build a complete, production-ready, single-file HTML website using modern web technologies.\n\n"
|
| 231 |
+
"**MANDATORY TECHNICAL REQUIREMENTS:**\n\n"
|
| 232 |
+
"1. **HTML Structure:**\n"
|
| 233 |
+
" ```html\n"
|
| 234 |
+
" <!DOCTYPE html>\n"
|
| 235 |
+
" <html lang=\"en\">\n"
|
| 236 |
+
" <head>\n"
|
| 237 |
+
" - Meta charset UTF-8\n"
|
| 238 |
+
" - Viewport meta tag\n"
|
| 239 |
+
" - SEO meta tags (title, description, keywords)\n"
|
| 240 |
+
" - Open Graph tags for social sharing\n"
|
| 241 |
+
" - Favicon (data URI or emoji)\n"
|
| 242 |
+
" - Tailwind CSS CDN: <script src=\"https://cdn.tailwindcss.com\"></script>\n"
|
| 243 |
+
" - Google Fonts from design brief\n"
|
| 244 |
+
" - AOS library:\n"
|
| 245 |
+
" <link href=\"https://unpkg.com/aos@2.3.1/dist/aos.css\" rel=\"stylesheet\">\n"
|
| 246 |
+
" <script src=\"https://unpkg.com/aos@2.3.1/dist/aos.js\"></script>\n"
|
| 247 |
+
" - Custom CSS in <style> tags\n"
|
| 248 |
+
" </head>\n"
|
| 249 |
+
" ```\n\n"
|
| 250 |
+
"2. **CSS Implementation:**\n"
|
| 251 |
+
" - Use Tailwind utility classes for layout, spacing, and responsive design\n"
|
| 252 |
+
" - Define custom CSS variables for colors from design brief:\n"
|
| 253 |
+
" ```css\n"
|
| 254 |
+
" :root {\n"
|
| 255 |
+
" --color-primary: #HEXCODE;\n"
|
| 256 |
+
" --color-secondary: #HEXCODE;\n"
|
| 257 |
+
" --color-text: #HEXCODE;\n"
|
| 258 |
+
" --color-bg: #HEXCODE;\n"
|
| 259 |
+
" /* etc */\n"
|
| 260 |
+
" }\n"
|
| 261 |
+
" ```\n"
|
| 262 |
+
" - Add custom CSS for:\n"
|
| 263 |
+
" * Smooth scroll behavior\n"
|
| 264 |
+
" * Custom button hover effects\n"
|
| 265 |
+
" * Gradient backgrounds if specified\n"
|
| 266 |
+
" * Any design-specific styles not achievable with Tailwind\n\n"
|
| 267 |
+
"3. **Animation Implementation:**\n"
|
| 268 |
+
" - Initialize AOS in script: `AOS.init({duration: 800, once: true});`\n"
|
| 269 |
+
" - Add AOS attributes to elements:\n"
|
| 270 |
+
" * `data-aos=\"fade-up\"` for hero elements\n"
|
| 271 |
+
" * `data-aos=\"fade-in\"` for content sections\n"
|
| 272 |
+
" * `data-aos=\"zoom-in\"` for cards/features\n"
|
| 273 |
+
" * `data-aos=\"slide-up\"` for CTAs\n"
|
| 274 |
+
" - Add CSS transitions for hover effects:\n"
|
| 275 |
+
" * Buttons: transform, shadow, background changes\n"
|
| 276 |
+
" * Cards: lift effect (translateY + shadow)\n"
|
| 277 |
+
" * Links: color/underline transitions\n"
|
| 278 |
+
" - Use staggered animations with `data-aos-delay`\n\n"
|
| 279 |
+
"4. **Responsive Design (Mobile-First):**\n"
|
| 280 |
+
" - Base styles for mobile (320px+)\n"
|
| 281 |
+
" - Tablet breakpoint (768px): `md:` prefix\n"
|
| 282 |
+
" - Desktop breakpoint (1024px): `lg:` prefix\n"
|
| 283 |
+
" - Large desktop (1280px): `xl:` prefix\n"
|
| 284 |
+
" - Test all sections at each breakpoint\n"
|
| 285 |
+
" - Mobile navigation (hamburger menu with smooth toggle)\n\n"
|
| 286 |
+
"5. **Required Sections (use semantic HTML):**\n"
|
| 287 |
+
" - `<header>` with `<nav>` (sticky or fixed)\n"
|
| 288 |
+
" - `<main>` containing:\n"
|
| 289 |
+
" * `<section>` for hero with unique background\n"
|
| 290 |
+
" * `<section>` for about/value prop\n"
|
| 291 |
+
" * `<section>` for features/services (grid layout)\n"
|
| 292 |
+
" * `<section>` for testimonials/social proof (if applicable)\n"
|
| 293 |
+
" * `<section>` for final CTA\n"
|
| 294 |
+
" - `<footer>` with navigation and credits\n\n"
|
| 295 |
+
"6. **UI Components to Implement:**\n"
|
| 296 |
+
" - **Navigation:** Responsive, with smooth scroll to sections, active state\n"
|
| 297 |
+
" - **Buttons:** Primary (filled), Secondary (outline), with hover/active states\n"
|
| 298 |
+
" - **Cards:** For features/services with consistent styling, hover effects\n"
|
| 299 |
+
" - **Hero:** Eye-catching background (gradient/image), centered content\n"
|
| 300 |
+
" - **Forms (if needed):** Styled inputs with focus states, validation-ready\n\n"
|
| 301 |
+
"7. **Accessibility Requirements:**\n"
|
| 302 |
+
" - Semantic HTML5 elements\n"
|
| 303 |
+
" - ARIA labels where needed\n"
|
| 304 |
+
" - Keyboard navigable (focus visible)\n"
|
| 305 |
+
" - Alt text for all images\n"
|
| 306 |
+
" - Sufficient color contrast (test against WCAG)\n"
|
| 307 |
+
" - Skip to content link\n\n"
|
| 308 |
+
"8. **Performance Optimizations:**\n"
|
| 309 |
+
" - Defer non-critical scripts\n"
|
| 310 |
+
" - Use font-display: swap for Google Fonts\n"
|
| 311 |
+
" - Minimize custom CSS/JS\n"
|
| 312 |
+
" - Use CSS transforms for animations (GPU accelerated)\n\n"
|
| 313 |
+
"9. **Code Quality:**\n"
|
| 314 |
+
" - Proper indentation (2 spaces)\n"
|
| 315 |
+
" - Comments for major sections\n"
|
| 316 |
+
" - Clean, readable code\n"
|
| 317 |
+
" - No console errors\n\n"
|
| 318 |
+
"**CRITICAL:** Save the complete, working HTML file to 'outputs/index.html' using FileWriterTool.\n"
|
| 319 |
+
"The file must be immediately viewable in a browser without any modifications.\n\n"
|
| 320 |
+
"**Design Brief Reference:** Use exact colors, fonts, and spacing from the Design Brief.\n"
|
| 321 |
+
"**Content Reference:** Use exact copy from the Content Map.\n\n"
|
| 322 |
+
"Think step-by-step:\n"
|
| 323 |
+
"1. Set up HTML boilerplate with all CDN links\n"
|
| 324 |
+
"2. Define CSS variables for the color palette\n"
|
| 325 |
+
"3. Build header/navigation\n"
|
| 326 |
+
"4. Create hero section with animations\n"
|
| 327 |
+
"5. Build each content section with appropriate Tailwind classes\n"
|
| 328 |
+
"6. Add AOS animations to key elements\n"
|
| 329 |
+
"7. Implement hover effects and transitions\n"
|
| 330 |
+
"8. Build responsive footer\n"
|
| 331 |
+
"9. Add mobile menu functionality if needed\n"
|
| 332 |
+
"10. Test responsive breakpoints\n"
|
| 333 |
+
"11. Save to outputs/index.html"
|
| 334 |
),
|
| 335 |
expected_output=(
|
| 336 |
+
"A complete, self-contained HTML file saved to 'outputs/index.html' that:\n"
|
| 337 |
+
"- Renders perfectly in all modern browsers\n"
|
| 338 |
+
"- Is fully responsive (mobile to 4K)\n"
|
| 339 |
+
"- Includes smooth animations and transitions\n"
|
| 340 |
+
"- Uses Tailwind CSS and AOS library\n"
|
| 341 |
+
"- Implements the exact design and content from previous tasks\n"
|
| 342 |
+
"- Has no errors or missing dependencies\n"
|
| 343 |
+
"- Is production-ready and deployable"
|
| 344 |
),
|
| 345 |
agent=developer,
|
| 346 |
context=[design_task, copywriting_task],
|
|
|
|
| 391 |
# Create preview
|
| 392 |
preview_html = f'<iframe srcdoc="{html_content.replace(chr(34), """)}" width="100%" height="800px" style="border: 2px solid #e0e0e0; border-radius: 8px;"></iframe>'
|
| 393 |
|
| 394 |
+
success_message = "β
**Success!** Your website has been generated with Tailwind CSS and AOS animations. Ready to download!"
|
| 395 |
|
| 396 |
return (
|
| 397 |
success_message,
|
|
|
|
| 417 |
except Exception as e:
|
| 418 |
error_trace = traceback.format_exc()
|
| 419 |
error_message = f"β **Error occurred during execution:**\n\n```python\n{str(e)}\n```\n\nPlease try again or check your API keys."
|
| 420 |
+
print(error_trace)
|
| 421 |
return (
|
| 422 |
error_message,
|
| 423 |
None,
|
|
|
|
| 425 |
gr.update(visible=False)
|
| 426 |
)
|
| 427 |
|
| 428 |
+
# --- 7. CREATE THE GRADIO INTERFACE ---
|
| 429 |
with gr.Blocks(theme=gr.themes.Soft(), css="""
|
| 430 |
.container { max-width: 1400px; margin: auto; }
|
| 431 |
.status-box { padding: 20px; border-radius: 8px; margin: 10px 0; }
|
|
|
|
| 434 |
|
| 435 |
gr.Markdown(
|
| 436 |
"""
|
| 437 |
+
# π¨ Vibe Coder AI - Professional Edition
|
| 438 |
+
### Create stunning websites with Tailwind CSS & AOS Animations
|
| 439 |
+
Enter your website vision, and our AI team will design, write, and code a complete, animated webpage using modern frameworks.
|
| 440 |
+
|
| 441 |
+
**π Powered by:** Tailwind CSS β’ AOS Animations β’ Google Fonts β’ Semantic HTML5
|
| 442 |
"""
|
| 443 |
)
|
| 444 |
|
| 445 |
with gr.Row():
|
| 446 |
prompt_input = gr.Textbox(
|
| 447 |
lines=4,
|
| 448 |
+
placeholder="Example: A website for my new coffee shop in Brooklyn. The vibe should be cozy, rustic, and artisanal with warm colors and smooth animations.",
|
| 449 |
label="βοΈ Describe Your Website Vibe",
|
| 450 |
elem_classes="container"
|
| 451 |
)
|
| 452 |
|
| 453 |
with gr.Row():
|
| 454 |
+
generate_btn = gr.Button("π Generate Professional Website", variant="primary", size="lg", scale=1)
|
| 455 |
|
| 456 |
with gr.Row():
|
| 457 |
gr.Examples(
|
| 458 |
examples=[
|
| 459 |
+
["A personal portfolio for a photographer. The vibe should be minimalist, modern, and clean with elegant fade-in animations."],
|
| 460 |
+
["A landing page for a new tech startup focused on AI. Vibe: futuristic, sleek, professional with bold gradients and smooth scrolling effects."],
|
| 461 |
+
["A website for a local bakery. Vibe: warm, friendly, and homemade with playful animations and pastel colors."],
|
| 462 |
+
["A fitness coach website. Vibe: energetic, motivating, and bold with dynamic animations and vibrant colors."],
|
| 463 |
+
["A luxury real estate agency. Vibe: sophisticated, elegant, minimal with subtle animations and gold accents."]
|
| 464 |
],
|
| 465 |
inputs=prompt_input,
|
| 466 |
label="π‘ Try these examples"
|
|
|
|
| 475 |
|
| 476 |
with gr.Row():
|
| 477 |
preview_output = gr.HTML(
|
| 478 |
+
label="π₯οΈ Live Preview (with animations)",
|
| 479 |
visible=True
|
| 480 |
)
|
| 481 |
|
|
|
|
| 493 |
variant="secondary"
|
| 494 |
)
|
| 495 |
|
| 496 |
+
# Hidden code display
|
| 497 |
with gr.Row(visible=False) as code_row:
|
| 498 |
code_output = gr.Code(
|
| 499 |
+
label="π Generated HTML Source Code (Tailwind CSS + AOS)",
|
| 500 |
language="html",
|
| 501 |
lines=15,
|
| 502 |
elem_classes="container"
|