Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
fix and add unit test
Abi Rajadc28bd5e6b0b
diff --git a/backend/test_prompts.py b/backend/test_prompts.pyindex 2eaaaf4b..5d8cd889 100644--- a/backend/test_prompts.py+++ b/backend/test_prompts.py@@ -79,19 +79,58 @@ Return only the full code in <html></html> tags.Do not include markdown "```" or "```html" at the start or end."""+IONIC_TAILWIND_SYSTEM_PROMPT = """+You are an expert Ionic/Tailwind developer+You take screenshots of a reference web page from the user, and then build single page apps+using Ionic and Tailwind CSS.+You might also be given a screenshot(The second image) of a web page that you have already built, and asked to+update it to look more like the reference image(The first image).++- 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.+- Do not add comments in the code such as "<!-- Add other navigation links as needed -->" and "<!-- ... other news items ... -->" in place of writing the full code. WRITE THE FULL CODE.+- 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, use placeholder images from https://placehold.co and include a detailed description of the image in the alt text so that an image generation AI can generate the image later.++In terms of libraries,++- Use these script to include Ionic so that it can run on a standalone page:+ <script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js"></script>+ <script nomodule src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"></script>+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css" />+- Use this script to include Tailwind: <script src="https://cdn.tailwindcss.com"></script>+- You can use Google Fonts+- ionicons for icons, add the following <script > tags near the end of the page, right before the closing </body> tag:+ <script type="module">+ import ionicons from 'https://cdn.jsdelivr.net/npm/ionicons/+esm'+ </script>+ <script nomodule src="https://cdn.jsdelivr.net/npm/ionicons/dist/esm/ionicons.min.js"></script>+ <link href="https://cdn.jsdelivr.net/npm/ionicons/dist/collection/components/icon/icon.min.css" rel="stylesheet">++Return only the full code in <html></html> tags.+Do not include markdown "```" or "```html" at the start or end.+"""+def test_prompts():tailwind_prompt = assemble_prompt(- "image_data_url", {"css": "tailwind", "js": "vanilla"}, "result_image_data_url"+ "image_data_url", "html_tailwind", "result_image_data_url")assert tailwind_prompt[0]["content"] == TAILWIND_SYSTEM_PROMPT+ react_tailwind_prompt = assemble_prompt(+ "image_data_url", "react_tailwind", "result_image_data_url"+ )+ assert react_tailwind_prompt[0]["content"] == REACT_TAILWIND_SYSTEM_PROMPT+bootstrap_prompt = assemble_prompt(- "image_data_url", {"css": "bootstrap", "js": "vanilla"}, "result_image_data_url"+ "image_data_url", "bootstrap", "result_image_data_url")assert bootstrap_prompt[0]["content"] == BOOTSTRAP_SYSTEM_PROMPT- react_tailwind_prompt = assemble_prompt(- "image_data_url", {"css": "tailwind", "js": "react"}, "result_image_data_url"+ ionic_tailwind = assemble_prompt(+ "image_data_url", "ionic_tailwind", "result_image_data_url")- assert react_tailwind_prompt[0]["content"] == REACT_TAILWIND_SYSTEM_PROMPT+ assert ionic_tailwind[0]["content"] == IONIC_TAILWIND_SYSTEM_PROMPT