Spaces:
Sleeping
Sleeping
Update agents/software_engineer.py
Browse files- agents/software_engineer.py +32 -18
agents/software_engineer.py
CHANGED
|
@@ -6,41 +6,55 @@ def run(state):
|
|
| 6 |
architecture = state["architecture"]
|
| 7 |
user_prompt = state["messages"][0].content
|
| 8 |
|
| 9 |
-
prompt = f"""
|
|
|
|
| 10 |
|
| 11 |
-
User
|
| 12 |
"{user_prompt}"
|
| 13 |
|
| 14 |
-
|
| 15 |
{architecture}
|
| 16 |
|
| 17 |
-
|
| 18 |
-
-
|
| 19 |
-
-
|
| 20 |
-
- Add a
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
-
|
| 26 |
-
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
"""
|
| 30 |
|
| 31 |
output = call_model(prompt)
|
| 32 |
|
| 33 |
-
# Clean
|
| 34 |
cleaned = re.sub(r"```(?:html|css)?", "", output).strip()
|
| 35 |
|
| 36 |
-
#
|
| 37 |
matches = re.findall(r"<!DOCTYPE html>.*?</html>", cleaned, flags=re.DOTALL | re.IGNORECASE)
|
| 38 |
if matches:
|
| 39 |
final_html = matches[0]
|
| 40 |
elif cleaned.lower().startswith("<!doctype"):
|
| 41 |
final_html = cleaned
|
| 42 |
else:
|
| 43 |
-
# fallback: wrap in valid HTML
|
| 44 |
final_html = f"""<!DOCTYPE html>
|
| 45 |
<html lang="en">
|
| 46 |
<head>
|
|
@@ -49,8 +63,8 @@ Focus strictly on the theme inferred from the prompt (e.g., coffee shop, car ren
|
|
| 49 |
<style>
|
| 50 |
body {{
|
| 51 |
font-family: Arial, sans-serif;
|
| 52 |
-
background-color: #f4f4f4;
|
| 53 |
padding: 2rem;
|
|
|
|
| 54 |
}}
|
| 55 |
</style>
|
| 56 |
</head>
|
|
|
|
| 6 |
architecture = state["architecture"]
|
| 7 |
user_prompt = state["messages"][0].content
|
| 8 |
|
| 9 |
+
prompt = f"""
|
| 10 |
+
You are a senior front-end engineer. Based on the user's request and the UI design plan below, generate a fully styled, modern HTML page with embedded CSS.
|
| 11 |
|
| 12 |
+
User Request:
|
| 13 |
"{user_prompt}"
|
| 14 |
|
| 15 |
+
UI Design Plan:
|
| 16 |
{architecture}
|
| 17 |
|
| 18 |
+
✅ HTML Requirements:
|
| 19 |
+
- Use a clean modern design, starting with <!DOCTYPE html> and ending with </html>
|
| 20 |
+
- Add a fixed top navigation bar with visible branding and 3–4 nav links
|
| 21 |
+
- Add a <section class="hero"> with:
|
| 22 |
+
- A full-screen background image matching the theme (e.g., car, cafe, yoga)
|
| 23 |
+
- A centered headline and optional subtext
|
| 24 |
+
- A semi-transparent dark overlay for contrast
|
| 25 |
+
- Add 2–4 visually styled content sections (like cards or blocks) with:
|
| 26 |
+
- Headings
|
| 27 |
+
- Paragraphs
|
| 28 |
+
- Optional images from https://source.unsplash.com
|
| 29 |
+
- At least one call-to-action button in any section
|
| 30 |
+
- Add a styled footer with basic contact or copyright info
|
| 31 |
|
| 32 |
+
🎨 Styling Requirements:
|
| 33 |
+
- Use embedded <style> in <head>, no external CSS
|
| 34 |
+
- Use Google-style modern color palette (e.g., #f8f9fa background, #333 text)
|
| 35 |
+
- All sections should have spacing and visual hierarchy (margin, padding, background)
|
| 36 |
+
- Make it fully responsive using flexbox/grid and @media queries
|
| 37 |
+
- Use system or Google-friendly fonts (Arial, Helvetica, sans-serif)
|
| 38 |
+
|
| 39 |
+
⚠️ IMPORTANT:
|
| 40 |
+
- Never generate yoga or unrelated themes unless prompted
|
| 41 |
+
- DO NOT include markdown, code fences, or explanation — return ONLY the raw HTML code
|
| 42 |
+
|
| 43 |
+
Output: Final valid HTML code only.
|
| 44 |
"""
|
| 45 |
|
| 46 |
output = call_model(prompt)
|
| 47 |
|
| 48 |
+
# Clean model output
|
| 49 |
cleaned = re.sub(r"```(?:html|css)?", "", output).strip()
|
| 50 |
|
| 51 |
+
# Try to extract full HTML
|
| 52 |
matches = re.findall(r"<!DOCTYPE html>.*?</html>", cleaned, flags=re.DOTALL | re.IGNORECASE)
|
| 53 |
if matches:
|
| 54 |
final_html = matches[0]
|
| 55 |
elif cleaned.lower().startswith("<!doctype"):
|
| 56 |
final_html = cleaned
|
| 57 |
else:
|
|
|
|
| 58 |
final_html = f"""<!DOCTYPE html>
|
| 59 |
<html lang="en">
|
| 60 |
<head>
|
|
|
|
| 63 |
<style>
|
| 64 |
body {{
|
| 65 |
font-family: Arial, sans-serif;
|
|
|
|
| 66 |
padding: 2rem;
|
| 67 |
+
background-color: #f5f5f5;
|
| 68 |
}}
|
| 69 |
</style>
|
| 70 |
</head>
|