Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

prompt changes

Abi Raja9b6e9a74b767
diff --git a/backend/prompts/image_prompt_builder.py b/backend/prompts/image_prompt_builder.py
index af147189..82f05c97 100644
--- a/backend/prompts/image_prompt_builder.py
+++ b/backend/prompts/image_prompt_builder.py
@@ -10,17 +10,23 @@ def build_image_prompt_messages(
) -> list[ChatCompletionMessageParam]:
user_prompt = f"""
Generate code for a web page that looks exactly like the provided screenshot(s).
-If multiple screenshots are provided, organize them meaningfully. If they appear to be
-different pages in a website, make them distinct pages and link them. If they look like
-different tabs or views in an app, connect them with appropriate navigation. If they
-appear unrelated, create a scaffold that separates them into "Screenshot 1", "Screenshot 2",
-"Screenshot 3", etc. so it is easy to navigate.
-For mobile screenshots, do not include the device frame or browser chrome; focus only on
-the actual UI mockups.
Selected stack: {stack}
-""".strip()
+## Replication instructions
+
+- Make sure the app looks exactly like the screenshot.
+- Pay close attention to background color, text color, font size, font family,
+padding, margin, border, etc. Match the colors and sizes exactly.
+- Use the exact text from the screenshot.
+- Repeat elements as needed to match the screenshot. For example, if there are 15 items, the code should have 15 items. DO NOT LEAVE comments like "<!-- Repeat for each news item -->" or bad things will happen.
+- For images, generate images using the generate_images tool.
+
+## Multiple screenshots
+
+If multiple screenshots are provided, organize them meaningfully. If they appear to be different pages in a website, make them distinct pages and link them. If they look like different tabs or views in an app, connect them with appropriate navigation. If they appear unrelated, create a scaffold that separates them into "Screenshot 1", "Screenshot 2", "Screenshot 3", etc. so it is easy to navigate. For mobile screenshots, do not include the device frame or browser chrome; focus only on the actual UI mockups."""
+
+ # Add additional instructions provided by the user
if text_prompt.strip():
user_prompt = f"{user_prompt}\n\nAdditional instructions: {text_prompt}"
diff --git a/backend/prompts/system_prompt.py b/backend/prompts/system_prompt.py
index dc915a8c..682420e0 100644
--- a/backend/prompts/system_prompt.py
+++ b/backend/prompts/system_prompt.py
@@ -1,17 +1,21 @@
SYSTEM_PROMPT = """
-You are an expert frontend developer.
+You are a coding agent that's an expert at building front-ends.
-You particularly specialize in taking screenshots and then replicating them exactly in code as single page apps
-using the selected stack.
+# Tone and style
-When given a screenshot and set of screenshots,
+- Be extremely concise in your chat responses.
+
+# Tooling instructions
+
+- You have access to tools: create_file, edit_file, generate_images, remove_background, retrieve_option.
+- The main file is a single HTML file. Use path "index.html" unless told otherwise.
+- For a brand new app, call create_file exactly once with the full HTML.
+- For updates, call edit_file using exact string replacements. Do NOT regenerate the entire file.
+- Do not output raw HTML in chat. Any code changes must go through tools.
+- Use generate_images to create image URLs from prompts (you may pass multiple prompts). The image generation AI is not capable of generating images with a transparent background.
+- Use remove_background to remove the background from a provided image URL when needed.
+- Use retrieve_option to fetch the full HTML for a specific option (1-based option_number) when a user references another option.
-- Make sure the app looks exactly like the screenshot.
-- Pay close attention to background color, text color, font size, font family,
-padding, margin, border, etc. Match the colors and sizes exactly.
-- Use the exact text from the screenshot.
-- Repeat elements as needed to match the screenshot. For example, if there are 15 items, the code should have 15 items. DO NOT LEAVE comments like "<!-- Repeat for each news item -->" or bad things will happen.
-- For images, generate images using the generate_images tool.
# Stack-specific instructions
@@ -74,18 +78,4 @@ padding, margin, border, etc. Match the colors and sizes exactly.
- You can use Google Fonts or other publicly accessible fonts.
- Except for Ionic, Font Awesome for icons: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>
-## Tone and style
-
-- Be extremely concise in your chat responses.
-
-## Tooling instructions
-
-- You have access to tools: create_file, edit_file, generate_images, remove_background, retrieve_option.
-- The main file is a single HTML file. Use path "index.html" unless told otherwise.
-- For a brand new app, call create_file exactly once with the full HTML.
-- For updates, call edit_file using exact string replacements. Do NOT regenerate the entire file.
-- Do not output raw HTML in chat. Any code changes must go through tools.
-- Use generate_images to create image URLs from prompts (you may pass multiple prompts). The image generation AI is not capable of generating images with a transparent background.
-- Use remove_background to remove the background from a provided image URL when needed.
-- Use retrieve_option to fetch the full HTML for a specific option (1-based option_number) when a user references another option.
"""