From dc28bd5e6b0b8377f0ae39ba1f43cda66b8c1a72 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Thu, 30 Nov 2023 16:07:08 -0500 Subject: [PATCH] fix and add unit test --- backend/test_prompts.py | 49 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/backend/test_prompts.py b/backend/test_prompts.py index 2eaaaf4..5d8cd88 100644 --- a/backend/test_prompts.py +++ b/backend/test_prompts.py @@ -79,19 +79,58 @@ Return only the full code in 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 "" and "" 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 "" 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: + + + +- Use this script to include Tailwind: +- You can use Google Fonts +- ionicons for icons, add the following + + + +Return only the full code in 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