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

Update agents/software_engineer.py

Browse files
Files changed (1) hide show
  1. agents/software_engineer.py +17 -23
agents/software_engineer.py CHANGED
@@ -4,39 +4,33 @@ import re
4
 
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 coffee shop website design:
9
-
10
- {design}
11
 
12
  Requirements:
13
- - Visually engaging homepage for a coffee shop
14
- - Include a top header with logo and nav links (Home, Menu, Contact)
15
- - Add a full-width hero section with a heading and call-to-action
16
- - Display 3-6 coffee items with images, names, and prices
17
- - Add a "Visit Us" or "Contact" section with hours, location, and contact form
18
- - Use <style> in <head> for embedded CSS
19
- - Responsive layout with Flexbox or CSS Grid
20
- - Modern, clean color palette
21
- - Only return the complete HTML (no explanation, no markdown)"""
22
-
23
-
24
- # Get output from model
25
  output = call_model(prompt)
26
 
27
- # 🔍 Clean up markdown, explanations, or duplicated tags
28
- cleaned = re.sub(r"```(?:html|css)?", "", output)
29
- cleaned = re.sub(r"(This example.+|Given the constraints.+|Here is.+|Below is.+)", "", cleaned, flags=re.IGNORECASE)
30
- cleaned = cleaned.strip()
31
 
32
- # 🛡 Ensure there's only one <html> document
33
  matches = re.findall(r"<!DOCTYPE html>.*?</html>", cleaned, flags=re.DOTALL | re.IGNORECASE)
34
  if matches:
35
  final_html = matches[0]
36
  elif cleaned.lower().startswith("<!doctype"):
37
  final_html = cleaned
38
  else:
39
- # Fallback: wrap whatever is returned
40
  final_html = f"""<!DOCTYPE html>
41
  <html lang="en">
42
  <head>
@@ -45,8 +39,8 @@ Requirements:
45
  <style>
46
  body {{
47
  font-family: Arial, sans-serif;
48
- background-color: #f4f4f4;
49
  padding: 2rem;
 
50
  }}
51
  </style>
52
  </head>
 
4
 
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>
 
39
  <style>
40
  body {{
41
  font-family: Arial, sans-serif;
 
42
  padding: 2rem;
43
+ background-color: #f4f4f4;
44
  }}
45
  </style>
46
  </head>