Skip to content

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

Python

Simplify screenshot system prompt

Abi Raja3635b402c00b
diff --git a/backend/prompts/__init__.py b/backend/prompts/__init__.py
index de508ad0..846bf304 100644
--- a/backend/prompts/__init__.py
+++ b/backend/prompts/__init__.py
@@ -3,7 +3,7 @@ from openai.types.chat import ChatCompletionMessageParam, ChatCompletionContentP
from custom_types import InputMode
from prompts.imported_code_prompts import IMPORTED_CODE_SYSTEM_PROMPTS
-from prompts.screenshot_system_prompts import SYSTEM_PROMPTS
+from prompts.screenshot_system_prompts import SYSTEM_PROMPT
from prompts.text_prompts import SYSTEM_PROMPTS as TEXT_SYSTEM_PROMPTS
from prompts.claude_prompts import GEMINI_VIDEO_PROMPT
from prompts.types import Stack, PromptContent
@@ -66,7 +66,7 @@ async def create_prompt(
ChatCompletionMessageParam,
{
"role": "system",
- "content": SYSTEM_PROMPTS[stack],
+ "content": SYSTEM_PROMPT,
},
)
]
@@ -152,7 +152,7 @@ def assemble_prompt(
stack: Stack,
text_prompt: str = "",
) -> list[ChatCompletionMessageParam]:
- system_content = SYSTEM_PROMPTS[stack]
+ system_content = SYSTEM_PROMPT
user_prompt = USER_PROMPT
# Append optional text instructions if provided
diff --git a/backend/prompts/screenshot_system_prompts.py b/backend/prompts/screenshot_system_prompts.py
index 71924fc2..75879efb 100644
--- a/backend/prompts/screenshot_system_prompts.py
+++ b/backend/prompts/screenshot_system_prompts.py
@@ -1,7 +1,4 @@
-from prompts.types import SystemPrompts
-
-
-HTML_TAILWIND_SYSTEM_PROMPT = """
+SYSTEM_PROMPT = """
You are an expert frontend developer.
You particularly specialize in taking screenshots and then replicating them exactly in code as single page apps
using Tailwind, HTML and JS.
@@ -84,12 +81,3 @@ Tooling instructions:
- Use retrieve_option to fetch the full HTML for a specific option (1-based option_number) when a user references another option.
- Any non-tool output should be short, user-facing chat updates.
"""
-
-SYSTEM_PROMPTS = SystemPrompts(
- html_css=HTML_TAILWIND_SYSTEM_PROMPT,
- html_tailwind=HTML_TAILWIND_SYSTEM_PROMPT,
- react_tailwind=HTML_TAILWIND_SYSTEM_PROMPT,
- bootstrap=HTML_TAILWIND_SYSTEM_PROMPT,
- ionic_tailwind=HTML_TAILWIND_SYSTEM_PROMPT,
- vue_tailwind=HTML_TAILWIND_SYSTEM_PROMPT,
-)
diff --git a/backend/tests/test_prompts.py b/backend/tests/test_prompts.py
index 96ee8e31..a889bed5 100644
--- a/backend/tests/test_prompts.py
+++ b/backend/tests/test_prompts.py
@@ -91,10 +91,7 @@ class TestCreatePrompt:
"generationType": "create",
}
- # Mock the system prompts
- mock_system_prompts: Dict[str, str] = {self.TEST_STACK: self.MOCK_SYSTEM_PROMPT}
-
- with patch("prompts.SYSTEM_PROMPTS", mock_system_prompts):
+ with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
messages = await create_prompt(
stack=self.TEST_STACK,
@@ -148,10 +145,7 @@ class TestCreatePrompt:
],
}
- # Mock the system prompts and image cache function
- mock_system_prompts = {self.TEST_STACK: self.MOCK_SYSTEM_PROMPT}
-
- with patch("prompts.SYSTEM_PROMPTS", mock_system_prompts):
+ with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
messages = await create_prompt(
stack=self.TEST_STACK,
@@ -379,10 +373,7 @@ class TestCreatePrompt:
]
}
- # Mock the system prompts and image cache function
- mock_system_prompts: Dict[str, str] = {self.TEST_STACK: self.MOCK_SYSTEM_PROMPT}
-
- with patch("prompts.SYSTEM_PROMPTS", mock_system_prompts):
+ with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
messages = await create_prompt(
stack=self.TEST_STACK,
@@ -454,10 +445,7 @@ class TestCreatePrompt:
]
}
- # Mock the system prompts and image cache function
- mock_system_prompts: Dict[str, str] = {self.TEST_STACK: self.MOCK_SYSTEM_PROMPT}
-
- with patch("prompts.SYSTEM_PROMPTS", mock_system_prompts):
+ with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
messages = await create_prompt(
stack=self.TEST_STACK,
@@ -534,10 +522,7 @@ class TestCreatePrompt:
]
}
- # Mock the system prompts and image cache function
- mock_system_prompts: Dict[str, str] = {self.TEST_STACK: self.MOCK_SYSTEM_PROMPT}
-
- with patch("prompts.SYSTEM_PROMPTS", mock_system_prompts):
+ with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
messages = await create_prompt(
stack=self.TEST_STACK,
diff --git a/backend/tests/test_prompts_additional.py b/backend/tests/test_prompts_additional.py
index f5a25e57..a7cd1b5e 100644
--- a/backend/tests/test_prompts_additional.py
+++ b/backend/tests/test_prompts_additional.py
@@ -97,10 +97,7 @@ class TestCreatePromptImageSupport:
]
}
- # Mock the system prompts and image cache function
- mock_system_prompts: Dict[str, str] = {self.TEST_STACK: self.MOCK_SYSTEM_PROMPT}
-
- with patch("prompts.SYSTEM_PROMPTS", mock_system_prompts):
+ with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
messages = await create_prompt(
stack=self.TEST_STACK,
@@ -177,10 +174,7 @@ class TestCreatePromptImageSupport:
]
}
- # Mock the system prompts and image cache function
- mock_system_prompts: Dict[str, str] = {self.TEST_STACK: self.MOCK_SYSTEM_PROMPT}
-
- with patch("prompts.SYSTEM_PROMPTS", mock_system_prompts):
+ with patch("prompts.SYSTEM_PROMPT", self.MOCK_SYSTEM_PROMPT):
# Call the function
messages = await create_prompt(
stack=self.TEST_STACK,