Rahul-8799 commited on
Commit
1836b2b
·
verified ·
1 Parent(s): ed2734f

Update agents/software_engineer.py

Browse files
Files changed (1) hide show
  1. agents/software_engineer.py +35 -27
agents/software_engineer.py CHANGED
@@ -7,52 +7,60 @@ def run(state):
7
  user_prompt = state["messages"][0].content
8
 
9
  prompt = f"""
10
- You are a front-end engineer. Generate a fully functional, styled HTML page with embedded CSS based on the prompt and UI architecture below.
11
 
12
- 🧾 User Prompt:
13
  "{user_prompt}"
14
 
15
- 📐 Architecture Plan:
16
  {architecture}
17
 
18
- 🎨 Design and Layout Requirements:
19
- - Fixed top navigation bar styled with `.navbar`, with links horizontally centered
20
- - Use `<nav><ul><li><a></a></li></ul></nav>` and style it with flexbox: center items horizontally, add background color
21
- - Add a `.hero` section:
22
- - Full screen height
23
- - Background image matching the theme via Unsplash
24
- - A semi-transparent dark overlay (`rgba(0,0,0,0.6)`) behind white centered text
25
- - Include at least 3 content sections:
26
- - Headline (`<h2>`), text, button
27
- - Optional section background colors (light gray/white alternation)
28
- - Buttons with `.btn` class must look visually appealing with hover effects
29
- - Add a `.footer` at the bottom with padding and centered text
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- 📱 Responsiveness:
32
- - Add `@media` queries to stack nav links vertically on narrow screens
33
- - Make text and sections adapt fluidly to different screen sizes
 
34
 
35
- 🧼 HTML Rules:
36
- - Use <style> in the <head> for all CSS
37
- - No markdown, no code fences, no explanation — only valid HTML
38
- - Final output must be a complete HTML page (start with <!DOCTYPE html>)
39
-
40
- Your output will be rendered directly in a browser.
41
  """
42
 
43
  output = call_model(prompt)
44
 
45
- # Cleanup model response
46
  cleaned = re.sub(r"```(?:html|css)?", "", output).strip()
47
 
48
- # Extract clean HTML
49
  matches = re.findall(r"<!DOCTYPE html>.*?</html>", cleaned, flags=re.DOTALL | re.IGNORECASE)
50
  if matches:
51
  final_html = matches[0]
52
  elif cleaned.lower().startswith("<!doctype"):
53
  final_html = cleaned
54
  else:
55
- # Fallback wrapper
56
  final_html = f"""<!DOCTYPE html>
57
  <html lang="en">
58
  <head>
 
7
  user_prompt = state["messages"][0].content
8
 
9
  prompt = f"""
10
+ You are a senior front-end engineer. Based on the user prompt and architecture, generate a beautiful, fully responsive HTML page with embedded CSS.
11
 
12
+ User Prompt:
13
  "{user_prompt}"
14
 
15
+ UI Design Plan:
16
  {architecture}
17
 
18
+ 🎨 Design Requirements:
19
+ - Full HTML page starting with <!DOCTYPE html>
20
+ - Use semantic HTML5 tags: <nav>, <section>, <footer>, etc.
21
+ - Fixed top `.navbar` with horizontally centered links (not floating), styled with padding, hover states, and active class
22
+ - Hero section:
23
+ - Full viewport height
24
+ - Unsplash image background based on the theme (car, travel, food, etc.)
25
+ - A dark overlay using `rgba(0,0,0,0.6)`
26
+ - Centered text and a button styled as `.btn`
27
+ - Content:
28
+ - Use `.container` with `max-width: 1200px; margin: auto;`
29
+ - 3 content sections styled with `.section` class, using alternating background colors (#fff, #f9f9f9)
30
+ - Each section must have a heading, paragraph, and one `.btn`
31
+ - Footer:
32
+ - Centered, with solid dark background and padding
33
+ - Color Palette:
34
+ - Use a visually appealing modern palette (not default black/gray)
35
+ - Accent color for buttons and nav hover states
36
+ - Typography:
37
+ - Use system font stack or Google Fonts if needed
38
+ - Responsiveness:
39
+ - Use Flexbox or Grid
40
+ - Add media queries for < 768px screens
41
+ - Stack nav items and center hero text on mobile
42
 
43
+ 🚫 DO NOT:
44
+ - Return markdown or explanations
45
+ - Include duplicate HTML tags
46
+ - Forget to close any HTML tag
47
 
48
+ Return only the final clean HTML code.
 
 
 
 
 
49
  """
50
 
51
  output = call_model(prompt)
52
 
53
+ # Clean markdown or triple backticks if any
54
  cleaned = re.sub(r"```(?:html|css)?", "", output).strip()
55
 
56
+ # Extract valid HTML content
57
  matches = re.findall(r"<!DOCTYPE html>.*?</html>", cleaned, flags=re.DOTALL | re.IGNORECASE)
58
  if matches:
59
  final_html = matches[0]
60
  elif cleaned.lower().startswith("<!doctype"):
61
  final_html = cleaned
62
  else:
63
+ # Wrap fallback
64
  final_html = f"""<!DOCTYPE html>
65
  <html lang="en">
66
  <head>