Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,500 +7,745 @@ import traceback
|
|
| 7 |
import shutil
|
| 8 |
import glob
|
| 9 |
import json
|
|
|
|
| 10 |
|
| 11 |
load_dotenv()
|
| 12 |
|
| 13 |
-
# --- SYSTEM
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 52 |
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
-
|
| 57 |
-
-
|
| 58 |
-
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
science, legal, estate, restaurant, retail, wellness, agriculture, construction, craft, cosmetic,
|
| 62 |
-
automotive, gaming, or education
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
- Team photos: http://static.photos/people/320x240/[1-6] (use different seeds)
|
| 67 |
-
- Product cards: http://static.photos/technology/640x360/100
|
| 68 |
-
- Background: http://static.photos/abstract/1200x630/777
|
| 69 |
-
- Testimonial avatars: http://static.photos/people/200x200/[201-203]
|
| 70 |
-
- Gallery: http://static.photos/nature/640x360/[301-306]
|
| 71 |
|
| 72 |
-
|
| 73 |
-
- Use consistent seeds within sections for cohesive design
|
| 74 |
-
- Match category to content (e.g., 'office' for corporate, 'food' for restaurant)
|
| 75 |
-
- Hero images: Use 1200x630 for full-width sections
|
| 76 |
-
- Cards/Features: Use 640x360 for medium-sized images
|
| 77 |
-
- Thumbnails: Use 320x240 or 200x200 for small images
|
| 78 |
-
- Always include descriptive alt text
|
| 79 |
-
- Add loading="lazy" for performance
|
| 80 |
"""
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
"""
|
| 93 |
|
| 94 |
-
# ---
|
| 95 |
try:
|
| 96 |
llm = LLM(
|
| 97 |
model="gemini/gemini-2.0-flash-exp",
|
| 98 |
-
temperature=0.
|
| 99 |
api_key=os.environ.get("GOOGLE_API_KEY")
|
| 100 |
)
|
| 101 |
except Exception as e:
|
| 102 |
-
print("
|
| 103 |
-
print("Error initializing Gemini LLM. Make sure you have set your GOOGLE_API_KEY.")
|
| 104 |
-
print(f"Error: {e}")
|
| 105 |
-
print("---\n\n")
|
| 106 |
llm = None
|
| 107 |
|
| 108 |
-
# --- 2. DEFINE TOOLS AND OUTPUT DIRECTORY ---
|
| 109 |
os.makedirs("outputs", exist_ok=True)
|
| 110 |
file_write_tool = FileWriterTool()
|
| 111 |
|
| 112 |
-
# ---
|
| 113 |
designer = Agent(
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
| 137 |
)
|
| 138 |
|
| 139 |
copywriter = Agent(
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
allow_delegation=False
|
| 162 |
)
|
| 163 |
|
| 164 |
developer = Agent(
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
"- Cross-browser compatibility\n"
|
| 195 |
-
"- SEO meta tags and Open Graph\n"
|
| 196 |
-
"- Accessibility (keyboard navigation, focus management, color contrast)\n"
|
| 197 |
-
"- Clean, maintainable code with comments\n\n"
|
| 198 |
-
"You ALWAYS include:\n"
|
| 199 |
-
"- Tailwind CSS via CDN for rapid, consistent styling\n"
|
| 200 |
-
"- AOS library for smooth scroll animations\n"
|
| 201 |
-
"- Google Fonts with font-display: swap\n"
|
| 202 |
-
"- Responsive images and proper alt text\n"
|
| 203 |
-
"- Smooth scrolling behavior\n"
|
| 204 |
-
"- Hover states and micro-interactions\n"
|
| 205 |
-
"- Mobile hamburger menu when needed\n"
|
| 206 |
-
"- Consistent spacing using design tokens\n\n"
|
| 207 |
-
f"IMAGE IMPLEMENTATION:\n{PROMPT_FOR_IMAGE_GENERATION}"
|
| 208 |
-
),
|
| 209 |
-
verbose=True,
|
| 210 |
-
llm=llm,
|
| 211 |
-
tools=[file_write_tool],
|
| 212 |
-
allow_delegation=False
|
| 213 |
)
|
| 214 |
|
| 215 |
-
# ---
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
|
|
|
| 287 |
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
" * Name and title/company\n\n"
|
| 317 |
-
"6. **Call-to-Action Section:**\n"
|
| 318 |
-
" - Headline (compelling, urgent)\n"
|
| 319 |
-
" - Supporting text (20-40 words)\n"
|
| 320 |
-
" - CTA button text\n\n"
|
| 321 |
-
"7. **Footer Content:**\n"
|
| 322 |
-
" - Brief tagline or description\n"
|
| 323 |
-
" - Navigation links (for all pages if multi-page)\n"
|
| 324 |
-
" - Copyright text with project name\n"
|
| 325 |
-
" - Social media platform suggestions\n\n"
|
| 326 |
-
"8. **Additional Pages Content (if multi-page):**\n"
|
| 327 |
-
" - Content for each additional page specified in the Design Brief\n"
|
| 328 |
-
" - Maintain consistent voice and tone\n"
|
| 329 |
-
" - Include page-specific CTAs and navigation\n\n"
|
| 330 |
-
"**Writing Guidelines:**\n"
|
| 331 |
-
"- Match the vibe/tone from the design brief perfectly\n"
|
| 332 |
-
"- Use active voice and power words\n"
|
| 333 |
-
"- Keep sentences concise (max 20 words)\n"
|
| 334 |
-
"- Include emotional triggers appropriate to the brand\n"
|
| 335 |
-
"- Make CTAs clear and action-oriented\n"
|
| 336 |
-
"- Ensure natural keyword integration for SEO\n"
|
| 337 |
-
"- Write at appropriate reading level for target audience"
|
| 338 |
-
),
|
| 339 |
-
expected_output=(
|
| 340 |
-
"A complete Content Map in markdown format with all sections filled out. "
|
| 341 |
-
"The project name with emoji should be prominently featured. "
|
| 342 |
-
"Content should be polished, professional, and ready to copy-paste into HTML. "
|
| 343 |
-
"Include clear labels for each content piece and its placement on the page. "
|
| 344 |
-
"If multi-page, provide content for all pages specified in the Design Brief."
|
| 345 |
-
),
|
| 346 |
-
agent=copywriter,
|
| 347 |
-
context=[design_task]
|
| 348 |
-
)
|
| 349 |
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
" - Use Tailwind utility classes for layout, spacing, and responsive design\n"
|
| 386 |
-
" - Define custom CSS variables for colors from design brief:\n"
|
| 387 |
-
" ```css\n"
|
| 388 |
-
" :root {\n"
|
| 389 |
-
" --color-primary: #HEXCODE;\n"
|
| 390 |
-
" --color-secondary: #HEXCODE;\n"
|
| 391 |
-
" --color-text: #HEXCODE;\n"
|
| 392 |
-
" --color-bg: #HEXCODE;\n"
|
| 393 |
-
" /* etc */\n"
|
| 394 |
-
" }\n"
|
| 395 |
-
" ```\n"
|
| 396 |
-
" - Add custom CSS for:\n"
|
| 397 |
-
" * Smooth scroll behavior\n"
|
| 398 |
-
" * Custom button hover effects\n"
|
| 399 |
-
" * Gradient backgrounds if specified\n"
|
| 400 |
-
" * Any design-specific styles not achievable with Tailwind\n\n"
|
| 401 |
-
"4. **Image Implementation:**\n"
|
| 402 |
-
" - Use the exact static.photos URLs from the Design Brief\n"
|
| 403 |
-
" - Format: <img src=\"http://static.photos/[category]/[dimensions]/[seed]\" alt=\"[description]\">\n"
|
| 404 |
-
" - Include proper alt text for all images\n"
|
| 405 |
-
" - Add loading=\"lazy\" for performance (except hero images)\n"
|
| 406 |
-
" - Add class=\"w-full h-auto\" for responsive images\n"
|
| 407 |
-
" - Example hero: <img src=\"http://static.photos/gradient/1200x630/42\" alt=\"Hero background\" class=\"w-full h-auto\">\n"
|
| 408 |
-
" - Example card: <img src=\"http://static.photos/technology/640x360/100\" alt=\"Feature image\" class=\"w-full h-auto rounded-lg\">\n\n"
|
| 409 |
-
"5. **Animation Implementation:**\n"
|
| 410 |
-
" - Initialize AOS in script: `AOS.init({duration: 800, once: true});`\n"
|
| 411 |
-
" - Add AOS attributes to elements:\n"
|
| 412 |
-
" * `data-aos=\"fade-up\"` for hero elements\n"
|
| 413 |
-
" * `data-aos=\"fade-in\"` for content sections\n"
|
| 414 |
-
" * `data-aos=\"zoom-in\"` for cards/features\n"
|
| 415 |
-
" * `data-aos=\"slide-up\"` for CTAs\n"
|
| 416 |
-
" - Add CSS transitions for hover effects:\n"
|
| 417 |
-
" * Buttons: transform, shadow, background changes\n"
|
| 418 |
-
" * Cards: lift effect (translateY + shadow)\n"
|
| 419 |
-
" * Links: color/underline transitions\n"
|
| 420 |
-
" - Use staggered animations with `data-aos-delay`\n\n"
|
| 421 |
-
"6. **Responsive Design (Mobile-First):**\n"
|
| 422 |
-
" - Base styles for mobile (320px+)\n"
|
| 423 |
-
" - Tablet breakpoint (768px): `md:` prefix\n"
|
| 424 |
-
" - Desktop breakpoint (1024px): `lg:` prefix\n"
|
| 425 |
-
" - Large desktop (1280px): `xl:` prefix\n"
|
| 426 |
-
" - Test all sections at each breakpoint\n"
|
| 427 |
-
" - Mobile navigation (hamburger menu with smooth toggle)\n\n"
|
| 428 |
-
"7. **Required Sections (use semantic HTML):**\n"
|
| 429 |
-
" - `<header>` with `<nav>` (sticky or fixed)\n"
|
| 430 |
-
" - `<main>` containing:\n"
|
| 431 |
-
" * `<section>` for hero with unique background\n"
|
| 432 |
-
" * `<section>` for about/value prop\n"
|
| 433 |
-
" * `<section>` for features/services (grid layout)\n"
|
| 434 |
-
" * `<section>` for testimonials/social proof (if applicable)\n"
|
| 435 |
-
" * `<section>` for final CTA\n"
|
| 436 |
-
" - `<footer>` with navigation and credits\n\n"
|
| 437 |
-
"8. **File Saving Instructions:**\n"
|
| 438 |
-
" - Single-page: Save to 'outputs/index.html'\n"
|
| 439 |
-
" - Multi-page: Save each page with descriptive names\n"
|
| 440 |
-
" - Ensure all internal links work correctly\n"
|
| 441 |
-
" - Test navigation between pages\n\n"
|
| 442 |
-
"9. **Accessibility Requirements:**\n"
|
| 443 |
-
" - Semantic HTML5 elements\n"
|
| 444 |
-
" - ARIA labels where needed\n"
|
| 445 |
-
" - Keyboard navigable (focus visible)\n"
|
| 446 |
-
" - Alt text for all images\n"
|
| 447 |
-
" - Sufficient color contrast (test against WCAG)\n"
|
| 448 |
-
" - Skip to content link\n\n"
|
| 449 |
-
"10. **Code Quality:**\n"
|
| 450 |
-
" - Proper indentation (2 spaces)\n"
|
| 451 |
-
" - Comments for major sections\n"
|
| 452 |
-
" - Clean, readable code\n"
|
| 453 |
-
" - No console errors\n\n"
|
| 454 |
-
"**CRITICAL:** Save all HTML files to 'outputs/' directory using FileWriterTool.\n"
|
| 455 |
-
"Files must be immediately viewable in a browser without any modifications.\n"
|
| 456 |
-
"Images must use static.photos URLs exactly as specified in the Design Brief.\n\n"
|
| 457 |
-
"**Design Brief Reference:** Use exact colors, fonts, spacing, images, and project name from the Design Brief.\n"
|
| 458 |
-
"**Content Reference:** Use exact copy from the Content Map.\n\n"
|
| 459 |
-
"Think step-by-step:\n"
|
| 460 |
-
"1. Identify if single-page or multi-page from Design Brief\n"
|
| 461 |
-
"2. Set up HTML boilerplate with all CDN links\n"
|
| 462 |
-
"3. Define CSS variables for the color palette\n"
|
| 463 |
-
"4. Build header/navigation (with multi-page links if applicable)\n"
|
| 464 |
-
"5. Create hero section with static.photos image and animations\n"
|
| 465 |
-
"6. Build each content section with appropriate Tailwind classes\n"
|
| 466 |
-
"7. Add static.photos images with proper dimensions\n"
|
| 467 |
-
"8. Add AOS animations to key elements\n"
|
| 468 |
-
"9. Implement hover effects and transitions\n"
|
| 469 |
-
"10. Build responsive footer\n"
|
| 470 |
-
"11. Add mobile menu functionality\n"
|
| 471 |
-
"12. For multi-page: Repeat for each additional page\n"
|
| 472 |
-
"13. Test responsive breakpoints\n"
|
| 473 |
-
"14. Save all files to outputs/ directory"
|
| 474 |
-
),
|
| 475 |
-
expected_output=(
|
| 476 |
-
"Complete, self-contained HTML file(s) saved to 'outputs/' directory that:\n"
|
| 477 |
-
"- Renders perfectly in all modern browsers\n"
|
| 478 |
-
"- Is fully responsive (mobile to 4K)\n"
|
| 479 |
-
"- Includes smooth animations and transitions\n"
|
| 480 |
-
"- Uses Tailwind CSS and AOS library\n"
|
| 481 |
-
"- Implements the exact design and content from previous tasks\n"
|
| 482 |
-
"- Uses static.photos images with correct dimensions\n"
|
| 483 |
-
"- Uses the project name consistently\n"
|
| 484 |
-
"- Has working navigation for multi-page projects\n"
|
| 485 |
-
"- Has no errors or missing dependencies\n"
|
| 486 |
-
"- Is production-ready and deployable"
|
| 487 |
-
),
|
| 488 |
-
agent=developer,
|
| 489 |
-
context=[design_task, copywriting_task],
|
| 490 |
-
tools=[file_write_tool]
|
| 491 |
-
)
|
| 492 |
|
| 493 |
-
# ---
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
|
| 501 |
-
|
|
|
|
|
|
|
| 502 |
def clean_outputs_directory():
|
| 503 |
-
"""Clean the outputs directory
|
| 504 |
if os.path.exists("outputs"):
|
| 505 |
for file in glob.glob("outputs/*"):
|
| 506 |
try:
|
|
@@ -509,13 +754,10 @@ def clean_outputs_directory():
|
|
| 509 |
print(f"Error removing {file}: {e}")
|
| 510 |
|
| 511 |
def create_zip_archive():
|
| 512 |
-
"""Create a ZIP archive of
|
| 513 |
try:
|
| 514 |
-
# Get all HTML files in outputs directory
|
| 515 |
html_files = glob.glob("outputs/*.html")
|
| 516 |
-
|
| 517 |
if len(html_files) > 1:
|
| 518 |
-
# Create ZIP file
|
| 519 |
shutil.make_archive("outputs/project", 'zip', "outputs")
|
| 520 |
return "outputs/project.zip"
|
| 521 |
return None
|
|
@@ -523,126 +765,158 @@ def create_zip_archive():
|
|
| 523 |
print(f"Error creating ZIP: {e}")
|
| 524 |
return None
|
| 525 |
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
try:
|
| 529 |
-
# Look for emoji + project name pattern
|
| 530 |
-
import re
|
| 531 |
-
pattern = r'([๐๐จ๐ซ๐โจ๐ฏ๐ฅ๐๐๐ญ๐ช๐ธ๐ฌ๐ฎ๐ฏ๐ผ๐๐ธ๐ฆ๐๐๐๏ธ๐๐ ๐๏ธ๐ฐ๐ต๐ณ๐๐๐จ๐ฑ๐ช๐๐ต๐๐ ๐๐๐ฎโ๐ท๐ข๐ฟ๐ฌ๐ฅ๐จ๐๐ญโ๏ธ๐๏ธ๐][^\n]*(?:Pro|Studio|Hub|Lab|Plus|App|Site|Portal|Platform|Space|Zone|World|Center|Market|Shop|Store|Pages?))'
|
| 532 |
-
match = re.search(pattern, str(result_text))
|
| 533 |
-
if match:
|
| 534 |
-
return match.group(1).strip()
|
| 535 |
-
return "โจ Awesome Project"
|
| 536 |
-
except:
|
| 537 |
-
return "โจ Awesome Project"
|
| 538 |
-
|
| 539 |
-
# --- 7. CREATE THE GRADIO WEB INTERFACE ---
|
| 540 |
-
def run_crew(prompt, use_template):
|
| 541 |
try:
|
| 542 |
if llm is None:
|
| 543 |
return (
|
| 544 |
-
"โ **Error:** Gemini LLM not initialized. Please check your GOOGLE_API_KEY
|
| 545 |
-
None,
|
| 546 |
-
gr.update(visible=False),
|
| 547 |
-
gr.update(visible=False),
|
| 548 |
-
gr.update(visible=False),
|
| 549 |
-
""
|
| 550 |
)
|
| 551 |
|
| 552 |
-
#
|
| 553 |
-
if
|
| 554 |
-
|
| 555 |
-
elif not use_template and prompt and prompt.strip() != "":
|
| 556 |
-
final_prompt = prompt
|
| 557 |
else:
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
|
| 567 |
-
|
|
|
|
|
|
|
| 568 |
clean_outputs_directory()
|
| 569 |
|
| 570 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 571 |
|
| 572 |
-
#
|
| 573 |
-
|
| 574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
|
| 576 |
-
|
| 577 |
-
project_name = extract_project_name(result)
|
| 578 |
-
print(f"\nโ
Project Name: {project_name}")
|
| 579 |
|
| 580 |
-
# Check
|
| 581 |
html_files = glob.glob("outputs/*.html")
|
| 582 |
-
|
| 583 |
if not html_files:
|
| 584 |
return (
|
| 585 |
-
"โ
|
| 586 |
-
None,
|
| 587 |
-
gr.update(visible=False),
|
| 588 |
-
gr.update(visible=False),
|
| 589 |
-
gr.update(visible=False),
|
| 590 |
-
""
|
| 591 |
)
|
| 592 |
|
| 593 |
-
#
|
| 594 |
-
is_multipage = len(html_files) > 1
|
| 595 |
-
|
| 596 |
-
# Create preview (show index.html or first file)
|
| 597 |
preview_file = "outputs/index.html" if os.path.exists("outputs/index.html") else html_files[0]
|
| 598 |
with open(preview_file, "r", encoding="utf-8") as file:
|
| 599 |
html_content = file.read()
|
| 600 |
|
| 601 |
preview_html = f'<iframe srcdoc="{html_content.replace(chr(34), """)}" width="100%" height="800px" style="border: 2px solid #e0e0e0; border-radius: 8px;"></iframe>'
|
| 602 |
|
| 603 |
-
# Prepare
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 604 |
if is_multipage:
|
| 605 |
-
file_list = ", ".join([os.path.basename(f) for f in html_files])
|
| 606 |
-
success_message = f"โ
**Project Generated: {project_name}**\n\nMulti-page website created with {len(html_files)} pages: {file_list}"
|
| 607 |
-
|
| 608 |
-
# Create ZIP archive
|
| 609 |
zip_path = create_zip_archive()
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
project_name
|
| 618 |
-
)
|
| 619 |
else:
|
| 620 |
-
success_message = f"โ
**Project Generated: {project_name}**\n\nSingle-page website ready to download!"
|
| 621 |
return (
|
| 622 |
success_message,
|
| 623 |
preview_html,
|
| 624 |
-
gr.update(value=preview_file, visible=True
|
| 625 |
gr.update(visible=False),
|
| 626 |
-
gr.update(visible=True)
|
| 627 |
-
project_name
|
| 628 |
)
|
| 629 |
-
|
| 630 |
except Exception as e:
|
| 631 |
error_trace = traceback.format_exc()
|
| 632 |
-
error_message = f"โ **Error occurred during execution:**\n\n```python\n{str(e)}\n```\n\nPlease try again or check your API keys."
|
| 633 |
print(error_trace)
|
| 634 |
return (
|
| 635 |
-
|
| 636 |
-
None,
|
| 637 |
-
gr.update(visible=False),
|
| 638 |
-
gr.update(visible=False),
|
| 639 |
-
gr.update(visible=False),
|
| 640 |
-
""
|
| 641 |
)
|
| 642 |
|
| 643 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
with gr.Blocks(theme=gr.themes.Soft(), css="""
|
| 645 |
.container { max-width: 1400px; margin: auto; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
.status-box {
|
| 647 |
padding: 20px;
|
| 648 |
border-radius: 12px;
|
|
@@ -651,225 +925,196 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 651 |
color: white;
|
| 652 |
font-weight: 500;
|
| 653 |
}
|
| 654 |
-
.
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
background: #f7fafc;
|
| 658 |
-
border-radius: 12px;
|
| 659 |
-
margin: 10px;
|
| 660 |
-
}
|
| 661 |
-
.template-selector {
|
| 662 |
-
border: 2px solid #e2e8f0;
|
| 663 |
-
border-radius: 12px;
|
| 664 |
padding: 15px;
|
|
|
|
| 665 |
background: #f8fafc;
|
|
|
|
| 666 |
}
|
| 667 |
-
.
|
| 668 |
-
font-size: 1.5rem;
|
| 669 |
-
font-weight: bold;
|
| 670 |
-
text-align: center;
|
| 671 |
-
padding: 15px;
|
| 672 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 673 |
-
-webkit-background-clip: text;
|
| 674 |
-
-webkit-text-fill-color: transparent;
|
| 675 |
-
margin: 20px 0;
|
| 676 |
-
}
|
| 677 |
-
.template-badge {
|
| 678 |
display: inline-block;
|
| 679 |
-
padding:
|
| 680 |
-
border-radius:
|
| 681 |
-
font-size: 0.
|
| 682 |
font-weight: 600;
|
| 683 |
-
margin
|
| 684 |
-
|
| 685 |
-
.single-page-badge {
|
| 686 |
-
background: #48bb78;
|
| 687 |
-
color: white;
|
| 688 |
-
}
|
| 689 |
-
.multi-page-badge {
|
| 690 |
-
background: #4299e1;
|
| 691 |
color: white;
|
| 692 |
}
|
| 693 |
""") as iface:
|
| 694 |
|
| 695 |
gr.Markdown(
|
| 696 |
"""
|
| 697 |
-
#
|
| 698 |
-
###
|
| 699 |
-
Generate complete, production-ready websites with our AI team. Support for both single-page and multi-page projects!
|
| 700 |
|
| 701 |
-
|
| 702 |
-
|
| 703 |
"""
|
| 704 |
)
|
| 705 |
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 738 |
|
| 739 |
with gr.Row():
|
| 740 |
generate_btn = gr.Button(
|
| 741 |
"๐ Generate Professional Website",
|
| 742 |
variant="primary",
|
| 743 |
-
size="lg"
|
| 744 |
-
scale=1
|
| 745 |
-
)
|
| 746 |
-
|
| 747 |
-
with gr.Row():
|
| 748 |
-
gr.Examples(
|
| 749 |
-
examples=[
|
| 750 |
-
["๐จ Portfolio - Minimalist designer portfolio with projects grid and contact form (Single Page)"],
|
| 751 |
-
["๐ SaaS Landing Page - Modern software startup with pricing cards and demo CTA (Single Page)"],
|
| 752 |
-
["๐ Restaurant Landing - Menu showcase with reservations and location info (Single Page)"],
|
| 753 |
-
["๐ Course Landing - Online course sales page with curriculum and testimonials (Single Page)"],
|
| 754 |
-
["๐๏ธ E-commerce Platform - Full online store with products, cart, and checkout (Multi-Page)"],
|
| 755 |
-
],
|
| 756 |
-
inputs=template_dropdown,
|
| 757 |
-
label="๐ก Popular Templates"
|
| 758 |
-
)
|
| 759 |
-
|
| 760 |
-
with gr.Row():
|
| 761 |
-
status_output = gr.Markdown(
|
| 762 |
-
value="",
|
| 763 |
-
label="Status",
|
| 764 |
-
elem_classes="status-box"
|
| 765 |
)
|
| 766 |
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
label="๐ฅ๏ธ Live Preview (with animations)",
|
| 770 |
-
visible=True
|
| 771 |
-
)
|
| 772 |
|
| 773 |
-
with gr.
|
| 774 |
-
with gr.
|
| 775 |
-
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
|
| 783 |
-
visible=False,
|
| 784 |
-
elem_classes="download-section"
|
| 785 |
)
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
"
|
| 789 |
-
|
| 790 |
-
variant="secondary"
|
| 791 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 792 |
|
| 793 |
-
#
|
| 794 |
with gr.Row(visible=False) as code_row:
|
| 795 |
code_output = gr.Code(
|
| 796 |
-
label="
|
| 797 |
language="html",
|
| 798 |
-
lines=
|
| 799 |
-
elem_classes="container"
|
| 800 |
)
|
| 801 |
|
| 802 |
-
#
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
return gr.update(visible=False), gr.update(visible=True)
|
| 808 |
-
|
| 809 |
-
use_template.change(
|
| 810 |
-
fn=toggle_input_mode,
|
| 811 |
-
inputs=[use_template],
|
| 812 |
-
outputs=[template_dropdown, custom_prompt]
|
| 813 |
)
|
| 814 |
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
value=f"### {project_name}",
|
| 830 |
-
visible=True
|
| 831 |
-
)
|
| 832 |
-
else:
|
| 833 |
-
project_display = gr.update(visible=False)
|
| 834 |
-
|
| 835 |
return (
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
view_btn,
|
| 841 |
-
project_display
|
| 842 |
)
|
| 843 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 844 |
generate_btn.click(
|
| 845 |
fn=generate_website,
|
| 846 |
-
inputs=[
|
| 847 |
-
outputs=[
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
]
|
| 855 |
)
|
| 856 |
|
| 857 |
view_code_btn.click(
|
| 858 |
fn=lambda: (
|
| 859 |
-
gr.update(visible=True),
|
| 860 |
-
open("outputs/index.html", "r", encoding="utf-8").read() if os.path.exists("outputs/index.html") else
|
| 861 |
),
|
| 862 |
-
inputs=None,
|
| 863 |
outputs=[code_row, code_output]
|
| 864 |
)
|
| 865 |
|
| 866 |
if __name__ == "__main__":
|
| 867 |
print("\n" + "="*50)
|
| 868 |
-
print("
|
| 869 |
print("="*50)
|
| 870 |
-
print("\nโ
|
| 871 |
-
print(
|
| 872 |
-
print("
|
| 873 |
-
print("
|
| 874 |
|
| 875 |
iface.launch(share=False)
|
|
|
|
| 7 |
import shutil
|
| 8 |
import glob
|
| 9 |
import json
|
| 10 |
+
from datetime import datetime
|
| 11 |
|
| 12 |
load_dotenv()
|
| 13 |
|
| 14 |
+
# --- WEBSITE TYPE SYSTEM DEFINITIONS ---
|
| 15 |
+
WEBSITE_TYPES = {
|
| 16 |
+
"SaaS Platform": {
|
| 17 |
+
"emoji": "๐",
|
| 18 |
+
"description": "Software as a Service platform website",
|
| 19 |
+
"pages": {
|
| 20 |
+
"single": ["Landing Page"],
|
| 21 |
+
"multi": ["Home", "Features", "Pricing", "About", "Blog", "Contact", "Login/Signup"]
|
| 22 |
+
},
|
| 23 |
+
"sections": {
|
| 24 |
+
"Hero": "Value proposition with clear CTA for free trial",
|
| 25 |
+
"Features": "Key features with icons and descriptions",
|
| 26 |
+
"How It Works": "3-step process visualization",
|
| 27 |
+
"Pricing": "Tiered pricing cards with feature comparison",
|
| 28 |
+
"Testimonials": "Customer success stories with metrics",
|
| 29 |
+
"Integration": "Logos of integrated platforms",
|
| 30 |
+
"FAQ": "Common questions addressed",
|
| 31 |
+
"CTA": "Final conversion section with trial offer"
|
| 32 |
+
},
|
| 33 |
+
"color_scheme": {
|
| 34 |
+
"primary": "#4F46E5", # Indigo
|
| 35 |
+
"secondary": "#06B6D4", # Cyan
|
| 36 |
+
"accent": "#10B981", # Emerald
|
| 37 |
+
"background": "#FFFFFF",
|
| 38 |
+
"text": "#1F2937",
|
| 39 |
+
"muted": "#6B7280"
|
| 40 |
+
},
|
| 41 |
+
"design_style": "Modern, clean, professional with subtle gradients",
|
| 42 |
+
"fonts": {
|
| 43 |
+
"heading": "Inter",
|
| 44 |
+
"body": "Inter"
|
| 45 |
+
},
|
| 46 |
+
"must_have_elements": [
|
| 47 |
+
"Sticky navigation with CTA button",
|
| 48 |
+
"Animated feature cards",
|
| 49 |
+
"Pricing toggle (monthly/yearly)",
|
| 50 |
+
"Trust badges and security icons",
|
| 51 |
+
"Live chat widget placeholder",
|
| 52 |
+
"Cookie consent banner"
|
| 53 |
+
]
|
| 54 |
+
},
|
| 55 |
+
|
| 56 |
+
"E-commerce Store": {
|
| 57 |
+
"emoji": "๐๏ธ",
|
| 58 |
+
"description": "Online shopping platform",
|
| 59 |
+
"pages": {
|
| 60 |
+
"single": ["Product Showcase"],
|
| 61 |
+
"multi": ["Home", "Shop", "Product Details", "Cart", "Checkout", "Account", "About", "Contact"]
|
| 62 |
+
},
|
| 63 |
+
"sections": {
|
| 64 |
+
"Hero": "Featured products carousel with offers",
|
| 65 |
+
"Categories": "Product categories grid",
|
| 66 |
+
"Featured Products": "Best sellers and new arrivals",
|
| 67 |
+
"Deals": "Special offers and discounts",
|
| 68 |
+
"Benefits": "Free shipping, returns, security",
|
| 69 |
+
"Newsletter": "Email subscription for deals",
|
| 70 |
+
"Reviews": "Customer testimonials",
|
| 71 |
+
"Brands": "Partner brand logos"
|
| 72 |
+
},
|
| 73 |
+
"color_scheme": {
|
| 74 |
+
"primary": "#DC2626", # Red
|
| 75 |
+
"secondary": "#F59E0B", # Amber
|
| 76 |
+
"accent": "#10B981", # Green for CTAs
|
| 77 |
+
"background": "#FFFFFF",
|
| 78 |
+
"text": "#111827",
|
| 79 |
+
"muted": "#6B7280"
|
| 80 |
+
},
|
| 81 |
+
"design_style": "Clean, product-focused with high-quality imagery",
|
| 82 |
+
"fonts": {
|
| 83 |
+
"heading": "Poppins",
|
| 84 |
+
"body": "Open Sans"
|
| 85 |
+
},
|
| 86 |
+
"must_have_elements": [
|
| 87 |
+
"Shopping cart icon with counter",
|
| 88 |
+
"Search bar with filters",
|
| 89 |
+
"Product quick view modals",
|
| 90 |
+
"Wishlist functionality",
|
| 91 |
+
"Product image zoom",
|
| 92 |
+
"Rating stars",
|
| 93 |
+
"Size/color selectors",
|
| 94 |
+
"Secure payment badges"
|
| 95 |
+
]
|
| 96 |
+
},
|
| 97 |
+
|
| 98 |
+
"Portfolio/Creative": {
|
| 99 |
+
"emoji": "๐จ",
|
| 100 |
+
"description": "Creative professional or agency portfolio",
|
| 101 |
+
"pages": {
|
| 102 |
+
"single": ["Portfolio Showcase"],
|
| 103 |
+
"multi": ["Home", "Portfolio", "About", "Services", "Process", "Contact"]
|
| 104 |
+
},
|
| 105 |
+
"sections": {
|
| 106 |
+
"Hero": "Creative statement with animated text",
|
| 107 |
+
"Work": "Portfolio grid with hover effects",
|
| 108 |
+
"About": "Story and expertise",
|
| 109 |
+
"Services": "What we offer",
|
| 110 |
+
"Process": "Creative workflow",
|
| 111 |
+
"Clients": "Client logos and testimonials",
|
| 112 |
+
"Awards": "Recognition and achievements",
|
| 113 |
+
"Contact": "Get in touch form"
|
| 114 |
+
},
|
| 115 |
+
"color_scheme": {
|
| 116 |
+
"primary": "#000000",
|
| 117 |
+
"secondary": "#FFFFFF",
|
| 118 |
+
"accent": "#FF6B6B",
|
| 119 |
+
"background": "#FAFAFA",
|
| 120 |
+
"text": "#1A1A1A",
|
| 121 |
+
"muted": "#666666"
|
| 122 |
+
},
|
| 123 |
+
"design_style": "Bold, minimalist, typography-focused with creative layouts",
|
| 124 |
+
"fonts": {
|
| 125 |
+
"heading": "Playfair Display",
|
| 126 |
+
"body": "Roboto"
|
| 127 |
+
},
|
| 128 |
+
"must_have_elements": [
|
| 129 |
+
"Masonry or grid portfolio layout",
|
| 130 |
+
"Smooth scroll animations",
|
| 131 |
+
"Before/after sliders",
|
| 132 |
+
"Video backgrounds",
|
| 133 |
+
"Parallax effects",
|
| 134 |
+
"Custom cursor",
|
| 135 |
+
"Loading animation",
|
| 136 |
+
"Social media links"
|
| 137 |
+
]
|
| 138 |
+
},
|
| 139 |
+
|
| 140 |
+
"Corporate/Business": {
|
| 141 |
+
"emoji": "๐ข",
|
| 142 |
+
"description": "Professional business or corporate website",
|
| 143 |
+
"pages": {
|
| 144 |
+
"single": ["Company Overview"],
|
| 145 |
+
"multi": ["Home", "About", "Services", "Industries", "Case Studies", "Team", "Careers", "Contact"]
|
| 146 |
+
},
|
| 147 |
+
"sections": {
|
| 148 |
+
"Hero": "Company vision with professional imagery",
|
| 149 |
+
"Services": "Core service offerings",
|
| 150 |
+
"About": "Company history and values",
|
| 151 |
+
"Statistics": "Key metrics and achievements",
|
| 152 |
+
"Industries": "Sectors served",
|
| 153 |
+
"Team": "Leadership profiles",
|
| 154 |
+
"Partners": "Strategic partnerships",
|
| 155 |
+
"News": "Latest updates and press"
|
| 156 |
+
},
|
| 157 |
+
"color_scheme": {
|
| 158 |
+
"primary": "#1E40AF", # Blue
|
| 159 |
+
"secondary": "#0F766E", # Teal
|
| 160 |
+
"accent": "#F59E0B", # Amber
|
| 161 |
+
"background": "#FFFFFF",
|
| 162 |
+
"text": "#1F2937",
|
| 163 |
+
"muted": "#6B7280"
|
| 164 |
+
},
|
| 165 |
+
"design_style": "Professional, trustworthy, clean with structured layouts",
|
| 166 |
+
"fonts": {
|
| 167 |
+
"heading": "Montserrat",
|
| 168 |
+
"body": "Source Sans Pro"
|
| 169 |
+
},
|
| 170 |
+
"must_have_elements": [
|
| 171 |
+
"Professional navigation",
|
| 172 |
+
"Dropdown menus",
|
| 173 |
+
"Team member cards",
|
| 174 |
+
"Timeline components",
|
| 175 |
+
"Statistics counters",
|
| 176 |
+
"Certificate badges",
|
| 177 |
+
"Newsletter signup",
|
| 178 |
+
"Office locations map"
|
| 179 |
+
]
|
| 180 |
+
},
|
| 181 |
+
|
| 182 |
+
"Restaurant/Food": {
|
| 183 |
+
"emoji": "๐",
|
| 184 |
+
"description": "Restaurant, cafe, or food service website",
|
| 185 |
+
"pages": {
|
| 186 |
+
"single": ["Restaurant Landing"],
|
| 187 |
+
"multi": ["Home", "Menu", "About", "Gallery", "Reservations", "Events", "Contact"]
|
| 188 |
+
},
|
| 189 |
+
"sections": {
|
| 190 |
+
"Hero": "Appetizing hero with reservation CTA",
|
| 191 |
+
"Menu Preview": "Featured dishes showcase",
|
| 192 |
+
"About": "Our story and chef",
|
| 193 |
+
"Specials": "Daily specials and offers",
|
| 194 |
+
"Gallery": "Food and ambiance photos",
|
| 195 |
+
"Testimonials": "Customer reviews",
|
| 196 |
+
"Hours": "Opening hours and location",
|
| 197 |
+
"Reservation": "Table booking form"
|
| 198 |
+
},
|
| 199 |
+
"color_scheme": {
|
| 200 |
+
"primary": "#DC2626", # Red
|
| 201 |
+
"secondary": "#854D0E", # Brown
|
| 202 |
+
"accent": "#16A34A", # Green
|
| 203 |
+
"background": "#FEF3C7",
|
| 204 |
+
"text": "#1F2937",
|
| 205 |
+
"muted": "#78716C"
|
| 206 |
+
},
|
| 207 |
+
"design_style": "Warm, inviting, appetizing with rich imagery",
|
| 208 |
+
"fonts": {
|
| 209 |
+
"heading": "Merriweather",
|
| 210 |
+
"body": "Open Sans"
|
| 211 |
+
},
|
| 212 |
+
"must_have_elements": [
|
| 213 |
+
"Menu with prices",
|
| 214 |
+
"Online reservation system",
|
| 215 |
+
"Photo gallery",
|
| 216 |
+
"Google Maps integration",
|
| 217 |
+
"Social media feed",
|
| 218 |
+
"Special offers banner",
|
| 219 |
+
"Delivery/takeout options",
|
| 220 |
+
"Customer reviews"
|
| 221 |
+
]
|
| 222 |
+
},
|
| 223 |
+
|
| 224 |
+
"Healthcare/Medical": {
|
| 225 |
+
"emoji": "๐ฅ",
|
| 226 |
+
"description": "Medical, healthcare, or wellness website",
|
| 227 |
+
"pages": {
|
| 228 |
+
"single": ["Clinic Overview"],
|
| 229 |
+
"multi": ["Home", "Services", "Doctors", "Appointments", "Patient Portal", "Resources", "About", "Contact"]
|
| 230 |
+
},
|
| 231 |
+
"sections": {
|
| 232 |
+
"Hero": "Welcome with appointment booking",
|
| 233 |
+
"Services": "Medical services offered",
|
| 234 |
+
"Doctors": "Medical team profiles",
|
| 235 |
+
"Why Choose Us": "Credentials and approach",
|
| 236 |
+
"Testimonials": "Patient stories",
|
| 237 |
+
"Insurance": "Accepted providers",
|
| 238 |
+
"Resources": "Health tips and articles",
|
| 239 |
+
"Emergency": "Emergency contact info"
|
| 240 |
+
},
|
| 241 |
+
"color_scheme": {
|
| 242 |
+
"primary": "#0891B2", # Cyan
|
| 243 |
+
"secondary": "#10B981", # Green
|
| 244 |
+
"accent": "#3B82F6", # Blue
|
| 245 |
+
"background": "#F0FDFA",
|
| 246 |
+
"text": "#0F172A",
|
| 247 |
+
"muted": "#64748B"
|
| 248 |
+
},
|
| 249 |
+
"design_style": "Clean, professional, trustworthy with calming colors",
|
| 250 |
+
"fonts": {
|
| 251 |
+
"heading": "Nunito Sans",
|
| 252 |
+
"body": "Open Sans"
|
| 253 |
+
},
|
| 254 |
+
"must_have_elements": [
|
| 255 |
+
"Appointment booking system",
|
| 256 |
+
"Doctor profiles with credentials",
|
| 257 |
+
"Service descriptions",
|
| 258 |
+
"Patient portal login",
|
| 259 |
+
"Insurance information",
|
| 260 |
+
"Emergency contacts",
|
| 261 |
+
"Health resources/blog",
|
| 262 |
+
"HIPAA compliance notice"
|
| 263 |
+
]
|
| 264 |
+
},
|
| 265 |
+
|
| 266 |
+
"Education/E-learning": {
|
| 267 |
+
"emoji": "๐",
|
| 268 |
+
"description": "Educational institution or online learning platform",
|
| 269 |
+
"pages": {
|
| 270 |
+
"single": ["Course Landing"],
|
| 271 |
+
"multi": ["Home", "Courses", "Programs", "Instructors", "Resources", "Student Portal", "About", "Contact"]
|
| 272 |
+
},
|
| 273 |
+
"sections": {
|
| 274 |
+
"Hero": "Learn and grow message with enrollment CTA",
|
| 275 |
+
"Courses": "Popular courses grid",
|
| 276 |
+
"Features": "Learning platform benefits",
|
| 277 |
+
"Instructors": "Expert teacher profiles",
|
| 278 |
+
"Testimonials": "Student success stories",
|
| 279 |
+
"Stats": "Graduation and success rates",
|
| 280 |
+
"Process": "How to get started",
|
| 281 |
+
"FAQ": "Common questions"
|
| 282 |
+
},
|
| 283 |
+
"color_scheme": {
|
| 284 |
+
"primary": "#7C3AED", # Purple
|
| 285 |
+
"secondary": "#2563EB", # Blue
|
| 286 |
+
"accent": "#F59E0B", # Amber
|
| 287 |
+
"background": "#FAFAF9",
|
| 288 |
+
"text": "#18181B",
|
| 289 |
+
"muted": "#71717A"
|
| 290 |
+
},
|
| 291 |
+
"design_style": "Modern, engaging, accessible with clear information hierarchy",
|
| 292 |
+
"fonts": {
|
| 293 |
+
"heading": "Raleway",
|
| 294 |
+
"body": "Inter"
|
| 295 |
+
},
|
| 296 |
+
"must_have_elements": [
|
| 297 |
+
"Course catalog with filters",
|
| 298 |
+
"Enrollment/registration forms",
|
| 299 |
+
"Student dashboard mockup",
|
| 300 |
+
"Video player placeholder",
|
| 301 |
+
"Progress indicators",
|
| 302 |
+
"Certificate badges",
|
| 303 |
+
"Calendar/schedule",
|
| 304 |
+
"Resource library"
|
| 305 |
+
]
|
| 306 |
+
},
|
| 307 |
+
|
| 308 |
+
"Real Estate": {
|
| 309 |
+
"emoji": "๐ ",
|
| 310 |
+
"description": "Real estate agency or property listing website",
|
| 311 |
+
"pages": {
|
| 312 |
+
"single": ["Property Showcase"],
|
| 313 |
+
"multi": ["Home", "Properties", "Property Details", "Agents", "Services", "About", "Contact"]
|
| 314 |
+
},
|
| 315 |
+
"sections": {
|
| 316 |
+
"Hero": "Property search with filters",
|
| 317 |
+
"Featured": "Featured properties carousel",
|
| 318 |
+
"Search": "Advanced search options",
|
| 319 |
+
"Services": "Buying, selling, renting",
|
| 320 |
+
"Agents": "Team of realtors",
|
| 321 |
+
"Testimonials": "Client experiences",
|
| 322 |
+
"Market": "Market trends and insights",
|
| 323 |
+
"Contact": "Schedule viewing"
|
| 324 |
+
},
|
| 325 |
+
"color_scheme": {
|
| 326 |
+
"primary": "#0F766E", # Teal
|
| 327 |
+
"secondary": "#B45309", # Brown
|
| 328 |
+
"accent": "#3B82F6", # Blue
|
| 329 |
+
"background": "#FFFFFF",
|
| 330 |
+
"text": "#1F2937",
|
| 331 |
+
"muted": "#6B7280"
|
| 332 |
+
},
|
| 333 |
+
"design_style": "Professional, clean, image-heavy with property showcases",
|
| 334 |
+
"fonts": {
|
| 335 |
+
"heading": "Playfair Display",
|
| 336 |
+
"body": "Source Sans Pro"
|
| 337 |
+
},
|
| 338 |
+
"must_have_elements": [
|
| 339 |
+
"Property search with filters",
|
| 340 |
+
"Property cards with details",
|
| 341 |
+
"Image galleries",
|
| 342 |
+
"Virtual tour buttons",
|
| 343 |
+
"Mortgage calculator",
|
| 344 |
+
"Agent contact cards",
|
| 345 |
+
"Map integration",
|
| 346 |
+
"Property comparison tool"
|
| 347 |
+
]
|
| 348 |
+
},
|
| 349 |
+
|
| 350 |
+
"Fitness/Gym": {
|
| 351 |
+
"emoji": "๐๏ธ",
|
| 352 |
+
"description": "Gym, fitness center, or personal training website",
|
| 353 |
+
"pages": {
|
| 354 |
+
"single": ["Fitness Landing"],
|
| 355 |
+
"multi": ["Home", "Classes", "Trainers", "Membership", "Schedule", "Blog", "Contact"]
|
| 356 |
+
},
|
| 357 |
+
"sections": {
|
| 358 |
+
"Hero": "Transform your body message with join CTA",
|
| 359 |
+
"Classes": "Class types and schedules",
|
| 360 |
+
"Trainers": "Expert trainer profiles",
|
| 361 |
+
"Membership": "Pricing plans",
|
| 362 |
+
"Transformation": "Before/after gallery",
|
| 363 |
+
"Features": "Gym facilities and equipment",
|
| 364 |
+
"Schedule": "Class timetable",
|
| 365 |
+
"Blog": "Fitness tips and nutrition"
|
| 366 |
+
},
|
| 367 |
+
"color_scheme": {
|
| 368 |
+
"primary": "#DC2626", # Red
|
| 369 |
+
"secondary": "#000000", # Black
|
| 370 |
+
"accent": "#22C55E", # Green
|
| 371 |
+
"background": "#FAFAFA",
|
| 372 |
+
"text": "#171717",
|
| 373 |
+
"muted": "#525252"
|
| 374 |
+
},
|
| 375 |
+
"design_style": "Energetic, bold, motivational with dynamic imagery",
|
| 376 |
+
"fonts": {
|
| 377 |
+
"heading": "Bebas Neue",
|
| 378 |
+
"body": "Roboto"
|
| 379 |
+
},
|
| 380 |
+
"must_have_elements": [
|
| 381 |
+
"Class schedule/timetable",
|
| 382 |
+
"Membership pricing cards",
|
| 383 |
+
"Trainer profiles",
|
| 384 |
+
"Transformation gallery",
|
| 385 |
+
"Class booking system",
|
| 386 |
+
"Nutrition tips section",
|
| 387 |
+
"BMI calculator",
|
| 388 |
+
"Free trial CTA"
|
| 389 |
+
]
|
| 390 |
+
},
|
| 391 |
+
|
| 392 |
+
"Technology/Startup": {
|
| 393 |
+
"emoji": "๐ก",
|
| 394 |
+
"description": "Tech startup or innovation company website",
|
| 395 |
+
"pages": {
|
| 396 |
+
"single": ["Startup Landing"],
|
| 397 |
+
"multi": ["Home", "Product", "Solutions", "Technology", "Company", "Blog", "Contact"]
|
| 398 |
+
},
|
| 399 |
+
"sections": {
|
| 400 |
+
"Hero": "Innovation message with demo request",
|
| 401 |
+
"Problem/Solution": "What we solve",
|
| 402 |
+
"Product": "Product features showcase",
|
| 403 |
+
"Technology": "Our tech stack",
|
| 404 |
+
"Partners": "Integration partners",
|
| 405 |
+
"Team": "Founding team",
|
| 406 |
+
"Investors": "Backed by",
|
| 407 |
+
"Press": "Media mentions"
|
| 408 |
+
},
|
| 409 |
+
"color_scheme": {
|
| 410 |
+
"primary": "#8B5CF6", # Purple
|
| 411 |
+
"secondary": "#3B82F6", # Blue
|
| 412 |
+
"accent": "#10B981", # Green
|
| 413 |
+
"background": "#0F0F1E",
|
| 414 |
+
"text": "#FFFFFF",
|
| 415 |
+
"muted": "#9CA3AF"
|
| 416 |
+
},
|
| 417 |
+
"design_style": "Futuristic, gradient-heavy, dark mode with neon accents",
|
| 418 |
+
"fonts": {
|
| 419 |
+
"heading": "Space Grotesk",
|
| 420 |
+
"body": "Inter"
|
| 421 |
+
},
|
| 422 |
+
"must_have_elements": [
|
| 423 |
+
"Animated hero section",
|
| 424 |
+
"Interactive product demo",
|
| 425 |
+
"Tech stack icons",
|
| 426 |
+
"Gradient backgrounds",
|
| 427 |
+
"Particle effects",
|
| 428 |
+
"Timeline roadmap",
|
| 429 |
+
"API documentation link",
|
| 430 |
+
"Developer resources"
|
| 431 |
+
]
|
| 432 |
+
}
|
| 433 |
+
}
|
| 434 |
|
| 435 |
+
# --- ENHANCED PROMPTS ---
|
| 436 |
+
ENHANCED_IMAGE_PROMPT = """
|
| 437 |
+
Image Guidelines for {website_type}:
|
| 438 |
|
| 439 |
+
Use static.photos service with appropriate categories:
|
| 440 |
+
- {category_suggestions}
|
| 441 |
|
| 442 |
+
Recommended dimensions:
|
| 443 |
+
- Hero: 1200x630
|
| 444 |
+
- Features: 640x360
|
| 445 |
+
- Testimonials: 200x200
|
| 446 |
+
- Gallery: 640x360
|
| 447 |
+
- Icons: 200x200
|
|
|
|
|
|
|
| 448 |
|
| 449 |
+
Example URLs:
|
| 450 |
+
{example_urls}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
|
| 452 |
+
Match images to the {design_style} style.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 453 |
"""
|
| 454 |
|
| 455 |
+
PROJECT_CONTEXT_PROMPT = """
|
| 456 |
+
You are creating a {website_type} website with the following specifications:
|
| 457 |
+
|
| 458 |
+
Project Name: {project_name}
|
| 459 |
+
Type: {page_type}
|
| 460 |
+
Style: {design_style}
|
| 461 |
+
Primary Purpose: {description}
|
| 462 |
+
|
| 463 |
+
Color Palette:
|
| 464 |
+
{color_details}
|
| 465 |
+
|
| 466 |
+
Typography:
|
| 467 |
+
- Headings: {heading_font}
|
| 468 |
+
- Body: {body_font}
|
| 469 |
+
|
| 470 |
+
Required Sections:
|
| 471 |
+
{sections}
|
| 472 |
+
|
| 473 |
+
Must-Have Elements:
|
| 474 |
+
{must_have_elements}
|
| 475 |
+
|
| 476 |
+
Target Audience: {target_audience}
|
| 477 |
"""
|
| 478 |
|
| 479 |
+
# --- SYSTEM SETUP ---
|
| 480 |
try:
|
| 481 |
llm = LLM(
|
| 482 |
model="gemini/gemini-2.0-flash-exp",
|
| 483 |
+
temperature=0.7,
|
| 484 |
api_key=os.environ.get("GOOGLE_API_KEY")
|
| 485 |
)
|
| 486 |
except Exception as e:
|
| 487 |
+
print(f"Error initializing Gemini LLM: {e}")
|
|
|
|
|
|
|
|
|
|
| 488 |
llm = None
|
| 489 |
|
|
|
|
| 490 |
os.makedirs("outputs", exist_ok=True)
|
| 491 |
file_write_tool = FileWriterTool()
|
| 492 |
|
| 493 |
+
# --- ENHANCED AGENTS ---
|
| 494 |
designer = Agent(
|
| 495 |
+
role='Senior Design Systems Architect',
|
| 496 |
+
goal='Create comprehensive design systems tailored to specific website types',
|
| 497 |
+
backstory=(
|
| 498 |
+
"You are a design systems expert who specializes in creating cohesive, "
|
| 499 |
+
"type-specific design languages. You understand that different website types "
|
| 500 |
+
"have distinct requirements:\n\n"
|
| 501 |
+
"- SaaS needs trust indicators and clear value props\n"
|
| 502 |
+
"- E-commerce requires product focus and purchase flow\n"
|
| 503 |
+
"- Portfolio demands creative expression\n"
|
| 504 |
+
"- Corporate needs professionalism and structure\n\n"
|
| 505 |
+
"You always consider:\n"
|
| 506 |
+
"- Industry-specific design patterns\n"
|
| 507 |
+
"- User expectations for each website type\n"
|
| 508 |
+
"- Conversion optimization for the specific goal\n"
|
| 509 |
+
"- Accessibility and performance\n"
|
| 510 |
+
"- Mobile-first responsive design\n\n"
|
| 511 |
+
"You create detailed design tokens including:\n"
|
| 512 |
+
"- Precise color values with semantic naming\n"
|
| 513 |
+
"- Typography scales with exact sizes\n"
|
| 514 |
+
"- Spacing systems (4px/8px grid)\n"
|
| 515 |
+
"- Component specifications\n"
|
| 516 |
+
"- Animation timings and easings"
|
| 517 |
+
),
|
| 518 |
+
verbose=True,
|
| 519 |
+
llm=llm,
|
| 520 |
+
allow_delegation=False
|
| 521 |
)
|
| 522 |
|
| 523 |
copywriter = Agent(
|
| 524 |
+
role='Conversion Copywriter & Content Strategist',
|
| 525 |
+
goal='Write compelling, type-specific copy that converts visitors into customers',
|
| 526 |
+
backstory=(
|
| 527 |
+
"You are a conversion-focused copywriter who understands that different "
|
| 528 |
+
"website types require different voices and messaging strategies:\n\n"
|
| 529 |
+
"- SaaS: Focus on benefits, ROI, and problem-solving\n"
|
| 530 |
+
"- E-commerce: Product benefits, urgency, and trust\n"
|
| 531 |
+
"- Portfolio: Creativity, expertise, and personality\n"
|
| 532 |
+
"- Corporate: Authority, reliability, and professionalism\n"
|
| 533 |
+
"- Healthcare: Empathy, trust, and expertise\n\n"
|
| 534 |
+
"You craft:\n"
|
| 535 |
+
"- Headlines that grab attention\n"
|
| 536 |
+
"- Subheadings that maintain interest\n"
|
| 537 |
+
"- CTAs that drive action\n"
|
| 538 |
+
"- Microcopy that guides users\n"
|
| 539 |
+
"- SEO-optimized content\n\n"
|
| 540 |
+
"You always match tone to the target audience and industry expectations."
|
| 541 |
+
),
|
| 542 |
+
verbose=True,
|
| 543 |
+
llm=llm,
|
| 544 |
+
allow_delegation=False
|
|
|
|
| 545 |
)
|
| 546 |
|
| 547 |
developer = Agent(
|
| 548 |
+
role='Full-Stack Frontend Developer',
|
| 549 |
+
goal='Build pixel-perfect, performant websites tailored to specific industries',
|
| 550 |
+
backstory=(
|
| 551 |
+
"You are an expert frontend developer who specializes in building "
|
| 552 |
+
"industry-specific websites with modern technologies:\n\n"
|
| 553 |
+
"**Technical Expertise:**\n"
|
| 554 |
+
"- Tailwind CSS for rapid, consistent styling\n"
|
| 555 |
+
"- Custom CSS for unique requirements\n"
|
| 556 |
+
"- JavaScript for interactivity\n"
|
| 557 |
+
"- AOS for scroll animations\n"
|
| 558 |
+
"- Performance optimization\n\n"
|
| 559 |
+
"**Industry-Specific Knowledge:**\n"
|
| 560 |
+
"- SaaS: Pricing toggles, feature comparisons, dashboards\n"
|
| 561 |
+
"- E-commerce: Product grids, cart functionality, filters\n"
|
| 562 |
+
"- Portfolio: Galleries, sliders, creative layouts\n"
|
| 563 |
+
"- Corporate: Professional navigation, team sections\n"
|
| 564 |
+
"- Healthcare: Appointment forms, service listings\n\n"
|
| 565 |
+
"You always implement:\n"
|
| 566 |
+
"- Semantic HTML5\n"
|
| 567 |
+
"- ARIA labels for accessibility\n"
|
| 568 |
+
"- Responsive design (mobile-first)\n"
|
| 569 |
+
"- SEO best practices\n"
|
| 570 |
+
"- Performance optimizations\n"
|
| 571 |
+
"- Cross-browser compatibility"
|
| 572 |
+
),
|
| 573 |
+
verbose=True,
|
| 574 |
+
llm=llm,
|
| 575 |
+
tools=[file_write_tool],
|
| 576 |
+
allow_delegation=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
)
|
| 578 |
|
| 579 |
+
# --- ENHANCED TASK CREATION ---
|
| 580 |
+
def create_design_task(website_type, project_name, custom_requirements, page_type):
|
| 581 |
+
"""Create a design task specific to the website type"""
|
| 582 |
+
|
| 583 |
+
type_config = WEBSITE_TYPES[website_type]
|
| 584 |
+
|
| 585 |
+
# Build context
|
| 586 |
+
context = PROJECT_CONTEXT_PROMPT.format(
|
| 587 |
+
website_type=website_type,
|
| 588 |
+
project_name=project_name,
|
| 589 |
+
page_type=page_type,
|
| 590 |
+
design_style=type_config["design_style"],
|
| 591 |
+
description=type_config["description"],
|
| 592 |
+
color_details=json.dumps(type_config["color_scheme"], indent=2),
|
| 593 |
+
heading_font=type_config["fonts"]["heading"],
|
| 594 |
+
body_font=type_config["fonts"]["body"],
|
| 595 |
+
sections=json.dumps(type_config["sections"], indent=2),
|
| 596 |
+
must_have_elements="\n".join(f"- {elem}" for elem in type_config["must_have_elements"]),
|
| 597 |
+
target_audience=f"Target audience for {website_type}"
|
| 598 |
+
)
|
| 599 |
+
|
| 600 |
+
# Build image guidelines
|
| 601 |
+
category_map = {
|
| 602 |
+
"SaaS Platform": "technology, office, abstract, gradient",
|
| 603 |
+
"E-commerce Store": "retail, product, lifestyle, fashion",
|
| 604 |
+
"Portfolio/Creative": "abstract, minimal, artistic, workspace",
|
| 605 |
+
"Corporate/Business": "office, business, professional, cityscape",
|
| 606 |
+
"Restaurant/Food": "food, restaurant, culinary, ambiance",
|
| 607 |
+
"Healthcare/Medical": "medical, wellness, healthcare, people",
|
| 608 |
+
"Education/E-learning": "education, study, classroom, books",
|
| 609 |
+
"Real Estate": "estate, architecture, interior, exterior",
|
| 610 |
+
"Fitness/Gym": "fitness, sport, gym, wellness",
|
| 611 |
+
"Technology/Startup": "technology, innovation, abstract, futuristic"
|
| 612 |
+
}
|
| 613 |
+
|
| 614 |
+
image_guidelines = ENHANCED_IMAGE_PROMPT.format(
|
| 615 |
+
website_type=website_type,
|
| 616 |
+
category_suggestions=category_map.get(website_type, "abstract, gradient"),
|
| 617 |
+
design_style=type_config["design_style"],
|
| 618 |
+
example_urls="\n".join([
|
| 619 |
+
f"- Hero: http://static.photos/{category_map.get(website_type, 'abstract').split(',')[0].strip()}/1200x630/100",
|
| 620 |
+
f"- Features: http://static.photos/{category_map.get(website_type, 'abstract').split(',')[0].strip()}/640x360/200",
|
| 621 |
+
f"- Team: http://static.photos/people/200x200/300"
|
| 622 |
+
])
|
| 623 |
+
)
|
| 624 |
+
|
| 625 |
+
return Task(
|
| 626 |
+
description=(
|
| 627 |
+
f"{context}\n\n"
|
| 628 |
+
f"Additional Requirements from User:\n{custom_requirements}\n\n"
|
| 629 |
+
f"{image_guidelines}\n\n"
|
| 630 |
+
"Create a comprehensive Design System that includes:\n"
|
| 631 |
+
"1. Complete color palette with exact hex codes\n"
|
| 632 |
+
"2. Typography system with sizes and weights\n"
|
| 633 |
+
"3. Spacing and grid system\n"
|
| 634 |
+
"4. Component specifications\n"
|
| 635 |
+
"5. Animation guidelines\n"
|
| 636 |
+
"6. Image URLs using static.photos\n"
|
| 637 |
+
"7. Layout structure for all sections\n"
|
| 638 |
+
"8. Responsive breakpoints\n"
|
| 639 |
+
"9. Interaction patterns\n"
|
| 640 |
+
"10. Accessibility requirements"
|
| 641 |
+
),
|
| 642 |
+
expected_output=(
|
| 643 |
+
"A detailed Design System document in markdown format with:\n"
|
| 644 |
+
"- All specifications clearly defined\n"
|
| 645 |
+
"- Exact measurements and values\n"
|
| 646 |
+
"- Static.photos URLs for all images\n"
|
| 647 |
+
"- Component states and variations\n"
|
| 648 |
+
"- Clear implementation guidelines"
|
| 649 |
+
),
|
| 650 |
+
agent=designer
|
| 651 |
+
)
|
| 652 |
|
| 653 |
+
def create_copywriting_task(website_type, project_name):
|
| 654 |
+
"""Create a copywriting task specific to the website type"""
|
| 655 |
+
|
| 656 |
+
type_config = WEBSITE_TYPES[website_type]
|
| 657 |
+
|
| 658 |
+
return Task(
|
| 659 |
+
description=(
|
| 660 |
+
f"Write compelling copy for a {website_type} called '{project_name}'.\n\n"
|
| 661 |
+
f"Website Sections:\n{json.dumps(type_config['sections'], indent=2)}\n\n"
|
| 662 |
+
"For each section, provide:\n"
|
| 663 |
+
"- Headlines (powerful, benefit-focused)\n"
|
| 664 |
+
"- Subheadlines (supporting, clarifying)\n"
|
| 665 |
+
"- Body copy (clear, engaging)\n"
|
| 666 |
+
"- CTAs (action-oriented)\n"
|
| 667 |
+
"- Microcopy (helpful, guiding)\n\n"
|
| 668 |
+
f"Match the tone to {website_type} expectations.\n"
|
| 669 |
+
"Include industry-specific terminology and benefits."
|
| 670 |
+
),
|
| 671 |
+
expected_output=(
|
| 672 |
+
"Complete website copy in markdown format with:\n"
|
| 673 |
+
"- All sections populated with relevant content\n"
|
| 674 |
+
"- Consistent brand voice throughout\n"
|
| 675 |
+
"- SEO-optimized headlines\n"
|
| 676 |
+
"- Clear CTAs for each section\n"
|
| 677 |
+
"- Professional, polished copy"
|
| 678 |
+
),
|
| 679 |
+
agent=copywriter
|
| 680 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
|
| 682 |
+
def create_development_task(website_type, page_type):
|
| 683 |
+
"""Create a development task specific to the website type"""
|
| 684 |
+
|
| 685 |
+
type_config = WEBSITE_TYPES[website_type]
|
| 686 |
+
pages = type_config["pages"]["multi" if page_type == "Multi-Page" else "single"]
|
| 687 |
+
|
| 688 |
+
return Task(
|
| 689 |
+
description=(
|
| 690 |
+
f"Build a complete {website_type} website.\n\n"
|
| 691 |
+
f"Pages to create: {', '.join(pages)}\n"
|
| 692 |
+
f"Must-have elements: {', '.join(type_config['must_have_elements'])}\n\n"
|
| 693 |
+
"Technical Requirements:\n"
|
| 694 |
+
"- Use Tailwind CSS via CDN\n"
|
| 695 |
+
"- Implement AOS animations\n"
|
| 696 |
+
"- Use static.photos for all images\n"
|
| 697 |
+
"- Create responsive layouts\n"
|
| 698 |
+
"- Add interactive elements\n"
|
| 699 |
+
"- Implement smooth scrolling\n"
|
| 700 |
+
"- Add hover effects\n"
|
| 701 |
+
"- Include mobile menu\n\n"
|
| 702 |
+
f"Save files to 'outputs/' directory:\n"
|
| 703 |
+
f"- {'index.html' if page_type == 'Single-Page' else 'Multiple HTML files'}"
|
| 704 |
+
),
|
| 705 |
+
expected_output=(
|
| 706 |
+
"Complete, production-ready HTML files that:\n"
|
| 707 |
+
"- Implement the exact design system\n"
|
| 708 |
+
"- Use all specified copy\n"
|
| 709 |
+
"- Include all required elements\n"
|
| 710 |
+
"- Are fully responsive\n"
|
| 711 |
+
"- Have smooth animations\n"
|
| 712 |
+
"- Work in all browsers"
|
| 713 |
+
),
|
| 714 |
+
agent=developer,
|
| 715 |
+
tools=[file_write_tool]
|
| 716 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 717 |
|
| 718 |
+
# --- CHAT HISTORY MANAGEMENT ---
|
| 719 |
+
class ChatHistory:
|
| 720 |
+
def __init__(self):
|
| 721 |
+
self.history = []
|
| 722 |
+
self.current_project = None
|
| 723 |
+
self.website_type = None
|
| 724 |
+
self.project_name = None
|
| 725 |
+
|
| 726 |
+
def add_message(self, role, content):
|
| 727 |
+
self.history.append({
|
| 728 |
+
"role": role,
|
| 729 |
+
"content": content,
|
| 730 |
+
"timestamp": datetime.now().isoformat()
|
| 731 |
+
})
|
| 732 |
+
|
| 733 |
+
def get_context(self):
|
| 734 |
+
if not self.history:
|
| 735 |
+
return ""
|
| 736 |
+
return "\n".join([f"{msg['role']}: {msg['content']}" for msg in self.history[-5:]])
|
| 737 |
+
|
| 738 |
+
def reset(self):
|
| 739 |
+
self.history = []
|
| 740 |
+
self.current_project = None
|
| 741 |
+
self.website_type = None
|
| 742 |
+
self.project_name = None
|
| 743 |
|
| 744 |
+
chat_history = ChatHistory()
|
| 745 |
+
|
| 746 |
+
# --- HELPER FUNCTIONS ---
|
| 747 |
def clean_outputs_directory():
|
| 748 |
+
"""Clean the outputs directory"""
|
| 749 |
if os.path.exists("outputs"):
|
| 750 |
for file in glob.glob("outputs/*"):
|
| 751 |
try:
|
|
|
|
| 754 |
print(f"Error removing {file}: {e}")
|
| 755 |
|
| 756 |
def create_zip_archive():
|
| 757 |
+
"""Create a ZIP archive of output files"""
|
| 758 |
try:
|
|
|
|
| 759 |
html_files = glob.glob("outputs/*.html")
|
|
|
|
| 760 |
if len(html_files) > 1:
|
|
|
|
| 761 |
shutil.make_archive("outputs/project", 'zip', "outputs")
|
| 762 |
return "outputs/project.zip"
|
| 763 |
return None
|
|
|
|
| 765 |
print(f"Error creating ZIP: {e}")
|
| 766 |
return None
|
| 767 |
|
| 768 |
+
# --- MAIN GENERATION FUNCTION ---
|
| 769 |
+
def generate_website(website_type, project_name_input, name_method, page_type, custom_requirements, is_modification=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 770 |
try:
|
| 771 |
if llm is None:
|
| 772 |
return (
|
| 773 |
+
"โ **Error:** Gemini LLM not initialized. Please check your GOOGLE_API_KEY.",
|
| 774 |
+
None, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 775 |
)
|
| 776 |
|
| 777 |
+
# Handle project name
|
| 778 |
+
if name_method == "Enter manually":
|
| 779 |
+
project_name = project_name_input if project_name_input else "My Project"
|
|
|
|
|
|
|
| 780 |
else:
|
| 781 |
+
# Generate project name with AI
|
| 782 |
+
project_name = f"{WEBSITE_TYPES[website_type]['emoji']} {website_type.split('/')[0]} Pro"
|
| 783 |
+
|
| 784 |
+
# Store in chat history
|
| 785 |
+
if not is_modification:
|
| 786 |
+
chat_history.reset()
|
| 787 |
+
chat_history.website_type = website_type
|
| 788 |
+
chat_history.project_name = project_name
|
| 789 |
|
| 790 |
+
chat_history.add_message("User", f"Generate {website_type} - {page_type}")
|
| 791 |
+
|
| 792 |
+
# Clean outputs
|
| 793 |
clean_outputs_directory()
|
| 794 |
|
| 795 |
+
# Create tasks
|
| 796 |
+
design_task = create_design_task(website_type, project_name, custom_requirements, page_type)
|
| 797 |
+
copywriting_task = create_copywriting_task(website_type, project_name)
|
| 798 |
+
copywriting_task.context = [design_task]
|
| 799 |
+
development_task = create_development_task(website_type, page_type)
|
| 800 |
+
development_task.context = [design_task, copywriting_task]
|
| 801 |
|
| 802 |
+
# Create and run crew
|
| 803 |
+
crew = Crew(
|
| 804 |
+
agents=[designer, copywriter, developer],
|
| 805 |
+
tasks=[design_task, copywriting_task, development_task],
|
| 806 |
+
process=Process.sequential,
|
| 807 |
+
verbose=True
|
| 808 |
+
)
|
| 809 |
|
| 810 |
+
result = crew.kickoff()
|
|
|
|
|
|
|
| 811 |
|
| 812 |
+
# Check output files
|
| 813 |
html_files = glob.glob("outputs/*.html")
|
|
|
|
| 814 |
if not html_files:
|
| 815 |
return (
|
| 816 |
+
"โ No files generated. Please try again.",
|
| 817 |
+
None, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 818 |
)
|
| 819 |
|
| 820 |
+
# Create preview
|
|
|
|
|
|
|
|
|
|
| 821 |
preview_file = "outputs/index.html" if os.path.exists("outputs/index.html") else html_files[0]
|
| 822 |
with open(preview_file, "r", encoding="utf-8") as file:
|
| 823 |
html_content = file.read()
|
| 824 |
|
| 825 |
preview_html = f'<iframe srcdoc="{html_content.replace(chr(34), """)}" width="100%" height="800px" style="border: 2px solid #e0e0e0; border-radius: 8px;"></iframe>'
|
| 826 |
|
| 827 |
+
# Prepare response
|
| 828 |
+
is_multipage = len(html_files) > 1
|
| 829 |
+
success_message = f"โ
**{project_name}** generated successfully!\n"
|
| 830 |
+
success_message += f"Type: {website_type} | Pages: {len(html_files)}"
|
| 831 |
+
|
| 832 |
+
chat_history.add_message("System", f"Generated {project_name}")
|
| 833 |
+
|
| 834 |
if is_multipage:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 835 |
zip_path = create_zip_archive()
|
| 836 |
+
return (
|
| 837 |
+
success_message,
|
| 838 |
+
preview_html,
|
| 839 |
+
gr.update(value=preview_file, visible=True),
|
| 840 |
+
gr.update(value=zip_path, visible=True) if zip_path else gr.update(visible=False),
|
| 841 |
+
gr.update(visible=True)
|
| 842 |
+
)
|
|
|
|
|
|
|
| 843 |
else:
|
|
|
|
| 844 |
return (
|
| 845 |
success_message,
|
| 846 |
preview_html,
|
| 847 |
+
gr.update(value=preview_file, visible=True),
|
| 848 |
gr.update(visible=False),
|
| 849 |
+
gr.update(visible=True)
|
|
|
|
| 850 |
)
|
| 851 |
+
|
| 852 |
except Exception as e:
|
| 853 |
error_trace = traceback.format_exc()
|
|
|
|
| 854 |
print(error_trace)
|
| 855 |
return (
|
| 856 |
+
f"โ Error: {str(e)}",
|
| 857 |
+
None, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 858 |
)
|
| 859 |
|
| 860 |
+
def modify_website(modification_request):
|
| 861 |
+
"""Modify the existing website based on user request"""
|
| 862 |
+
if not chat_history.current_project:
|
| 863 |
+
return "โ Please generate a website first before requesting modifications."
|
| 864 |
+
|
| 865 |
+
chat_history.add_message("User", modification_request)
|
| 866 |
+
|
| 867 |
+
# Create modification task
|
| 868 |
+
modification_task = Task(
|
| 869 |
+
description=(
|
| 870 |
+
f"Modify the existing {chat_history.website_type} website.\n\n"
|
| 871 |
+
f"Previous context:\n{chat_history.get_context()}\n\n"
|
| 872 |
+
f"Modification request: {modification_request}\n\n"
|
| 873 |
+
"Update the HTML files accordingly."
|
| 874 |
+
),
|
| 875 |
+
expected_output="Modified HTML files with requested changes",
|
| 876 |
+
agent=developer,
|
| 877 |
+
tools=[file_write_tool]
|
| 878 |
+
)
|
| 879 |
+
|
| 880 |
+
crew = Crew(
|
| 881 |
+
agents=[developer],
|
| 882 |
+
tasks=[modification_task],
|
| 883 |
+
process=Process.sequential
|
| 884 |
+
)
|
| 885 |
+
|
| 886 |
+
try:
|
| 887 |
+
result = crew.kickoff()
|
| 888 |
+
chat_history.add_message("System", f"Modified: {modification_request[:50]}...")
|
| 889 |
+
return "โ
Modifications applied successfully!"
|
| 890 |
+
except Exception as e:
|
| 891 |
+
return f"โ Error applying modifications: {str(e)}"
|
| 892 |
+
|
| 893 |
+
# --- GRADIO INTERFACE ---
|
| 894 |
with gr.Blocks(theme=gr.themes.Soft(), css="""
|
| 895 |
.container { max-width: 1400px; margin: auto; }
|
| 896 |
+
.type-card {
|
| 897 |
+
border: 2px solid #e2e8f0;
|
| 898 |
+
border-radius: 12px;
|
| 899 |
+
padding: 15px;
|
| 900 |
+
margin: 10px 0;
|
| 901 |
+
background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
|
| 902 |
+
cursor: pointer;
|
| 903 |
+
transition: all 0.3s ease;
|
| 904 |
+
}
|
| 905 |
+
.type-card:hover {
|
| 906 |
+
transform: translateY(-2px);
|
| 907 |
+
box-shadow: 0 8px 20px rgba(0,0,0,0.1);
|
| 908 |
+
border-color: #4F46E5;
|
| 909 |
+
}
|
| 910 |
+
.type-title {
|
| 911 |
+
font-size: 1.2rem;
|
| 912 |
+
font-weight: 600;
|
| 913 |
+
color: #1a202c;
|
| 914 |
+
margin-bottom: 8px;
|
| 915 |
+
}
|
| 916 |
+
.type-description {
|
| 917 |
+
color: #4a5568;
|
| 918 |
+
font-size: 0.9rem;
|
| 919 |
+
}
|
| 920 |
.status-box {
|
| 921 |
padding: 20px;
|
| 922 |
border-radius: 12px;
|
|
|
|
| 925 |
color: white;
|
| 926 |
font-weight: 500;
|
| 927 |
}
|
| 928 |
+
.chat-box {
|
| 929 |
+
border: 1px solid #e2e8f0;
|
| 930 |
+
border-radius: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 931 |
padding: 15px;
|
| 932 |
+
margin: 10px 0;
|
| 933 |
background: #f8fafc;
|
| 934 |
+
min-height: 100px;
|
| 935 |
}
|
| 936 |
+
.feature-badge {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 937 |
display: inline-block;
|
| 938 |
+
padding: 4px 12px;
|
| 939 |
+
border-radius: 20px;
|
| 940 |
+
font-size: 0.85rem;
|
| 941 |
font-weight: 600;
|
| 942 |
+
margin: 4px;
|
| 943 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 944 |
color: white;
|
| 945 |
}
|
| 946 |
""") as iface:
|
| 947 |
|
| 948 |
gr.Markdown(
|
| 949 |
"""
|
| 950 |
+
# ๐ Professional Website Builder AI
|
| 951 |
+
### Industry-Specific Website Generation with Tailwind CSS & Modern Animations
|
|
|
|
| 952 |
|
| 953 |
+
Generate complete, production-ready websites tailored to your industry with our specialized AI team.
|
| 954 |
+
Each website type comes with industry-specific components, design patterns, and content.
|
| 955 |
"""
|
| 956 |
)
|
| 957 |
|
| 958 |
+
with gr.Row():
|
| 959 |
+
with gr.Column(scale=1):
|
| 960 |
+
gr.Markdown("### ๐ฏ Step 1: Choose Website Type")
|
| 961 |
+
|
| 962 |
+
website_type = gr.Radio(
|
| 963 |
+
choices=list(WEBSITE_TYPES.keys()),
|
| 964 |
+
value="SaaS Platform",
|
| 965 |
+
label="Select Industry/Type",
|
| 966 |
+
interactive=True
|
| 967 |
+
)
|
| 968 |
+
|
| 969 |
+
# Display type details
|
| 970 |
+
with gr.Box():
|
| 971 |
+
type_details = gr.Markdown(
|
| 972 |
+
value=f"**{WEBSITE_TYPES['SaaS Platform']['description']}**\n\n"
|
| 973 |
+
f"Design Style: {WEBSITE_TYPES['SaaS Platform']['design_style']}\n\n"
|
| 974 |
+
f"Key Elements: {', '.join(WEBSITE_TYPES['SaaS Platform']['must_have_elements'][:3])}..."
|
| 975 |
+
)
|
| 976 |
+
|
| 977 |
+
with gr.Column(scale=1):
|
| 978 |
+
gr.Markdown("### ๐ Step 2: Project Details")
|
| 979 |
+
|
| 980 |
+
name_method = gr.Radio(
|
| 981 |
+
choices=["Generate with AI", "Enter manually"],
|
| 982 |
+
value="Generate with AI",
|
| 983 |
+
label="Project Name Method"
|
| 984 |
+
)
|
| 985 |
+
|
| 986 |
+
project_name_input = gr.Textbox(
|
| 987 |
+
placeholder="Enter your project name (e.g., TechFlow Pro)",
|
| 988 |
+
label="Project Name",
|
| 989 |
+
visible=False
|
| 990 |
+
)
|
| 991 |
+
|
| 992 |
+
page_type = gr.Radio(
|
| 993 |
+
choices=["Single-Page", "Multi-Page"],
|
| 994 |
+
value="Single-Page",
|
| 995 |
+
label="Website Structure"
|
| 996 |
+
)
|
| 997 |
+
|
| 998 |
+
custom_requirements = gr.Textbox(
|
| 999 |
+
lines=3,
|
| 1000 |
+
placeholder="Any specific requirements? (e.g., 'Add a video hero section', 'Include testimonial carousel', 'Dark mode design')",
|
| 1001 |
+
label="Custom Requirements (Optional)"
|
| 1002 |
+
)
|
| 1003 |
|
| 1004 |
with gr.Row():
|
| 1005 |
generate_btn = gr.Button(
|
| 1006 |
"๐ Generate Professional Website",
|
| 1007 |
variant="primary",
|
| 1008 |
+
size="lg"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1009 |
)
|
| 1010 |
|
| 1011 |
+
# Status and Preview
|
| 1012 |
+
status_output = gr.Markdown(elem_classes="status-box")
|
|
|
|
|
|
|
|
|
|
| 1013 |
|
| 1014 |
+
with gr.Tabs():
|
| 1015 |
+
with gr.TabItem("๐ฅ๏ธ Live Preview"):
|
| 1016 |
+
preview_output = gr.HTML()
|
| 1017 |
+
|
| 1018 |
+
with gr.TabItem("๐ฌ Modify Website"):
|
| 1019 |
+
gr.Markdown(
|
| 1020 |
+
"""
|
| 1021 |
+
### Make Changes to Your Generated Website
|
| 1022 |
+
After generating a website, you can request modifications here.
|
| 1023 |
+
"""
|
|
|
|
|
|
|
| 1024 |
)
|
| 1025 |
+
modification_input = gr.Textbox(
|
| 1026 |
+
lines=3,
|
| 1027 |
+
placeholder="E.g., 'Change the hero background to blue gradient', 'Add more testimonials', 'Make the navigation sticky'",
|
| 1028 |
+
label="What would you like to change?"
|
|
|
|
| 1029 |
)
|
| 1030 |
+
modify_btn = gr.Button("๐ง Apply Modifications", variant="secondary")
|
| 1031 |
+
modification_status = gr.Markdown()
|
| 1032 |
+
|
| 1033 |
+
# Download Section
|
| 1034 |
+
with gr.Row():
|
| 1035 |
+
download_single = gr.File(label="๐ฅ Download HTML", visible=False)
|
| 1036 |
+
download_zip = gr.File(label="๐ฆ Download Project (ZIP)", visible=False)
|
| 1037 |
+
view_code_btn = gr.Button("๐๏ธ View Source Code", visible=False)
|
| 1038 |
|
| 1039 |
+
# Code Display
|
| 1040 |
with gr.Row(visible=False) as code_row:
|
| 1041 |
code_output = gr.Code(
|
| 1042 |
+
label="Generated HTML Source Code",
|
| 1043 |
language="html",
|
| 1044 |
+
lines=20
|
|
|
|
| 1045 |
)
|
| 1046 |
|
| 1047 |
+
# Feature showcase
|
| 1048 |
+
gr.Markdown(
|
| 1049 |
+
"""
|
| 1050 |
+
### โจ Features by Website Type
|
| 1051 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1052 |
)
|
| 1053 |
|
| 1054 |
+
with gr.Row():
|
| 1055 |
+
for i, (type_name, config) in enumerate(list(WEBSITE_TYPES.items())[:3]):
|
| 1056 |
+
with gr.Column():
|
| 1057 |
+
gr.Markdown(
|
| 1058 |
+
f"""
|
| 1059 |
+
**{config['emoji']} {type_name}**
|
| 1060 |
+
|
| 1061 |
+
{' '.join([f'<span class="feature-badge">{elem.split()[0]}</span>' for elem in config['must_have_elements'][:3]])}
|
| 1062 |
+
"""
|
| 1063 |
+
)
|
| 1064 |
+
|
| 1065 |
+
# Event Handlers
|
| 1066 |
+
def update_type_details(selected_type):
|
| 1067 |
+
config = WEBSITE_TYPES[selected_type]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1068 |
return (
|
| 1069 |
+
f"**{config['description']}**\n\n"
|
| 1070 |
+
f"Design Style: {config['design_style']}\n\n"
|
| 1071 |
+
f"Fonts: {config['fonts']['heading']} / {config['fonts']['body']}\n\n"
|
| 1072 |
+
f"Key Elements: {', '.join(config['must_have_elements'][:3])}..."
|
|
|
|
|
|
|
| 1073 |
)
|
| 1074 |
|
| 1075 |
+
def toggle_name_input(method):
|
| 1076 |
+
return gr.update(visible=(method == "Enter manually"))
|
| 1077 |
+
|
| 1078 |
+
# Connect events
|
| 1079 |
+
website_type.change(
|
| 1080 |
+
fn=update_type_details,
|
| 1081 |
+
inputs=[website_type],
|
| 1082 |
+
outputs=[type_details]
|
| 1083 |
+
)
|
| 1084 |
+
|
| 1085 |
+
name_method.change(
|
| 1086 |
+
fn=toggle_name_input,
|
| 1087 |
+
inputs=[name_method],
|
| 1088 |
+
outputs=[project_name_input]
|
| 1089 |
+
)
|
| 1090 |
+
|
| 1091 |
generate_btn.click(
|
| 1092 |
fn=generate_website,
|
| 1093 |
+
inputs=[website_type, project_name_input, name_method, page_type, custom_requirements],
|
| 1094 |
+
outputs=[status_output, preview_output, download_single, download_zip, view_code_btn]
|
| 1095 |
+
)
|
| 1096 |
+
|
| 1097 |
+
modify_btn.click(
|
| 1098 |
+
fn=modify_website,
|
| 1099 |
+
inputs=[modification_input],
|
| 1100 |
+
outputs=[modification_status]
|
|
|
|
| 1101 |
)
|
| 1102 |
|
| 1103 |
view_code_btn.click(
|
| 1104 |
fn=lambda: (
|
| 1105 |
+
gr.update(visible=True),
|
| 1106 |
+
open("outputs/index.html", "r", encoding="utf-8").read() if os.path.exists("outputs/index.html") else ""
|
| 1107 |
),
|
|
|
|
| 1108 |
outputs=[code_row, code_output]
|
| 1109 |
)
|
| 1110 |
|
| 1111 |
if __name__ == "__main__":
|
| 1112 |
print("\n" + "="*50)
|
| 1113 |
+
print("๐ Professional Website Builder AI")
|
| 1114 |
print("="*50)
|
| 1115 |
+
print(f"\nโ
{len(WEBSITE_TYPES)} website types loaded")
|
| 1116 |
+
print("๐จ Industry-specific design systems ready")
|
| 1117 |
+
print("๐ฌ Chat modification system enabled")
|
| 1118 |
+
print("\n๐ Launching interface...\n")
|
| 1119 |
|
| 1120 |
iface.launch(share=False)
|