Rahul-8799 commited on
Commit
1ff23ba
·
verified ·
1 Parent(s): 46dad67

Update agents/software_engineer.py

Browse files
Files changed (1) hide show
  1. 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. Create a complete HTML page with embedded CSS for the following UI design:
9
 
10
  {design}
11
 
12
  Requirements:
13
- - Self-contained HTML document with <!DOCTYPE>
14
- - CSS must be embedded in <style> inside <head>
15
- - Design should reflect the user’s theme (e.g., yoga site, fintech dashboard, travel blog, etc.)
16
- - Use a mobile-responsive layout (flex/grid, media queries)
17
- - Include common web elements like a header, hero section, content cards, and footer
18
- - Only return the final HTML. Do NOT explain or include markdown. Do NOT include planning or wireframes.
 
 
 
 
 
19
  """
20
 
21
  output = call_model(prompt)
22
 
23
- # Remove any markdown fences or extra explanations
24
  cleaned = re.sub(r"```(?:html|css)?", "", output).strip()
25
 
26
- # Try to extract a clean HTML document
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
- # If malformed, wrap it in a basic HTML structure
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>