add a vue tailwind generation option
This commit is contained in:
parent
2ab95eb2c0
commit
fa7ffdfaeb
@ -49,7 +49,7 @@ async def main():
|
||||
for filename in evals:
|
||||
filepath = os.path.join(INPUT_DIR, filename)
|
||||
data_url = await image_to_data_url(filepath)
|
||||
task = generate_code_core(data_url, "svg")
|
||||
task = generate_code_core(data_url, "vue_tailwind")
|
||||
tasks.append(task)
|
||||
|
||||
results = await asyncio.gather(*tasks)
|
||||
|
||||
@ -15,6 +15,7 @@ from screenshot_system_prompts import (
|
||||
REACT_TAILWIND_SYSTEM_PROMPT,
|
||||
TAILWIND_SYSTEM_PROMPT,
|
||||
SVG_SYSTEM_PROMPT,
|
||||
VUE_TAILWIND_SYSTEM_PROMPT,
|
||||
)
|
||||
|
||||
|
||||
@ -77,6 +78,8 @@ def assemble_prompt(
|
||||
system_content = BOOTSTRAP_SYSTEM_PROMPT
|
||||
elif generated_code_config == "ionic_tailwind":
|
||||
system_content = IONIC_TAILWIND_SYSTEM_PROMPT
|
||||
elif generated_code_config == "vue_tailwind":
|
||||
system_content = VUE_TAILWIND_SYSTEM_PROMPT
|
||||
elif generated_code_config == "svg":
|
||||
system_content = SVG_SYSTEM_PROMPT
|
||||
else:
|
||||
|
||||
@ -111,6 +111,48 @@ Return only the full code in <html></html> tags.
|
||||
Do not include markdown "```" or "```html" at the start or end.
|
||||
"""
|
||||
|
||||
VUE_TAILWIND_SYSTEM_PROMPT = """
|
||||
You are an expert Vue/Tailwind developer
|
||||
You take screenshots of a reference web page from the user, and then build single page apps
|
||||
using Vue 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.
|
||||
- Use Vue using the global build like so:
|
||||
|
||||
<div id="app">{{ message }}</div>
|
||||
<script>
|
||||
const { createApp, ref } = Vue
|
||||
createApp({
|
||||
setup() {
|
||||
const message = ref('Hello vue!')
|
||||
return {
|
||||
message
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
</script>
|
||||
|
||||
In terms of libraries,
|
||||
|
||||
- Use these script to include Vue so that it can run on a standalone page:
|
||||
<script src="https://registry.npmmirror.com/vue/3.3.11/files/dist/vue.global.js"></script>
|
||||
- Use this script to include Tailwind: <script src="https://cdn.tailwindcss.com"></script>
|
||||
- You can use Google Fonts
|
||||
- Font Awesome for icons: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>
|
||||
|
||||
Return only the full code in <html></html> tags.
|
||||
Do not include markdown "```" or "```html" at the start or end.
|
||||
The return result must only include the code.
|
||||
"""
|
||||
|
||||
|
||||
SVG_SYSTEM_PROMPT = """
|
||||
You are an expert at building SVGs.
|
||||
|
||||
@ -113,6 +113,48 @@ Return only the full code in <html></html> tags.
|
||||
Do not include markdown "```" or "```html" at the start or end.
|
||||
"""
|
||||
|
||||
VUE_TAILWIND_SYSTEM_PROMPT = """
|
||||
You are an expert Vue/Tailwind developer
|
||||
You take screenshots of a reference web page from the user, and then build single page apps
|
||||
using Vue 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.
|
||||
- Use Vue using the global build like so:
|
||||
|
||||
<div id="app">{{ message }}</div>
|
||||
<script>
|
||||
const { createApp, ref } = Vue
|
||||
createApp({
|
||||
setup() {
|
||||
const message = ref('Hello vue!')
|
||||
return {
|
||||
message
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
</script>
|
||||
|
||||
In terms of libraries,
|
||||
|
||||
- Use these script to include Vue so that it can run on a standalone page:
|
||||
<script src="https://registry.npmmirror.com/vue/3.3.11/files/dist/vue.global.js"></script>
|
||||
- Use this script to include Tailwind: <script src="https://cdn.tailwindcss.com"></script>
|
||||
- You can use Google Fonts
|
||||
- Font Awesome for icons: <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"></link>
|
||||
|
||||
Return only the full code in <html></html> tags.
|
||||
Do not include markdown "```" or "```html" at the start or end.
|
||||
The return result must only include the code.
|
||||
"""
|
||||
|
||||
SVG_SYSTEM_PROMPT = """
|
||||
You are an expert at building SVGs.
|
||||
You take screenshots of a reference web page from the user, and then build a SVG that looks exactly like the screenshot.
|
||||
@ -257,6 +299,10 @@ def test_prompts():
|
||||
assert ionic_tailwind[0]["content"] == IONIC_TAILWIND_SYSTEM_PROMPT
|
||||
assert ionic_tailwind[1]["content"][2]["text"] == USER_PROMPT # type: ignore
|
||||
|
||||
vue = assemble_prompt("image_data_url", "vue_tailwind", "result_image_data_url")
|
||||
assert vue[0]["content"] == VUE_TAILWIND_SYSTEM_PROMPT
|
||||
assert vue[1]["content"][2]["text"] == USER_PROMPT # type: ignore
|
||||
|
||||
svg_prompt = assemble_prompt("image_data_url", "svg", "result_image_data_url")
|
||||
assert svg_prompt[0]["content"] == SVG_SYSTEM_PROMPT
|
||||
assert svg_prompt[1]["content"][2]["text"] == SVG_USER_PROMPT # type: ignore
|
||||
|
||||
@ -37,6 +37,13 @@ function generateDisplayComponent(config: GeneratedCodeConfig) {
|
||||
<span className="font-semibold">Tailwind</span>
|
||||
</div>
|
||||
);
|
||||
case GeneratedCodeConfig.VUE_TAILWIND:
|
||||
return (
|
||||
<div>
|
||||
<span className="font-semibold">Vue</span> +{" "}
|
||||
<span className="font-semibold">Tailwind</span>
|
||||
</div>
|
||||
);
|
||||
case GeneratedCodeConfig.SVG:
|
||||
return (
|
||||
<div>
|
||||
@ -90,6 +97,14 @@ function OutputSettingsSection({
|
||||
<SelectItem value={GeneratedCodeConfig.BOOTSTRAP}>
|
||||
{generateDisplayComponent(GeneratedCodeConfig.BOOTSTRAP)}
|
||||
</SelectItem>
|
||||
<SelectItem value={GeneratedCodeConfig.VUE_TAILWIND}>
|
||||
<div className="flex items-center">
|
||||
{generateDisplayComponent(GeneratedCodeConfig.VUE_TAILWIND)}
|
||||
<Badge className="ml-2" variant="secondary">
|
||||
Beta
|
||||
</Badge>
|
||||
</div>
|
||||
</SelectItem>
|
||||
<SelectItem value={GeneratedCodeConfig.IONIC_TAILWIND}>
|
||||
<div className="flex items-center">
|
||||
{generateDisplayComponent(GeneratedCodeConfig.IONIC_TAILWIND)}
|
||||
|
||||
@ -7,6 +7,7 @@ export enum EditorTheme {
|
||||
export enum GeneratedCodeConfig {
|
||||
HTML_TAILWIND = "html_tailwind",
|
||||
REACT_TAILWIND = "react_tailwind",
|
||||
VUE_TAILWIND = "vue_tailwind",
|
||||
BOOTSTRAP = "bootstrap",
|
||||
IONIC_TAILWIND = "ionic_tailwind",
|
||||
SVG = "svg",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user