Spaces:
Sleeping
Sleeping
Update agents/software_engineer.py
Browse files- agents/software_engineer.py +15 -10
agents/software_engineer.py
CHANGED
|
@@ -5,32 +5,37 @@ import re
|
|
| 5 |
def run(state):
|
| 6 |
design = state["architecture"]
|
| 7 |
|
| 8 |
-
prompt = f"""You are a front-end engineer.
|
| 9 |
|
| 10 |
{design}
|
| 11 |
|
| 12 |
Requirements:
|
| 13 |
-
-
|
| 14 |
-
- CSS
|
| 15 |
-
-
|
| 16 |
-
- Use
|
| 17 |
-
- Include
|
| 18 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
"""
|
| 20 |
|
| 21 |
output = call_model(prompt)
|
| 22 |
|
| 23 |
-
#
|
| 24 |
cleaned = re.sub(r"```(?:html|css)?", "", output).strip()
|
| 25 |
|
| 26 |
-
#
|
| 27 |
matches = re.findall(r"<!DOCTYPE html>.*?</html>", cleaned, flags=re.DOTALL | re.IGNORECASE)
|
| 28 |
if matches:
|
| 29 |
final_html = matches[0]
|
| 30 |
elif cleaned.lower().startswith("<!doctype"):
|
| 31 |
final_html = cleaned
|
| 32 |
else:
|
| 33 |
-
#
|
| 34 |
final_html = f"""<!DOCTYPE html>
|
| 35 |
<html lang="en">
|
| 36 |
<head>
|
|
|
|
| 5 |
def run(state):
|
| 6 |
design = state["architecture"]
|
| 7 |
|
| 8 |
+
prompt = f"""You are a front-end engineer. Your task is to generate a fully styled, professional-looking website as a complete HTML document, based on the following UI design specification:
|
| 9 |
|
| 10 |
{design}
|
| 11 |
|
| 12 |
Requirements:
|
| 13 |
+
- Output must be a complete HTML page, starting with <!DOCTYPE html> and ending with </html>
|
| 14 |
+
- CSS should be embedded in <style> within the <head> (do NOT link external CSS)
|
| 15 |
+
- Use a visually appealing color palette appropriate to the theme (e.g., yoga, fintech, photography, etc.)
|
| 16 |
+
- Use responsive layout (Flexbox or Grid) and mobile-friendly design
|
| 17 |
+
- Include a header, a hero section with image or bold title, at least 3 content cards/sections, and a footer
|
| 18 |
+
- If applicable, include a contact or testimonial section
|
| 19 |
+
- Use realistic placeholder images from https://source.unsplash.com
|
| 20 |
+
- NEVER return markdown formatting or explanations — just raw HTML only
|
| 21 |
+
- Structure the page in a way that makes sense for the theme (yoga, tech, travel, art, etc.)
|
| 22 |
+
|
| 23 |
+
Only return the raw HTML. Do NOT explain the code or include commentary.
|
| 24 |
"""
|
| 25 |
|
| 26 |
output = call_model(prompt)
|
| 27 |
|
| 28 |
+
# 🧹 Clean up markdown (if model still adds it)
|
| 29 |
cleaned = re.sub(r"```(?:html|css)?", "", output).strip()
|
| 30 |
|
| 31 |
+
# 🛡 Extract just one clean HTML document
|
| 32 |
matches = re.findall(r"<!DOCTYPE html>.*?</html>", cleaned, flags=re.DOTALL | re.IGNORECASE)
|
| 33 |
if matches:
|
| 34 |
final_html = matches[0]
|
| 35 |
elif cleaned.lower().startswith("<!doctype"):
|
| 36 |
final_html = cleaned
|
| 37 |
else:
|
| 38 |
+
# Fallback: wrap whatever came back
|
| 39 |
final_html = f"""<!DOCTYPE html>
|
| 40 |
<html lang="en">
|
| 41 |
<head>
|